提交 62bef66f 编写于 作者: J Junio C Hamano

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
...@@ -14,7 +14,7 @@ SYNOPSIS ...@@ -14,7 +14,7 @@ SYNOPSIS
[--ignore-date] [--ignore-space-change | --ignore-whitespace] [--ignore-date] [--ignore-space-change | --ignore-whitespace]
[--whitespace=<option>] [-C<n>] [-p<n>] [--directory=<dir>] [--whitespace=<option>] [-C<n>] [-p<n>] [--directory=<dir>]
[--exclude=<path>] [--include=<path>] [--reject] [-q | --quiet] [--exclude=<path>] [--include=<path>] [--reject] [-q | --quiet]
[--[no-]scissors] [--[no-]scissors] [-S[<keyid>]]
[(<mbox> | <Maildir>)...] [(<mbox> | <Maildir>)...]
'git am' (--continue | --skip | --abort) 'git am' (--continue | --skip | --abort)
...@@ -119,6 +119,10 @@ default. You can use `--no-utf8` to override this. ...@@ -119,6 +119,10 @@ default. You can use `--no-utf8` to override this.
Skip the current patch. This is only meaningful when Skip the current patch. This is only meaningful when
restarting an aborted patch. restarting an aborted patch.
-S[<keyid>]::
--gpg-sign[=<keyid>]::
GPG-sign commits.
--continue:: --continue::
-r:: -r::
--resolved:: --resolved::
......
...@@ -8,7 +8,8 @@ git-cherry-pick - Apply the changes introduced by some existing commits ...@@ -8,7 +8,8 @@ git-cherry-pick - Apply the changes introduced by some existing commits
SYNOPSIS SYNOPSIS
-------- --------
[verse] [verse]
'git cherry-pick' [--edit] [-n] [-m parent-number] [-s] [-x] [--ff] <commit>... 'git cherry-pick' [--edit] [-n] [-m parent-number] [-s] [-x] [--ff]
[-S[<keyid>]] <commit>...
'git cherry-pick' --continue 'git cherry-pick' --continue
'git cherry-pick' --quit 'git cherry-pick' --quit
'git cherry-pick' --abort 'git cherry-pick' --abort
...@@ -100,6 +101,10 @@ effect to your index in a row. ...@@ -100,6 +101,10 @@ effect to your index in a row.
--signoff:: --signoff::
Add Signed-off-by line at the end of the commit message. Add Signed-off-by line at the end of the commit message.
-S[<keyid>]::
--gpg-sign[=<keyid>]::
GPG-sign commits.
--ff:: --ff::
If the current HEAD is the same as the parent of the If the current HEAD is the same as the parent of the
cherry-pick'ed commit, then a fast forward to this commit will cherry-pick'ed commit, then a fast forward to this commit will
......
...@@ -281,6 +281,10 @@ which makes little sense. ...@@ -281,6 +281,10 @@ which makes little sense.
specified, `-s recursive`. Note the reversal of 'ours' and specified, `-s recursive`. Note the reversal of 'ours' and
'theirs' as noted above for the `-m` option. 'theirs' as noted above for the `-m` option.
-S[<keyid>]::
--gpg-sign[=<keyid>]::
GPG-sign commits.
-q:: -q::
--quiet:: --quiet::
Be quiet. Implies --no-stat. Be quiet. Implies --no-stat.
......
...@@ -8,7 +8,7 @@ git-revert - Revert some existing commits ...@@ -8,7 +8,7 @@ git-revert - Revert some existing commits
SYNOPSIS SYNOPSIS
-------- --------
[verse] [verse]
'git revert' [--[no-]edit] [-n] [-m parent-number] [-s] <commit>... 'git revert' [--[no-]edit] [-n] [-m parent-number] [-s] [-S[<keyid>]] <commit>...
'git revert' --continue 'git revert' --continue
'git revert' --quit 'git revert' --quit
'git revert' --abort 'git revert' --abort
...@@ -80,6 +80,10 @@ more details. ...@@ -80,6 +80,10 @@ more details.
This is useful when reverting more than one commits' This is useful when reverting more than one commits'
effect to your index in a row. effect to your index in a row.
-S[<keyid>]::
--gpg-sign[=<keyid>]::
GPG-sign commits.
-s:: -s::
--signoff:: --signoff::
Add Signed-off-by line at the end of the commit message. Add Signed-off-by line at the end of the commit message.
......
...@@ -89,6 +89,8 @@ static void parse_args(int argc, const char **argv, struct replay_opts *opts) ...@@ -89,6 +89,8 @@ static void parse_args(int argc, const char **argv, struct replay_opts *opts)
OPT_STRING(0, "strategy", &opts->strategy, N_("strategy"), N_("merge strategy")), OPT_STRING(0, "strategy", &opts->strategy, N_("strategy"), N_("merge strategy")),
OPT_CALLBACK('X', "strategy-option", &opts, N_("option"), OPT_CALLBACK('X', "strategy-option", &opts, N_("option"),
N_("option for merge strategy"), option_parse_x), N_("option for merge strategy"), option_parse_x),
{ OPTION_STRING, 'S', "gpg-sign", &opts->gpg_sign, N_("key id"),
N_("GPG sign commit"), PARSE_OPT_OPTARG, NULL, (intptr_t) "" },
OPT_END(), OPT_END(),
OPT_END(), OPT_END(),
OPT_END(), OPT_END(),
......
...@@ -10,6 +10,7 @@ is rather slow but allows you to resurrect other people's topic ...@@ -10,6 +10,7 @@ is rather slow but allows you to resurrect other people's topic
branches." branches."
OPTIONS_KEEPDASHDASH= OPTIONS_KEEPDASHDASH=
OPTIONS_STUCKLONG=
OPTIONS_SPEC="\ OPTIONS_SPEC="\
git resurrect $USAGE git resurrect $USAGE
-- --
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
SUBDIRECTORY_OK=Yes SUBDIRECTORY_OK=Yes
OPTIONS_KEEPDASHDASH= OPTIONS_KEEPDASHDASH=
OPTIONS_STUCKLONG=t
OPTIONS_SPEC="\ OPTIONS_SPEC="\
git am [options] [(<mbox>|<Maildir>)...] git am [options] [(<mbox>|<Maildir>)...]
git am [options] (--continue | --skip | --abort) git am [options] (--continue | --skip | --abort)
...@@ -37,6 +38,7 @@ abort restore the original branch and abort the patching operation. ...@@ -37,6 +38,7 @@ abort restore the original branch and abort the patching operation.
committer-date-is-author-date lie about committer date committer-date-is-author-date lie about committer date
ignore-date use current timestamp for author date ignore-date use current timestamp for author date
rerere-autoupdate update the index with reused conflict resolution if possible rerere-autoupdate update the index with reused conflict resolution if possible
S,gpg-sign? GPG-sign commits
rebasing* (internal use for git-rebase)" rebasing* (internal use for git-rebase)"
. git-sh-setup . git-sh-setup
...@@ -374,6 +376,7 @@ git_apply_opt= ...@@ -374,6 +376,7 @@ git_apply_opt=
committer_date_is_author_date= committer_date_is_author_date=
ignore_date= ignore_date=
allow_rerere_autoupdate= allow_rerere_autoupdate=
gpg_sign_opt=
if test "$(git config --bool --get am.keepcr)" = true if test "$(git config --bool --get am.keepcr)" = true
then then
...@@ -413,14 +416,14 @@ it will be removed. Please do not use it anymore." ...@@ -413,14 +416,14 @@ it will be removed. Please do not use it anymore."
abort=t ;; abort=t ;;
--rebasing) --rebasing)
rebasing=t threeway=t ;; rebasing=t threeway=t ;;
--resolvemsg) --resolvemsg=*)
shift; resolvemsg=$1 ;; resolvemsg="${1#--resolvemsg=}" ;;
--whitespace|--directory|--exclude|--include) --whitespace=*|--directory=*|--exclude=*|--include=*)
git_apply_opt="$git_apply_opt $(sq "$1=$2")"; shift ;; git_apply_opt="$git_apply_opt $(sq "$1")" ;;
-C|-p) -C*|-p*)
git_apply_opt="$git_apply_opt $(sq "$1$2")"; shift ;; git_apply_opt="$git_apply_opt $(sq "$1")" ;;
--patch-format) --patch-format=*)
shift ; patch_format="$1" ;; patch_format="${1#--patch-format=}" ;;
--reject|--ignore-whitespace|--ignore-space-change) --reject|--ignore-whitespace|--ignore-space-change)
git_apply_opt="$git_apply_opt $1" ;; git_apply_opt="$git_apply_opt $1" ;;
--committer-date-is-author-date) --committer-date-is-author-date)
...@@ -435,6 +438,10 @@ it will be removed. Please do not use it anymore." ...@@ -435,6 +438,10 @@ it will be removed. Please do not use it anymore."
keepcr=t ;; keepcr=t ;;
--no-keep-cr) --no-keep-cr)
keepcr=f ;; keepcr=f ;;
--gpg-sign)
gpg_sign_opt=-S ;;
--gpg-sign=*)
gpg_sign_opt="-S${1#--gpg-sign=}" ;;
--) --)
shift; break ;; shift; break ;;
*) *)
...@@ -899,7 +906,8 @@ did you forget to use 'git add'?" ...@@ -899,7 +906,8 @@ did you forget to use 'git add'?"
GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE" GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
export GIT_COMMITTER_DATE export GIT_COMMITTER_DATE
fi && fi &&
git commit-tree $tree ${parent:+-p} $parent <"$dotest/final-commit" git commit-tree ${parent:+-p} $parent ${gpg_sign_opt:+"$gpg_sign_opt"} $tree \
<"$dotest/final-commit"
) && ) &&
git update-ref -m "$GIT_REFLOG_ACTION: $FIRSTLINE" HEAD $commit $parent || git update-ref -m "$GIT_REFLOG_ACTION: $FIRSTLINE" HEAD $commit $parent ||
stop_here $this stop_here $this
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
PERL='@@PERL@@' PERL='@@PERL@@'
OPTIONS_KEEPDASHDASH= OPTIONS_KEEPDASHDASH=
OPTIONS_STUCKLONG=
OPTIONS_SPEC="\ OPTIONS_SPEC="\
git instaweb [options] (--start | --stop | --restart) git instaweb [options] (--start | --stop | --restart)
-- --
......
...@@ -153,6 +153,15 @@ do ...@@ -153,6 +153,15 @@ do
--no-verify-signatures) --no-verify-signatures)
verify_signatures=--no-verify-signatures verify_signatures=--no-verify-signatures
;; ;;
--gpg-sign|-S)
gpg_sign_args=-S
;;
--gpg-sign=*)
gpg_sign_args=$(git rev-parse --sq-quote "-S${1#--gpg-sign=}")
;;
-S*)
gpg_sign_args=$(git rev-parse --sq-quote "$1")
;;
--d|--dr|--dry|--dry-|--dry-r|--dry-ru|--dry-run) --d|--dr|--dry|--dry-|--dry-r|--dry-ru|--dry-run)
dry_run=--dry-run dry_run=--dry-run
;; ;;
...@@ -320,11 +329,13 @@ merge_name=$(git fmt-merge-msg $log_arg <"$GIT_DIR/FETCH_HEAD") || exit ...@@ -320,11 +329,13 @@ merge_name=$(git fmt-merge-msg $log_arg <"$GIT_DIR/FETCH_HEAD") || exit
case "$rebase" in case "$rebase" in
true) true)
eval="git-rebase $diffstat $strategy_args $merge_args $rebase_args $verbosity" eval="git-rebase $diffstat $strategy_args $merge_args $rebase_args $verbosity"
eval="$eval $gpg_sign_args"
eval="$eval --onto $merge_head ${oldremoteref:-$merge_head}" eval="$eval --onto $merge_head ${oldremoteref:-$merge_head}"
;; ;;
*) *)
eval="git-merge $diffstat $no_commit $verify_signatures $edit $squash $no_ff $ff_only" eval="git-merge $diffstat $no_commit $verify_signatures $edit $squash $no_ff $ff_only"
eval="$eval $log_arg $strategy_args $merge_args $verbosity $progress" eval="$eval $log_arg $strategy_args $merge_args $verbosity $progress"
eval="$eval $gpg_sign_args"
eval="$eval \"\$merge_name\" HEAD $merge_head" eval="$eval \"\$merge_name\" HEAD $merge_head"
;; ;;
esac esac
......
#!/bin/sh #!/bin/sh
OPTIONS_KEEPDASHDASH= OPTIONS_KEEPDASHDASH=
OPTIONS_STUCKLONG=
OPTIONS_SPEC="\ OPTIONS_SPEC="\
git quiltimport [options] git quiltimport [options]
-- --
......
...@@ -6,7 +6,8 @@ ...@@ -6,7 +6,8 @@
case "$action" in case "$action" in
continue) continue)
git am --resolved --resolvemsg="$resolvemsg" && git am --resolved --resolvemsg="$resolvemsg" \
${gpg_sign_opt:+"$gpg_sign_opt"} &&
move_to_original_branch move_to_original_branch
return return
;; ;;
...@@ -26,7 +27,7 @@ then ...@@ -26,7 +27,7 @@ then
# empty commits and even if it didn't the format doesn't really lend # empty commits and even if it didn't the format doesn't really lend
# itself well to recording empty patches. fortunately, cherry-pick # itself well to recording empty patches. fortunately, cherry-pick
# makes this easy # makes this easy
git cherry-pick --allow-empty "$revisions" git cherry-pick ${gpg_sign_opt:+"$gpg_sign_opt"} --allow-empty "$revisions"
ret=$? ret=$?
else else
rm -f "$GIT_DIR/rebased-patches" rm -f "$GIT_DIR/rebased-patches"
...@@ -60,7 +61,8 @@ else ...@@ -60,7 +61,8 @@ else
return $? return $?
fi fi
git am $git_am_opt --rebasing --resolvemsg="$resolvemsg" <"$GIT_DIR/rebased-patches" git am $git_am_opt --rebasing --resolvemsg="$resolvemsg" \
${gpg_sign_opt:+"$gpg_sign_opt"} <"$GIT_DIR/rebased-patches"
ret=$? ret=$?
rm -f "$GIT_DIR/rebased-patches" rm -f "$GIT_DIR/rebased-patches"
......
...@@ -179,9 +179,10 @@ exit_with_patch () { ...@@ -179,9 +179,10 @@ exit_with_patch () {
echo "$1" > "$state_dir"/stopped-sha echo "$1" > "$state_dir"/stopped-sha
make_patch $1 make_patch $1
git rev-parse --verify HEAD > "$amend" git rev-parse --verify HEAD > "$amend"
gpg_sign_opt_quoted=${gpg_sign_opt:+$(git rev-parse --sq-quote "$gpg_sign_opt")}
warn "You can amend the commit now, with" warn "You can amend the commit now, with"
warn warn
warn " git commit --amend" warn " git commit --amend $gpg_sign_opt_quoted"
warn warn
warn "Once you are satisfied with your changes, run" warn "Once you are satisfied with your changes, run"
warn warn
...@@ -248,7 +249,9 @@ pick_one () { ...@@ -248,7 +249,9 @@ pick_one () {
test -d "$rewritten" && test -d "$rewritten" &&
pick_one_preserving_merges "$@" && return pick_one_preserving_merges "$@" && return
output eval git cherry-pick "$strategy_args" $empty_args $ff "$@" output eval git cherry-pick \
${gpg_sign_opt:+$(git rev-parse --sq-quote "$gpg_sign_opt")} \
"$strategy_args" $empty_args $ff "$@"
} }
pick_one_preserving_merges () { pick_one_preserving_merges () {
...@@ -351,7 +354,8 @@ pick_one_preserving_merges () { ...@@ -351,7 +354,8 @@ pick_one_preserving_merges () {
new_parents=${new_parents# $first_parent} new_parents=${new_parents# $first_parent}
merge_args="--no-log --no-ff" merge_args="--no-log --no-ff"
if ! do_with_author output eval \ if ! do_with_author output eval \
'git merge $merge_args $strategy_args -m "$msg_content" $new_parents' 'git merge ${gpg_sign_opt:+"$gpg_sign_opt"} \
$merge_args $strategy_args -m "$msg_content" $new_parents'
then then
printf "%s\n" "$msg_content" > "$GIT_DIR"/MERGE_MSG printf "%s\n" "$msg_content" > "$GIT_DIR"/MERGE_MSG
die_with_patch $sha1 "Error redoing merge $sha1" die_with_patch $sha1 "Error redoing merge $sha1"
...@@ -359,7 +363,9 @@ pick_one_preserving_merges () { ...@@ -359,7 +363,9 @@ pick_one_preserving_merges () {
echo "$sha1 $(git rev-parse HEAD^0)" >> "$rewritten_list" echo "$sha1 $(git rev-parse HEAD^0)" >> "$rewritten_list"
;; ;;
*) *)
output eval git cherry-pick "$strategy_args" "$@" || output eval git cherry-pick \
${gpg_sign_opt:+$(git rev-parse --sq-quote "$gpg_sign_opt")} \
"$strategy_args" "$@" ||
die_with_patch $sha1 "Could not pick $sha1" die_with_patch $sha1 "Could not pick $sha1"
;; ;;
esac esac
...@@ -470,7 +476,8 @@ do_pick () { ...@@ -470,7 +476,8 @@ do_pick () {
--no-post-rewrite -n -q -C $1 && --no-post-rewrite -n -q -C $1 &&
pick_one -n $1 && pick_one -n $1 &&
git commit --allow-empty --allow-empty-message \ git commit --allow-empty --allow-empty-message \
--amend --no-post-rewrite -n -q -C $1 || --amend --no-post-rewrite -n -q -C $1 \
${gpg_sign_opt:+"$gpg_sign_opt"} ||
die_with_patch $1 "Could not apply $1... $2" die_with_patch $1 "Could not apply $1... $2"
else else
pick_one $1 || pick_one $1 ||
...@@ -497,7 +504,7 @@ do_next () { ...@@ -497,7 +504,7 @@ do_next () {
mark_action_done mark_action_done
do_pick $sha1 "$rest" do_pick $sha1 "$rest"
git commit --amend --no-post-rewrite || { git commit --amend --no-post-rewrite ${gpg_sign_opt:+"$gpg_sign_opt"} || {
warn "Could not amend commit after successfully picking $sha1... $rest" warn "Could not amend commit after successfully picking $sha1... $rest"
warn "This is most likely due to an empty commit message, or the pre-commit hook" warn "This is most likely due to an empty commit message, or the pre-commit hook"
warn "failed. If the pre-commit hook failed, you may need to resolve the issue before" warn "failed. If the pre-commit hook failed, you may need to resolve the issue before"
...@@ -542,19 +549,22 @@ do_next () { ...@@ -542,19 +549,22 @@ do_next () {
squash|s|fixup|f) squash|s|fixup|f)
# This is an intermediate commit; its message will only be # This is an intermediate commit; its message will only be
# used in case of trouble. So use the long version: # used in case of trouble. So use the long version:
do_with_author output git commit --amend --no-verify -F "$squash_msg" || do_with_author output git commit --amend --no-verify -F "$squash_msg" \
${gpg_sign_opt:+"$gpg_sign_opt"} ||
die_failed_squash $sha1 "$rest" die_failed_squash $sha1 "$rest"
;; ;;
*) *)
# This is the final command of this squash/fixup group # This is the final command of this squash/fixup group
if test -f "$fixup_msg" if test -f "$fixup_msg"
then then
do_with_author git commit --amend --no-verify -F "$fixup_msg" || do_with_author git commit --amend --no-verify -F "$fixup_msg" \
${gpg_sign_opt:+"$gpg_sign_opt"} ||
die_failed_squash $sha1 "$rest" die_failed_squash $sha1 "$rest"
else else
cp "$squash_msg" "$GIT_DIR"/SQUASH_MSG || exit cp "$squash_msg" "$GIT_DIR"/SQUASH_MSG || exit
rm -f "$GIT_DIR"/MERGE_MSG rm -f "$GIT_DIR"/MERGE_MSG
do_with_author git commit --amend --no-verify -F "$GIT_DIR"/SQUASH_MSG -e || do_with_author git commit --amend --no-verify -F "$GIT_DIR"/SQUASH_MSG -e \
${gpg_sign_opt:+"$gpg_sign_opt"} ||
die_failed_squash $sha1 "$rest" die_failed_squash $sha1 "$rest"
fi fi
rm -f "$squash_msg" "$fixup_msg" rm -f "$squash_msg" "$fixup_msg"
...@@ -819,14 +829,15 @@ continue) ...@@ -819,14 +829,15 @@ continue)
else else
if ! test -f "$author_script" if ! test -f "$author_script"
then then
gpg_sign_opt_quoted=${gpg_sign_opt:+$(git rev-parse --sq-quote "$gpg_sign_opt")}
die "You have staged changes in your working tree. If these changes are meant to be die "You have staged changes in your working tree. If these changes are meant to be
squashed into the previous commit, run: squashed into the previous commit, run:
git commit --amend git commit --amend $gpg_sign_opt_quoted
If they are meant to go into a new commit, run: If they are meant to go into a new commit, run:
git commit git commit $gpg_sign_opt_quoted
In both case, once you're done, continue with: In both case, once you're done, continue with:
...@@ -842,10 +853,12 @@ In both case, once you're done, continue with: ...@@ -842,10 +853,12 @@ In both case, once you're done, continue with:
die "\ die "\
You have uncommitted changes in your working tree. Please, commit them You have uncommitted changes in your working tree. Please, commit them
first and then run 'git rebase --continue' again." first and then run 'git rebase --continue' again."
do_with_author git commit --amend --no-verify -F "$msg" -e || do_with_author git commit --amend --no-verify -F "$msg" -e \
${gpg_sign_opt:+"$gpg_sign_opt"} ||
die "Could not commit staged changes." die "Could not commit staged changes."
else else
do_with_author git commit --no-verify -F "$msg" -e || do_with_author git commit --no-verify -F "$msg" -e \
${gpg_sign_opt:+"$gpg_sign_opt"} ||
die "Could not commit staged changes." die "Could not commit staged changes."
fi fi
fi fi
......
...@@ -27,7 +27,7 @@ continue_merge () { ...@@ -27,7 +27,7 @@ continue_merge () {
cmt=`cat "$state_dir/current"` cmt=`cat "$state_dir/current"`
if ! git diff-index --quiet --ignore-submodules HEAD -- if ! git diff-index --quiet --ignore-submodules HEAD --
then then
if ! git commit --no-verify -C "$cmt" if ! git commit ${gpg_sign_opt:+"$gpg_sign_opt"} --no-verify -C "$cmt"
then then
echo "Commit failed, please do not call \"git commit\"" echo "Commit failed, please do not call \"git commit\""
echo "directly, but instead do one of the following: " echo "directly, but instead do one of the following: "
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
SUBDIRECTORY_OK=Yes SUBDIRECTORY_OK=Yes
OPTIONS_KEEPDASHDASH= OPTIONS_KEEPDASHDASH=
OPTIONS_STUCKLONG=t
OPTIONS_SPEC="\ OPTIONS_SPEC="\
git rebase [-i] [options] [--exec <cmd>] [--onto <newbase>] [<upstream>] [<branch>] git rebase [-i] [options] [--exec <cmd>] [--onto <newbase>] [<upstream>] [<branch>]
git rebase [-i] [options] [--exec <cmd>] [--onto <newbase>] --root [<branch>] git rebase [-i] [options] [--exec <cmd>] [--onto <newbase>] --root [<branch>]
...@@ -36,6 +37,7 @@ ignore-date! passed to 'git am' ...@@ -36,6 +37,7 @@ ignore-date! passed to 'git am'
whitespace=! passed to 'git apply' whitespace=! passed to 'git apply'
ignore-whitespace! passed to 'git apply' ignore-whitespace! passed to 'git apply'
C=! passed to 'git apply' C=! passed to 'git apply'
S,gpg-sign? GPG-sign commits
Actions: Actions:
continue! continue continue! continue
abort! abort and check out the original branch abort! abort and check out the original branch
...@@ -84,6 +86,7 @@ preserve_merges= ...@@ -84,6 +86,7 @@ preserve_merges=
autosquash= autosquash=
keep_empty= keep_empty=
test "$(git config --bool rebase.autosquash)" = "true" && autosquash=t test "$(git config --bool rebase.autosquash)" = "true" && autosquash=t
gpg_sign_opt=
read_basic_state () { read_basic_state () {
test -f "$state_dir/head-name" && test -f "$state_dir/head-name" &&
...@@ -106,6 +109,8 @@ read_basic_state () { ...@@ -106,6 +109,8 @@ read_basic_state () {
strategy_opts="$(cat "$state_dir"/strategy_opts)" strategy_opts="$(cat "$state_dir"/strategy_opts)"
test -f "$state_dir"/allow_rerere_autoupdate && test -f "$state_dir"/allow_rerere_autoupdate &&
allow_rerere_autoupdate="$(cat "$state_dir"/allow_rerere_autoupdate)" 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)"
} }
write_basic_state () { write_basic_state () {
...@@ -119,6 +124,7 @@ write_basic_state () { ...@@ -119,6 +124,7 @@ write_basic_state () {
"$state_dir"/strategy_opts "$state_dir"/strategy_opts
test -n "$allow_rerere_autoupdate" && echo "$allow_rerere_autoupdate" > \ test -n "$allow_rerere_autoupdate" && echo "$allow_rerere_autoupdate" > \
"$state_dir"/allow_rerere_autoupdate "$state_dir"/allow_rerere_autoupdate
test -n "$gpg_sign_opt" && echo "$gpg_sign_opt" > "$state_dir"/gpg_sign_opt
} }
output () { output () {
...@@ -236,23 +242,19 @@ do ...@@ -236,23 +242,19 @@ do
test $total_argc -eq 2 || usage test $total_argc -eq 2 || usage
action=${1##--} action=${1##--}
;; ;;
--onto) --onto=*)
test 2 -le "$#" || usage onto="${1#--onto=}"
onto="$2"
shift
;; ;;
-x) --exec=*)
test 2 -le "$#" || usage cmd="${cmd}exec ${1#--exec=}${LF}"
cmd="${cmd}exec $2${LF}"
shift
;; ;;
-i) --interactive)
interactive_rebase=explicit interactive_rebase=explicit
;; ;;
-k) --keep-empty)
keep_empty=yes keep_empty=yes
;; ;;
-p) --preserve-merges)
preserve_merges=t preserve_merges=t
test -z "$interactive_rebase" && interactive_rebase=implied test -z "$interactive_rebase" && interactive_rebase=implied
;; ;;
...@@ -268,21 +270,19 @@ do ...@@ -268,21 +270,19 @@ do
--no-fork-point) --no-fork-point)
fork_point= fork_point=
;; ;;
-M|-m) --merge)
do_merge=t do_merge=t
;; ;;
-X) --strategy-option=*)
shift strategy_opts="$strategy_opts $(git rev-parse --sq-quote "--${1#--strategy-option=}")"
strategy_opts="$strategy_opts $(git rev-parse --sq-quote "--$1")"
do_merge=t do_merge=t
test -z "$strategy" && strategy=recursive test -z "$strategy" && strategy=recursive
;; ;;
-s) --strategy=*)
shift strategy="${1#--strategy=}"
strategy="$1"
do_merge=t do_merge=t
;; ;;
-n) --no-stat)
diffstat= diffstat=
;; ;;
--stat) --stat)
...@@ -291,21 +291,20 @@ do ...@@ -291,21 +291,20 @@ do
--autostash) --autostash)
autostash=true autostash=true
;; ;;
-v) --verbose)
verbose=t verbose=t
diffstat=t diffstat=t
GIT_QUIET= GIT_QUIET=
;; ;;
-q) --quiet)
GIT_QUIET=t GIT_QUIET=t
git_am_opt="$git_am_opt -q" git_am_opt="$git_am_opt -q"
verbose= verbose=
diffstat= diffstat=
;; ;;
--whitespace) --whitespace=*)
shift git_am_opt="$git_am_opt --whitespace=${1#--whitespace=}"
git_am_opt="$git_am_opt --whitespace=$1" case "${1#--whitespace=}" in
case "$1" in
fix|strip) fix|strip)
force_rebase=t force_rebase=t
;; ;;
...@@ -318,19 +317,24 @@ do ...@@ -318,19 +317,24 @@ do
git_am_opt="$git_am_opt $1" git_am_opt="$git_am_opt $1"
force_rebase=t force_rebase=t
;; ;;
-C) -C*)
shift git_am_opt="$git_am_opt $1"
git_am_opt="$git_am_opt -C$1"
;; ;;
--root) --root)
rebase_root=t rebase_root=t
;; ;;
-f|--no-ff) --force-rebase|--no-ff)
force_rebase=t force_rebase=t
;; ;;
--rerere-autoupdate|--no-rerere-autoupdate) --rerere-autoupdate|--no-rerere-autoupdate)
allow_rerere_autoupdate="$1" allow_rerere_autoupdate="$1"
;; ;;
--gpg-sign)
gpg_sign_opt=-S
;;
--gpg-sign=*)
gpg_sign_opt="-S${1#--gpg-sign=}"
;;
--) --)
shift shift
break break
......
...@@ -9,6 +9,7 @@ LONG_USAGE='Summarizes the changes between two commits to the standard output, ...@@ -9,6 +9,7 @@ LONG_USAGE='Summarizes the changes between two commits to the standard output,
and includes the given URL in the generated summary.' and includes the given URL in the generated summary.'
SUBDIRECTORY_OK='Yes' SUBDIRECTORY_OK='Yes'
OPTIONS_KEEPDASHDASH= OPTIONS_KEEPDASHDASH=
OPTIONS_STUCKLONG=
OPTIONS_SPEC='git request-pull [options] start url [end] OPTIONS_SPEC='git request-pull [options] start url [end]
-- --
p show patch text as well p show patch text as well
......
...@@ -72,6 +72,8 @@ if test -n "$OPTIONS_SPEC"; then ...@@ -72,6 +72,8 @@ if test -n "$OPTIONS_SPEC"; then
parseopt_extra= parseopt_extra=
[ -n "$OPTIONS_KEEPDASHDASH" ] && [ -n "$OPTIONS_KEEPDASHDASH" ] &&
parseopt_extra="--keep-dashdash" parseopt_extra="--keep-dashdash"
[ -n "$OPTIONS_STUCKLONG" ] &&
parseopt_extra="$parseopt_extra --stuck-long"
eval "$( eval "$(
echo "$OPTIONS_SPEC" | echo "$OPTIONS_SPEC" |
......
...@@ -392,11 +392,18 @@ static int run_git_commit(const char *defmsg, struct replay_opts *opts, ...@@ -392,11 +392,18 @@ static int run_git_commit(const char *defmsg, struct replay_opts *opts,
{ {
struct argv_array array; struct argv_array array;
int rc; int rc;
char *gpg_sign;
argv_array_init(&array); argv_array_init(&array);
argv_array_push(&array, "commit"); argv_array_push(&array, "commit");
argv_array_push(&array, "-n"); argv_array_push(&array, "-n");
if (opts->gpg_sign) {
gpg_sign = xmalloc(3 + strlen(opts->gpg_sign));
sprintf(gpg_sign, "-S%s", opts->gpg_sign);
argv_array_push(&array, gpg_sign);
free(gpg_sign);
}
if (opts->signoff) if (opts->signoff)
argv_array_push(&array, "-s"); argv_array_push(&array, "-s");
if (!opts->edit) { if (!opts->edit) {
...@@ -808,6 +815,8 @@ static int populate_opts_cb(const char *key, const char *value, void *data) ...@@ -808,6 +815,8 @@ static int populate_opts_cb(const char *key, const char *value, void *data)
opts->mainline = git_config_int(key, value); opts->mainline = git_config_int(key, value);
else if (!strcmp(key, "options.strategy")) else if (!strcmp(key, "options.strategy"))
git_config_string(&opts->strategy, key, value); git_config_string(&opts->strategy, key, value);
else if (!strcmp(key, "options.gpg-sign"))
git_config_string(&opts->gpg_sign, key, value);
else if (!strcmp(key, "options.strategy-option")) { else if (!strcmp(key, "options.strategy-option")) {
ALLOC_GROW(opts->xopts, opts->xopts_nr + 1, opts->xopts_alloc); ALLOC_GROW(opts->xopts, opts->xopts_nr + 1, opts->xopts_alloc);
opts->xopts[opts->xopts_nr++] = xstrdup(value); opts->xopts[opts->xopts_nr++] = xstrdup(value);
...@@ -981,6 +990,8 @@ static void save_opts(struct replay_opts *opts) ...@@ -981,6 +990,8 @@ static void save_opts(struct replay_opts *opts)
} }
if (opts->strategy) if (opts->strategy)
git_config_set_in_file(opts_file, "options.strategy", opts->strategy); git_config_set_in_file(opts_file, "options.strategy", opts->strategy);
if (opts->gpg_sign)
git_config_set_in_file(opts_file, "options.gpg-sign", opts->gpg_sign);
if (opts->xopts) { if (opts->xopts) {
int i; int i;
for (i = 0; i < opts->xopts_nr; i++) for (i = 0; i < opts->xopts_nr; i++)
......
...@@ -37,6 +37,8 @@ struct replay_opts { ...@@ -37,6 +37,8 @@ struct replay_opts {
int mainline; int mainline;
const char *gpg_sign;
/* Merge strategy */ /* Merge strategy */
const char *strategy; const char *strategy;
const char **xopts; const char **xopts;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册