From 93c44d493b8c98b9bb74e4f78aa90ee20a01f078 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Sat, 12 May 2007 02:42:00 -0400 Subject: git-add: allow path limiting with -u Rather than updating all working tree paths, we limit ourselves to paths listed on the command line. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/t2200-add-update.sh | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 t/t2200-add-update.sh (limited to 't/t2200-add-update.sh') diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh new file mode 100755 index 0000000000..83005e70d0 --- /dev/null +++ b/t/t2200-add-update.sh @@ -0,0 +1,38 @@ +#!/bin/sh + +test_description='git-add -u with path limiting + +This test creates a working tree state with three files: + + top (previously committed, modified) + dir/sub (previously committed, modified) + dir/other (untracked) + +and issues a git-add -u with path limiting on "dir" to add +only the updates to dir/sub.' + +. ./test-lib.sh + +test_expect_success 'setup' ' +echo initial >top && +mkdir dir && +echo initial >dir/sub && +git-add dir/sub top && +git-commit -m initial && +echo changed >top && +echo changed >dir/sub && +echo other >dir/other +' + +test_expect_success 'update' 'git-add -u dir' + +test_expect_success 'update touched correct path' \ + 'test "`git-diff-files --name-status dir/sub`" = ""' + +test_expect_success 'update did not touch other tracked files' \ + 'test "`git-diff-files --name-status top`" = "M top"' + +test_expect_success 'update did not touch untracked files' \ + 'test "`git-diff-files --name-status dir/other`" = ""' + +test_done -- cgit v1.2.3 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/t2200-add-update.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 't/t2200-add-update.sh') diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh index 83005e70d0..0a703af149 100755 --- a/t/t2200-add-update.sh +++ b/t/t2200-add-update.sh @@ -1,6 +1,6 @@ #!/bin/sh -test_description='git-add -u with path limiting +test_description='git add -u with path limiting This test creates a working tree state with three files: @@ -8,7 +8,7 @@ This test creates a working tree state with three files: dir/sub (previously committed, modified) dir/other (untracked) -and issues a git-add -u with path limiting on "dir" to add +and issues a git add -u with path limiting on "dir" to add only the updates to dir/sub.' . ./test-lib.sh @@ -17,22 +17,22 @@ test_expect_success 'setup' ' echo initial >top && mkdir dir && echo initial >dir/sub && -git-add dir/sub top && +git add dir/sub top && git-commit -m initial && echo changed >top && echo changed >dir/sub && echo other >dir/other ' -test_expect_success 'update' 'git-add -u dir' +test_expect_success 'update' 'git add -u dir' test_expect_success 'update touched correct path' \ - 'test "`git-diff-files --name-status dir/sub`" = ""' + 'test "`git diff-files --name-status dir/sub`" = ""' test_expect_success 'update did not touch other tracked files' \ - 'test "`git-diff-files --name-status top`" = "M top"' + 'test "`git diff-files --name-status top`" = "M top"' test_expect_success 'update did not touch untracked files' \ - 'test "`git-diff-files --name-status dir/other`" = ""' + 'test "`git diff-files --name-status dir/other`" = ""' test_done -- cgit v1.2.3 From a4882c27f8b3793d94b03fd503a0c67ad9772cf6 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 15 Aug 2007 14:12:14 -0700 Subject: Fix "git add -u" data corruption. This applies to 'maint' to fix a rather serious data corruption issue. When "git add -u" affects a subdirectory in such a way that the only changes to its contents are path removals, the next tree object written out of that index was bogus, as the remove codepath forgot to invalidate the cache-tree entry. Reported by Salikh Zakirov. Signed-off-by: Junio C Hamano --- t/t2200-add-update.sh | 59 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 16 deletions(-) (limited to 't/t2200-add-update.sh') diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh index 83005e70d0..4c7c6af432 100755 --- a/t/t2200-add-update.sh +++ b/t/t2200-add-update.sh @@ -13,26 +13,53 @@ only the updates to dir/sub.' . ./test-lib.sh -test_expect_success 'setup' ' -echo initial >top && -mkdir dir && -echo initial >dir/sub && -git-add dir/sub top && -git-commit -m initial && -echo changed >top && -echo changed >dir/sub && -echo other >dir/other +test_expect_success setup ' + echo initial >check && + echo initial >top && + mkdir dir1 dir2 && + echo initial >dir1/sub1 && + echo initial >dir1/sub2 && + echo initial >dir2/sub3 && + git add check dir1 dir2 top && + test_tick + git-commit -m initial && + + echo changed >check && + echo changed >top && + echo changed >dir2/sub3 && + rm -f dir1/sub1 && + echo other >dir2/other +' + +test_expect_success update ' + git add -u dir1 dir2 ' -test_expect_success 'update' 'git-add -u dir' +test_expect_success 'update noticed a removal' ' + test "$(git-ls-files dir1/sub1)" = "" +' -test_expect_success 'update touched correct path' \ - 'test "`git-diff-files --name-status dir/sub`" = ""' +test_expect_success 'update touched correct path' ' + test "$(git-diff-files --name-status dir2/sub3)" = "" +' -test_expect_success 'update did not touch other tracked files' \ - 'test "`git-diff-files --name-status top`" = "M top"' +test_expect_success 'update did not touch other tracked files' ' + test "$(git-diff-files --name-status check)" = "M check" && + test "$(git-diff-files --name-status top)" = "M top" +' -test_expect_success 'update did not touch untracked files' \ - 'test "`git-diff-files --name-status dir/other`" = ""' +test_expect_success 'update did not touch untracked files' ' + test "$(git-ls-files dir2/other)" = "" +' + +test_expect_success 'cache tree has not been corrupted' ' + + git ls-files -s | + sed -e "s/ 0 / /" >expect && + git ls-tree -r $(git write-tree) | + sed -e "s/ blob / /" >current && + diff -u expect current + +' test_done -- cgit v1.2.3 From 2ed2c222dfe372385dc562fb5dc246d5595c1eae Mon Sep 17 00:00:00 2001 From: Salikh Zakirov Date: Thu, 16 Aug 2007 02:01:43 +0900 Subject: git-add -u paths... now works from subdirectory git-add -u also takes the path limiters, but unlike the command without the -u option, the code forgot that it could be invoked from a subdirectory, and did not correctly handle the prefix. Signed-off-by: Salikh Zakirov Signed-off-by: Junio C Hamano --- t/t2200-add-update.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 't/t2200-add-update.sh') diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh index 4c7c6af432..58cd7f31be 100755 --- a/t/t2200-add-update.sh +++ b/t/t2200-add-update.sh @@ -62,4 +62,18 @@ test_expect_success 'cache tree has not been corrupted' ' ' +test_expect_success 'update from a subdirectory' ' + ( + cd dir1 && + echo more >sub2 && + git add -u sub2 + ) +' + +test_expect_success 'change gets noticed' ' + + test "$(git diff-files --name-status dir1)" = "" + +' + test_done -- cgit v1.2.3 From 43b98acc23306fd7fff888477937063361a09593 Mon Sep 17 00:00:00 2001 From: Benoit Sigoure Date: Fri, 14 Sep 2007 10:29:04 +0200 Subject: Add test to check recent fix to "git add -u" An earlier commit fixed type-change case in "git add -u". This adds a test to make sure we do not introduce regression. At the same time, it fixes a stupid typo in the error message. Signed-off-by: Benoit Sigoure Signed-off-by: Junio C Hamano --- t/t2200-add-update.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 't/t2200-add-update.sh') diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh index 61d08bb431..eb1ced3c37 100755 --- a/t/t2200-add-update.sh +++ b/t/t2200-add-update.sh @@ -16,11 +16,12 @@ only the updates to dir/sub.' test_expect_success setup ' echo initial >check && echo initial >top && + echo initial >foo && mkdir dir1 dir2 && echo initial >dir1/sub1 && echo initial >dir1/sub2 && echo initial >dir2/sub3 && - git add check dir1 dir2 top && + git add check dir1 dir2 top foo && test_tick git-commit -m initial && @@ -76,4 +77,12 @@ test_expect_success 'change gets noticed' ' ' +test_expect_success 'replace a file with a symlink' ' + + rm foo && + ln -s top foo && + git add -u -- foo + +' + test_done -- cgit v1.2.3 From 25487bde2ab756a423489fc942b37c1550555b93 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 11 Nov 2007 18:44:16 -0800 Subject: t2200: test more cases of "add -u" Signed-off-by: Junio C Hamano --- t/t2200-add-update.sh | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 't/t2200-add-update.sh') diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh index eb1ced3c37..24f892f793 100755 --- a/t/t2200-add-update.sh +++ b/t/t2200-add-update.sh @@ -1,6 +1,6 @@ #!/bin/sh -test_description='git add -u with path limiting +test_description='git add -u This test creates a working tree state with three files: @@ -9,7 +9,10 @@ This test creates a working tree state with three files: dir/other (untracked) and issues a git add -u with path limiting on "dir" to add -only the updates to dir/sub.' +only the updates to dir/sub. + +Also tested are "git add -u" without limiting, and "git add -u" +without contents changes.' . ./test-lib.sh @@ -85,4 +88,27 @@ test_expect_success 'replace a file with a symlink' ' ' +test_expect_success 'add everything changed' ' + + git add -u && + test -z "$(git diff-files)" + +' + +test_expect_success 'touch and then add -u' ' + + touch check && + git add -u && + test -z "$(git diff-files)" + +' + +test_expect_success 'touch and then add explicitly' ' + + touch check && + git add check && + test -z "$(git diff-files)" + +' + 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/t2200-add-update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t2200-add-update.sh') diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh index 24f892f793..b664341926 100755 --- a/t/t2200-add-update.sh +++ b/t/t2200-add-update.sh @@ -62,7 +62,7 @@ test_expect_success 'cache tree has not been corrupted' ' sed -e "s/ 0 / /" >expect && git ls-tree -r $(git write-tree) | sed -e "s/ blob / /" >current && - diff -u expect current + test_cmp expect current ' -- cgit v1.2.3 From 38ed1d89f759699de56004b08668e1764613f47b Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 21 May 2008 12:04:34 -0700 Subject: "git-add -n -u" should not add but just report Signed-off-by: Junio C Hamano --- t/t2200-add-update.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 't/t2200-add-update.sh') diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh index b664341926..f57a6e077c 100755 --- a/t/t2200-add-update.sh +++ b/t/t2200-add-update.sh @@ -111,4 +111,21 @@ test_expect_success 'touch and then add explicitly' ' ' +test_expect_success 'add -n -u should not add but just report' ' + + ( + echo "add '\''check'\''" && + echo "remove '\''top'\''" + ) >expect && + before=$(git ls-files -s check top) && + echo changed >>check && + rm -f top && + git add -n -u >actual && + after=$(git ls-files -s check top) && + + test "$before" = "$after" && + test_cmp expect actual + +' + test_done -- cgit v1.2.3 From 0cb0e143ffa7d66b7feea0a967b3ac9ae6cd62b0 Mon Sep 17 00:00:00 2001 From: Nanako Shiraishi Date: Wed, 3 Sep 2008 17:59:27 +0900 Subject: tests: use "git xyzzy" form (t0000 - t3599) Converts tests between t0050-t3903. Signed-off-by: Nanako Shiraishi Signed-off-by: Junio C Hamano --- t/t2200-add-update.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 't/t2200-add-update.sh') diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh index f57a6e077c..cd9231cf61 100755 --- a/t/t2200-add-update.sh +++ b/t/t2200-add-update.sh @@ -26,7 +26,7 @@ test_expect_success setup ' echo initial >dir2/sub3 && git add check dir1 dir2 top foo && test_tick - git-commit -m initial && + git commit -m initial && echo changed >check && echo changed >top && @@ -40,20 +40,20 @@ test_expect_success update ' ' test_expect_success 'update noticed a removal' ' - test "$(git-ls-files dir1/sub1)" = "" + test "$(git ls-files dir1/sub1)" = "" ' test_expect_success 'update touched correct path' ' - test "$(git-diff-files --name-status dir2/sub3)" = "" + test "$(git diff-files --name-status dir2/sub3)" = "" ' test_expect_success 'update did not touch other tracked files' ' - test "$(git-diff-files --name-status check)" = "M check" && - test "$(git-diff-files --name-status top)" = "M top" + test "$(git diff-files --name-status check)" = "M check" && + test "$(git diff-files --name-status top)" = "M top" ' test_expect_success 'update did not touch untracked files' ' - test "$(git-ls-files dir2/other)" = "" + test "$(git ls-files dir2/other)" = "" ' test_expect_success 'cache tree has not been corrupted' ' -- cgit v1.2.3 From 4cc8d6c62db1f82b3c98468806d2ee54c7e037ca Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 28 Jan 2009 14:24:53 -0800 Subject: add -u: do not fail to resolve a path as deleted After you resolve a conflicted merge to remove the path, "git add -u" failed to record the removal. Instead it errored out by saying that the removed path is not found in the work tree, but that is what the user already knows, and the wanted to record the removal as the resolution, so the error does not make sense. Signed-off-by: Junio C Hamano --- t/t2200-add-update.sh | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) (limited to 't/t2200-add-update.sh') diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh index cd9231cf61..b2ddf5ace3 100755 --- a/t/t2200-add-update.sh +++ b/t/t2200-add-update.sh @@ -12,7 +12,7 @@ and issues a git add -u with path limiting on "dir" to add only the updates to dir/sub. Also tested are "git add -u" without limiting, and "git add -u" -without contents changes.' +without contents changes, and other conditions' . ./test-lib.sh @@ -128,4 +128,52 @@ test_expect_success 'add -n -u should not add but just report' ' ' +test_expect_success 'add -u resolves unmerged paths' ' + git reset --hard && + one=$(echo 1 | git hash-object -w --stdin) && + two=$(echo 2 | git hash-object -w --stdin) && + three=$(echo 3 | git hash-object -w --stdin) && + { + for path in path1 path2 + do + echo "100644 $one 1 $path" + echo "100644 $two 2 $path" + echo "100644 $three 3 $path" + done + echo "100644 $one 1 path3" + echo "100644 $one 1 path4" + echo "100644 $one 3 path5" + echo "100644 $one 3 path6" + } | + git update-index --index-info && + echo 3 >path1 && + echo 2 >path3 && + echo 2 >path5 && + git add -u && + git ls-files -s "path?" >actual && + { + echo "100644 $three 0 path1" + echo "100644 $one 1 path3" + echo "100644 $one 1 path4" + echo "100644 $one 3 path5" + echo "100644 $one 3 path6" + } >expect && + test_cmp expect actual && + + # Bonus tests. Explicit resolving + git add path3 path5 && + test_must_fail git add path4 && + test_must_fail git add path6 && + git rm path4 && + git rm path6 && + + git ls-files -s "path?" >actual && + { + echo "100644 $three 0 path1" + echo "100644 $two 0 path3" + echo "100644 $two 0 path5" + } >expect + +' + test_done -- cgit v1.2.3 From 0aaaef7b0f83ccd97d586b5c951adcb912af2664 Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Mon, 9 Feb 2009 10:24:51 +0100 Subject: t2200, t7004: Avoid glob pattern that also matches files On Windows, there is an unfortunate interaction between the MSYS bash and git's command line processing: - Since Windows's CMD does not do the wildcard expansion, but passes arguments like path* through to the programs, the programs must do the expansion themselves. This happens in the startup code before main() is entered. - bash, however, passes the argument "path*" to git, assuming that git will see the unquoted word unchanged as a single argument. But actually git expands the unquoted word before main() is entered. In t2200, not all names that the test case is interested in exist as files at the time when 'git ls-files' is invoked. git expands "path?" to only the subset of files the exist, and only that subset was listed, so that the test failed. We now list all interesting paths explicitly. In t7004, git exanded the pattern "*a*" to "actual" (the file that stdout was redirected to), which is not what the was tested for. We fix it by renaming the output file (and removing any existing files matching *a*). This was originally fixed by Johannes Schindelin. Signed-off-by: Johannes Sixt --- t/t2200-add-update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t2200-add-update.sh') diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh index b2ddf5ace3..5a8d52f2ff 100755 --- a/t/t2200-add-update.sh +++ b/t/t2200-add-update.sh @@ -150,7 +150,7 @@ test_expect_success 'add -u resolves unmerged paths' ' echo 2 >path3 && echo 2 >path5 && git add -u && - git ls-files -s "path?" >actual && + git ls-files -s path1 path2 path3 path4 path5 path6 >actual && { echo "100644 $three 0 path1" echo "100644 $one 1 path3" -- cgit v1.2.3 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/t2200-add-update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t2200-add-update.sh') diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh index 5a8d52f2ff..912075063b 100755 --- a/t/t2200-add-update.sh +++ b/t/t2200-add-update.sh @@ -80,7 +80,7 @@ test_expect_success 'change gets noticed' ' ' -test_expect_success 'replace a file with a symlink' ' +test_expect_success SYMLINKS 'replace a file with a symlink' ' rm foo && ln -s top foo && -- cgit v1.2.3 From 1e7ef746d3a635742690817fefe00b66a044dfe5 Mon Sep 17 00:00:00 2001 From: Chris Packham Date: Tue, 9 Feb 2010 17:30:48 -0500 Subject: test for add with non-existent pathspec Add a test for 'git add -u pathspec' and 'git add pathspec' where pathspec does not exist. The expected result is that git add exits with an error message and an appropriate exit code. Signed-off-by: Chris Packham Signed-off-by: Junio C Hamano --- t/t2200-add-update.sh | 5 +++++ 1 file changed, 5 insertions(+) (limited to 't/t2200-add-update.sh') diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh index 912075063b..2ad2819a34 100755 --- a/t/t2200-add-update.sh +++ b/t/t2200-add-update.sh @@ -176,4 +176,9 @@ test_expect_success 'add -u resolves unmerged paths' ' ' +test_expect_success '"add -u non-existent" should fail' ' + test_must_fail git add -u non-existent && + ! (git ls-files | grep "non-existent") +' + test_done -- cgit v1.2.3 From a48fcd836971d065b9bf16b8cd046fd1aff9b279 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Sat, 30 Oct 2010 20:46:54 -0500 Subject: tests: add missing && Breaks in a test assertion's && chain can potentially hide failures from earlier commands in the chain. Commands intended to fail should be marked with !, test_must_fail, or test_might_fail. The examples in this patch do not require that. Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- t/t2200-add-update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t2200-add-update.sh') diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh index 2ad2819a34..0692427cb6 100755 --- a/t/t2200-add-update.sh +++ b/t/t2200-add-update.sh @@ -25,7 +25,7 @@ test_expect_success setup ' echo initial >dir1/sub2 && echo initial >dir2/sub3 && git add check dir1 dir2 top foo && - test_tick + test_tick && git commit -m initial && echo changed >check && -- cgit v1.2.3 From 475c73eb8c65fe7b4cb55f05aeb9eee547e4a359 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Tue, 22 Feb 2011 23:41:32 +0000 Subject: i18n: git-add "remove '%s'" message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make the "remove '%s'" message translatable. It's displayed under `git add -u --verbose`. Also skip the corresponding test when output is not in the C locale. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- t/t2200-add-update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t2200-add-update.sh') diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh index 0692427cb6..856e7da1f2 100755 --- a/t/t2200-add-update.sh +++ b/t/t2200-add-update.sh @@ -111,7 +111,7 @@ test_expect_success 'touch and then add explicitly' ' ' -test_expect_success 'add -n -u should not add but just report' ' +test_expect_success C_LOCALE_OUTPUT 'add -n -u should not add but just report' ' ( echo "add '\''check'\''" && -- cgit v1.2.3 From c36f94123bb16d412fc0f7c49d655bfe4259c4b6 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 12 Apr 2011 15:50:55 -0700 Subject: i18n: use test_i18ncmp in t1200 and t2200 Signed-off-by: Junio C Hamano --- t/t2200-add-update.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 't/t2200-add-update.sh') diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh index 856e7da1f2..2d7d3115d5 100755 --- a/t/t2200-add-update.sh +++ b/t/t2200-add-update.sh @@ -111,7 +111,7 @@ test_expect_success 'touch and then add explicitly' ' ' -test_expect_success C_LOCALE_OUTPUT 'add -n -u should not add but just report' ' +test_expect_success 'add -n -u should not add but just report' ' ( echo "add '\''check'\''" && @@ -124,7 +124,7 @@ test_expect_success C_LOCALE_OUTPUT 'add -n -u should not add but just report' ' after=$(git ls-files -s check top) && test "$before" = "$after" && - test_cmp expect actual + test_i18ncmp expect actual ' -- cgit v1.2.3 From 75973b2cb58bf2b3038c5c214fc0a1b96d6868fe Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 20 Apr 2011 18:11:19 -0700 Subject: Fix "add -u" that sometimes fails to resolve unmerged paths "git add -u" updates the index with the updated contents from the working tree by internally running "diff-files" to grab the set of paths that are different from the index. Then it updates the index entries for the paths that are modified in the working tree, and deletes the index entries for the paths that are deleted in the working tree. It ignored the output from the diff-files that indicated that a path is unmerged. For these paths, it instead relied on the fact that an unmerged path is followed by the result of comparison between stage #2 (ours) and the working tree, and used that to update or delete such a path when it is used to record the resolution of a conflict. As the result, when a path did not have stage #2 (e.g. "we deleted while the other side added"), these unmerged stages were left behind, instead of recording what the user resolved in the working tree. Since we recently fixed "diff-files" to indicate if the corresponding path exists on the working tree for an unmerged path, we do not have to rely on the comparison with stage #2 anymore. We can instead tell the diff-files not to compare with higher stages, and use the unmerged output to update the index to reflect the state of the working tree. The changes to the test vector in t2200 illustrates the nature of the bug and the fix. The test expected stage #1 and #3 entries be left behind, but it was codifying the buggy behaviour. Signed-off-by: Junio C Hamano --- t/t2200-add-update.sh | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) (limited to 't/t2200-add-update.sh') diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh index 2ad2819a34..d3bb9fab4f 100755 --- a/t/t2200-add-update.sh +++ b/t/t2200-add-update.sh @@ -149,31 +149,21 @@ test_expect_success 'add -u resolves unmerged paths' ' echo 3 >path1 && echo 2 >path3 && echo 2 >path5 && - git add -u && - git ls-files -s path1 path2 path3 path4 path5 path6 >actual && - { - echo "100644 $three 0 path1" - echo "100644 $one 1 path3" - echo "100644 $one 1 path4" - echo "100644 $one 3 path5" - echo "100644 $one 3 path6" - } >expect && - test_cmp expect actual && - # Bonus tests. Explicit resolving - git add path3 path5 && + # Explicit resolving by adding removed paths should fail test_must_fail git add path4 && test_must_fail git add path6 && - git rm path4 && - git rm path6 && - git ls-files -s "path?" >actual && + # "add -u" should notice removals no matter what stages + # the index entries are in. + git add -u && + git ls-files -s path1 path2 path3 path4 path5 path6 >actual && { echo "100644 $three 0 path1" echo "100644 $two 0 path3" echo "100644 $two 0 path5" - } >expect - + } >expect && + test_cmp expect actual ' test_expect_success '"add -u non-existent" should fail' ' -- cgit v1.2.3