From cf94ccda356cc732a883f16342440330d3f644ec Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 7 Feb 2008 00:02:08 -0800 Subject: gitattributes: fix relative path matching There was an embarrassing pair of off-by-one miscounting that failed to match path "a/b/c" when "a/.gitattributes" tried to name it with relative path "b/c". This fixes it. Signed-off-by: Junio C Hamano --- t/t0003-attributes.sh | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100755 t/t0003-attributes.sh (limited to 't/t0003-attributes.sh') diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh new file mode 100755 index 0000000000..47f08a46c2 --- /dev/null +++ b/t/t0003-attributes.sh @@ -0,0 +1,49 @@ +#!/bin/sh + +test_description=gitattributes + +. ./test-lib.sh + +attr_check () { + + path="$1" + expect="$2" + + git check-attr test -- "$path" >actual && + echo "$path: test: $2" >expect && + diff -u expect actual + +} + + +test_expect_success 'setup' ' + + mkdir -p a/b/d a/c && + ( + echo "f test=f" + ) >.gitattributes && + ( + echo "g test=a/g" && + echo "b/g test=a/b/g" + ) >a/.gitattributes && + ( + echo "h test=a/b/h" && + echo "d/* test=a/b/d/*" + ) >a/b/.gitattributes + +' + +test_expect_success 'attribute test' ' + + attr_check f f && + attr_check a/f f && + attr_check a/c/f f && + attr_check a/g a/g && + attr_check a/b/g a/b/g && + attr_check b/g unspecified && + attr_check a/b/h a/b/h && + attr_check a/b/d/g "a/b/d/*" + +' + +test_done -- cgit v1.2.3 From 82ebb0b6ec7470cab96a013d3d719c109003ef83 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 12 Mar 2008 17:36:36 -0400 Subject: add test_cmp function for test scripts Many scripts compare actual and expected output using "diff -u". This is nicer than "cmp" because the output shows how the two differ. However, not all versions of diff understand -u, leading to unnecessary test failure. This adds a test_cmp function to the test scripts and switches all "diff -u" invocations to use it. The function uses the contents of "$GIT_TEST_CMP" to compare its arguments; the default is "diff -u". On systems with a less-capable diff, you can do: GIT_TEST_CMP=cmp make test Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/t0003-attributes.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t0003-attributes.sh') diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh index 47f08a46c2..3faf135e38 100755 --- a/t/t0003-attributes.sh +++ b/t/t0003-attributes.sh @@ -11,7 +11,7 @@ attr_check () { git check-attr test -- "$path" >actual && echo "$path: test: $2" >expect && - diff -u expect actual + test_cmp expect actual } -- cgit v1.2.3 From 82881b38235d0a46a4486dc5dc819c5d0ee3f2c1 Mon Sep 17 00:00:00 2001 From: Matthew Ogilvie Date: Tue, 22 Apr 2008 12:19:12 -0600 Subject: gitattributes: Fix subdirectory attributes specified from root directory Signed-off-by: Matthew Ogilvie Signed-off-by: Junio C Hamano --- t/t0003-attributes.sh | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 't/t0003-attributes.sh') diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh index 47f08a46c2..e7fa4f5d43 100755 --- a/t/t0003-attributes.sh +++ b/t/t0003-attributes.sh @@ -21,6 +21,7 @@ test_expect_success 'setup' ' mkdir -p a/b/d a/c && ( echo "f test=f" + echo "a/i test=a/i" ) >.gitattributes && ( echo "g test=a/g" && @@ -46,4 +47,11 @@ test_expect_success 'attribute test' ' ' +test_expect_success 'root subdir attribute test' ' + + attr_check a/i a/i && + attr_check subdir/a/i unspecified + +' + test_done -- cgit v1.2.3 From 2d35d556e27cd3e7f3d2eea04a7f0d7ee8513f8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Sun, 8 Jun 2008 17:16:11 +0200 Subject: Ignore .gitattributes in bare repositories Attributes can be specified at three different places: the internal table of default values, the file $GIT_DIR/info/attributes and files named .gitattributes in the work tree. Since bare repositories don't have a work tree, git should ignore any .gitattributes files there. This patch makes git do that, so the only way left for a user to specify attributes in a bare repository is the file info/attributes (in addition to changing the defaults and recompiling). In addition, git-check-attr is now allowed to run without a work tree. Like any user of the code in attr.c, it ignores the .gitattributes files when run in a bare repository. It can still read from info/attributes. Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- t/t0003-attributes.sh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 't/t0003-attributes.sh') diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh index c56d2fbaba..3d8e06a20f 100755 --- a/t/t0003-attributes.sh +++ b/t/t0003-attributes.sh @@ -54,4 +54,39 @@ test_expect_success 'root subdir attribute test' ' ' +test_expect_success 'setup bare' ' + + git clone --bare . bare.git && + cd bare.git + +' + +test_expect_success 'bare repository: check that .gitattribute is ignored' ' + + ( + echo "f test=f" + echo "a/i test=a/i" + ) >.gitattributes && + attr_check f unspecified && + attr_check a/f unspecified && + attr_check a/c/f unspecified && + attr_check a/i unspecified && + attr_check subdir/a/i unspecified + +' + +test_expect_success 'bare repository: test info/attributes' ' + + ( + echo "f test=f" + echo "a/i test=a/i" + ) >info/attributes && + attr_check f f && + attr_check a/f f && + attr_check a/c/f f && + attr_check a/i a/i && + attr_check subdir/a/i unspecified + +' + test_done -- cgit v1.2.3 From b4666852a06af0c969ad8f1c444d0b48c4451e76 Mon Sep 17 00:00:00 2001 From: Dmitry Potapov Date: Tue, 7 Oct 2008 04:16:52 +0400 Subject: check-attr: Add --stdin option This allows multiple paths to be specified on stdin. Signed-off-by: Dmitry Potapov Signed-off-by: Shawn O. Pearce --- t/t0003-attributes.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 't/t0003-attributes.sh') diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh index 3d8e06a20f..1c77192eb3 100755 --- a/t/t0003-attributes.sh +++ b/t/t0003-attributes.sh @@ -47,6 +47,23 @@ test_expect_success 'attribute test' ' ' +test_expect_success 'attribute test: read paths from stdin' ' + + cat < expect +f: test: f +a/f: test: f +a/c/f: test: f +a/g: test: a/g +a/b/g: test: a/b/g +b/g: test: unspecified +a/b/h: test: a/b/h +a/b/d/g: test: a/b/d/* +EOF + + sed -e "s/:.*//" < expect | git check-attr --stdin test > actual && + test_cmp expect actual +' + test_expect_success 'root subdir attribute test' ' attr_check a/i a/i && -- cgit v1.2.3