From a852ec7f273cf61296a80ddfc26c23acf2163f2f Mon Sep 17 00:00:00 2001 From: Phillip Wood Date: Tue, 20 Mar 2018 11:10:55 +0000 Subject: rebase: extend --signoff support Allow --signoff to be used with --interactive and --merge. In interactive mode only commits marked to be picked, edited or reworded will be signed off. The main motivation for this patch was to allow one to run 'git rebase --exec "make check" --signoff' which is useful when preparing a patch series for publication and is more convenient than doing the signoff with another --exec command. This change also allows --root without --onto to work with --signoff as well (--root with --onto was already supported). Signed-off-by: Phillip Wood Signed-off-by: Junio C Hamano --- git-rebase.sh | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index 37b8f13971..5a5a65f3d2 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -90,6 +90,7 @@ action= preserve_merges= autosquash= keep_empty= +signoff= test "$(git config --bool rebase.autosquash)" = "true" && autosquash=t case "$(git config --bool commit.gpgsign)" in true) gpg_sign_opt=-S ;; @@ -119,6 +120,10 @@ read_basic_state () { allow_rerere_autoupdate="$(cat "$state_dir"/allow_rerere_autoupdate)" test -f "$state_dir"/gpg_sign_opt && gpg_sign_opt="$(cat "$state_dir"/gpg_sign_opt)" + test -f "$state_dir"/signoff && { + signoff="$(cat "$state_dir"/signoff)" + force_rebase=t + } } write_basic_state () { @@ -133,6 +138,7 @@ write_basic_state () { test -n "$allow_rerere_autoupdate" && echo "$allow_rerere_autoupdate" > \ "$state_dir"/allow_rerere_autoupdate test -n "$gpg_sign_opt" && echo "$gpg_sign_opt" > "$state_dir"/gpg_sign_opt + test -n "$signoff" && echo "$signoff" >"$state_dir"/signoff } output () { @@ -328,7 +334,13 @@ do --ignore-whitespace) git_am_opt="$git_am_opt $1" ;; - --committer-date-is-author-date|--ignore-date|--signoff|--no-signoff) + --signoff) + signoff=--signoff + ;; + --no-signoff) + signoff= + ;; + --committer-date-is-author-date|--ignore-date) git_am_opt="$git_am_opt $1" force_rebase=t ;; @@ -458,6 +470,12 @@ then git_format_patch_opt="$git_format_patch_opt --progress" fi +if test -n "$signoff" +then + git_am_opt="$git_am_opt $signoff" + force_rebase=t +fi + if test -z "$rebase_root" then case "$#" in -- cgit v1.2.3 From b79966aa386fc58801e93496cd4e97d82acd53a5 Mon Sep 17 00:00:00 2001 From: Phillip Wood Date: Tue, 20 Mar 2018 11:10:56 +0000 Subject: rebase -p: error out if --signoff is given rebase --preserve-merges does not support --signoff so error out rather than just silently ignoring it so that the user knows the commits will not be signed off. Signed-off-by: Phillip Wood Signed-off-by: Junio C Hamano --- git-rebase.sh | 2 ++ 1 file changed, 2 insertions(+) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index 5a5a65f3d2..e65b65acb4 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -472,6 +472,8 @@ fi if test -n "$signoff" then + test -n "$preserve_merges" && + die "$(gettext "error: cannot combine '--signoff' with '--preserve-merges'")" git_am_opt="$git_am_opt $signoff" force_rebase=t fi -- cgit v1.2.3 From da27a6fbd50861149b32cfd1f9e5c36a935c575a Mon Sep 17 00:00:00 2001 From: Phillip Wood Date: Tue, 20 Mar 2018 11:10:57 +0000 Subject: rebase --keep-empty: always use interactive rebase rebase --merge accepts --keep-empty but just ignores it, by using an implicit interactive rebase the user still gets the rename detection of a merge based rebase but with with --keep-empty support. If rebase --keep-empty without --interactive or --merge stops for the user to resolve merge conflicts then 'git rebase --continue' will fail. This is because it uses a different code path that does not create $git_dir/rebase-apply. As rebase --keep-empty was implemented using cherry-pick it has never supported the am options and now that interactive rebases support --signoff there is no loss of functionality by using an implicit interactive rebase. Signed-off-by: Phillip Wood Signed-off-by: Junio C Hamano --- git-rebase.sh | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index e65b65acb4..ee8c77ad99 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -452,6 +452,11 @@ then test -z "$interactive_rebase" && interactive_rebase=implied fi +if test -n "$keep_empty" +then + test -z "$interactive_rebase" && interactive_rebase=implied +fi + if test -n "$interactive_rebase" then type=interactive -- cgit v1.2.3