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 <giuseppe.bilotta@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Giuseppe Bilotta committed Apr 18, 2017 at 11:29 UTC 9f79524a6af0527e380742ee103ca4fbcd440b42
3 files changed +53 -1
Documentation/git-rebase.txt
+5
@@ -365,6 +365,11 @@ default is `--no-fork-point`, otherwise the default is `--fork-point`.
365 of the rebased commits (see linkgit:git-am[1]).
366 Incompatible with the --interactive option.
367
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 +
373 -i::
374 --interactive::
375 Make a list of the commits which are about to be rebased. Let the
git-rebase.sh
+2 -1
@@ -34,6 +34,7 @@ root! rebase all reachable commits up to the root(s)
34 autosquash move commits that begin with squash!/fixup! under -i
35 committer-date-is-author-date! passed to 'git am'
36 ignore-date! passed to 'git am'
37 +signoff passed to 'git am'
38 whitespace=! passed to 'git apply'
39 ignore-whitespace! passed to 'git apply'
40 C=! passed to 'git apply'
@@ -320,7 +321,7 @@ do
321 --ignore-whitespace)
322 git_am_opt="$git_am_opt $1"
323 ;;
323 - --committer-date-is-author-date|--ignore-date)
324 + --committer-date-is-author-date|--ignore-date|--signoff|--no-signoff)
325 git_am_opt="$git_am_opt $1"
326 force_rebase=t
327 ;;
t/t3428-rebase-signoff.sh new
+46
@@ -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