]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'jc/check-attr-honor-working-tree'
authorJunio C Hamano <gitster@pobox.com>
Fri, 14 Mar 2014 21:05:59 +0000 (14:05 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 14 Mar 2014 21:06:00 +0000 (14:06 -0700)
"git check-attr" when (trying to) work on a repository with a
working tree did not work well when the working tree was specified
via --work-tree (and obviously with --git-dir).

The command also works in a bare repository but it reads from the
(possibly stale, irrelevant and/or nonexistent) index, which may
need to be fixed to read from HEAD, but that is a completely
separate issue.  As a related tangent to this separate issue, we
may want to also fix "check-ignore", which refuses to work in a
bare repository, to also operate in a bare one.

* jc/check-attr-honor-working-tree:
  check-attr: move to the top of working tree when in non-bare repository
  t0003: do not chdir the whole test process

1  2 
builtin/check-attr.c
t/t0003-attributes.sh

Simple merge
index b9d79476e20b4ddf0f9e85c672df2061fb910f9d,6e6aef598836b6405006390aac5c5f11901de54d..f0fbb425545019a6275a347a5826f6ba2977d394
@@@ -195,57 -196,18 +195,66 @@@ test_expect_success 'root subdir attrib
        attr_check subdir/a/i unspecified
  '
  
 +test_expect_success 'negative patterns' '
 +      echo "!f test=bar" >.gitattributes &&
 +      git check-attr test -- '"'"'!f'"'"' 2>errors &&
 +      test_i18ngrep "Negative patterns are ignored" errors
 +'
 +
 +test_expect_success 'patterns starting with exclamation' '
 +      echo "\!f test=foo" >.gitattributes &&
 +      attr_check "!f" foo
 +'
 +
 +test_expect_success '"**" test' '
 +      echo "**/f foo=bar" >.gitattributes &&
 +      cat <<\EOF >expect &&
 +f: foo: bar
 +a/f: foo: bar
 +a/b/f: foo: bar
 +a/b/c/f: foo: bar
 +EOF
 +      git check-attr foo -- "f" >actual 2>err &&
 +      git check-attr foo -- "a/f" >>actual 2>>err &&
 +      git check-attr foo -- "a/b/f" >>actual 2>>err &&
 +      git check-attr foo -- "a/b/c/f" >>actual 2>>err &&
 +      test_cmp expect actual &&
 +      test_line_count = 0 err
 +'
 +
 +test_expect_success '"**" with no slashes test' '
 +      echo "a**f foo=bar" >.gitattributes &&
 +      git check-attr foo -- "f" >actual &&
 +      cat <<\EOF >expect &&
 +f: foo: unspecified
 +af: foo: bar
 +axf: foo: bar
 +a/f: foo: unspecified
 +a/b/f: foo: unspecified
 +a/b/c/f: foo: unspecified
 +EOF
 +      git check-attr foo -- "f" >actual 2>err &&
 +      git check-attr foo -- "af" >>actual 2>err &&
 +      git check-attr foo -- "axf" >>actual 2>err &&
 +      git check-attr foo -- "a/f" >>actual 2>>err &&
 +      git check-attr foo -- "a/b/f" >>actual 2>>err &&
 +      git check-attr foo -- "a/b/c/f" >>actual 2>>err &&
 +      test_cmp expect actual &&
 +      test_line_count = 0 err
 +'
 +
+ test_expect_success 'using --git-dir and --work-tree' '
+       mkdir unreal real &&
+       git init real &&
+       echo "file test=in-real" >real/.gitattributes &&
+       (
+               cd unreal &&
+               attr_check file in-real "--git-dir ../real/.git --work-tree ../real"
+       )
+ '
  test_expect_success 'setup bare' '
-       git clone --bare . bare.git &&
-       cd bare.git
+       git clone --bare . bare.git
  '
  
  test_expect_success 'bare repository: check that .gitattribute is ignored' '