1#!/bin/sh 2 3test_description='git merge 4 5Testing merge when using a custom message for the merge commit.' 6 7TEST_PASSES_SANITIZE_LEAK=true 8. ./test-lib.sh 9 10create_merge_msgs() { 11 echo >exp.subject "custom message" 12 13 cp exp.subject exp.log && 14 echo >>exp.log "" && 15 echo >>exp.log "* tag 'c2':" && 16 echo >>exp.log " c2" 17} 18 19test_expect_success 'setup' ' 20 echo c0 >c0.c && 21 git add c0.c && 22 git commit -m c0 && 23 git tag c0 && 24 echo c1 >c1.c && 25 git add c1.c && 26 git commit -m c1 && 27 git tag c1 && 28 git reset --hard c0 && 29 echo c2 >c2.c && 30 git add c2.c && 31 git commit -m c2 && 32 git tag c2 && 33 create_merge_msgs 34' 35 36 37test_expect_success 'merge c2 with a custom message' ' 38 git reset --hard c1 && 39 git merge -m "$(cat exp.subject)" c2 && 40 git cat-file commit HEAD >raw && 41 sed -e "1,/^$/d" raw >actual && 42 test_cmp exp.subject actual 43' 44 45test_expect_success 'merge --log appends to custom message' ' 46 git reset --hard c1 && 47 git merge --log -m "$(cat exp.subject)" c2 && 48 git cat-file commit HEAD >raw && 49 sed -e "1,/^$/d" raw >actual && 50 test_cmp exp.log actual 51' 52 53mesg_with_comment_and_newlines=' 54# text 55 56' 57 58test_expect_success 'prepare file with comment line and trailing newlines' ' 59 printf "%s" "$mesg_with_comment_and_newlines" >expect 60' 61 62test_expect_success 'cleanup commit messages (verbatim option)' ' 63 git reset --hard c1 && 64 git merge --cleanup=verbatim -F expect c2 && 65 git cat-file commit HEAD >raw && 66 sed -e "1,/^$/d" raw >actual && 67 test_cmp expect actual 68' 69 70test_expect_success 'cleanup commit messages (whitespace option)' ' 71 git reset --hard c1 && 72 test_write_lines "" "# text" "" >text && 73 echo "# text" >expect && 74 git merge --cleanup=whitespace -F text c2 && 75 git cat-file commit HEAD >raw && 76 sed -e "1,/^$/d" raw >actual && 77 test_cmp expect actual 78' 79 80test_expect_success 'cleanup merge messages (scissors option)' ' 81 git reset --hard c1 && 82 cat >text <<-\EOF && 83 84 # to be kept 85 86 # ------------------------ >8 ------------------------ 87 # to be kept, too 88 # ------------------------ >8 ------------------------ 89 to be removed 90 # ------------------------ >8 ------------------------ 91 to be removed, too 92 EOF 93 94 cat >expect <<-\EOF && 95 # to be kept 96 97 # ------------------------ >8 ------------------------ 98 # to be kept, too 99 EOF 100 git merge --cleanup=scissors -e -F text c2 && 101 git cat-file commit HEAD >raw && 102 sed -e "1,/^$/d" raw >actual && 103 test_cmp expect actual 104' 105 106test_expect_success 'cleanup commit messages (strip option)' ' 107 git reset --hard c1 && 108 test_write_lines "" "# text" "sample" "" >text && 109 echo sample >expect && 110 git merge --cleanup=strip -F text c2 && 111 git cat-file commit HEAD >raw && 112 sed -e "1,/^$/d" raw >actual && 113 test_cmp expect actual 114' 115 116test_done 117