add a test for 'got cherrypick' with existing merge conflicts
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
diff --git a/regress/cmdline/cherrypick.sh b/regress/cmdline/cherrypick.sh
index c61d700..8cca1c7 100755
--- a/regress/cmdline/cherrypick.sh
+++ b/regress/cmdline/cherrypick.sh
@@ -155,5 +155,85 @@ function test_cherrypick_root_commit {
test_done "$testroot" "$ret"
}
+function test_cherrypick_into_work_tree_with_conflicts {
+ local testroot=`test_init cherrypick_into_work_tree_with_conflicts`
+
+ got checkout $testroot/repo $testroot/wt > /dev/null
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ (cd $testroot/repo && git checkout -q -b newbranch)
+ echo "modified delta on branch" > $testroot/repo/gamma/delta
+ git_commit $testroot/repo -m "committing to delta on newbranch"
+
+ echo "modified alpha on branch" > $testroot/repo/alpha
+ (cd $testroot/repo && git rm -q beta)
+ echo "new file on branch" > $testroot/repo/epsilon/new
+ (cd $testroot/repo && git add epsilon/new)
+ git_commit $testroot/repo -m "committing more changes on newbranch"
+
+ local branch_rev=`git_show_head $testroot/repo`
+
+ # fake a merge conflict
+ echo '<<<<<<<' > $testroot/wt/alpha
+ echo 'alpha' >> $testroot/wt/alpha
+ echo '=======' >> $testroot/wt/alpha
+ echo 'alpha, too' >> $testroot/wt/alpha
+ echo '>>>>>>>' >> $testroot/wt/alpha
+ cp $testroot/wt/alpha $testroot/content.expected
+
+ echo "C alpha" > $testroot/stdout.expected
+ (cd $testroot/wt && got status > $testroot/stdout)
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ (cd $testroot/wt && got cherrypick $branch_rev \
+ > $testroot/stdout 2> $testroot/stderr)
+ ret="$?"
+ if [ "$ret" == "0" ]; then
+ echo "cherrypick succeeded unexpectedly" >&2
+ test_done "$testroot" "1"
+ return 1
+ fi
+
+ echo -n > $testroot/stdout.expected
+ echo -n "got: work tree contains conflicted files; " \
+ > $testroot/stderr.expected
+ echo "these conflicts must be resolved first" \
+ >> $testroot/stderr.expected
+
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ cmp -s $testroot/stderr.expected $testroot/stderr
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stderr.expected $testroot/stderr
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ cmp -s $testroot/content.expected $testroot/wt/alpha
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/content.expected $testroot/wt/alpha
+ fi
+ test_done "$testroot" "$ret"
+}
+
run_test test_cherrypick_basic
run_test test_cherrypick_root_commit
+run_test test_cherrypick_into_work_tree_with_conflicts