add test for merge result when lines are inserted at the top of a file Based on a patch by Omar Polo
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
diff --git a/regress/cmdline/histedit.sh b/regress/cmdline/histedit.sh
index 051f0be..3dc4a6a 100755
--- a/regress/cmdline/histedit.sh
+++ b/regress/cmdline/histedit.sh
@@ -1917,6 +1917,62 @@ EOF
test_done "$testroot" "$ret"
}
+test_histedit_prepend_line() {
+ local testroot=`test_init histedit_prepend_line`
+ local orig_commit=`git_show_head $testroot/repo`
+
+ got checkout $testroot/repo $testroot/wt > /dev/null
+
+ ed "$testroot/wt/alpha" <<EOF >/dev/null 2>&1
+0i
+first line
+.
+wq
+EOF
+
+ cp $testroot/wt/alpha $testroot/content.expected
+
+ (cd $testroot/wt/ && got commit -m 'modified alpha on master' \
+ alpha > /dev/null)
+ ret="$?"
+ if [ "$?" != 0 ]; then
+ echo "got commit failed unexpectedly" >&2
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ local top_commit=`git_show_head $testroot/repo`
+ echo "pick $top_commit" > "$testroot/histedit-script"
+
+ (cd $testroot/wt/ && got update -c $orig_commit > /dev/null)
+ ret="$?"
+ if [ "$?" != 0 ]; then
+ echo "got update failed unexpectedly" >&2
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ (cd $testroot/wt && got histedit -F "$testroot/histedit-script" \
+ > /dev/null)
+ ret="$?"
+ if [ "$?" != 0 ]; then
+ echo "got histedit failed unexpectedly" >&2
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ cp $testroot/wt/alpha $testroot/content
+ cmp -s $testroot/content.expected $testroot/content
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/content.expected $testroot/content
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ test_done "$testroot" $ret
+}
+
test_parseargs "$@"
run_test test_histedit_no_op
run_test test_histedit_swap
@@ -1936,3 +1992,4 @@ run_test test_histedit_fold_add_delete
run_test test_histedit_fold_only
run_test test_histedit_fold_only_empty_logmsg
run_test test_histedit_edit_only
+run_test test_histedit_prepend_line