]>
git.ipfire.org Git - thirdparty/git.git/blob - t/t3428-rebase-signoff.sh
3 test_description
='git rebase --signoff
5 This test runs git rebase --signoff and make sure that it works.
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 &&
29 # Expected commit message after rebase --signoff
30 cat >expected-signed <<-EOF &&
36 # Expected commit message after conflict resolution for rebase --signoff
37 cat >expected-signed-conflict <<-EOF &&
52 # Expected commit message after rebase without --signoff (or with --no-signoff)
53 cat >expected-unsigned <<-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 &&
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' '
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 &&
95 GIT_EDITOR="sed -n /Conflicts:/,/^\\\$/p >actual" \
96 git rebase --continue &&
97 cat >expect <<-\EOF &&
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' '
110 FAKE_LINES="edit 1 edit 3 edit 2" \
111 git rebase -i --signoff first third
115 test_must_fail git rebase --continue &&
116 git checkout --ours file &&
119 git rebase --continue &&
122 git log --format=%B -n3 >actual &&
123 cat >expect <<-EOF &&
126 Signed-off-by: $ident
130 Signed-off-by: $ident
134 Signed-off-by: $ident
137 test_cmp expect actual