commit-graph: fix bug around octopus merges
[gitweb.git] / t / t7604-merge-custom-message.sh
index aba127913294154e8f51fda746b9ede0b583a2e5..cd4f9607dc13ce7acfebc62d67bb4dbf1ef46135 100755 (executable)
@@ -49,4 +49,67 @@ test_expect_success 'merge --log appends to custom message' '
        test_cmp exp.log actual
 '
 
+mesg_with_comment_and_newlines='
+# text
+
+'
+
+test_expect_success 'prepare file with comment line and trailing newlines'  '
+       printf "%s" "$mesg_with_comment_and_newlines" >expect
+'
+
+test_expect_success 'cleanup commit messages (verbatim option)' '
+       git reset --hard c1 &&
+       git merge --cleanup=verbatim -F expect c2 &&
+       git cat-file commit HEAD >raw &&
+       sed -e "1,/^$/d" raw >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'cleanup commit messages (whitespace option)' '
+       git reset --hard c1 &&
+       test_write_lines "" "# text" "" >text &&
+       echo "# text" >expect &&
+       git merge --cleanup=whitespace -F text c2 &&
+       git cat-file commit HEAD >raw &&
+       sed -e "1,/^$/d" raw >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'cleanup merge messages (scissors option)' '
+       git reset --hard c1 &&
+       cat >text <<-\EOF &&
+
+       # to be kept
+
+         # ------------------------ >8 ------------------------
+       # to be kept, too
+       # ------------------------ >8 ------------------------
+       to be removed
+       # ------------------------ >8 ------------------------
+       to be removed, too
+       EOF
+
+       cat >expect <<-\EOF &&
+       # to be kept
+
+         # ------------------------ >8 ------------------------
+       # to be kept, too
+       EOF
+       git merge --cleanup=scissors -e -F text c2 &&
+       git cat-file commit HEAD >raw &&
+       sed -e "1,/^$/d" raw >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'cleanup commit messages (strip option)' '
+       git reset --hard c1 &&
+       test_write_lines "" "# text" "sample" "" >text &&
+       echo sample >expect &&
+       git merge --cleanup=strip -F text c2 &&
+       git cat-file commit HEAD >raw &&
+       sed -e "1,/^$/d" raw >actual &&
+       test_cmp expect actual
+'
+
 test_done