Skip to content

Commit 62bef66

Browse files
committed
Merge branch 'bc/gpg-sign-everywhere'
Teach "--gpg-sign" option to many commands that create commits. * bc/gpg-sign-everywhere: pull: add the --gpg-sign option. rebase: add the --gpg-sign option rebase: parse options in stuck-long mode rebase: don't try to match -M option rebase: remove useless arguments check am: add the --gpg-sign option am: parse options in stuck-long mode git-sh-setup.sh: add variable to use the stuck-long mode cherry-pick, revert: add the --gpg-sign option
2 parents d8a1bac + ea230d8 commit 62bef66

18 files changed

+135
-59
lines changed

Documentation/git-am.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ SYNOPSIS
1414
[--ignore-date] [--ignore-space-change | --ignore-whitespace]
1515
[--whitespace=<option>] [-C<n>] [-p<n>] [--directory=<dir>]
1616
[--exclude=<path>] [--include=<path>] [--reject] [-q | --quiet]
17-
[--[no-]scissors]
17+
[--[no-]scissors] [-S[<keyid>]]
1818
[(<mbox> | <Maildir>)...]
1919
'git am' (--continue | --skip | --abort)
2020

@@ -119,6 +119,10 @@ default. You can use `--no-utf8` to override this.
119119
Skip the current patch. This is only meaningful when
120120
restarting an aborted patch.
121121

122+
-S[<keyid>]::
123+
--gpg-sign[=<keyid>]::
124+
GPG-sign commits.
125+
122126
--continue::
123127
-r::
124128
--resolved::

Documentation/git-cherry-pick.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ git-cherry-pick - Apply the changes introduced by some existing commits
88
SYNOPSIS
99
--------
1010
[verse]
11-
'git cherry-pick' [--edit] [-n] [-m parent-number] [-s] [-x] [--ff] <commit>...
11+
'git cherry-pick' [--edit] [-n] [-m parent-number] [-s] [-x] [--ff]
12+
[-S[<keyid>]] <commit>...
1213
'git cherry-pick' --continue
1314
'git cherry-pick' --quit
1415
'git cherry-pick' --abort
@@ -100,6 +101,10 @@ effect to your index in a row.
100101
--signoff::
101102
Add Signed-off-by line at the end of the commit message.
102103

104+
-S[<keyid>]::
105+
--gpg-sign[=<keyid>]::
106+
GPG-sign commits.
107+
103108
--ff::
104109
If the current HEAD is the same as the parent of the
105110
cherry-pick'ed commit, then a fast forward to this commit will

Documentation/git-rebase.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,10 @@ which makes little sense.
281281
specified, `-s recursive`. Note the reversal of 'ours' and
282282
'theirs' as noted above for the `-m` option.
283283

284+
-S[<keyid>]::
285+
--gpg-sign[=<keyid>]::
286+
GPG-sign commits.
287+
284288
-q::
285289
--quiet::
286290
Be quiet. Implies --no-stat.

Documentation/git-revert.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ git-revert - Revert some existing commits
88
SYNOPSIS
99
--------
1010
[verse]
11-
'git revert' [--[no-]edit] [-n] [-m parent-number] [-s] <commit>...
11+
'git revert' [--[no-]edit] [-n] [-m parent-number] [-s] [-S[<keyid>]] <commit>...
1212
'git revert' --continue
1313
'git revert' --quit
1414
'git revert' --abort
@@ -80,6 +80,10 @@ more details.
8080
This is useful when reverting more than one commits'
8181
effect to your index in a row.
8282

83+
-S[<keyid>]::
84+
--gpg-sign[=<keyid>]::
85+
GPG-sign commits.
86+
8387
-s::
8488
--signoff::
8589
Add Signed-off-by line at the end of the commit message.

builtin/revert.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ static void parse_args(int argc, const char **argv, struct replay_opts *opts)
8989
OPT_STRING(0, "strategy", &opts->strategy, N_("strategy"), N_("merge strategy")),
9090
OPT_CALLBACK('X', "strategy-option", &opts, N_("option"),
9191
N_("option for merge strategy"), option_parse_x),
92+
{ OPTION_STRING, 'S', "gpg-sign", &opts->gpg_sign, N_("key id"),
93+
N_("GPG sign commit"), PARSE_OPT_OPTARG, NULL, (intptr_t) "" },
9294
OPT_END(),
9395
OPT_END(),
9496
OPT_END(),

contrib/git-resurrect.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ is rather slow but allows you to resurrect other people's topic
1010
branches."
1111

1212
OPTIONS_KEEPDASHDASH=
13+
OPTIONS_STUCKLONG=
1314
OPTIONS_SPEC="\
1415
git resurrect $USAGE
1516
--

git-am.sh

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
SUBDIRECTORY_OK=Yes
66
OPTIONS_KEEPDASHDASH=
7+
OPTIONS_STUCKLONG=t
78
OPTIONS_SPEC="\
89
git am [options] [(<mbox>|<Maildir>)...]
910
git am [options] (--continue | --skip | --abort)
@@ -37,6 +38,7 @@ abort restore the original branch and abort the patching operation.
3738
committer-date-is-author-date lie about committer date
3839
ignore-date use current timestamp for author date
3940
rerere-autoupdate update the index with reused conflict resolution if possible
41+
S,gpg-sign? GPG-sign commits
4042
rebasing* (internal use for git-rebase)"
4143

4244
. git-sh-setup
@@ -374,6 +376,7 @@ git_apply_opt=
374376
committer_date_is_author_date=
375377
ignore_date=
376378
allow_rerere_autoupdate=
379+
gpg_sign_opt=
377380

378381
if test "$(git config --bool --get am.keepcr)" = true
379382
then
@@ -413,14 +416,14 @@ it will be removed. Please do not use it anymore."
413416
abort=t ;;
414417
--rebasing)
415418
rebasing=t threeway=t ;;
416-
--resolvemsg)
417-
shift; resolvemsg=$1 ;;
418-
--whitespace|--directory|--exclude|--include)
419-
git_apply_opt="$git_apply_opt $(sq "$1=$2")"; shift ;;
420-
-C|-p)
421-
git_apply_opt="$git_apply_opt $(sq "$1$2")"; shift ;;
422-
--patch-format)
423-
shift ; patch_format="$1" ;;
419+
--resolvemsg=*)
420+
resolvemsg="${1#--resolvemsg=}" ;;
421+
--whitespace=*|--directory=*|--exclude=*|--include=*)
422+
git_apply_opt="$git_apply_opt $(sq "$1")" ;;
423+
-C*|-p*)
424+
git_apply_opt="$git_apply_opt $(sq "$1")" ;;
425+
--patch-format=*)
426+
patch_format="${1#--patch-format=}" ;;
424427
--reject|--ignore-whitespace|--ignore-space-change)
425428
git_apply_opt="$git_apply_opt $1" ;;
426429
--committer-date-is-author-date)
@@ -435,6 +438,10 @@ it will be removed. Please do not use it anymore."
435438
keepcr=t ;;
436439
--no-keep-cr)
437440
keepcr=f ;;
441+
--gpg-sign)
442+
gpg_sign_opt=-S ;;
443+
--gpg-sign=*)
444+
gpg_sign_opt="-S${1#--gpg-sign=}" ;;
438445
--)
439446
shift; break ;;
440447
*)
@@ -899,7 +906,8 @@ did you forget to use 'git add'?"
899906
GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
900907
export GIT_COMMITTER_DATE
901908
fi &&
902-
git commit-tree $tree ${parent:+-p} $parent <"$dotest/final-commit"
909+
git commit-tree ${parent:+-p} $parent ${gpg_sign_opt:+"$gpg_sign_opt"} $tree \
910+
<"$dotest/final-commit"
903911
) &&
904912
git update-ref -m "$GIT_REFLOG_ACTION: $FIRSTLINE" HEAD $commit $parent ||
905913
stop_here $this

git-instaweb.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
PERL='@@PERL@@'
77
OPTIONS_KEEPDASHDASH=
8+
OPTIONS_STUCKLONG=
89
OPTIONS_SPEC="\
910
git instaweb [options] (--start | --stop | --restart)
1011
--

git-pull.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,15 @@ do
153153
--no-verify-signatures)
154154
verify_signatures=--no-verify-signatures
155155
;;
156+
--gpg-sign|-S)
157+
gpg_sign_args=-S
158+
;;
159+
--gpg-sign=*)
160+
gpg_sign_args=$(git rev-parse --sq-quote "-S${1#--gpg-sign=}")
161+
;;
162+
-S*)
163+
gpg_sign_args=$(git rev-parse --sq-quote "$1")
164+
;;
156165
--d|--dr|--dry|--dry-|--dry-r|--dry-ru|--dry-run)
157166
dry_run=--dry-run
158167
;;
@@ -320,11 +329,13 @@ merge_name=$(git fmt-merge-msg $log_arg <"$GIT_DIR/FETCH_HEAD") || exit
320329
case "$rebase" in
321330
true)
322331
eval="git-rebase $diffstat $strategy_args $merge_args $rebase_args $verbosity"
332+
eval="$eval $gpg_sign_args"
323333
eval="$eval --onto $merge_head ${oldremoteref:-$merge_head}"
324334
;;
325335
*)
326336
eval="git-merge $diffstat $no_commit $verify_signatures $edit $squash $no_ff $ff_only"
327-
eval="$eval $log_arg $strategy_args $merge_args $verbosity $progress"
337+
eval="$eval $log_arg $strategy_args $merge_args $verbosity $progress"
338+
eval="$eval $gpg_sign_args"
328339
eval="$eval \"\$merge_name\" HEAD $merge_head"
329340
;;
330341
esac

git-quiltimport.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/sh
22
OPTIONS_KEEPDASHDASH=
3+
OPTIONS_STUCKLONG=
34
OPTIONS_SPEC="\
45
git quiltimport [options]
56
--

0 commit comments

Comments
 (0)