interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / t / t7604-merge-custom-message.sh

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