From c43ce6d603c68f716f83f1da68cc4692202085e0 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 3 Aug 2006 14:41:29 -0700 Subject: Add a couple of subdirectory tests. We still have too few of them, but we have to start from somewhere. The general rule is to make tests easy to debug when run with -v (notice use of seemingly useless echo everywhere in the new tests). Signed-off-by: Junio C Hamano --- t/t1020-subdirectory.sh | 109 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100755 t/t1020-subdirectory.sh (limited to 't/t1020-subdirectory.sh') diff --git a/t/t1020-subdirectory.sh b/t/t1020-subdirectory.sh new file mode 100755 index 0000000000..4409b87f8d --- /dev/null +++ b/t/t1020-subdirectory.sh @@ -0,0 +1,109 @@ +#!/bin/sh +# +# Copyright (c) 2006 Junio C Hamano +# + +test_description='Try various core-level commands in subdirectory. +' + +. ./test-lib.sh + +test_expect_success setup ' + long="a b c d e f g h i j k l m n o p q r s t u v w x y z" && + for c in $long; do echo $c; done >one && + mkdir dir && + for c in x y z $long a b c; do echo $c; done >dir/two && + cp one original.one && + cp dir/two original.two +' +HERE=`pwd` +LF=' +' + +test_expect_success 'update-index and ls-files' ' + cd $HERE && + git-update-index --add one && + case "`git-ls-files`" in + one) echo ok one ;; + *) echo bad one; exit 1 ;; + esac && + cd dir && + git-update-index --add two && + case "`git-ls-files`" in + two) echo ok two ;; + *) echo bad two; exit 1 ;; + esac && + cd .. && + case "`git-ls-files`" in + dir/two"$LF"one) echo ok both ;; + *) echo bad; exit 1 ;; + esac +' + +test_expect_success 'cat-file' ' + cd $HERE && + two=`git-ls-files -s dir/two` && + two=`expr "$two" : "[0-7]* \\([0-9a-f]*\\)"` && + echo "$two" && + git-cat-file -p "$two" >actual && + cmp dir/two actual && + cd dir && + git-cat-file -p "$two" >actual && + cmp two actual +' +rm -f actual dir/actual + +test_expect_success 'diff-files' ' + cd $HERE && + echo a >>one && + echo d >>dir/two && + case "`git-diff-files --name-only`" in + dir/two"$LF"one) echo ok top ;; + *) echo bad top; exit 1 ;; + esac && + # diff should not omit leading paths + cd dir && + case "`git-diff-files --name-only`" in + dir/two"$LF"one) echo ok subdir ;; + *) echo bad subdir; exit 1 ;; + esac && + case "`git-diff-files --name-only .`" in + dir/two) echo ok subdir limited ;; + *) echo bad subdir limited; exit 1 ;; + esac +' + +test_expect_success 'write-tree' ' + cd $HERE && + top=`git-write-tree` && + echo $top && + cd dir && + sub=`git-write-tree` && + echo $sub && + test "z$top" = "z$sub" +' + +test_expect_success 'checkout-index' ' + cd $HERE && + git-checkout-index -f -u one && + cmp one original.one && + cd dir && + git-checkout-index -f -u two && + cmp two ../original.two +' + +test_expect_success 'read-tree' ' + cd $HERE && + rm -f one dir/two && + tree=`git-write-tree` && + git-read-tree --reset -u "$tree" && + cmp one original.one && + cmp dir/two original.two && + cd dir && + rm -f two && + git-read-tree --reset -u "$tree" && + cmp two ../original.two && + cmp ../one ../original.one +' + +test_done -- cgit v1.2.1 From 68025633e352264898de44ec4856552d9a3abece Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sat, 20 Jan 2007 03:09:34 +0100 Subject: Do not verify filenames in a bare repository For example, it makes no sense to check the presence of a file named "HEAD" when calling "git log HEAD" in a bare repository. Noticed by Han-Wen Nienhuys. Signed-off-by: Johannes Schindelin --- t/t1020-subdirectory.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 't/t1020-subdirectory.sh') diff --git a/t/t1020-subdirectory.sh b/t/t1020-subdirectory.sh index 4409b87f8d..c090c96185 100755 --- a/t/t1020-subdirectory.sh +++ b/t/t1020-subdirectory.sh @@ -106,4 +106,33 @@ test_expect_success 'read-tree' ' cmp ../one ../original.one ' +test_expect_success 'no file/rev ambuguity check inside .git' ' + cd $HERE && + git commit -a -m 1 && + cd $HERE/.git && + git show -s HEAD +' + +test_expect_success 'no file/rev ambuguity check inside a bare repo' ' + cd $HERE && + git clone -s --bare .git foo.git && + cd foo.git && GIT_DIR=. git show -s HEAD +' + +# This still does not work as it should... +: test_expect_success 'no file/rev ambuguity check inside a bare repo' ' + cd $HERE && + git clone -s --bare .git foo.git && + cd foo.git && git show -s HEAD +' + +test_expect_success 'detection should not be fooled by a symlink' ' + cd $HERE && + rm -fr foo.git && + git clone -s .git another && + ln -s another yetanother && + cd yetanother/.git && + git show -s HEAD +' + test_done -- cgit v1.2.1 From 3dff5379bf1e3fda5e5a84ca5813b0c0cfd51be7 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Sat, 3 Feb 2007 23:49:16 -0500 Subject: Assorted typo fixes Signed-off-by: Junio C Hamano --- t/t1020-subdirectory.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 't/t1020-subdirectory.sh') diff --git a/t/t1020-subdirectory.sh b/t/t1020-subdirectory.sh index c090c96185..1e8f9e59df 100755 --- a/t/t1020-subdirectory.sh +++ b/t/t1020-subdirectory.sh @@ -106,21 +106,21 @@ test_expect_success 'read-tree' ' cmp ../one ../original.one ' -test_expect_success 'no file/rev ambuguity check inside .git' ' +test_expect_success 'no file/rev ambiguity check inside .git' ' cd $HERE && git commit -a -m 1 && cd $HERE/.git && git show -s HEAD ' -test_expect_success 'no file/rev ambuguity check inside a bare repo' ' +test_expect_success 'no file/rev ambiguity check inside a bare repo' ' cd $HERE && git clone -s --bare .git foo.git && cd foo.git && GIT_DIR=. git show -s HEAD ' # This still does not work as it should... -: test_expect_success 'no file/rev ambuguity check inside a bare repo' ' +: test_expect_success 'no file/rev ambiguity check inside a bare repo' ' cd $HERE && git clone -s --bare .git foo.git && cd foo.git && git show -s HEAD -- cgit v1.2.1 From 5be60078c935ed08ee8eb5a32680bdfb6bb5bdf3 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 2 Jul 2007 22:52:14 -0700 Subject: Rewrite "git-frotz" to "git frotz" This uses the remove-dashes target to replace "git-frotz" to "git frotz". Signed-off-by: Junio C Hamano --- t/t1020-subdirectory.sh | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 't/t1020-subdirectory.sh') diff --git a/t/t1020-subdirectory.sh b/t/t1020-subdirectory.sh index 1e8f9e59df..b9cef3422c 100755 --- a/t/t1020-subdirectory.sh +++ b/t/t1020-subdirectory.sh @@ -22,19 +22,19 @@ LF=' test_expect_success 'update-index and ls-files' ' cd $HERE && - git-update-index --add one && - case "`git-ls-files`" in + git update-index --add one && + case "`git ls-files`" in one) echo ok one ;; *) echo bad one; exit 1 ;; esac && cd dir && - git-update-index --add two && - case "`git-ls-files`" in + git update-index --add two && + case "`git ls-files`" in two) echo ok two ;; *) echo bad two; exit 1 ;; esac && cd .. && - case "`git-ls-files`" in + case "`git ls-files`" in dir/two"$LF"one) echo ok both ;; *) echo bad; exit 1 ;; esac @@ -42,13 +42,13 @@ test_expect_success 'update-index and ls-files' ' test_expect_success 'cat-file' ' cd $HERE && - two=`git-ls-files -s dir/two` && + two=`git ls-files -s dir/two` && two=`expr "$two" : "[0-7]* \\([0-9a-f]*\\)"` && echo "$two" && - git-cat-file -p "$two" >actual && + git cat-file -p "$two" >actual && cmp dir/two actual && cd dir && - git-cat-file -p "$two" >actual && + git cat-file -p "$two" >actual && cmp two actual ' rm -f actual dir/actual @@ -57,17 +57,17 @@ test_expect_success 'diff-files' ' cd $HERE && echo a >>one && echo d >>dir/two && - case "`git-diff-files --name-only`" in + case "`git diff-files --name-only`" in dir/two"$LF"one) echo ok top ;; *) echo bad top; exit 1 ;; esac && # diff should not omit leading paths cd dir && - case "`git-diff-files --name-only`" in + case "`git diff-files --name-only`" in dir/two"$LF"one) echo ok subdir ;; *) echo bad subdir; exit 1 ;; esac && - case "`git-diff-files --name-only .`" in + case "`git diff-files --name-only .`" in dir/two) echo ok subdir limited ;; *) echo bad subdir limited; exit 1 ;; esac @@ -75,33 +75,33 @@ test_expect_success 'diff-files' ' test_expect_success 'write-tree' ' cd $HERE && - top=`git-write-tree` && + top=`git write-tree` && echo $top && cd dir && - sub=`git-write-tree` && + sub=`git write-tree` && echo $sub && test "z$top" = "z$sub" ' test_expect_success 'checkout-index' ' cd $HERE && - git-checkout-index -f -u one && + git checkout-index -f -u one && cmp one original.one && cd dir && - git-checkout-index -f -u two && + git checkout-index -f -u two && cmp two ../original.two ' test_expect_success 'read-tree' ' cd $HERE && rm -f one dir/two && - tree=`git-write-tree` && - git-read-tree --reset -u "$tree" && + tree=`git write-tree` && + git read-tree --reset -u "$tree" && cmp one original.one && cmp dir/two original.two && cd dir && rm -f two && - git-read-tree --reset -u "$tree" && + git read-tree --reset -u "$tree" && cmp two ../original.two && cmp ../one ../original.one ' -- cgit v1.2.1 From f69e836fab2b634281d92a0d304de4d768e479cc Mon Sep 17 00:00:00 2001 From: Bryan Donlan Date: Sun, 4 May 2008 01:37:59 -0400 Subject: Fix tests breaking when checkout path contains shell metacharacters This fixes the remainder of the issues where the test script itself is at fault for failing when the git checkout path contains whitespace or other shell metacharacters. The majority of git svn tests used the idiom test_expect_success "title" "test script using $svnrepo" These were changed to have the test script in single-quotes: test_expect_success "title" 'test script using "$svnrepo"' which unfortunately makes the patch appear larger than it really is. One consequence of this change is that in the verbose test output the value of $svnrepo (and in some cases other variables, too) is no longer expanded, i.e. previously we saw * expecting success: test script using /path/to/git/t/trash/svnrepo but now it is: * expecting success: test script using "$svnrepo" Signed-off-by: Bryan Donlan Signed-off-by: Junio C Hamano --- t/t1020-subdirectory.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 't/t1020-subdirectory.sh') diff --git a/t/t1020-subdirectory.sh b/t/t1020-subdirectory.sh index b9cef3422c..fc386ba033 100755 --- a/t/t1020-subdirectory.sh +++ b/t/t1020-subdirectory.sh @@ -21,7 +21,7 @@ LF=' ' test_expect_success 'update-index and ls-files' ' - cd $HERE && + cd "$HERE" && git update-index --add one && case "`git ls-files`" in one) echo ok one ;; @@ -41,7 +41,7 @@ test_expect_success 'update-index and ls-files' ' ' test_expect_success 'cat-file' ' - cd $HERE && + cd "$HERE" && two=`git ls-files -s dir/two` && two=`expr "$two" : "[0-7]* \\([0-9a-f]*\\)"` && echo "$two" && @@ -54,7 +54,7 @@ test_expect_success 'cat-file' ' rm -f actual dir/actual test_expect_success 'diff-files' ' - cd $HERE && + cd "$HERE" && echo a >>one && echo d >>dir/two && case "`git diff-files --name-only`" in @@ -74,7 +74,7 @@ test_expect_success 'diff-files' ' ' test_expect_success 'write-tree' ' - cd $HERE && + cd "$HERE" && top=`git write-tree` && echo $top && cd dir && @@ -84,7 +84,7 @@ test_expect_success 'write-tree' ' ' test_expect_success 'checkout-index' ' - cd $HERE && + cd "$HERE" && git checkout-index -f -u one && cmp one original.one && cd dir && @@ -93,7 +93,7 @@ test_expect_success 'checkout-index' ' ' test_expect_success 'read-tree' ' - cd $HERE && + cd "$HERE" && rm -f one dir/two && tree=`git write-tree` && git read-tree --reset -u "$tree" && @@ -107,27 +107,27 @@ test_expect_success 'read-tree' ' ' test_expect_success 'no file/rev ambiguity check inside .git' ' - cd $HERE && + cd "$HERE" && git commit -a -m 1 && - cd $HERE/.git && + cd "$HERE"/.git && git show -s HEAD ' test_expect_success 'no file/rev ambiguity check inside a bare repo' ' - cd $HERE && + cd "$HERE" && git clone -s --bare .git foo.git && cd foo.git && GIT_DIR=. git show -s HEAD ' # This still does not work as it should... : test_expect_success 'no file/rev ambiguity check inside a bare repo' ' - cd $HERE && + cd "$HERE" && git clone -s --bare .git foo.git && cd foo.git && git show -s HEAD ' test_expect_success 'detection should not be fooled by a symlink' ' - cd $HERE && + cd "$HERE" && rm -fr foo.git && git clone -s .git another && ln -s another yetanother && -- cgit v1.2.1 From 704a3143d5ba0709727430154ef3dad600aad4de Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Wed, 4 Mar 2009 22:38:24 +0100 Subject: Use prerequisite tags to skip tests that depend on symbolic links Many tests depend on that symbolic links work. This introduces a check that sets the prerequisite tag SYMLINKS if the file system supports symbolic links. Since so many tests have to check for this prerequisite, we do the check in test-lib.sh, so that we don't need to repeat the test in many scripts. To check for 'ln -s' failures, you can use a FAT partition on Linux: $ mkdosfs -C git-on-fat 1000000 $ sudo mount -o loop,uid=j6t,gid=users,shortname=winnt git-on-fat /mnt Clone git to /mnt and $ GIT_SKIP_TESTS='t0001.1[34] t0010 t1301 t403[34] t4129.[47] t5701.7 t7701.3 t9100 t9101.26 t9119 t9124.[67] t9200.10 t9600.6' \ make test (These additionally skipped tests depend on POSIX permissions that FAT on Linux does not provide.) Signed-off-by: Johannes Sixt --- t/t1020-subdirectory.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t1020-subdirectory.sh') diff --git a/t/t1020-subdirectory.sh b/t/t1020-subdirectory.sh index fc386ba033..210e594f6f 100755 --- a/t/t1020-subdirectory.sh +++ b/t/t1020-subdirectory.sh @@ -126,7 +126,7 @@ test_expect_success 'no file/rev ambiguity check inside a bare repo' ' cd foo.git && git show -s HEAD ' -test_expect_success 'detection should not be fooled by a symlink' ' +test_expect_success SYMLINKS 'detection should not be fooled by a symlink' ' cd "$HERE" && rm -fr foo.git && git clone -s .git another && -- cgit v1.2.1 From 335f87871fe5aa6b3fd55b2b4e80f16fe9681483 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Thu, 24 Jun 2010 17:44:49 +0000 Subject: tests: Say "pass" rather than "ok" on empty lines for TAP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Lines that begin with "ok" confuse the TAP harness because it can't distinguish them from a test counter. Work around the issue by saying "pass" instead, which isn't a reserved TAP word. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- t/t1020-subdirectory.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 't/t1020-subdirectory.sh') diff --git a/t/t1020-subdirectory.sh b/t/t1020-subdirectory.sh index 210e594f6f..56874996a6 100755 --- a/t/t1020-subdirectory.sh +++ b/t/t1020-subdirectory.sh @@ -24,18 +24,18 @@ test_expect_success 'update-index and ls-files' ' cd "$HERE" && git update-index --add one && case "`git ls-files`" in - one) echo ok one ;; + one) echo pass one ;; *) echo bad one; exit 1 ;; esac && cd dir && git update-index --add two && case "`git ls-files`" in - two) echo ok two ;; + two) echo pass two ;; *) echo bad two; exit 1 ;; esac && cd .. && case "`git ls-files`" in - dir/two"$LF"one) echo ok both ;; + dir/two"$LF"one) echo pass both ;; *) echo bad; exit 1 ;; esac ' @@ -58,17 +58,17 @@ test_expect_success 'diff-files' ' echo a >>one && echo d >>dir/two && case "`git diff-files --name-only`" in - dir/two"$LF"one) echo ok top ;; + dir/two"$LF"one) echo pass top ;; *) echo bad top; exit 1 ;; esac && # diff should not omit leading paths cd dir && case "`git diff-files --name-only`" in - dir/two"$LF"one) echo ok subdir ;; + dir/two"$LF"one) echo pass subdir ;; *) echo bad subdir; exit 1 ;; esac && case "`git diff-files --name-only .`" in - dir/two) echo ok subdir limited ;; + dir/two) echo pass subdir limited ;; *) echo bad subdir limited; exit 1 ;; esac ' -- cgit v1.2.1 From fd4ec4f2bb980ce07bb28d5823a95610f251d00b Mon Sep 17 00:00:00 2001 From: Jens Lehmann Date: Mon, 6 Sep 2010 20:39:54 +0200 Subject: Several tests: cd inside subshell instead of around Fixed all places where it was a straightforward change from cd'ing into a directory and back via "cd .." to a cd inside a subshell. Found these places with "git grep -w "cd \.\.". Signed-off-by: Jens Lehmann Signed-off-by: Junio C Hamano --- t/t1020-subdirectory.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 't/t1020-subdirectory.sh') diff --git a/t/t1020-subdirectory.sh b/t/t1020-subdirectory.sh index 56874996a6..c36157a896 100755 --- a/t/t1020-subdirectory.sh +++ b/t/t1020-subdirectory.sh @@ -27,13 +27,13 @@ test_expect_success 'update-index and ls-files' ' one) echo pass one ;; *) echo bad one; exit 1 ;; esac && - cd dir && + (cd dir && git update-index --add two && case "`git ls-files`" in two) echo pass two ;; *) echo bad two; exit 1 ;; - esac && - cd .. && + esac + ) && case "`git ls-files`" in dir/two"$LF"one) echo pass both ;; *) echo bad; exit 1 ;; -- cgit v1.2.1 From 18a826924284339e2b637ab747f196235bee1939 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Mon, 6 Sep 2010 20:42:54 -0500 Subject: tests: subshell indentation stylefix Format the subshells introduced by the previous patch (Several tests: cd inside subshell instead of around, 2010-09-06) like so: ( cd subdir && ... ) && This is generally easier to read and has the nice side-effect that this patch will show what commands are used in the subshell, making it easier to check for lost environment variables and similar behavior changes. Cc: Jens Lehmann Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- t/t1020-subdirectory.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 't/t1020-subdirectory.sh') diff --git a/t/t1020-subdirectory.sh b/t/t1020-subdirectory.sh index c36157a896..0d0da17eb8 100755 --- a/t/t1020-subdirectory.sh +++ b/t/t1020-subdirectory.sh @@ -27,12 +27,13 @@ test_expect_success 'update-index and ls-files' ' one) echo pass one ;; *) echo bad one; exit 1 ;; esac && - (cd dir && - git update-index --add two && - case "`git ls-files`" in - two) echo pass two ;; - *) echo bad two; exit 1 ;; - esac + ( + cd dir && + git update-index --add two && + case "`git ls-files`" in + two) echo pass two ;; + *) echo bad two; exit 1 ;; + esac ) && case "`git ls-files`" in dir/two"$LF"one) echo pass both ;; -- cgit v1.2.1 From fd3c32c9815441ebbc3d46a3ff4ef862b3a9688c Mon Sep 17 00:00:00 2001 From: Jens Lehmann Date: Tue, 7 Sep 2010 12:29:20 +0200 Subject: t1020: Get rid of 'cd "$HERE"' at the start of each test To achieve that, all cd commands which weren't inside a subshell had to be put into a new one. Signed-off-by: Jens Lehmann Signed-off-by: Junio C Hamano --- t/t1020-subdirectory.sh | 91 +++++++++++++++++++++++++++---------------------- 1 file changed, 50 insertions(+), 41 deletions(-) (limited to 't/t1020-subdirectory.sh') diff --git a/t/t1020-subdirectory.sh b/t/t1020-subdirectory.sh index 0d0da17eb8..a3ac33801a 100755 --- a/t/t1020-subdirectory.sh +++ b/t/t1020-subdirectory.sh @@ -16,12 +16,10 @@ test_expect_success setup ' cp one original.one && cp dir/two original.two ' -HERE=`pwd` LF=' ' test_expect_success 'update-index and ls-files' ' - cd "$HERE" && git update-index --add one && case "`git ls-files`" in one) echo pass one ;; @@ -42,20 +40,20 @@ test_expect_success 'update-index and ls-files' ' ' test_expect_success 'cat-file' ' - cd "$HERE" && two=`git ls-files -s dir/two` && two=`expr "$two" : "[0-7]* \\([0-9a-f]*\\)"` && echo "$two" && git cat-file -p "$two" >actual && cmp dir/two actual && - cd dir && - git cat-file -p "$two" >actual && - cmp two actual + ( + cd dir && + git cat-file -p "$two" >actual && + cmp two actual + ) ' rm -f actual dir/actual test_expect_success 'diff-files' ' - cd "$HERE" && echo a >>one && echo d >>dir/two && case "`git diff-files --name-only`" in @@ -63,77 +61,88 @@ test_expect_success 'diff-files' ' *) echo bad top; exit 1 ;; esac && # diff should not omit leading paths - cd dir && - case "`git diff-files --name-only`" in - dir/two"$LF"one) echo pass subdir ;; - *) echo bad subdir; exit 1 ;; - esac && - case "`git diff-files --name-only .`" in - dir/two) echo pass subdir limited ;; - *) echo bad subdir limited; exit 1 ;; - esac + ( + cd dir && + case "`git diff-files --name-only`" in + dir/two"$LF"one) echo pass subdir ;; + *) echo bad subdir; exit 1 ;; + esac && + case "`git diff-files --name-only .`" in + dir/two) echo pass subdir limited ;; + *) echo bad subdir limited; exit 1 ;; + esac + ) ' test_expect_success 'write-tree' ' - cd "$HERE" && top=`git write-tree` && echo $top && - cd dir && - sub=`git write-tree` && - echo $sub && - test "z$top" = "z$sub" + ( + cd dir && + sub=`git write-tree` && + echo $sub && + test "z$top" = "z$sub" + ) ' test_expect_success 'checkout-index' ' - cd "$HERE" && git checkout-index -f -u one && cmp one original.one && - cd dir && - git checkout-index -f -u two && - cmp two ../original.two + ( + cd dir && + git checkout-index -f -u two && + cmp two ../original.two + ) ' test_expect_success 'read-tree' ' - cd "$HERE" && rm -f one dir/two && tree=`git write-tree` && git read-tree --reset -u "$tree" && cmp one original.one && cmp dir/two original.two && - cd dir && - rm -f two && - git read-tree --reset -u "$tree" && - cmp two ../original.two && - cmp ../one ../original.one + ( + cd dir && + rm -f two && + git read-tree --reset -u "$tree" && + cmp two ../original.two && + cmp ../one ../original.one + ) ' test_expect_success 'no file/rev ambiguity check inside .git' ' - cd "$HERE" && git commit -a -m 1 && - cd "$HERE"/.git && - git show -s HEAD + ( + cd .git && + git show -s HEAD + ) ' test_expect_success 'no file/rev ambiguity check inside a bare repo' ' - cd "$HERE" && git clone -s --bare .git foo.git && - cd foo.git && GIT_DIR=. git show -s HEAD + ( + cd foo.git && + GIT_DIR=. git show -s HEAD + ) ' # This still does not work as it should... : test_expect_success 'no file/rev ambiguity check inside a bare repo' ' - cd "$HERE" && git clone -s --bare .git foo.git && - cd foo.git && git show -s HEAD + ( + cd foo.git && + git show -s HEAD + ) ' test_expect_success SYMLINKS 'detection should not be fooled by a symlink' ' - cd "$HERE" && rm -fr foo.git && git clone -s .git another && ln -s another yetanother && - cd yetanother/.git && - git show -s HEAD + ( + cd yetanother/.git && + git show -s HEAD + ) ' test_done -- cgit v1.2.1 From 101662c22518de4abfbd5b2fc38b3ec1fa638494 Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Fri, 26 Nov 2010 22:32:37 +0700 Subject: t1020-subdirectory: test alias expansion in a subdirectory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a test for alias expansion in a subdirectory of the worktree. Signed-off-by: Michael J Gruber Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- t/t1020-subdirectory.sh | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 't/t1020-subdirectory.sh') diff --git a/t/t1020-subdirectory.sh b/t/t1020-subdirectory.sh index a3ac33801a..1fd187c5eb 100755 --- a/t/t1020-subdirectory.sh +++ b/t/t1020-subdirectory.sh @@ -110,6 +110,14 @@ test_expect_success 'read-tree' ' ) ' +test_expect_success 'alias expansion' ' + ( + git config alias.ss status && + cd dir && + git status && + git ss + ) +' test_expect_success 'no file/rev ambiguity check inside .git' ' git commit -a -m 1 && ( -- cgit v1.2.1 From 0daed41791373a5530c2b33e09b134ce8820e0c2 Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Wed, 27 Apr 2011 10:36:26 +0200 Subject: t1020: test !alias in subdirectory Signed-off-by: Michael J Gruber Signed-off-by: Junio C Hamano --- t/t1020-subdirectory.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 't/t1020-subdirectory.sh') diff --git a/t/t1020-subdirectory.sh b/t/t1020-subdirectory.sh index 1fd187c5eb..66e40d38a3 100755 --- a/t/t1020-subdirectory.sh +++ b/t/t1020-subdirectory.sh @@ -118,6 +118,17 @@ test_expect_success 'alias expansion' ' git ss ) ' + +test_expect_success '!alias expansion' ' + pwd >expect && + ( + git config alias.test !pwd && + cd dir && + git test >../actual + ) && + test_cmp expect actual +' + test_expect_success 'no file/rev ambiguity check inside .git' ' git commit -a -m 1 && ( -- cgit v1.2.1 From 7cf16a14f5c070f7b14cf28023769450133172ae Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Wed, 27 Apr 2011 10:36:27 +0200 Subject: handle_alias: provide GIT_PREFIX to !alias Provide an environment variable GIT_PREFIX which contains the subdirectory from which a !alias was called (i.e. 'git rev-parse --show-prefix') since these cd to the to level directory before they are executed. Signed-off-by: Michael J Gruber Signed-off-by: Junio C Hamano --- t/t1020-subdirectory.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 't/t1020-subdirectory.sh') diff --git a/t/t1020-subdirectory.sh b/t/t1020-subdirectory.sh index 66e40d38a3..ddc3921ac6 100755 --- a/t/t1020-subdirectory.sh +++ b/t/t1020-subdirectory.sh @@ -129,6 +129,16 @@ test_expect_success '!alias expansion' ' test_cmp expect actual ' +test_expect_success 'GIT_PREFIX for !alias' ' + printf "dir/" >expect && + ( + git config alias.test "!sh -c \"printf \$GIT_PREFIX\"" && + cd dir && + git test >../actual + ) && + test_cmp expect actual +' + test_expect_success 'no file/rev ambiguity check inside .git' ' git commit -a -m 1 && ( -- cgit v1.2.1 From ea5070c91f23e41a88dec48d2f8d96444c2d647a Mon Sep 17 00:00:00 2001 From: Jens Lehmann Date: Wed, 25 May 2011 22:10:41 +0200 Subject: Teach read-tree the -n|--dry-run option The option can be used to check if read-tree with the same set of other options like "-m" and "-u" would succeed without actually changing either the index or the working tree. The relevant tests in the t10?? range were extended to do a read-tree -n before the real read-tree to make sure neither the index nor any local files were changed with -n and the same exit code as without -n is returned. The helper functions added for that purpose reside in the new t/lib-read-tree.sh file. The only exception is #13 in t1004 ("unlinking an un-unlink-able symlink"). As this is an issue of wrong directory permissions it is not detected with -n. Signed-off-by: Jens Lehmann Signed-off-by: Junio C Hamano --- t/t1020-subdirectory.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 't/t1020-subdirectory.sh') diff --git a/t/t1020-subdirectory.sh b/t/t1020-subdirectory.sh index ddc3921ac6..f6a44c9ee0 100755 --- a/t/t1020-subdirectory.sh +++ b/t/t1020-subdirectory.sh @@ -7,6 +7,7 @@ test_description='Try various core-level commands in subdirectory. ' . ./test-lib.sh +. "$TEST_DIRECTORY"/lib-read-tree.sh test_expect_success setup ' long="a b c d e f g h i j k l m n o p q r s t u v w x y z" && @@ -98,13 +99,13 @@ test_expect_success 'checkout-index' ' test_expect_success 'read-tree' ' rm -f one dir/two && tree=`git write-tree` && - git read-tree --reset -u "$tree" && + read_tree_u_must_succeed --reset -u "$tree" && cmp one original.one && cmp dir/two original.two && ( cd dir && rm -f two && - git read-tree --reset -u "$tree" && + read_tree_u_must_succeed --reset -u "$tree" && cmp two ../original.two && cmp ../one ../original.one ) -- cgit v1.2.1 From 1f5d271f5e8f7b1e2a5b296ff43ca4087eb08244 Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Wed, 25 May 2011 20:37:12 -0700 Subject: setup: Provide GIT_PREFIX to built-ins GIT_PREFIX was added in 7cf16a14f5c070f7b14cf28023769450133172ae so that aliases can know the directory from which a !alias was called. Knowing the prefix relative to the root is helpful in other programs so export it to built-ins as well. Helped-by: Michael J Gruber Signed-off-by: David Aguilar Signed-off-by: Junio C Hamano --- t/t1020-subdirectory.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 't/t1020-subdirectory.sh') diff --git a/t/t1020-subdirectory.sh b/t/t1020-subdirectory.sh index ddc3921ac6..3c7448026d 100755 --- a/t/t1020-subdirectory.sh +++ b/t/t1020-subdirectory.sh @@ -139,6 +139,22 @@ test_expect_success 'GIT_PREFIX for !alias' ' test_cmp expect actual ' +test_expect_success 'GIT_PREFIX for built-ins' ' + # Use GIT_EXTERNAL_DIFF to test that the "diff" built-in + # receives the GIT_PREFIX variable. + printf "dir/" >expect && + printf "#!/bin/sh\n" >diff && + printf "printf \"\$GIT_PREFIX\"" >>diff && + chmod +x diff && + ( + cd dir && + printf "change" >two && + env GIT_EXTERNAL_DIFF=./diff git diff >../actual + git checkout -- two + ) && + test_cmp expect actual +' + test_expect_success 'no file/rev ambiguity check inside .git' ' git commit -a -m 1 && ( -- cgit v1.2.1 From 3f4ab627146fcb1e1887198f520f39fb84fde73a Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 8 Aug 2011 11:51:00 -0700 Subject: test: consolidate definition of $LF As we seem to need this variable that holds a single LF character in many places, define it in test-lib.sh and let the test scripts use it. Signed-off-by: Junio C Hamano --- t/t1020-subdirectory.sh | 2 -- 1 file changed, 2 deletions(-) (limited to 't/t1020-subdirectory.sh') diff --git a/t/t1020-subdirectory.sh b/t/t1020-subdirectory.sh index f6a44c9ee0..7e79961228 100755 --- a/t/t1020-subdirectory.sh +++ b/t/t1020-subdirectory.sh @@ -17,8 +17,6 @@ test_expect_success setup ' cp one original.one && cp dir/two original.two ' -LF=' -' test_expect_success 'update-index and ls-files' ' git update-index --add one && -- cgit v1.2.1