Skip to content

Commit 9f79524

Browse files
Oblomovgitster
authored andcommitted
rebase: pass --[no-]signoff option to git am
This makes it easy to sign off a whole patchset before submission. Signed-off-by: Giuseppe Bilotta <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0fb3c4f commit 9f79524

File tree

3 files changed

+53
-1
lines changed

3 files changed

+53
-1
lines changed

Documentation/git-rebase.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,11 @@ default is `--no-fork-point`, otherwise the default is `--fork-point`.
365365
of the rebased commits (see linkgit:git-am[1]).
366366
Incompatible with the --interactive option.
367367

368+
--signoff::
369+
This flag is passed to 'git am' to sign off all the rebased
370+
commits (see linkgit:git-am[1]). Incompatible with the
371+
--interactive option.
372+
368373
-i::
369374
--interactive::
370375
Make a list of the commits which are about to be rebased. Let the

git-rebase.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ root! rebase all reachable commits up to the root(s)
3434
autosquash move commits that begin with squash!/fixup! under -i
3535
committer-date-is-author-date! passed to 'git am'
3636
ignore-date! passed to 'git am'
37+
signoff passed to 'git am'
3738
whitespace=! passed to 'git apply'
3839
ignore-whitespace! passed to 'git apply'
3940
C=! passed to 'git apply'
@@ -320,7 +321,7 @@ do
320321
--ignore-whitespace)
321322
git_am_opt="$git_am_opt $1"
322323
;;
323-
--committer-date-is-author-date|--ignore-date)
324+
--committer-date-is-author-date|--ignore-date|--signoff|--no-signoff)
324325
git_am_opt="$git_am_opt $1"
325326
force_rebase=t
326327
;;

t/t3428-rebase-signoff.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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 after rebase --signoff
16+
cat >expected-signed <<EOF
17+
first
18+
19+
Signed-off-by: $(git var GIT_COMMITTER_IDENT | sed -e "s/>.*/>/")
20+
EOF
21+
22+
# Expected commit message after rebase without --signoff (or with --no-signoff)
23+
cat >expected-unsigned <<EOF
24+
first
25+
EOF
26+
27+
28+
# We configure an alias to do the rebase --signoff so that
29+
# on the next subtest we can show that --no-signoff overrides the alias
30+
test_expect_success 'rebase --signoff adds a sign-off line' '
31+
git commit --allow-empty -m "Initial empty commit" &&
32+
git add file && git commit -m first &&
33+
git config alias.rbs "rebase --signoff" &&
34+
git rbs HEAD^ &&
35+
git cat-file commit HEAD | sed -e "1,/^\$/d" > actual &&
36+
test_cmp expected-signed actual
37+
'
38+
39+
test_expect_success 'rebase --no-signoff does not add a sign-off line' '
40+
git commit --amend -m "first" &&
41+
git rbs --no-signoff HEAD^ &&
42+
git cat-file commit HEAD | sed -e "1,/^\$/d" > actual &&
43+
test_cmp expected-unsigned actual
44+
'
45+
46+
test_done

0 commit comments

Comments
 (0)