Merge branch 'ab/retire-refs-unused-funcs'
[git/debian.git] / t / t3405-rebase-malformed.sh
blob2524331861869d6b9ee9f80082c09d2ed089e8fe
1 #!/bin/sh
3 test_description='rebase should handle arbitrary git message'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
8 . ./test-lib.sh
9 . "$TEST_DIRECTORY"/lib-rebase.sh
11 cat >F <<\EOF
12 This is an example of a commit log message
13 that does not conform to git commit convention.
15 It has two paragraphs, but its first paragraph is not friendly
16 to oneline summary format.
17 EOF
19 cat >G <<\EOF
20 commit log message containing a diff
21 EOF
24 test_expect_success setup '
26 >file1 &&
27 >file2 &&
28 git add file1 file2 &&
29 test_tick &&
30 git commit -m "Initial commit" &&
31 git branch diff-in-message &&
32 git branch empty-message-merge &&
34 git checkout -b multi-line-subject &&
35 cat F >file2 &&
36 git add file2 &&
37 test_tick &&
38 git commit -F F &&
40 git cat-file commit HEAD | sed -e "1,/^\$/d" >F0 &&
42 git checkout diff-in-message &&
43 echo "commit log message containing a diff" >G &&
44 echo "" >>G &&
45 cat G >file2 &&
46 git add file2 &&
47 git diff --cached >>G &&
48 test_tick &&
49 git commit -F G &&
51 git cat-file commit HEAD | sed -e "1,/^\$/d" >G0 &&
53 git checkout empty-message-merge &&
54 echo file3 >file3 &&
55 git add file3 &&
56 git commit --allow-empty-message -m "" &&
58 git checkout main &&
60 echo One >file1 &&
61 test_tick &&
62 git add file1 &&
63 git commit -m "Second commit"
66 test_expect_success 'rebase commit with multi-line subject' '
68 git rebase main multi-line-subject &&
69 git cat-file commit HEAD | sed -e "1,/^\$/d" >F1 &&
71 test_cmp F0 F1 &&
72 test_cmp F F0
75 test_expect_success 'rebase commit with diff in message' '
76 git rebase main diff-in-message &&
77 git cat-file commit HEAD | sed -e "1,/^$/d" >G1 &&
78 test_cmp G0 G1 &&
79 test_cmp G G0
82 test_expect_success 'rebase -m commit with empty message' '
83 git rebase -m main empty-message-merge
86 test_expect_success 'rebase -i commit with empty message' '
87 git checkout diff-in-message &&
88 set_fake_editor &&
89 test_must_fail env FAKE_COMMIT_MESSAGE=" " FAKE_LINES="reword 1" \
90 git rebase -i HEAD^
93 test_done