Merge branch 'es/worktree-repair-copied' into cw/worktrees-relative
[git/gitster.git] / t / t3405-rebase-malformed.sh
blob8979bc340734f860f56c49a4380366dca1d46ee8
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_PASSES_SANITIZE_LEAK=true
9 . ./test-lib.sh
10 . "$TEST_DIRECTORY"/lib-rebase.sh
12 cat >F <<\EOF
13 This is an example of a commit log message
14 that does not conform to git commit convention.
16 It has two paragraphs, but its first paragraph is not friendly
17 to oneline summary format.
18 EOF
20 cat >G <<\EOF
21 commit log message containing a diff
22 EOF
25 test_expect_success setup '
27 >file1 &&
28 >file2 &&
29 git add file1 file2 &&
30 test_tick &&
31 git commit -m "Initial commit" &&
32 git branch diff-in-message &&
33 git branch empty-message-merge &&
35 git checkout -b multi-line-subject &&
36 cat F >file2 &&
37 git add file2 &&
38 test_tick &&
39 git commit -F F &&
41 git cat-file commit HEAD | sed -e "1,/^\$/d" >F0 &&
43 git checkout diff-in-message &&
44 echo "commit log message containing a diff" >G &&
45 echo "" >>G &&
46 cat G >file2 &&
47 git add file2 &&
48 git diff --cached >>G &&
49 test_tick &&
50 git commit -F G &&
52 git cat-file commit HEAD | sed -e "1,/^\$/d" >G0 &&
54 git checkout empty-message-merge &&
55 echo file3 >file3 &&
56 git add file3 &&
57 git commit --allow-empty-message -m "" &&
59 git checkout main &&
61 echo One >file1 &&
62 test_tick &&
63 git add file1 &&
64 git commit -m "Second commit"
67 test_expect_success 'rebase commit with multi-line subject' '
69 git rebase main multi-line-subject &&
70 git cat-file commit HEAD | sed -e "1,/^\$/d" >F1 &&
72 test_cmp F0 F1 &&
73 test_cmp F F0
76 test_expect_success 'rebase commit with diff in message' '
77 git rebase main diff-in-message &&
78 git cat-file commit HEAD | sed -e "1,/^$/d" >G1 &&
79 test_cmp G0 G1 &&
80 test_cmp G G0
83 test_expect_success 'rebase -m commit with empty message' '
84 git rebase -m main empty-message-merge
87 test_expect_success 'rebase -i commit with empty message' '
88 git checkout diff-in-message &&
89 set_fake_editor &&
90 test_must_fail env FAKE_COMMIT_MESSAGE=" " FAKE_LINES="reword 1" \
91 git rebase -i HEAD^
94 test_done