[RFC PATCH 6/7] rebase -i: Prepare for squash in terms of do_pick --amend
- From
Fabian Ruch <bafain@gmail.com>
- Date
- Jun 19, 2014, 03:28 UTC
- Message-ID
- <53A258ED.1020604@gmail.com>
- In-Reply-To
- <cover.1403146774.git.bafain@gmail.com>
Rewrite `squash` and `fixup` handling in `do_next` using the atomic sequence
pick_one
commitin order to test the correctness of a single `do_squash` or parametrized `do_pick` and make the subsequent patch reimplementing `squash` in terms of such a single function more readable.
Might be squashed into the subsequent commit.
Signed-off-by: Fabian Ruch <bafain@gmail.com> --- git-rebase--interactive.sh | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh index e4992dc..ada520d 100644 --- a/git-rebase--interactive.sh +++ b/git-rebase--interactive.sh @@ -613,15 +613,15 @@ do_next () { author_script_content=$(get_author_ident_from_commit HEAD) echo "$author_script_content" > "$author_script" eval "$author_script_content" - if ! pick_one -n $sha1 - then - git rev-parse --verify HEAD >"$amend" - die_failed_squash $sha1 "$rest" - fi case "$(peek_next_command)" in squash|s|fixup|f) # This is an intermediate commit; its message will only be # used in case of trouble. So use the long version: + if ! pick_one -n $sha1 + then + git rev-parse --verify HEAD >"$amend" + die_failed_squash $sha1 "Could not apply $sha1... $rest" + fi do_with_author output git commit --amend --no-verify -F "$squash_msg" \ ${gpg_sign_opt:+"$gpg_sign_opt"} || die_failed_squash $sha1 "$rest" @@ -630,12 +630,22 @@ do_next () { # This is the final command of this squash/fixup group if test -f "$fixup_msg" then + if ! pick_one -n $sha1 + then + git rev-parse --verify HEAD >"$amend" + die_failed_squash $sha1 "Could not apply $sha1... $rest" + fi do_with_author git commit --amend --no-verify -F "$fixup_msg" \ ${gpg_sign_opt:+"$gpg_sign_opt"} || die_failed_squash $sha1 "$rest" else cp "$squash_msg" "$GIT_DIR"/SQUASH_MSG || exit rm -f "$GIT_DIR"/MERGE_MSG + if ! pick_one -n $sha1 + then + git rev-parse --verify HEAD >"$amend" + die_failed_squash $sha1 "Could not apply $sha1... $rest" + fi 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"
-- 2.0.0