From b2eabcc2539c021ea6cb2d1d2d28c8213986a186 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 29 Jun 2008 16:51:38 +0200 Subject: Add new test to ensure git-merge handles pull.twohead and pull.octopus Test if the given strategies are used and test the case when multiple strategies are configured using a space separated list. Also test if the best strategy is picked if none is specified. This is done by adding a simple test case where recursive detects a rename, but resolve does not, and verify that finally merge will pick up the previous. Signed-off-by: Miklos Vajna Signed-off-by: Junio C Hamano --- t/t7601-merge-pull-config.sh | 129 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100755 t/t7601-merge-pull-config.sh (limited to 't/t7601-merge-pull-config.sh') diff --git a/t/t7601-merge-pull-config.sh b/t/t7601-merge-pull-config.sh new file mode 100755 index 0000000000..32585f8e0d --- /dev/null +++ b/t/t7601-merge-pull-config.sh @@ -0,0 +1,129 @@ +#!/bin/sh + +test_description='git-merge + +Testing pull.* configuration parsing.' + +. ./test-lib.sh + +test_expect_success 'setup' ' + echo c0 >c0.c && + git add c0.c && + git commit -m c0 && + git tag c0 && + echo c1 >c1.c && + git add c1.c && + git commit -m c1 && + git tag c1 && + git reset --hard c0 && + echo c2 >c2.c && + git add c2.c && + git commit -m c2 && + git tag c2 && + git reset --hard c0 && + echo c3 >c3.c && + git add c3.c && + git commit -m c3 && + git tag c3 +' + +test_expect_success 'merge c1 with c2' ' + git reset --hard c1 && + test -f c0.c && + test -f c1.c && + test ! -f c2.c && + test ! -f c3.c && + git merge c2 && + test -f c1.c && + test -f c2.c +' + +test_expect_success 'merge c1 with c2 (ours in pull.twohead)' ' + git reset --hard c1 && + git config pull.twohead ours && + git merge c2 && + test -f c1.c && + ! test -f c2.c +' + +test_expect_success 'merge c1 with c2 and c3 (recursive in pull.octopus)' ' + git reset --hard c1 && + git config pull.octopus "recursive" && + test_must_fail git merge c2 c3 && + test "$(git rev-parse c1)" = "$(git rev-parse HEAD)" +' + +test_expect_success 'merge c1 with c2 and c3 (recursive and octopus in pull.octopus)' ' + git reset --hard c1 && + git config pull.octopus "recursive octopus" && + git merge c2 c3 && + test "$(git rev-parse c1)" != "$(git rev-parse HEAD)" && + test "$(git rev-parse c1)" = "$(git rev-parse HEAD^1)" && + test "$(git rev-parse c2)" = "$(git rev-parse HEAD^2)" && + test "$(git rev-parse c3)" = "$(git rev-parse HEAD^3)" && + git diff --exit-code && + test -f c0.c && + test -f c1.c && + test -f c2.c && + test -f c3.c +' + +conflict_count() +{ + eval $1=`{ + git diff-files --name-only + git ls-files --unmerged + } | wc -l` +} + +# c4 - c5 +# \ c6 +# +# There are two conflicts here: +# +# 1) Because foo.c is renamed to bar.c, recursive will handle this, +# resolve won't. +# +# 2) One in conflict.c and that will always fail. + +test_expect_success 'setup conflicted merge' ' + git reset --hard c0 && + echo A >conflict.c && + git add conflict.c && + echo contents >foo.c && + git add foo.c && + git commit -m c4 && + git tag c4 && + echo B >conflict.c && + git add conflict.c && + git mv foo.c bar.c && + git commit -m c5 && + git tag c5 && + git reset --hard c4 && + echo C >conflict.c && + git add conflict.c && + echo secondline >> foo.c && + git add foo.c && + git commit -m c6 && + git tag c6 +' + +# First do the merge with resolve and recursive then verify that +# recusive is choosen. + +test_expect_success 'merge picks up the best result' ' + git config pull.twohead "recursive resolve" && + git reset --hard c5 && + git merge -s resolve c6 + conflict_count resolve_count && + git reset --hard c5 && + git merge -s recursive c6 + conflict_count recursive_count && + git reset --hard c5 && + git merge c6 + conflict_count auto_count && + test "$auto_count" = "$recursive_count" && + test "$auto_count" != "$resolve_count" +' + +test_done -- cgit v1.2.3 From 1c6669351a47c834cceb75d6044a1aae259fc69f Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 5 Jul 2008 16:23:58 +0200 Subject: Fix t7601-merge-pull-config.sh on AIX The test failed on AIX (and likely other OS, such as apparently OSX) where wc -l outputs whitespace. Also, avoid unnecessary eval in conflict_count(). Signed-off-by: Miklos Vajna Signed-off-by: Junio C Hamano --- t/t7601-merge-pull-config.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 't/t7601-merge-pull-config.sh') diff --git a/t/t7601-merge-pull-config.sh b/t/t7601-merge-pull-config.sh index 32585f8e0d..95b4d71c51 100755 --- a/t/t7601-merge-pull-config.sh +++ b/t/t7601-merge-pull-config.sh @@ -70,10 +70,10 @@ test_expect_success 'merge c1 with c2 and c3 (recursive and octopus in pull.octo conflict_count() { - eval $1=`{ + { git diff-files --name-only git ls-files --unmerged - } | wc -l` + } | wc -l } # c4 - c5 @@ -115,15 +115,15 @@ test_expect_success 'merge picks up the best result' ' git config pull.twohead "recursive resolve" && git reset --hard c5 && git merge -s resolve c6 - conflict_count resolve_count && + resolve_count=$(conflict_count) && git reset --hard c5 && git merge -s recursive c6 - conflict_count recursive_count && + recursive_count=$(conflict_count) && git reset --hard c5 && git merge c6 - conflict_count auto_count && - test "$auto_count" = "$recursive_count" && - test "$auto_count" != "$resolve_count" + auto_count=$(conflict_count) && + test $auto_count = $recursive_count && + test $auto_count != $resolve_count ' test_done -- cgit v1.2.3 From 1719b5e446f54e4196903ae6ed5f8867a5755bf6 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 21 Jul 2008 18:10:47 +0200 Subject: builtin-merge: give a proper error message for invalid strategies in config 'git merge -s foobar' diagnosed invalid "foobar" strategy and errored out with a message, but foobar in pull.twohead or pull.octopus was just silently ignored. This makes invalid strategy both on the command line and in the configuration file to trigger the same error. Signed-off-by: Miklos Vajna Signed-off-by: Junio C Hamano --- t/t7601-merge-pull-config.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 't/t7601-merge-pull-config.sh') diff --git a/t/t7601-merge-pull-config.sh b/t/t7601-merge-pull-config.sh index 95b4d71c51..6b9f6388c7 100755 --- a/t/t7601-merge-pull-config.sh +++ b/t/t7601-merge-pull-config.sh @@ -126,4 +126,16 @@ test_expect_success 'merge picks up the best result' ' test $auto_count != $resolve_count ' +test_expect_success 'merge errors out on invalid strategy' ' + git config pull.twohead "foobar" && + git reset --hard c5 && + test_must_fail git merge c6 +' + +test_expect_success 'merge errors out on invalid strategy' ' + git config --unset-all pull.twohead && + git reset --hard c5 && + test_must_fail git merge -s "resolve recursive" c6 +' + test_done -- cgit v1.2.3 From 4d175ef71d60086b898e4d871e699794d6a93dbf Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 22 Jul 2008 19:05:59 +0200 Subject: t7601: extend the 'merge picks up the best result' test The test only checked if the best result picking code works if there are multiple strategies set in the config. Add a similar one that tests if the same true if the -s option of git merge was used multiple times. Signed-off-by: Miklos Vajna Signed-off-by: Junio C Hamano --- t/t7601-merge-pull-config.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 't/t7601-merge-pull-config.sh') diff --git a/t/t7601-merge-pull-config.sh b/t/t7601-merge-pull-config.sh index 6b9f6388c7..55aa6b5f27 100755 --- a/t/t7601-merge-pull-config.sh +++ b/t/t7601-merge-pull-config.sh @@ -112,6 +112,21 @@ test_expect_success 'setup conflicted merge' ' # recusive is choosen. test_expect_success 'merge picks up the best result' ' + git config --unset-all pull.twohead && + git reset --hard c5 && + git merge -s resolve c6 + resolve_count=$(conflict_count) && + git reset --hard c5 && + git merge -s recursive c6 + recursive_count=$(conflict_count) && + git reset --hard c5 && + git merge -s recursive -s resolve c6 + auto_count=$(conflict_count) && + test $auto_count = $recursive_count && + test $auto_count != $resolve_count +' + +test_expect_success 'merge picks up the best result (from config)' ' git config pull.twohead "recursive resolve" && git reset --hard c5 && git merge -s resolve c6 -- cgit v1.2.3 From 47a528ad24185133867ebb5bb7692db2cb8bef39 Mon Sep 17 00:00:00 2001 From: Nanako Shiraishi Date: Wed, 3 Sep 2008 17:59:33 +0900 Subject: tests: use "git xyzzy" form (t7200 - t9001) Converts tests between t7201-t9001. Signed-off-by: Nanako Shiraishi Signed-off-by: Junio C Hamano --- t/t7601-merge-pull-config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t7601-merge-pull-config.sh') diff --git a/t/t7601-merge-pull-config.sh b/t/t7601-merge-pull-config.sh index 55aa6b5f27..7ba94ea99b 100755 --- a/t/t7601-merge-pull-config.sh +++ b/t/t7601-merge-pull-config.sh @@ -1,6 +1,6 @@ #!/bin/sh -test_description='git-merge +test_description='git merge Testing pull.* configuration parsing.' -- cgit v1.2.3