Git 2.45
[git/gitster.git] / t / t7604-merge-custom-message.sh
blobeca755510160be797ff1b08b67f4e18fa10dddb9
1 #!/bin/sh
3 test_description='git merge
5 Testing merge when using a custom message for the merge commit.'
7 TEST_PASSES_SANITIZE_LEAK=true
8 . ./test-lib.sh
10 create_merge_msgs() {
11 echo >exp.subject "custom message"
13 cp exp.subject exp.log &&
14 echo >>exp.log "" &&
15 echo >>exp.log "* tag 'c2':" &&
16 echo >>exp.log " c2"
19 test_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
37 test_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
45 test_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
53 mesg_with_comment_and_newlines='
54 # text
58 test_expect_success 'prepare file with comment line and trailing newlines' '
59 printf "%s" "$mesg_with_comment_and_newlines" >expect
62 test_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
70 test_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
80 test_expect_success 'cleanup merge messages (scissors option)' '
81 git reset --hard c1 &&
82 cat >text <<-\EOF &&
84 # to be kept
86 # ------------------------ >8 ------------------------
87 # to be kept, too
88 # ------------------------ >8 ------------------------
89 to be removed
90 # ------------------------ >8 ------------------------
91 to be removed, too
92 EOF
94 cat >expect <<-\EOF &&
95 # to be kept
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
106 test_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
116 test_done