1#!/bin/sh
2
3test_description='rebase should handle arbitrary git message'
4
5. ./test-lib.sh
6. "$TEST_DIRECTORY"/lib-rebase.sh
7
8cat >F <<\EOF
9This is an example of a commit log message
10that does not conform to git commit convention.
11
12It has two paragraphs, but its first paragraph is not friendly
13to oneline summary format.
14EOF
15
16cat >G <<\EOF
17commit log message containing a diff
18EOF
19
20
21test_expect_success setup '
22
23 >file1 &&
24 >file2 &&
25 git add file1 file2 &&
26 test_tick &&
27 git commit -m "Initial commit" &&
28 git branch diff-in-message &&
29 git branch empty-message-merge &&
30
31 git checkout -b multi-line-subject &&
32 cat F >file2 &&
33 git add file2 &&
34 test_tick &&
35 git commit -F F &&
36
37 git cat-file commit HEAD | sed -e "1,/^\$/d" >F0 &&
38
39 git checkout diff-in-message &&
40 echo "commit log message containing a diff" >G &&
41 echo "" >>G &&
42 cat G >file2 &&
43 git add file2 &&
44 git diff --cached >>G &&
45 test_tick &&
46 git commit -F G &&
47
48 git cat-file commit HEAD | sed -e "1,/^\$/d" >G0 &&
49
50 git checkout empty-message-merge &&
51 echo file3 >file3 &&
52 git add file3 &&
53 git commit --allow-empty-message -m "" &&
54
55 git checkout master &&
56
57 echo One >file1 &&
58 test_tick &&
59 git add file1 &&
60 git commit -m "Second commit"
61'
62
63test_expect_success 'rebase commit with multi-line subject' '
64
65 git rebase master multi-line-subject &&
66 git cat-file commit HEAD | sed -e "1,/^\$/d" >F1 &&
67
68 test_cmp F0 F1 &&
69 test_cmp F F0
70'
71
72test_expect_success 'rebase commit with diff in message' '
73 git rebase master diff-in-message &&
74 git cat-file commit HEAD | sed -e "1,/^$/d" >G1 &&
75 test_cmp G0 G1 &&
76 test_cmp G G0
77'
78
79test_expect_success 'rebase -m commit with empty message' '
80 git rebase -m master empty-message-merge
81'
82
83test_expect_success 'rebase -i commit with empty message' '
84 git checkout diff-in-message &&
85 set_fake_editor &&
86 env FAKE_COMMIT_MESSAGE=" " FAKE_LINES="reword 1" \
87 git rebase -i HEAD^
88'
89
90test_done