]>
Commit | Line | Data |
---|---|---|
9f79524a GB |
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 | ||
b6046abc | 8 | TEST_PASSES_SANITIZE_LEAK=true |
9f79524a GB |
9 | . ./test-lib.sh |
10 | ||
aac1c6e8 PW |
11 | test_expect_success 'setup' ' |
12 | git commit --allow-empty -m "Initial empty commit" && | |
13 | test_commit first file a && | |
14 | ||
15 | ident="$GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" && | |
9f79524a | 16 | |
aac1c6e8 PW |
17 | # Expected commit message for initial commit after rebase --signoff |
18 | cat >expected-initial-signed <<-EOF && | |
19 | Initial empty commit | |
a852ec7f | 20 | |
aac1c6e8 PW |
21 | Signed-off-by: $ident |
22 | EOF | |
a852ec7f | 23 | |
aac1c6e8 PW |
24 | # Expected commit message after rebase --signoff |
25 | cat >expected-signed <<-EOF && | |
26 | first | |
9f79524a | 27 | |
aac1c6e8 PW |
28 | Signed-off-by: $ident |
29 | EOF | |
9f79524a | 30 | |
aac1c6e8 PW |
31 | # Expected commit message after rebase without --signoff (or with --no-signoff) |
32 | cat >expected-unsigned <<-EOF && | |
33 | first | |
34 | EOF | |
9f79524a | 35 | |
aac1c6e8 PW |
36 | git config alias.rbs "rebase --signoff" |
37 | ' | |
9f79524a GB |
38 | |
39 | # We configure an alias to do the rebase --signoff so that | |
40 | # on the next subtest we can show that --no-signoff overrides the alias | |
b4454d5a PW |
41 | test_expect_success 'rebase --apply --signoff adds a sign-off line' ' |
42 | git rbs --apply HEAD^ && | |
1ad81756 | 43 | test_commit_message HEAD expected-signed |
9f79524a GB |
44 | ' |
45 | ||
46 | test_expect_success 'rebase --no-signoff does not add a sign-off line' ' | |
47 | git commit --amend -m "first" && | |
48 | git rbs --no-signoff HEAD^ && | |
1ad81756 | 49 | test_commit_message HEAD expected-unsigned |
9f79524a GB |
50 | ' |
51 | ||
a852ec7f PW |
52 | test_expect_success 'rebase --exec --signoff adds a sign-off line' ' |
53 | test_when_finished "rm exec" && | |
54 | git commit --amend -m "first" && | |
55 | git rebase --exec "touch exec" --signoff HEAD^ && | |
56 | test_path_is_file exec && | |
1ad81756 | 57 | test_commit_message HEAD expected-signed |
a852ec7f PW |
58 | ' |
59 | ||
60 | test_expect_success 'rebase --root --signoff adds a sign-off line' ' | |
61 | git commit --amend -m "first" && | |
62 | git rebase --root --keep-empty --signoff && | |
1ad81756 PW |
63 | test_commit_message HEAD^ expected-initial-signed && |
64 | test_commit_message HEAD expected-signed | |
a852ec7f PW |
65 | ' |
66 | ||
67 | test_expect_success 'rebase -i --signoff fails' ' | |
68 | git commit --amend -m "first" && | |
69 | git rebase -i --signoff HEAD^ && | |
1ad81756 | 70 | test_commit_message HEAD expected-signed |
a852ec7f PW |
71 | ' |
72 | ||
73 | test_expect_success 'rebase -m --signoff fails' ' | |
74 | git commit --amend -m "first" && | |
75 | git rebase -m --signoff HEAD^ && | |
1ad81756 | 76 | test_commit_message HEAD expected-signed |
a852ec7f | 77 | ' |
9f79524a | 78 | test_done |