Junio C Hamano | d7f6bae | 2007-07-28 17:57:25 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
Martin von Zweigbergk | a230949 | 2012-06-26 07:51:56 -0700 | [diff] [blame] | 3 | test_description='rebase should handle arbitrary git message' |
Junio C Hamano | d7f6bae | 2007-07-28 17:57:25 -0700 | [diff] [blame] | 4 | |
| 5 | . ./test-lib.sh |
| 6 | |
| 7 | cat >F <<\EOF |
| 8 | This is an example of a commit log message |
| 9 | that does not conform to git commit convention. |
| 10 | |
| 11 | It has two paragraphs, but its first paragraph is not friendly |
| 12 | to oneline summary format. |
| 13 | EOF |
| 14 | |
Martin von Zweigbergk | a230949 | 2012-06-26 07:51:56 -0700 | [diff] [blame] | 15 | cat >G <<\EOF |
| 16 | commit log message containing a diff |
| 17 | EOF |
| 18 | |
| 19 | |
Junio C Hamano | d7f6bae | 2007-07-28 17:57:25 -0700 | [diff] [blame] | 20 | test_expect_success setup ' |
| 21 | |
| 22 | >file1 && |
| 23 | >file2 && |
| 24 | git add file1 file2 && |
| 25 | test_tick && |
| 26 | git commit -m "Initial commit" && |
Martin von Zweigbergk | a230949 | 2012-06-26 07:51:56 -0700 | [diff] [blame] | 27 | git branch diff-in-message |
Junio C Hamano | d7f6bae | 2007-07-28 17:57:25 -0700 | [diff] [blame] | 28 | |
Martin von Zweigbergk | a230949 | 2012-06-26 07:51:56 -0700 | [diff] [blame] | 29 | git checkout -b multi-line-subject && |
Junio C Hamano | d7f6bae | 2007-07-28 17:57:25 -0700 | [diff] [blame] | 30 | cat F >file2 && |
| 31 | git add file2 && |
| 32 | test_tick && |
| 33 | git commit -F F && |
| 34 | |
| 35 | git cat-file commit HEAD | sed -e "1,/^\$/d" >F0 && |
| 36 | |
Martin von Zweigbergk | a230949 | 2012-06-26 07:51:56 -0700 | [diff] [blame] | 37 | git checkout diff-in-message && |
| 38 | echo "commit log message containing a diff" >G && |
| 39 | echo "" >>G |
| 40 | cat G >file2 && |
| 41 | git add file2 && |
| 42 | git diff --cached >>G && |
| 43 | test_tick && |
| 44 | git commit -F G && |
| 45 | |
| 46 | git cat-file commit HEAD | sed -e "1,/^\$/d" >G0 && |
| 47 | |
Junio C Hamano | d7f6bae | 2007-07-28 17:57:25 -0700 | [diff] [blame] | 48 | git checkout master && |
| 49 | |
| 50 | echo One >file1 && |
| 51 | test_tick && |
| 52 | git add file1 && |
| 53 | git commit -m "Second commit" |
| 54 | ' |
| 55 | |
Martin von Zweigbergk | a230949 | 2012-06-26 07:51:56 -0700 | [diff] [blame] | 56 | test_expect_success 'rebase commit with multi-line subject' ' |
Junio C Hamano | d7f6bae | 2007-07-28 17:57:25 -0700 | [diff] [blame] | 57 | |
Martin von Zweigbergk | a230949 | 2012-06-26 07:51:56 -0700 | [diff] [blame] | 58 | git rebase master multi-line-subject && |
Junio C Hamano | d7f6bae | 2007-07-28 17:57:25 -0700 | [diff] [blame] | 59 | git cat-file commit HEAD | sed -e "1,/^\$/d" >F1 && |
| 60 | |
Jeff King | 82ebb0b | 2008-03-12 17:36:36 -0400 | [diff] [blame] | 61 | test_cmp F0 F1 && |
| 62 | test_cmp F F0 |
Junio C Hamano | d7f6bae | 2007-07-28 17:57:25 -0700 | [diff] [blame] | 63 | ' |
| 64 | |
Martin von Zweigbergk | a230949 | 2012-06-26 07:51:56 -0700 | [diff] [blame] | 65 | test_expect_success 'rebase commit with diff in message' ' |
| 66 | git rebase master diff-in-message && |
| 67 | git cat-file commit HEAD | sed -e "1,/^$/d" >G1 && |
| 68 | test_cmp G0 G1 && |
| 69 | test_cmp G G0 |
| 70 | ' |
| 71 | |
Junio C Hamano | d7f6bae | 2007-07-28 17:57:25 -0700 | [diff] [blame] | 72 | test_done |