@@ -179,9 +179,10 @@ exit_with_patch () {
179179 echo " $1 " > " $state_dir " /stopped-sha
180180 make_patch $1
181181 git rev-parse --verify HEAD > " $amend "
182+ gpg_sign_opt_quoted=${gpg_sign_opt: +$(git rev-parse --sq-quote " $gpg_sign_opt " )}
182183 warn " You can amend the commit now, with"
183184 warn
184- warn " git commit --amend"
185+ warn " git commit --amend $gpg_sign_opt_quoted "
185186 warn
186187 warn " Once you are satisfied with your changes, run"
187188 warn
@@ -248,7 +249,9 @@ pick_one () {
248249
249250 test -d " $rewritten " &&
250251 pick_one_preserving_merges " $@ " && return
251- output eval git cherry-pick " $strategy_args " $empty_args $ff " $@ "
252+ output eval git cherry-pick \
253+ ${gpg_sign_opt: +$(git rev-parse --sq-quote " $gpg_sign_opt " )} \
254+ " $strategy_args " $empty_args $ff " $@ "
252255}
253256
254257pick_one_preserving_merges () {
@@ -351,15 +354,18 @@ pick_one_preserving_merges () {
351354 new_parents=${new_parents# $first_parent }
352355 merge_args=" --no-log --no-ff"
353356 if ! do_with_author output eval \
354- ' git merge $merge_args $strategy_args -m "$msg_content" $new_parents'
357+ ' git merge ${gpg_sign_opt:+"$gpg_sign_opt"} \
358+ $merge_args $strategy_args -m "$msg_content" $new_parents'
355359 then
356360 printf " %s\n" " $msg_content " > " $GIT_DIR " /MERGE_MSG
357361 die_with_patch $sha1 " Error redoing merge $sha1 "
358362 fi
359363 echo " $sha1 $( git rev-parse HEAD^0) " >> " $rewritten_list "
360364 ;;
361365 * )
362- output eval git cherry-pick " $strategy_args " " $@ " ||
366+ output eval git cherry-pick \
367+ ${gpg_sign_opt: +$(git rev-parse --sq-quote " $gpg_sign_opt " )} \
368+ " $strategy_args " " $@ " ||
363369 die_with_patch $sha1 " Could not pick $sha1 "
364370 ;;
365371 esac
@@ -470,7 +476,8 @@ do_pick () {
470476 --no-post-rewrite -n -q -C $1 &&
471477 pick_one -n $1 &&
472478 git commit --allow-empty --allow-empty-message \
473- --amend --no-post-rewrite -n -q -C $1 ||
479+ --amend --no-post-rewrite -n -q -C $1 \
480+ ${gpg_sign_opt: +" $gpg_sign_opt " } ||
474481 die_with_patch $1 " Could not apply $1 ... $2 "
475482 else
476483 pick_one $1 ||
@@ -497,7 +504,7 @@ do_next () {
497504
498505 mark_action_done
499506 do_pick $sha1 " $rest "
500- git commit --amend --no-post-rewrite || {
507+ git commit --amend --no-post-rewrite ${gpg_sign_opt : + " $gpg_sign_opt " } || {
501508 warn " Could not amend commit after successfully picking $sha1 ... $rest "
502509 warn " This is most likely due to an empty commit message, or the pre-commit hook"
503510 warn " failed. If the pre-commit hook failed, you may need to resolve the issue before"
@@ -542,19 +549,22 @@ do_next () {
542549 squash|s|fixup|f)
543550 # This is an intermediate commit; its message will only be
544551 # used in case of trouble. So use the long version:
545- do_with_author output git commit --amend --no-verify -F " $squash_msg " ||
552+ do_with_author output git commit --amend --no-verify -F " $squash_msg " \
553+ ${gpg_sign_opt: +" $gpg_sign_opt " } ||
546554 die_failed_squash $sha1 " $rest "
547555 ;;
548556 * )
549557 # This is the final command of this squash/fixup group
550558 if test -f " $fixup_msg "
551559 then
552- do_with_author git commit --amend --no-verify -F " $fixup_msg " ||
560+ do_with_author git commit --amend --no-verify -F " $fixup_msg " \
561+ ${gpg_sign_opt: +" $gpg_sign_opt " } ||
553562 die_failed_squash $sha1 " $rest "
554563 else
555564 cp " $squash_msg " " $GIT_DIR " /SQUASH_MSG || exit
556565 rm -f " $GIT_DIR " /MERGE_MSG
557- do_with_author git commit --amend --no-verify -F " $GIT_DIR " /SQUASH_MSG -e ||
566+ do_with_author git commit --amend --no-verify -F " $GIT_DIR " /SQUASH_MSG -e \
567+ ${gpg_sign_opt: +" $gpg_sign_opt " } ||
558568 die_failed_squash $sha1 " $rest "
559569 fi
560570 rm -f " $squash_msg " " $fixup_msg "
@@ -819,14 +829,15 @@ continue)
819829 else
820830 if ! test -f " $author_script "
821831 then
832+ gpg_sign_opt_quoted=${gpg_sign_opt: +$(git rev-parse --sq-quote " $gpg_sign_opt " )}
822833 die " You have staged changes in your working tree. If these changes are meant to be
823834squashed into the previous commit, run:
824835
825- git commit --amend
836+ git commit --amend $gpg_sign_opt_quoted
826837
827838If they are meant to go into a new commit, run:
828839
829- git commit
840+ git commit $gpg_sign_opt_quoted
830841
831842In both case, once you're done, continue with:
832843
@@ -842,10 +853,12 @@ In both case, once you're done, continue with:
842853 die " \
843854You have uncommitted changes in your working tree. Please, commit them
844855first and then run 'git rebase --continue' again."
845- do_with_author git commit --amend --no-verify -F " $msg " -e ||
856+ do_with_author git commit --amend --no-verify -F " $msg " -e \
857+ ${gpg_sign_opt: +" $gpg_sign_opt " } ||
846858 die " Could not commit staged changes."
847859 else
848- do_with_author git commit --no-verify -F " $msg " -e ||
860+ do_with_author git commit --no-verify -F " $msg " -e \
861+ ${gpg_sign_opt: +" $gpg_sign_opt " } ||
849862 die " Could not commit staged changes."
850863 fi
851864 fi
0 commit comments