rebase -i: Extract function do_with_author
Call it instead of repeating similar code blocks in several places. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
5c5d059a0d
commit
7756ecffe7
@ -203,6 +203,15 @@ has_action () {
|
|||||||
sane_grep '^[^#]' "$1" >/dev/null
|
sane_grep '^[^#]' "$1" >/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Run command with GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, and
|
||||||
|
# GIT_AUTHOR_DATE exported from the current environment.
|
||||||
|
do_with_author () {
|
||||||
|
GIT_AUTHOR_NAME="$GIT_AUTHOR_NAME" \
|
||||||
|
GIT_AUTHOR_EMAIL="$GIT_AUTHOR_EMAIL" \
|
||||||
|
GIT_AUTHOR_DATE="$GIT_AUTHOR_DATE" \
|
||||||
|
"$@"
|
||||||
|
}
|
||||||
|
|
||||||
pick_one () {
|
pick_one () {
|
||||||
no_ff=
|
no_ff=
|
||||||
case "$1" in -n) sha1=$2; no_ff=t ;; *) sha1=$1 ;; esac
|
case "$1" in -n) sha1=$2; no_ff=t ;; *) sha1=$1 ;; esac
|
||||||
@ -324,11 +333,8 @@ pick_one_preserving_merges () {
|
|||||||
msg="$(commit_message $sha1)"
|
msg="$(commit_message $sha1)"
|
||||||
# No point in merging the first parent, that's HEAD
|
# No point in merging the first parent, that's HEAD
|
||||||
new_parents=${new_parents# $first_parent}
|
new_parents=${new_parents# $first_parent}
|
||||||
if ! GIT_AUTHOR_NAME="$GIT_AUTHOR_NAME" \
|
if ! do_with_author output \
|
||||||
GIT_AUTHOR_EMAIL="$GIT_AUTHOR_EMAIL" \
|
git merge $STRATEGY -m "$msg" $new_parents
|
||||||
GIT_AUTHOR_DATE="$GIT_AUTHOR_DATE" \
|
|
||||||
output git merge $STRATEGY -m "$msg" \
|
|
||||||
$new_parents
|
|
||||||
then
|
then
|
||||||
printf "%s\n" "$msg" > "$GIT_DIR"/MERGE_MSG
|
printf "%s\n" "$msg" > "$GIT_DIR"/MERGE_MSG
|
||||||
die_with_patch $sha1 "Error redoing merge $sha1"
|
die_with_patch $sha1 "Error redoing merge $sha1"
|
||||||
@ -470,11 +476,9 @@ do_next () {
|
|||||||
if test $failed = f
|
if test $failed = f
|
||||||
then
|
then
|
||||||
# This is like --amend, but with a different message
|
# This is like --amend, but with a different message
|
||||||
GIT_AUTHOR_NAME="$GIT_AUTHOR_NAME" \
|
do_with_author $USE_OUTPUT git commit --no-verify \
|
||||||
GIT_AUTHOR_EMAIL="$GIT_AUTHOR_EMAIL" \
|
$MSG_OPT "$EDIT_OR_FILE" ||
|
||||||
GIT_AUTHOR_DATE="$GIT_AUTHOR_DATE" \
|
failed=t
|
||||||
$USE_OUTPUT git commit --no-verify \
|
|
||||||
$MSG_OPT "$EDIT_OR_FILE" || failed=t
|
|
||||||
fi
|
fi
|
||||||
if test $failed = t
|
if test $failed = t
|
||||||
then
|
then
|
||||||
@ -605,8 +609,7 @@ first and then run 'git rebase --continue' again."
|
|||||||
git reset --soft HEAD^ ||
|
git reset --soft HEAD^ ||
|
||||||
die "Cannot rewind the HEAD"
|
die "Cannot rewind the HEAD"
|
||||||
fi
|
fi
|
||||||
export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE &&
|
do_with_author git commit --no-verify -F "$MSG" -e || {
|
||||||
git commit --no-verify -F "$MSG" -e || {
|
|
||||||
test -n "$amend" && git reset --soft $amend
|
test -n "$amend" && git reset --soft $amend
|
||||||
die "Could not commit staged changes."
|
die "Could not commit staged changes."
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user