5
This test runs git rebase --signoff and make sure that it works.
6
'
7
8
-TEST_PASSES_SANITIZE_LEAK=true
8
. ./test-lib.sh
9
+. "$TEST_DIRECTORY"/lib-rebase.sh
10
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 &&
19
20
ident="$GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" &&
21
33
Signed-off-by: $ident
34
EOF
35
36
+ # Expected commit message after conflict resolution for rebase --signoff
37
+ cat >expected-signed-conflict <<-EOF &&
38
+ third
39
+
40
+ Signed-off-by: $ident
41
+
42
+ conflict
43
+
44
+ Signed-off-by: $ident
45
+
46
+ file-2
47
+
48
+ Signed-off-by: $ident
49
+
50
+ EOF
51
+
52
# Expected commit message after rebase without --signoff (or with --no-signoff)
53
cat >expected-unsigned <<-EOF &&
54
first
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' '
42
- git rbs --apply HEAD^ &&
43
- test_commit_message HEAD expected-signed
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
69
'
70
71
test_expect_success 'rebase --no-signoff does not add a sign-off line' '
76
77
test_expect_success 'rebase --exec --signoff adds a sign-off line' '
78
test_when_finished "rm exec" &&
54
- git commit --amend -m "first" &&
55
- git rebase --exec "touch exec" --signoff HEAD^ &&
79
+ git rebase --exec "touch exec" --signoff first^ first &&
80
test_path_is_file exec &&
81
test_commit_message HEAD expected-signed
82
'
83
84
test_expect_success 'rebase --root --signoff adds a sign-off line' '
61
- git commit --amend -m "first" &&
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
89
'
90
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
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
100
+
101
+ EOF
102
+ test_cmp expect actual &&
103
+ git log --format=%B -n3 >actual &&
104
+ test_cmp expected-signed-conflict actual
105
'
106
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
107
+test_expect_success 'rebase -i --signoff adds a sign-off line when editing commit' '
108
+ (
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
125
+
126
+ Signed-off-by: $ident
127
+
128
+ third
129
+
130
+ Signed-off-by: $ident
131
+
132
+ file-2
133
+
134
+ Signed-off-by: $ident
135
+
136
+ EOF
137
+ test_cmp expect actual
138
'
139
+
140
test_done