]> git.ipfire.org Git - thirdparty/git.git/blame - t/t7604-merge-custom-message.sh
l10n: fr v2.23.0 round 2
[thirdparty/git.git] / t / t7604-merge-custom-message.sh
CommitLineData
c1fb35b9
MV
1#!/bin/sh
2
47a528ad 3test_description='git merge
c1fb35b9
MV
4
5Testing merge when using a custom message for the merge commit.'
6
7. ./test-lib.sh
8
5f35afad
TRC
9create_merge_msgs() {
10 echo >exp.subject "custom message"
d4e6c4bd
TRC
11
12 cp exp.subject exp.log &&
13 echo >>exp.log "" &&
57b58db7 14 echo >>exp.log "* tag 'c2':" &&
d4e6c4bd 15 echo >>exp.log " c2"
5f35afad
TRC
16}
17
c1fb35b9 18test_expect_success 'setup' '
b720e1e3 19 echo c0 >c0.c &&
c1fb35b9
MV
20 git add c0.c &&
21 git commit -m c0 &&
22 git tag c0 &&
b720e1e3 23 echo c1 >c1.c &&
c1fb35b9
MV
24 git add c1.c &&
25 git commit -m c1 &&
26 git tag c1 &&
27 git reset --hard c0 &&
b720e1e3 28 echo c2 >c2.c &&
c1fb35b9
MV
29 git add c2.c &&
30 git commit -m c2 &&
5f35afad
TRC
31 git tag c2 &&
32 create_merge_msgs
c1fb35b9
MV
33'
34
c1fb35b9 35
c1fb35b9
MV
36test_expect_success 'merge c2 with a custom message' '
37 git reset --hard c1 &&
5f35afad 38 git merge -m "$(cat exp.subject)" c2 &&
b720e1e3
DL
39 git cat-file commit HEAD >raw &&
40 sed -e "1,/^$/d" raw >actual &&
5f35afad 41 test_cmp exp.subject actual
c1fb35b9
MV
42'
43
f0ecac2b 44test_expect_success 'merge --log appends to custom message' '
d4e6c4bd
TRC
45 git reset --hard c1 &&
46 git merge --log -m "$(cat exp.subject)" c2 &&
b720e1e3
DL
47 git cat-file commit HEAD >raw &&
48 sed -e "1,/^$/d" raw >actual &&
d4e6c4bd
TRC
49 test_cmp exp.log actual
50'
51
d540b70c
DL
52mesg_with_comment_and_newlines='
53# text
54
55'
56
57test_expect_success 'prepare file with comment line and trailing newlines' '
58 printf "%s" "$mesg_with_comment_and_newlines" >expect
59'
60
61test_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
67'
68
69test_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
77'
78
79test_expect_success 'cleanup merge messages (scissors option)' '
80 git reset --hard c1 &&
81 cat >text <<-\EOF &&
82
83 # to be kept
84
85 # ------------------------ >8 ------------------------
86 # to be kept, too
87 # ------------------------ >8 ------------------------
88 to be removed
89 # ------------------------ >8 ------------------------
90 to be removed, too
91 EOF
92
93 cat >expect <<-\EOF &&
94 # to be kept
95
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
103'
104
105test_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
113'
114
c1fb35b9 115test_done