Skip to content

Commit ce06461

Browse files
peffgitster
authored andcommitted
add tests for merge message headings
When calling "git merge $X", we automatically generate a commit message containing something like "Merge branch '$X'". This test script checks that those messages say what they should, and exposes a failure when merging a refname that is ambiguous between a tag and a branch. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5dc36a5 commit ce06461

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

t/t7608-merge-messages.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/sh
2+
3+
test_description='test auto-generated merge messages'
4+
. ./test-lib.sh
5+
6+
check_oneline() {
7+
echo "$1" | sed "s/Q/'/g" >expect &&
8+
git log -1 --pretty=tformat:%s >actual &&
9+
test_cmp expect actual
10+
}
11+
12+
test_expect_success 'merge local branch' '
13+
test_commit master-1 &&
14+
git checkout -b local-branch &&
15+
test_commit branch-1 &&
16+
git checkout master &&
17+
test_commit master-2 &&
18+
git merge local-branch &&
19+
check_oneline "Merge branch Qlocal-branchQ"
20+
'
21+
22+
test_expect_success 'merge octopus branches' '
23+
git checkout -b octopus-a master &&
24+
test_commit octopus-1 &&
25+
git checkout -b octopus-b master &&
26+
test_commit octopus-2 &&
27+
git checkout master &&
28+
git merge octopus-a octopus-b &&
29+
check_oneline "Merge branches Qoctopus-aQ and Qoctopus-bQ"
30+
'
31+
32+
test_expect_success 'merge tag' '
33+
git checkout -b tag-branch master &&
34+
test_commit tag-1 &&
35+
git checkout master &&
36+
test_commit master-3 &&
37+
git merge tag-1 &&
38+
check_oneline "Merge commit Qtag-1Q"
39+
'
40+
41+
test_expect_failure 'ambiguous tag' '
42+
git checkout -b ambiguous master &&
43+
test_commit ambiguous &&
44+
git checkout master &&
45+
test_commit master-4 &&
46+
git merge ambiguous &&
47+
check_oneline "Merge commit QambiguousQ"
48+
'
49+
50+
test_done

0 commit comments

Comments
 (0)