@@ -179,9 +179,10 @@ exit_with_patch () {
179
179
echo " $1 " > " $state_dir " /stopped-sha
180
180
make_patch $1
181
181
git rev-parse --verify HEAD > " $amend "
182
+ gpg_sign_opt_quoted=${gpg_sign_opt: +$(git rev-parse --sq-quote " $gpg_sign_opt " )}
182
183
warn " You can amend the commit now, with"
183
184
warn
184
- warn " git commit --amend"
185
+ warn " git commit --amend $gpg_sign_opt_quoted "
185
186
warn
186
187
warn " Once you are satisfied with your changes, run"
187
188
warn
@@ -248,7 +249,9 @@ pick_one () {
248
249
249
250
test -d " $rewritten " &&
250
251
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 " $@ "
252
255
}
253
256
254
257
pick_one_preserving_merges () {
@@ -351,15 +354,18 @@ pick_one_preserving_merges () {
351
354
new_parents=${new_parents# $first_parent }
352
355
merge_args=" --no-log --no-ff"
353
356
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'
355
359
then
356
360
printf " %s\n" " $msg_content " > " $GIT_DIR " /MERGE_MSG
357
361
die_with_patch $sha1 " Error redoing merge $sha1 "
358
362
fi
359
363
echo " $sha1 $( git rev-parse HEAD^0) " >> " $rewritten_list "
360
364
;;
361
365
* )
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 " " $@ " ||
363
369
die_with_patch $sha1 " Could not pick $sha1 "
364
370
;;
365
371
esac
@@ -470,7 +476,8 @@ do_pick () {
470
476
--no-post-rewrite -n -q -C $1 &&
471
477
pick_one -n $1 &&
472
478
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 " } ||
474
481
die_with_patch $1 " Could not apply $1 ... $2 "
475
482
else
476
483
pick_one $1 ||
@@ -497,7 +504,7 @@ do_next () {
497
504
498
505
mark_action_done
499
506
do_pick $sha1 " $rest "
500
- git commit --amend --no-post-rewrite || {
507
+ git commit --amend --no-post-rewrite ${gpg_sign_opt : + " $gpg_sign_opt " } || {
501
508
warn " Could not amend commit after successfully picking $sha1 ... $rest "
502
509
warn " This is most likely due to an empty commit message, or the pre-commit hook"
503
510
warn " failed. If the pre-commit hook failed, you may need to resolve the issue before"
@@ -542,19 +549,22 @@ do_next () {
542
549
squash|s|fixup|f)
543
550
# This is an intermediate commit; its message will only be
544
551
# 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 " } ||
546
554
die_failed_squash $sha1 " $rest "
547
555
;;
548
556
* )
549
557
# This is the final command of this squash/fixup group
550
558
if test -f " $fixup_msg "
551
559
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 " } ||
553
562
die_failed_squash $sha1 " $rest "
554
563
else
555
564
cp " $squash_msg " " $GIT_DIR " /SQUASH_MSG || exit
556
565
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 " } ||
558
568
die_failed_squash $sha1 " $rest "
559
569
fi
560
570
rm -f " $squash_msg " " $fixup_msg "
@@ -819,14 +829,15 @@ continue)
819
829
else
820
830
if ! test -f " $author_script "
821
831
then
832
+ gpg_sign_opt_quoted=${gpg_sign_opt: +$(git rev-parse --sq-quote " $gpg_sign_opt " )}
822
833
die " You have staged changes in your working tree. If these changes are meant to be
823
834
squashed into the previous commit, run:
824
835
825
- git commit --amend
836
+ git commit --amend $gpg_sign_opt_quoted
826
837
827
838
If they are meant to go into a new commit, run:
828
839
829
- git commit
840
+ git commit $gpg_sign_opt_quoted
830
841
831
842
In both case, once you're done, continue with:
832
843
@@ -842,10 +853,12 @@ In both case, once you're done, continue with:
842
853
die " \
843
854
You have uncommitted changes in your working tree. Please, commit them
844
855
first 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 " } ||
846
858
die " Could not commit staged changes."
847
859
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 " } ||
849
862
die " Could not commit staged changes."
850
863
fi
851
864
fi
0 commit comments