From af6e17519978eed17c406206e1afc9f0501abf77 Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Mon, 20 Sep 2010 02:28:37 -0600 Subject: t6022: Add test combinations of {content conflict?, D/F conflict remains?} Add testing of the various ways that a renamed file to a path involved in a directory/file conflict may be involved in. This includes whether or not there are conflicts of the contents of the renamed file (if the file was modified on both sides of history), and whether the directory from the other side of the merge will disappear as a result of the merge or not. Signed-off-by: Elijah Newren Signed-off-by: Junio C Hamano --- t/t6022-merge-rename.sh | 128 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) (limited to 't/t6022-merge-rename.sh') diff --git a/t/t6022-merge-rename.sh b/t/t6022-merge-rename.sh index b66544b76d..a992206077 100755 --- a/t/t6022-merge-rename.sh +++ b/t/t6022-merge-rename.sh @@ -3,6 +3,11 @@ test_description='Merge-recursive merging renames' . ./test-lib.sh +modify () { + sed -e "$1" <"$2" >"$2.x" && + mv "$2.x" "$2" +} + test_expect_success setup \ ' cat >A <<\EOF && @@ -341,4 +346,127 @@ test_expect_success 'merge of identical changes in a renamed file' ' GIT_MERGE_VERBOSITY=3 git merge change+rename | grep "^Skipped B" ' +test_expect_success 'setup for rename + d/f conflicts' ' + git reset --hard && + git checkout --orphan dir-in-way && + git rm -rf . && + + mkdir sub && + mkdir dir && + printf "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n" >sub/file && + echo foo >dir/file-in-the-way && + git add -A && + git commit -m "Common commmit" && + + echo 11 >>sub/file && + echo more >>dir/file-in-the-way && + git add -u && + git commit -m "Commit to merge, with dir in the way" && + + git checkout -b dir-not-in-way && + git reset --soft HEAD^ && + git rm -rf dir && + git commit -m "Commit to merge, with dir removed" -- dir sub/file && + + git checkout -b renamed-file-has-no-conflicts dir-in-way~1 && + git rm -rf dir && + git rm sub/file && + printf "1\n2\n3\n4\n5555\n6\n7\n8\n9\n10\n" >dir && + git add dir && + git commit -m "Independent change" && + + git checkout -b renamed-file-has-conflicts dir-in-way~1 && + git rm -rf dir && + git mv sub/file dir && + echo 12 >>dir && + git add dir && + git commit -m "Conflicting change" +' + +printf "1\n2\n3\n4\n5555\n6\n7\n8\n9\n10\n11\n" >expected + +test_expect_success 'Rename+D/F conflict; renamed file merges + dir not in way' ' + git reset --hard && + git checkout -q renamed-file-has-no-conflicts^0 && + git merge --strategy=recursive dir-not-in-way && + git diff --quiet && + test -f dir && + test_cmp expected dir +' + +test_expect_failure 'Rename+D/F conflict; renamed file merges but dir in way' ' + git reset --hard && + rm -rf dir~* && + git checkout -q renamed-file-has-no-conflicts^0 && + test_must_fail git merge --strategy=recursive dir-in-way >output && + + grep "CONFLICT (delete/modify): dir/file-in-the-way" output && + grep "Auto-merging dir" output && + grep "Adding as dir~HEAD instead" output && + + test 2 = "$(git ls-files -u | wc -l)" && + test 2 = "$(git ls-files -u dir/file-in-the-way | wc -l)" && + + test_must_fail git diff --quiet && + test_must_fail git diff --cached --quiet && + + test -f dir/file-in-the-way && + test -f dir~HEAD && + test_cmp expected dir~HEAD +' + +cat >expected <<\EOF && +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +<<<<<<< HEAD +12 +======= +11 +>>>>>>> dir-not-in-way +EOF + +test_expect_failure 'Rename+D/F conflict; renamed file cannot merge, dir not in way' ' + git reset --hard && + rm -rf dir~* && + git checkout -q renamed-file-has-conflicts^0 && + test_must_fail git merge --strategy=recursive dir-not-in-way && + + test 3 = "$(git ls-files -u | wc -l)" && + test 3 = "$(git ls-files -u dir | wc -l)" && + + test_must_fail git diff --quiet && + test_must_fail git diff --cached --quiet && + + test -f dir && + test_cmp expected dir +' + +test_expect_failure 'Rename+D/F conflict; renamed file cannot merge and dir in the way' ' + modify s/dir-not-in-way/dir-in-way/ expected && + + git reset --hard && + rm -rf dir~* && + git checkout -q renamed-file-has-conflicts^0 && + test_must_fail git merge --strategy=recursive dir-in-way && + + test 5 = "$(git ls-files -u | wc -l)" && + test 3 = "$(git ls-files -u dir | grep -v file-in-the-way | wc -l)" && + test 2 = "$(git ls-files -u dir/file-in-the-way | wc -l)" && + + test_must_fail git diff --quiet && + test_must_fail git diff --cached --quiet && + + test -f dir/file-in-the-way && + test -f dir~HEAD && + test_cmp expected dir~HEAD +' + test_done -- cgit v1.2.1 From 3398f2f58317e1a22093a0149a5eae1fe208b024 Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Mon, 20 Sep 2010 02:28:38 -0600 Subject: t6022: Add tests for reversing order of merges when D/F conflicts present When merging two branches with some path involved in a D/F conflict, the choice of which branch to merge into the other matters for (at least) two reasons: (1) whether the working copy has a directory full of files that is in the way of a file, or a file exists that is in the way of a directory of files, (2) when the directory full of files does not disappear due to the merge, what files at the same paths should be renamed to (e.g. filename~HEAD vs. filename~otherbranch). Add some tests that reverse the merge order of two other tests, and which verify the contents are as expected (namely, that the results are identical other than modified-for-uniqueness filenames involving branch names). Signed-off-by: Elijah Newren Signed-off-by: Junio C Hamano --- t/t6022-merge-rename.sh | 58 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 't/t6022-merge-rename.sh') diff --git a/t/t6022-merge-rename.sh b/t/t6022-merge-rename.sh index a992206077..2839dfb5e0 100755 --- a/t/t6022-merge-rename.sh +++ b/t/t6022-merge-rename.sh @@ -415,6 +415,28 @@ test_expect_failure 'Rename+D/F conflict; renamed file merges but dir in way' ' test_cmp expected dir~HEAD ' +test_expect_failure 'Same as previous, but merged other way' ' + git reset --hard && + rm -rf dir~* && + git checkout -q dir-in-way^0 && + test_must_fail git merge --strategy=recursive renamed-file-has-no-conflicts >output 2>errors && + + ! grep "error: refusing to lose untracked file at" errors && + grep "CONFLICT (delete/modify): dir/file-in-the-way" output && + grep "Auto-merging dir" output && + grep "Adding as dir~renamed-file-has-no-conflicts instead" output && + + test 2 = "$(git ls-files -u | wc -l)" && + test 2 = "$(git ls-files -u dir/file-in-the-way | wc -l)" && + + test_must_fail git diff --quiet && + test_must_fail git diff --cached --quiet && + + test -f dir/file-in-the-way && + test -f dir~renamed-file-has-no-conflicts && + test_cmp expected dir~renamed-file-has-no-conflicts +' + cat >expected <<\EOF && 1 2 @@ -469,4 +491,40 @@ test_expect_failure 'Rename+D/F conflict; renamed file cannot merge and dir in t test_cmp expected dir~HEAD ' +cat >expected <<\EOF && +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +<<<<<<< HEAD +11 +======= +12 +>>>>>>> renamed-file-has-conflicts +EOF + +test_expect_failure 'Same as previous, but merged other way' ' + git reset --hard && + rm -rf dir~* && + git checkout -q dir-in-way^0 && + test_must_fail git merge --strategy=recursive renamed-file-has-conflicts && + + test 5 = "$(git ls-files -u | wc -l)" && + test 3 = "$(git ls-files -u dir | grep -v file-in-the-way | wc -l)" && + test 2 = "$(git ls-files -u dir/file-in-the-way | wc -l)" && + + test_must_fail git diff --quiet && + test_must_fail git diff --cached --quiet && + + test -f dir/file-in-the-way && + test -f dir~renamed-file-has-conflicts && + test_cmp expected dir~renamed-file-has-conflicts +' + test_done -- cgit v1.2.1 From 588504b694133cba85982fbace532d2156f859eb Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Mon, 20 Sep 2010 02:28:39 -0600 Subject: t6022: Add tests with both rename source & dest involved in D/F conflicts Having the source of a rename be involved in a directory/file conflict does not currently pose any difficulties to the current merge-recursive algorithm (in contrast to destinations of renames and D/F conflicts). However, combining the two seemed like good testcases to include for completeness. Signed-off-by: Elijah Newren Signed-off-by: Junio C Hamano --- t/t6022-merge-rename.sh | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 't/t6022-merge-rename.sh') diff --git a/t/t6022-merge-rename.sh b/t/t6022-merge-rename.sh index 2839dfb5e0..2af863c126 100755 --- a/t/t6022-merge-rename.sh +++ b/t/t6022-merge-rename.sh @@ -527,4 +527,42 @@ test_expect_failure 'Same as previous, but merged other way' ' test_cmp expected dir~renamed-file-has-conflicts ' +test_expect_success 'setup both rename source and destination involved in D/F conflict' ' + git reset --hard && + git checkout --orphan rename-dest && + git rm -rf . && + git clean -fdqx && + + mkdir one && + echo stuff >one/file && + git add -A && + git commit -m "Common commmit" && + + git mv one/file destdir && + git commit -m "Renamed to destdir" && + + git checkout -b source-conflict HEAD~1 && + git rm -rf one && + mkdir destdir && + touch one destdir/foo && + git add -A && + git commit -m "Conflicts in the way" +' + +test_expect_failure 'both rename source and destination involved in D/F conflict' ' + git reset --hard && + rm -rf dir~* && + git checkout -q rename-dest^0 && + test_must_fail git merge --strategy=recursive source-conflict && + + test 1 = "$(git ls-files -u | wc -l)" && + + test_must_fail git diff --quiet && + + test -f destdir/foo && + test -f one && + test -f destdir~HEAD && + test "stuff" = "$(cat destdir~HEAD)" +' + test_done -- cgit v1.2.1 From 52304ecddf9458dcf4321c89c96a5e1bc025676d Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Mon, 20 Sep 2010 02:28:40 -0600 Subject: t6022: Add paired rename+D/F conflict: (two/file, one/file) -> (one, two) An interesting testcase is having two files each in their own subdirectory getting renamed to the toplevel at the directory pathname of the other. Questions arise as to whether the order of operations matters and whether the directories can correctly get out of the way and make room for the new files. Signed-off-by: Elijah Newren Signed-off-by: Junio C Hamano --- t/t6022-merge-rename.sh | 63 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) (limited to 't/t6022-merge-rename.sh') diff --git a/t/t6022-merge-rename.sh b/t/t6022-merge-rename.sh index 2af863c126..a38b383c89 100755 --- a/t/t6022-merge-rename.sh +++ b/t/t6022-merge-rename.sh @@ -565,4 +565,67 @@ test_expect_failure 'both rename source and destination involved in D/F conflict test "stuff" = "$(cat destdir~HEAD)" ' +test_expect_success 'setup pair rename to parent of other (D/F conflicts)' ' + git reset --hard && + git checkout --orphan rename-two && + git rm -rf . && + git clean -fdqx && + + mkdir one && + mkdir two && + echo stuff >one/file && + echo other >two/file && + git add -A && + git commit -m "Common commmit" && + + git rm -rf one && + git mv two/file one && + git commit -m "Rename two/file -> one" && + + git checkout -b rename-one HEAD~1 && + git rm -rf two && + git mv one/file two && + rm -r one && + git commit -m "Rename one/file -> two" +' + +test_expect_failure 'pair rename to parent of other (D/F conflicts) w/ untracked dir' ' + git checkout -q rename-one^0 && + mkdir one && + test_must_fail git merge --strategy=recursive rename-two && + + test 2 = "$(git ls-files -u | wc -l)" && + test 1 = "$(git ls-files -u one | wc -l)" && + test 1 = "$(git ls-files -u two | wc -l)" && + + test_must_fail git diff --quiet && + + test 4 = $(find . | grep -v .git | wc -l) && + + test -d one && + test -f one~rename-two && + test -f two && + test "other" = $(cat one~rename-two) && + test "stuff" = $(cat two) +' + +test_expect_success 'pair rename to parent of other (D/F conflicts) w/ clean start' ' + git reset --hard && + git clean -fdqx && + test_must_fail git merge --strategy=recursive rename-two && + + test 2 = "$(git ls-files -u | wc -l)" && + test 1 = "$(git ls-files -u one | wc -l)" && + test 1 = "$(git ls-files -u two | wc -l)" && + + test_must_fail git diff --quiet && + + test 3 = $(find . | grep -v .git | wc -l) && + + test -f one && + test -f two && + test "other" = $(cat one) && + test "stuff" = $(cat two) +' + test_done -- cgit v1.2.1 From 707983484b7dcdd5fe3e09b30d0fdf6dac89c940 Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Mon, 20 Sep 2010 02:28:41 -0600 Subject: t6022: Add tests for rename/rename combined with D/F conflicts Add tests where one file is renamed to two different paths in different sides of history, and where each of the new files matches the name of a directory from the opposite side of history. Include tests for both the case where the merge results in those directories not being cleanly removed, and where those directories are cleanly removed during the merge. Signed-off-by: Elijah Newren Signed-off-by: Junio C Hamano --- t/t6022-merge-rename.sh | 79 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) (limited to 't/t6022-merge-rename.sh') diff --git a/t/t6022-merge-rename.sh b/t/t6022-merge-rename.sh index a38b383c89..02dea16459 100755 --- a/t/t6022-merge-rename.sh +++ b/t/t6022-merge-rename.sh @@ -628,4 +628,83 @@ test_expect_success 'pair rename to parent of other (D/F conflicts) w/ clean sta test "stuff" = $(cat two) ' +test_expect_success 'setup rename of one file to two, with directories in the way' ' + git reset --hard && + git checkout --orphan first-rename && + git rm -rf . && + git clean -fdqx && + + echo stuff >original && + git add -A && + git commit -m "Common commmit" && + + mkdir two && + >two/file && + git add two/file && + git mv original one && + git commit -m "Put two/file in the way, rename to one" && + + git checkout -b second-rename HEAD~1 && + mkdir one && + >one/file && + git add one/file && + git mv original two && + git commit -m "Put one/file in the way, rename to two" +' + +test_expect_failure 'check handling of differently renamed file with D/F conflicts' ' + git checkout -q first-rename^0 && + test_must_fail git merge --strategy=recursive second-rename && + + test 5 = "$(git ls-files -s | wc -l)" && + test 3 = "$(git ls-files -u | wc -l)" && + test 1 = "$(git ls-files -u one | wc -l)" && + test 1 = "$(git ls-files -u two | wc -l)" && + test 1 = "$(git ls-files -u original | wc -l)" && + test 2 = "$(git ls-files -o | wc -l)" && + + test -f one/file && + test -f two/file && + test -f one~HEAD && + test -f two~second-rename && + ! test -f original +' + +test_expect_success 'setup rename one file to two; directories moving out of the way' ' + git reset --hard && + git checkout --orphan first-rename-redo && + git rm -rf . && + git clean -fdqx && + + echo stuff >original && + mkdir one two && + touch one/file two/file && + git add -A && + git commit -m "Common commmit" && + + git rm -rf one && + git mv original one && + git commit -m "Rename to one" && + + git checkout -b second-rename-redo HEAD~1 && + git rm -rf two && + git mv original two && + git commit -m "Rename to two" +' + +test_expect_failure 'check handling of differently renamed file with D/F conflicts' ' + git checkout -q first-rename-redo^0 && + test_must_fail git merge --strategy=recursive second-rename-redo && + + test 3 = "$(git ls-files -u | wc -l)" && + test 1 = "$(git ls-files -u one | wc -l)" && + test 1 = "$(git ls-files -u two | wc -l)" && + test 1 = "$(git ls-files -u original | wc -l)" && + test 0 = "$(git ls-files -o | wc -l)" && + + test -f one && + test -f two && + ! test -f original +' + test_done -- cgit v1.2.1 From 07413c5a3115df424bee1ebe627676df0734f787 Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Mon, 20 Sep 2010 02:29:00 -0600 Subject: merge-recursive: Move handling of double rename of one file to two Move the handling of rename/rename conflicts where one file is renamed to two different files, from process_renames() to process_df_entry(). Signed-off-by: Elijah Newren Signed-off-by: Junio C Hamano --- t/t6022-merge-rename.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t6022-merge-rename.sh') diff --git a/t/t6022-merge-rename.sh b/t/t6022-merge-rename.sh index 02dea16459..1f29c0a94d 100755 --- a/t/t6022-merge-rename.sh +++ b/t/t6022-merge-rename.sh @@ -652,7 +652,7 @@ test_expect_success 'setup rename of one file to two, with directories in the wa git commit -m "Put one/file in the way, rename to two" ' -test_expect_failure 'check handling of differently renamed file with D/F conflicts' ' +test_expect_success 'check handling of differently renamed file with D/F conflicts' ' git checkout -q first-rename^0 && test_must_fail git merge --strategy=recursive second-rename && -- cgit v1.2.1 From 882fd11aff6f0e8add77e75924678cce875a0eaf Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Mon, 20 Sep 2010 02:29:03 -0600 Subject: merge-recursive: Delay content merging for renames Move the handling of content merging for renames from process_renames() to process_df_entry(). Signed-off-by: Elijah Newren Signed-off-by: Junio C Hamano --- t/t6022-merge-rename.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t6022-merge-rename.sh') diff --git a/t/t6022-merge-rename.sh b/t/t6022-merge-rename.sh index 1f29c0a94d..edbfa477c1 100755 --- a/t/t6022-merge-rename.sh +++ b/t/t6022-merge-rename.sh @@ -455,7 +455,7 @@ cat >expected <<\EOF && >>>>>>> dir-not-in-way EOF -test_expect_failure 'Rename+D/F conflict; renamed file cannot merge, dir not in way' ' +test_expect_success 'Rename+D/F conflict; renamed file cannot merge, dir not in way' ' git reset --hard && rm -rf dir~* && git checkout -q renamed-file-has-conflicts^0 && -- cgit v1.2.1 From a0de2f6bd3b79f7ab61ea90f795b964a7f7f3d6d Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Mon, 20 Sep 2010 02:29:05 -0600 Subject: conflict_rename_delete(): Check whether D/F conflicts are still present If all the paths below some directory involved in a D/F conflict were not removed during the rest of the merge, then the contents of the file whose path conflicted needs to be recorded in file with an alternative filename. Signed-off-by: Elijah Newren Signed-off-by: Junio C Hamano --- t/t6022-merge-rename.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 't/t6022-merge-rename.sh') diff --git a/t/t6022-merge-rename.sh b/t/t6022-merge-rename.sh index edbfa477c1..9bf190e03f 100755 --- a/t/t6022-merge-rename.sh +++ b/t/t6022-merge-rename.sh @@ -549,7 +549,7 @@ test_expect_success 'setup both rename source and destination involved in D/F co git commit -m "Conflicts in the way" ' -test_expect_failure 'both rename source and destination involved in D/F conflict' ' +test_expect_success 'both rename source and destination involved in D/F conflict' ' git reset --hard && rm -rf dir~* && git checkout -q rename-dest^0 && @@ -589,7 +589,7 @@ test_expect_success 'setup pair rename to parent of other (D/F conflicts)' ' git commit -m "Rename one/file -> two" ' -test_expect_failure 'pair rename to parent of other (D/F conflicts) w/ untracked dir' ' +test_expect_success 'pair rename to parent of other (D/F conflicts) w/ untracked dir' ' git checkout -q rename-one^0 && mkdir one && test_must_fail git merge --strategy=recursive rename-two && -- cgit v1.2.1 From 2adc7dcc111636ed16601dc7516ced1c5cfda088 Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Mon, 20 Sep 2010 02:29:06 -0600 Subject: conflict_rename_rename_1to2(): Fix checks for presence of D/F conflicts This function is called from process_df_entry(), near the end of the merge. Rather than just checking whether one of the sides of the merge had a directory at the same path as one of our files, check whether that directory is still present by this point of our merge. Signed-off-by: Elijah Newren Signed-off-by: Junio C Hamano --- t/t6022-merge-rename.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t6022-merge-rename.sh') diff --git a/t/t6022-merge-rename.sh b/t/t6022-merge-rename.sh index 9bf190e03f..0b6700242c 100755 --- a/t/t6022-merge-rename.sh +++ b/t/t6022-merge-rename.sh @@ -692,7 +692,7 @@ test_expect_success 'setup rename one file to two; directories moving out of the git commit -m "Rename to two" ' -test_expect_failure 'check handling of differently renamed file with D/F conflicts' ' +test_expect_success 'check handling of differently renamed file with D/F conflicts' ' git checkout -q first-rename-redo^0 && test_must_fail git merge --strategy=recursive second-rename-redo && -- cgit v1.2.1 From 4ab9a157d06956ce5a1060a28404cbade3039fa2 Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Mon, 20 Sep 2010 02:29:07 -0600 Subject: merge_content(): Check whether D/F conflicts are still present If all the paths below some directory involved in a D/F conflict were not removed during the rest of the merge, then the contents of the file whose path conflicted needs to be recorded in file with an alternative filename. Signed-off-by: Elijah Newren Signed-off-by: Junio C Hamano --- t/t6022-merge-rename.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 't/t6022-merge-rename.sh') diff --git a/t/t6022-merge-rename.sh b/t/t6022-merge-rename.sh index 0b6700242c..422092e11c 100755 --- a/t/t6022-merge-rename.sh +++ b/t/t6022-merge-rename.sh @@ -394,7 +394,7 @@ test_expect_success 'Rename+D/F conflict; renamed file merges + dir not in way' test_cmp expected dir ' -test_expect_failure 'Rename+D/F conflict; renamed file merges but dir in way' ' +test_expect_success 'Rename+D/F conflict; renamed file merges but dir in way' ' git reset --hard && rm -rf dir~* && git checkout -q renamed-file-has-no-conflicts^0 && @@ -415,7 +415,7 @@ test_expect_failure 'Rename+D/F conflict; renamed file merges but dir in way' ' test_cmp expected dir~HEAD ' -test_expect_failure 'Same as previous, but merged other way' ' +test_expect_success 'Same as previous, but merged other way' ' git reset --hard && rm -rf dir~* && git checkout -q dir-in-way^0 && @@ -471,7 +471,7 @@ test_expect_success 'Rename+D/F conflict; renamed file cannot merge, dir not in test_cmp expected dir ' -test_expect_failure 'Rename+D/F conflict; renamed file cannot merge and dir in the way' ' +test_expect_success 'Rename+D/F conflict; renamed file cannot merge and dir in the way' ' modify s/dir-not-in-way/dir-in-way/ expected && git reset --hard && @@ -509,7 +509,7 @@ cat >expected <<\EOF && >>>>>>> renamed-file-has-conflicts EOF -test_expect_failure 'Same as previous, but merged other way' ' +test_expect_success 'Same as previous, but merged other way' ' git reset --hard && rm -rf dir~* && git checkout -q dir-in-way^0 && -- cgit v1.2.1 From 9f6cea97c97ee505bd6771db7df69f04df9b4fc4 Mon Sep 17 00:00:00 2001 From: Brian Gernhardt Date: Mon, 8 Nov 2010 16:29:26 -0500 Subject: t6022: Use -eq not = to test output of wc -l When comparing numbers such as "3" to "$(wc -l)", we should check for numerical equality using -eq instead of string equality using = because some implementations of wc output extra whitespace. Signed-off-by: Brian Gernhardt Signed-off-by: Junio C Hamano --- t/t6022-merge-rename.sh | 64 ++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) (limited to 't/t6022-merge-rename.sh') diff --git a/t/t6022-merge-rename.sh b/t/t6022-merge-rename.sh index 422092e11c..66473f088e 100755 --- a/t/t6022-merge-rename.sh +++ b/t/t6022-merge-rename.sh @@ -404,8 +404,8 @@ test_expect_success 'Rename+D/F conflict; renamed file merges but dir in way' ' grep "Auto-merging dir" output && grep "Adding as dir~HEAD instead" output && - test 2 = "$(git ls-files -u | wc -l)" && - test 2 = "$(git ls-files -u dir/file-in-the-way | wc -l)" && + test 2 -eq "$(git ls-files -u | wc -l)" && + test 2 -eq "$(git ls-files -u dir/file-in-the-way | wc -l)" && test_must_fail git diff --quiet && test_must_fail git diff --cached --quiet && @@ -426,8 +426,8 @@ test_expect_success 'Same as previous, but merged other way' ' grep "Auto-merging dir" output && grep "Adding as dir~renamed-file-has-no-conflicts instead" output && - test 2 = "$(git ls-files -u | wc -l)" && - test 2 = "$(git ls-files -u dir/file-in-the-way | wc -l)" && + test 2 -eq "$(git ls-files -u | wc -l)" && + test 2 -eq "$(git ls-files -u dir/file-in-the-way | wc -l)" && test_must_fail git diff --quiet && test_must_fail git diff --cached --quiet && @@ -461,8 +461,8 @@ test_expect_success 'Rename+D/F conflict; renamed file cannot merge, dir not in git checkout -q renamed-file-has-conflicts^0 && test_must_fail git merge --strategy=recursive dir-not-in-way && - test 3 = "$(git ls-files -u | wc -l)" && - test 3 = "$(git ls-files -u dir | wc -l)" && + test 3 -eq "$(git ls-files -u | wc -l)" && + test 3 -eq "$(git ls-files -u dir | wc -l)" && test_must_fail git diff --quiet && test_must_fail git diff --cached --quiet && @@ -479,9 +479,9 @@ test_expect_success 'Rename+D/F conflict; renamed file cannot merge and dir in t git checkout -q renamed-file-has-conflicts^0 && test_must_fail git merge --strategy=recursive dir-in-way && - test 5 = "$(git ls-files -u | wc -l)" && - test 3 = "$(git ls-files -u dir | grep -v file-in-the-way | wc -l)" && - test 2 = "$(git ls-files -u dir/file-in-the-way | wc -l)" && + test 5 -eq "$(git ls-files -u | wc -l)" && + test 3 -eq "$(git ls-files -u dir | grep -v file-in-the-way | wc -l)" && + test 2 -eq "$(git ls-files -u dir/file-in-the-way | wc -l)" && test_must_fail git diff --quiet && test_must_fail git diff --cached --quiet && @@ -515,9 +515,9 @@ test_expect_success 'Same as previous, but merged other way' ' git checkout -q dir-in-way^0 && test_must_fail git merge --strategy=recursive renamed-file-has-conflicts && - test 5 = "$(git ls-files -u | wc -l)" && - test 3 = "$(git ls-files -u dir | grep -v file-in-the-way | wc -l)" && - test 2 = "$(git ls-files -u dir/file-in-the-way | wc -l)" && + test 5 -eq "$(git ls-files -u | wc -l)" && + test 3 -eq "$(git ls-files -u dir | grep -v file-in-the-way | wc -l)" && + test 2 -eq "$(git ls-files -u dir/file-in-the-way | wc -l)" && test_must_fail git diff --quiet && test_must_fail git diff --cached --quiet && @@ -555,7 +555,7 @@ test_expect_success 'both rename source and destination involved in D/F conflict git checkout -q rename-dest^0 && test_must_fail git merge --strategy=recursive source-conflict && - test 1 = "$(git ls-files -u | wc -l)" && + test 1 -eq "$(git ls-files -u | wc -l)" && test_must_fail git diff --quiet && @@ -594,13 +594,13 @@ test_expect_success 'pair rename to parent of other (D/F conflicts) w/ untracked mkdir one && test_must_fail git merge --strategy=recursive rename-two && - test 2 = "$(git ls-files -u | wc -l)" && - test 1 = "$(git ls-files -u one | wc -l)" && - test 1 = "$(git ls-files -u two | wc -l)" && + test 2 -eq "$(git ls-files -u | wc -l)" && + test 1 -eq "$(git ls-files -u one | wc -l)" && + test 1 -eq "$(git ls-files -u two | wc -l)" && test_must_fail git diff --quiet && - test 4 = $(find . | grep -v .git | wc -l) && + test 4 -eq $(find . | grep -v .git | wc -l) && test -d one && test -f one~rename-two && @@ -614,13 +614,13 @@ test_expect_success 'pair rename to parent of other (D/F conflicts) w/ clean sta git clean -fdqx && test_must_fail git merge --strategy=recursive rename-two && - test 2 = "$(git ls-files -u | wc -l)" && - test 1 = "$(git ls-files -u one | wc -l)" && - test 1 = "$(git ls-files -u two | wc -l)" && + test 2 -eq "$(git ls-files -u | wc -l)" && + test 1 -eq "$(git ls-files -u one | wc -l)" && + test 1 -eq "$(git ls-files -u two | wc -l)" && test_must_fail git diff --quiet && - test 3 = $(find . | grep -v .git | wc -l) && + test 3 -eq $(find . | grep -v .git | wc -l) && test -f one && test -f two && @@ -656,12 +656,12 @@ test_expect_success 'check handling of differently renamed file with D/F conflic git checkout -q first-rename^0 && test_must_fail git merge --strategy=recursive second-rename && - test 5 = "$(git ls-files -s | wc -l)" && - test 3 = "$(git ls-files -u | wc -l)" && - test 1 = "$(git ls-files -u one | wc -l)" && - test 1 = "$(git ls-files -u two | wc -l)" && - test 1 = "$(git ls-files -u original | wc -l)" && - test 2 = "$(git ls-files -o | wc -l)" && + test 5 -eq "$(git ls-files -s | wc -l)" && + test 3 -eq "$(git ls-files -u | wc -l)" && + test 1 -eq "$(git ls-files -u one | wc -l)" && + test 1 -eq "$(git ls-files -u two | wc -l)" && + test 1 -eq "$(git ls-files -u original | wc -l)" && + test 2 -eq "$(git ls-files -o | wc -l)" && test -f one/file && test -f two/file && @@ -696,11 +696,11 @@ test_expect_success 'check handling of differently renamed file with D/F conflic git checkout -q first-rename-redo^0 && test_must_fail git merge --strategy=recursive second-rename-redo && - test 3 = "$(git ls-files -u | wc -l)" && - test 1 = "$(git ls-files -u one | wc -l)" && - test 1 = "$(git ls-files -u two | wc -l)" && - test 1 = "$(git ls-files -u original | wc -l)" && - test 0 = "$(git ls-files -o | wc -l)" && + test 3 -eq "$(git ls-files -u | wc -l)" && + test 1 -eq "$(git ls-files -u one | wc -l)" && + test 1 -eq "$(git ls-files -u two | wc -l)" && + test 1 -eq "$(git ls-files -u original | wc -l)" && + test 0 -eq "$(git ls-files -o | wc -l)" && test -f one && test -f two && -- cgit v1.2.1