]> git.ipfire.org Git - thirdparty/git.git/blob - t/t3428-rebase-signoff.sh
Merge branch 'ps/reftable-block-iteration-optim'
[thirdparty/git.git] / t / t3428-rebase-signoff.sh
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
8 TEST_PASSES_SANITIZE_LEAK=true
9 . ./test-lib.sh
10
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>" &&
16
17 # Expected commit message for initial commit after rebase --signoff
18 cat >expected-initial-signed <<-EOF &&
19 Initial empty commit
20
21 Signed-off-by: $ident
22 EOF
23
24 # Expected commit message after rebase --signoff
25 cat >expected-signed <<-EOF &&
26 first
27
28 Signed-off-by: $ident
29 EOF
30
31 # Expected commit message after rebase without --signoff (or with --no-signoff)
32 cat >expected-unsigned <<-EOF &&
33 first
34 EOF
35
36 git config alias.rbs "rebase --signoff"
37 '
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
41 test_expect_success 'rebase --apply --signoff adds a sign-off line' '
42 git rbs --apply HEAD^ &&
43 test_commit_message HEAD expected-signed
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^ &&
49 test_commit_message HEAD expected-unsigned
50 '
51
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 &&
57 test_commit_message HEAD expected-signed
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 &&
63 test_commit_message HEAD^ expected-initial-signed &&
64 test_commit_message HEAD expected-signed
65 '
66
67 test_expect_success 'rebase -i --signoff fails' '
68 git commit --amend -m "first" &&
69 git rebase -i --signoff HEAD^ &&
70 test_commit_message HEAD expected-signed
71 '
72
73 test_expect_success 'rebase -m --signoff fails' '
74 git commit --amend -m "first" &&
75 git rebase -m --signoff HEAD^ &&
76 test_commit_message HEAD expected-signed
77 '
78 test_done