The second batch
[git.git] / t / t3428-rebase-signoff.sh
blob6f57aed9fac68f1b5d670b2e3c35bcc84690a525
1 #!/bin/sh
3 test_description='git rebase --signoff
5 This test runs git rebase --signoff and make sure that it works.
8 . ./test-lib.sh
9 . "$TEST_DIRECTORY"/lib-rebase.sh
11 test_expect_success 'setup' '
12 git commit --allow-empty -m "Initial empty commit" &&
13 test_commit first file a &&
14 test_commit second file &&
15 git checkout -b conflict-branch first &&
16 test_commit file-2 file-2 &&
17 test_commit conflict file &&
18 test_commit third file &&
20 ident="$GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" &&
22 # Expected commit message for initial commit after rebase --signoff
23 cat >expected-initial-signed <<-EOF &&
24 Initial empty commit
26 Signed-off-by: $ident
27 EOF
29 # Expected commit message after rebase --signoff
30 cat >expected-signed <<-EOF &&
31 first
33 Signed-off-by: $ident
34 EOF
36 # Expected commit message after conflict resolution for rebase --signoff
37 cat >expected-signed-conflict <<-EOF &&
38 third
40 Signed-off-by: $ident
42 conflict
44 Signed-off-by: $ident
46 file-2
48 Signed-off-by: $ident
50 EOF
52 # Expected commit message after rebase without --signoff (or with --no-signoff)
53 cat >expected-unsigned <<-EOF &&
54 first
55 EOF
57 git config alias.rbs "rebase --signoff"
60 # We configure an alias to do the rebase --signoff so that
61 # on the next subtest we can show that --no-signoff overrides the alias
62 test_expect_success 'rebase --apply --signoff adds a sign-off line' '
63 test_must_fail git rbs --apply second third &&
64 git checkout --theirs file &&
65 git add file &&
66 git rebase --continue &&
67 git log --format=%B -n3 >actual &&
68 test_cmp expected-signed-conflict actual
71 test_expect_success 'rebase --no-signoff does not add a sign-off line' '
72 git commit --amend -m "first" &&
73 git rbs --no-signoff HEAD^ &&
74 test_commit_message HEAD expected-unsigned
77 test_expect_success 'rebase --exec --signoff adds a sign-off line' '
78 test_when_finished "rm exec" &&
79 git rebase --exec "touch exec" --signoff first^ first &&
80 test_path_is_file exec &&
81 test_commit_message HEAD expected-signed
84 test_expect_success 'rebase --root --signoff adds a sign-off line' '
85 git checkout first &&
86 git rebase --root --keep-empty --signoff &&
87 test_commit_message HEAD^ expected-initial-signed &&
88 test_commit_message HEAD expected-signed
91 test_expect_success 'rebase -m --signoff adds a sign-off line' '
92 test_must_fail git rebase -m --signoff second third &&
93 git checkout --theirs file &&
94 git add file &&
95 GIT_EDITOR="sed -n /Conflicts:/,/^\\\$/p >actual" \
96 git rebase --continue &&
97 cat >expect <<-\EOF &&
98 # Conflicts:
99 # file
102 test_cmp expect actual &&
103 git log --format=%B -n3 >actual &&
104 test_cmp expected-signed-conflict actual
107 test_expect_success 'rebase -i --signoff adds a sign-off line when editing commit' '
109 set_fake_editor &&
110 FAKE_LINES="edit 1 edit 3 edit 2" \
111 git rebase -i --signoff first third
112 ) &&
113 echo a >a &&
114 git add a &&
115 test_must_fail git rebase --continue &&
116 git checkout --ours file &&
117 echo b >a &&
118 git add a file &&
119 git rebase --continue &&
120 echo c >a &&
121 git add a &&
122 git log --format=%B -n3 >actual &&
123 cat >expect <<-EOF &&
124 conflict
126 Signed-off-by: $ident
128 third
130 Signed-off-by: $ident
132 file-2
134 Signed-off-by: $ident
137 test_cmp expect actual
140 test_done