From 436a8b126a75cef9597ff6f86f40baabbce2e300 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sun, 25 Jan 2009 21:00:55 +0100 Subject: [PATCH] rebase -i -p: add a helper to add mappings for rewritten commits The function add_rewritten() is supposed to be called just after a successful commit, with the original commit(s) stored in "$REWRITTEN"/original. If the next command is not a squash, "$REWRITTEN"/original is deleted after adding the mapping. Signed-off-by: Johannes Schindelin --- git-rebase--interactive.sh | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh index 4fb1aee0a0..37d87f4e9b 100755 --- a/git-rebase--interactive.sh +++ b/git-rebase--interactive.sh @@ -163,6 +163,27 @@ comment_for_reflog () { esac } +peek_next_command () { + sed -n -e "/^#/d" -e '/^$/d' -e "s/ .*//p" -e "q" < "$TODO" +} + +# expects the original commit name(s) in "$REWRITTEN"/original +# records the current HEAD as the rewritten commit +add_rewritten () { + test ! -d "$REWRITTEN" && return + rewritten=$(git rev-parse --verify HEAD) && + for original in $(cat "$REWRITTEN"/original) + do + original=$(git rev-parse --verify "$original") && + echo $rewritten > "$REWRITTEN"/$original || break + done && + case "$(peek_next_command)" in + squash|s) ;; # do nothing + *) rm "$REWRITTEN"/original;; + esac || + die "Could not store information about rewritten commit" +} + # if the given commit name ends in an apostrophe, returns the rewritten commit parse_commit () { case "$1" in @@ -427,10 +448,6 @@ update_squash_messages () { esac >>"$SQUASH_MSG" } -peek_next_command () { - sed -n -e "/^#/d" -e '/^$/d' -e "s/ .*//p" -e "q" < "$TODO" -} - # A squash/fixup has failed. Prepare the long version of the squash # commit message, then die_with_patch. This code path requires the # user to edit the combined commit message for all commits that have -- 2.11.4.GIT