]> git.ipfire.org Git - thirdparty/git.git/blob - t/t3428-rebase-signoff.sh
hashmap: use *_entry APIs for iteration
[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-lib.sh
9
10 # A simple file to commit
11 cat >file <<EOF
12 a
13 EOF
14
15 # Expected commit message for initial commit after rebase --signoff
16 cat >expected-initial-signed <<EOF
17 Initial empty commit
18
19 Signed-off-by: $(git var GIT_COMMITTER_IDENT | sed -e "s/>.*/>/")
20 EOF
21
22 # Expected commit message after rebase --signoff
23 cat >expected-signed <<EOF
24 first
25
26 Signed-off-by: $(git var GIT_COMMITTER_IDENT | sed -e "s/>.*/>/")
27 EOF
28
29 # Expected commit message after rebase without --signoff (or with --no-signoff)
30 cat >expected-unsigned <<EOF
31 first
32 EOF
33
34
35 # We configure an alias to do the rebase --signoff so that
36 # on the next subtest we can show that --no-signoff overrides the alias
37 test_expect_success 'rebase --signoff adds a sign-off line' '
38 git commit --allow-empty -m "Initial empty commit" &&
39 git add file && git commit -m first &&
40 git config alias.rbs "rebase --signoff" &&
41 git rbs HEAD^ &&
42 git cat-file commit HEAD | sed -e "1,/^\$/d" > actual &&
43 test_cmp expected-signed actual
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 git cat-file commit HEAD | sed -e "1,/^\$/d" > actual &&
50 test_cmp expected-unsigned actual
51 '
52
53 test_expect_success 'rebase --exec --signoff adds a sign-off line' '
54 test_when_finished "rm exec" &&
55 git commit --amend -m "first" &&
56 git rebase --exec "touch exec" --signoff HEAD^ &&
57 test_path_is_file exec &&
58 git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
59 test_cmp expected-signed actual
60 '
61
62 test_expect_success 'rebase --root --signoff adds a sign-off line' '
63 git commit --amend -m "first" &&
64 git rebase --root --keep-empty --signoff &&
65 git cat-file commit HEAD^ | sed -e "1,/^\$/d" >actual &&
66 test_cmp expected-initial-signed actual &&
67 git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
68 test_cmp expected-signed actual
69 '
70
71 test_expect_success 'rebase -i --signoff fails' '
72 git commit --amend -m "first" &&
73 git rebase -i --signoff HEAD^ &&
74 git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
75 test_cmp expected-signed actual
76 '
77
78 test_expect_success 'rebase -m --signoff fails' '
79 git commit --amend -m "first" &&
80 git rebase -m --signoff HEAD^ &&
81 git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
82 test_cmp expected-signed actual
83 '
84 test_done