rebase: add the --gpg-sign option
Signed-off-by: Nicolas Vigier <boklm@mars-attacks.org> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
b6e9e73e8a
commit
3ee5e54038
@ -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.
|
||||||
|
@ -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
|
|||||||
# 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
|
|||||||
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 () {
|
|||||||
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 () {
|
|||||||
|
|
||||||
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 () {
|
|||||||
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 () {
|
|||||||
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 () {
|
|||||||
--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 () {
|
|||||||
|
|
||||||
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 () {
|
|||||||
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)
|
|||||||
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:
|
|||||||
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 () {
|
|||||||
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: "
|
||||||
|
@ -37,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
|
||||||
@ -85,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" &&
|
||||||
@ -107,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 () {
|
||||||
@ -120,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 () {
|
||||||
@ -324,6 +329,12 @@ do
|
|||||||
--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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user