From 50753d00d691c1ea16bc72446705aee2c128fc2f Mon Sep 17 00:00:00 2001 From: Jeff King Date: Sat, 8 Mar 2008 20:27:04 -0800 Subject: Add a test for read-tree -u --reset with a D/F conflict Signed-off-by: Junio C Hamano --- t/t1005-read-tree-reset.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 t/t1005-read-tree-reset.sh (limited to 't/t1005-read-tree-reset.sh') diff --git a/t/t1005-read-tree-reset.sh b/t/t1005-read-tree-reset.sh new file mode 100755 index 0000000000..f1b12167b8 --- /dev/null +++ b/t/t1005-read-tree-reset.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +test_description='read-tree -u --reset' + +. ./test-lib.sh + +# two-tree test + +test_expect_success 'setup' ' + git init && + mkdir df && + echo content >df/file && + git add df/file && + git commit -m one && + git ls-files >expect && + rm -rf df && + echo content >df && + git add df && + echo content >new && + git add new && + git commit -m two +' + +test_expect_failure 'reset should work' ' + git read-tree -u --reset HEAD^ && + git ls-files >actual && + diff -u expect actual +' + +test_done -- cgit v1.2.3 From 34110cd4e394e3f92c01a4709689b384c34645d8 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Thu, 6 Mar 2008 18:12:28 -0800 Subject: Make 'unpack_trees()' have a separate source and destination index We will always unpack into our own internal index, but we will take the source from wherever specified, and we will optionally write the result to a specified index (optionally, because not everybody even _wants_ any result: the index diffing really wants to just walk the tree and index in parallel). This ends up removing a fair number more lines than it adds, for the simple reason that we can now skip all the crud that tried to be oh-so-careful about maintaining our position in the index as we were traversing and modifying it. Since we don't actually modify the source index any more, we can just update the 'o->pos' pointer without worrying about whether an index entry got removed or replaced or added to. Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- t/t1005-read-tree-reset.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t1005-read-tree-reset.sh') diff --git a/t/t1005-read-tree-reset.sh b/t/t1005-read-tree-reset.sh index f1b12167b8..8c4556408e 100755 --- a/t/t1005-read-tree-reset.sh +++ b/t/t1005-read-tree-reset.sh @@ -21,7 +21,7 @@ test_expect_success 'setup' ' git commit -m two ' -test_expect_failure 'reset should work' ' +test_expect_success 'reset should work' ' git read-tree -u --reset HEAD^ && git ls-files >actual && diff -u expect actual -- 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/t1005-read-tree-reset.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t1005-read-tree-reset.sh') diff --git a/t/t1005-read-tree-reset.sh b/t/t1005-read-tree-reset.sh index 8c4556408e..b0d31f5a9b 100755 --- a/t/t1005-read-tree-reset.sh +++ b/t/t1005-read-tree-reset.sh @@ -24,7 +24,7 @@ test_expect_success 'setup' ' test_expect_success 'reset should work' ' git read-tree -u --reset HEAD^ && git ls-files >actual && - diff -u expect actual + test_cmp expect actual ' test_done -- cgit v1.2.3 From d1a43f2aa4bfb5aef29e9e1fe1fb9bb18c0e8b65 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 15 Oct 2008 16:00:06 -0700 Subject: reset --hard/read-tree --reset -u: remove unmerged new paths When aborting a failed merge that has brought in a new path using "git reset --hard" or "git read-tree --reset -u", we used to first forget about the new path (via read_cache_unmerged) and then matched the working tree to what is recorded in the index, thus ending up leaving the new path in the work tree. Signed-off-by: Junio C Hamano --- t/t1005-read-tree-reset.sh | 60 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 't/t1005-read-tree-reset.sh') diff --git a/t/t1005-read-tree-reset.sh b/t/t1005-read-tree-reset.sh index b0d31f5a9b..849911683a 100755 --- a/t/t1005-read-tree-reset.sh +++ b/t/t1005-read-tree-reset.sh @@ -27,4 +27,64 @@ test_expect_success 'reset should work' ' test_cmp expect actual ' +test_expect_success 'reset should remove remnants from a failed merge' ' + git read-tree --reset -u HEAD && + git ls-files -s >expect && + sha1=$(git rev-parse :new) && + ( + echo "100644 $sha1 1 old" + echo "100644 $sha1 3 old" + ) | git update-index --index-info && + >old && + git ls-files -s && + git read-tree --reset -u HEAD && + git ls-files -s >actual && + ! test -f old +' + +test_expect_success 'Porcelain reset should remove remnants too' ' + git read-tree --reset -u HEAD && + git ls-files -s >expect && + sha1=$(git rev-parse :new) && + ( + echo "100644 $sha1 1 old" + echo "100644 $sha1 3 old" + ) | git update-index --index-info && + >old && + git ls-files -s && + git reset --hard && + git ls-files -s >actual && + ! test -f old +' + +test_expect_success 'Porcelain checkout -f should remove remnants too' ' + git read-tree --reset -u HEAD && + git ls-files -s >expect && + sha1=$(git rev-parse :new) && + ( + echo "100644 $sha1 1 old" + echo "100644 $sha1 3 old" + ) | git update-index --index-info && + >old && + git ls-files -s && + git checkout -f && + git ls-files -s >actual && + ! test -f old +' + +test_expect_success 'Porcelain checkout -f HEAD should remove remnants too' ' + git read-tree --reset -u HEAD && + git ls-files -s >expect && + sha1=$(git rev-parse :new) && + ( + echo "100644 $sha1 1 old" + echo "100644 $sha1 3 old" + ) | git update-index --index-info && + >old && + git ls-files -s && + git checkout -f HEAD && + git ls-files -s >actual && + ! test -f old +' + test_done -- cgit v1.2.3