use strpbrk(3) to search for characters from a given set
[git/debian.git] / t / t7604-merge-custom-message.sh
blobcd4f9607dc13ce7acfebc62d67bb4dbf1ef46135
1 #!/bin/sh
3 test_description='git merge
5 Testing merge when using a custom message for the merge commit.'
7 . ./test-lib.sh
9 create_merge_msgs() {
10 echo >exp.subject "custom message"
12 cp exp.subject exp.log &&
13 echo >>exp.log "" &&
14 echo >>exp.log "* tag 'c2':" &&
15 echo >>exp.log " c2"
18 test_expect_success 'setup' '
19 echo c0 >c0.c &&
20 git add c0.c &&
21 git commit -m c0 &&
22 git tag c0 &&
23 echo c1 >c1.c &&
24 git add c1.c &&
25 git commit -m c1 &&
26 git tag c1 &&
27 git reset --hard c0 &&
28 echo c2 >c2.c &&
29 git add c2.c &&
30 git commit -m c2 &&
31 git tag c2 &&
32 create_merge_msgs
36 test_expect_success 'merge c2 with a custom message' '
37 git reset --hard c1 &&
38 git merge -m "$(cat exp.subject)" c2 &&
39 git cat-file commit HEAD >raw &&
40 sed -e "1,/^$/d" raw >actual &&
41 test_cmp exp.subject actual
44 test_expect_success 'merge --log appends to custom message' '
45 git reset --hard c1 &&
46 git merge --log -m "$(cat exp.subject)" c2 &&
47 git cat-file commit HEAD >raw &&
48 sed -e "1,/^$/d" raw >actual &&
49 test_cmp exp.log actual
52 mesg_with_comment_and_newlines='
53 # text
57 test_expect_success 'prepare file with comment line and trailing newlines' '
58 printf "%s" "$mesg_with_comment_and_newlines" >expect
61 test_expect_success 'cleanup commit messages (verbatim option)' '
62 git reset --hard c1 &&
63 git merge --cleanup=verbatim -F expect c2 &&
64 git cat-file commit HEAD >raw &&
65 sed -e "1,/^$/d" raw >actual &&
66 test_cmp expect actual
69 test_expect_success 'cleanup commit messages (whitespace option)' '
70 git reset --hard c1 &&
71 test_write_lines "" "# text" "" >text &&
72 echo "# text" >expect &&
73 git merge --cleanup=whitespace -F text c2 &&
74 git cat-file commit HEAD >raw &&
75 sed -e "1,/^$/d" raw >actual &&
76 test_cmp expect actual
79 test_expect_success 'cleanup merge messages (scissors option)' '
80 git reset --hard c1 &&
81 cat >text <<-\EOF &&
83 # to be kept
85 # ------------------------ >8 ------------------------
86 # to be kept, too
87 # ------------------------ >8 ------------------------
88 to be removed
89 # ------------------------ >8 ------------------------
90 to be removed, too
91 EOF
93 cat >expect <<-\EOF &&
94 # to be kept
96 # ------------------------ >8 ------------------------
97 # to be kept, too
98 EOF
99 git merge --cleanup=scissors -e -F text c2 &&
100 git cat-file commit HEAD >raw &&
101 sed -e "1,/^$/d" raw >actual &&
102 test_cmp expect actual
105 test_expect_success 'cleanup commit messages (strip option)' '
106 git reset --hard c1 &&
107 test_write_lines "" "# text" "sample" "" >text &&
108 echo sample >expect &&
109 git merge --cleanup=strip -F text c2 &&
110 git cat-file commit HEAD >raw &&
111 sed -e "1,/^$/d" raw >actual &&
112 test_cmp expect actual
115 test_done