#!/bin/sh
-test_description='git-merge
+test_description='git merge
Testing pull.* configuration parsing.'
conflict_count()
{
- eval $1=`{
+ {
git diff-files --name-only
git ls-files --unmerged
- } | wc -l`
+ } | wc -l
}
# c4 - c5
# 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
- 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_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