Giuseppe Bilotta | 9f79524 | 2017-04-18 11:29:05 +0200 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='git rebase --signoff |
| 4 | |
| 5 | This test runs git rebase --signoff and make sure that it works. |
| 6 | ' |
| 7 | |
Ævar Arnfjörð Bjarmason | b6046ab | 2022-11-08 19:17:42 +0100 | [diff] [blame] | 8 | TEST_PASSES_SANITIZE_LEAK=true |
Giuseppe Bilotta | 9f79524 | 2017-04-18 11:29:05 +0200 | [diff] [blame] | 9 | . ./test-lib.sh |
| 10 | |
| 11 | # A simple file to commit |
| 12 | cat >file <<EOF |
| 13 | a |
| 14 | EOF |
| 15 | |
Phillip Wood | a852ec7 | 2018-03-20 11:10:55 +0000 | [diff] [blame] | 16 | # Expected commit message for initial commit after rebase --signoff |
| 17 | cat >expected-initial-signed <<EOF |
| 18 | Initial empty commit |
| 19 | |
| 20 | Signed-off-by: $(git var GIT_COMMITTER_IDENT | sed -e "s/>.*/>/") |
| 21 | EOF |
| 22 | |
Giuseppe Bilotta | 9f79524 | 2017-04-18 11:29:05 +0200 | [diff] [blame] | 23 | # Expected commit message after rebase --signoff |
| 24 | cat >expected-signed <<EOF |
| 25 | first |
| 26 | |
| 27 | Signed-off-by: $(git var GIT_COMMITTER_IDENT | sed -e "s/>.*/>/") |
| 28 | EOF |
| 29 | |
| 30 | # Expected commit message after rebase without --signoff (or with --no-signoff) |
| 31 | cat >expected-unsigned <<EOF |
| 32 | first |
| 33 | EOF |
| 34 | |
| 35 | |
| 36 | # We configure an alias to do the rebase --signoff so that |
| 37 | # on the next subtest we can show that --no-signoff overrides the alias |
| 38 | test_expect_success 'rebase --signoff adds a sign-off line' ' |
| 39 | git commit --allow-empty -m "Initial empty commit" && |
| 40 | git add file && git commit -m first && |
| 41 | git config alias.rbs "rebase --signoff" && |
| 42 | git rbs HEAD^ && |
| 43 | git cat-file commit HEAD | sed -e "1,/^\$/d" > actual && |
| 44 | test_cmp expected-signed actual |
| 45 | ' |
| 46 | |
| 47 | test_expect_success 'rebase --no-signoff does not add a sign-off line' ' |
| 48 | git commit --amend -m "first" && |
| 49 | git rbs --no-signoff HEAD^ && |
| 50 | git cat-file commit HEAD | sed -e "1,/^\$/d" > actual && |
| 51 | test_cmp expected-unsigned actual |
| 52 | ' |
| 53 | |
Phillip Wood | a852ec7 | 2018-03-20 11:10:55 +0000 | [diff] [blame] | 54 | test_expect_success 'rebase --exec --signoff adds a sign-off line' ' |
| 55 | test_when_finished "rm exec" && |
| 56 | git commit --amend -m "first" && |
| 57 | git rebase --exec "touch exec" --signoff HEAD^ && |
| 58 | test_path_is_file exec && |
| 59 | git cat-file commit HEAD | sed -e "1,/^\$/d" >actual && |
| 60 | test_cmp expected-signed actual |
| 61 | ' |
| 62 | |
| 63 | test_expect_success 'rebase --root --signoff adds a sign-off line' ' |
| 64 | git commit --amend -m "first" && |
| 65 | git rebase --root --keep-empty --signoff && |
| 66 | git cat-file commit HEAD^ | sed -e "1,/^\$/d" >actual && |
| 67 | test_cmp expected-initial-signed actual && |
| 68 | git cat-file commit HEAD | sed -e "1,/^\$/d" >actual && |
| 69 | test_cmp expected-signed actual |
| 70 | ' |
| 71 | |
| 72 | test_expect_success 'rebase -i --signoff fails' ' |
| 73 | git commit --amend -m "first" && |
| 74 | git rebase -i --signoff HEAD^ && |
| 75 | git cat-file commit HEAD | sed -e "1,/^\$/d" >actual && |
| 76 | test_cmp expected-signed actual |
| 77 | ' |
| 78 | |
| 79 | test_expect_success 'rebase -m --signoff fails' ' |
| 80 | git commit --amend -m "first" && |
| 81 | git rebase -m --signoff HEAD^ && |
| 82 | git cat-file commit HEAD | sed -e "1,/^\$/d" >actual && |
| 83 | test_cmp expected-signed actual |
| 84 | ' |
Giuseppe Bilotta | 9f79524 | 2017-04-18 11:29:05 +0200 | [diff] [blame] | 85 | test_done |