From 250fab4a8458a697b92b90baa914e9324f587247 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sun, 25 Jan 2009 20:58:08 +0100 Subject: [PATCH] rebase -i -p: Add the "merge" command The syntax is "merge parents original " and the action is to merge the given parents, and mark the result as the rewritten version of the original merge commit. As "git merge -m " insists on appending its own message, we call "commit --amend -m " after the merge. Signed-off-by: Johannes Schindelin --- git-rebase--interactive.sh | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh index 37d87f4e9b..c3ea09c653 100755 --- a/git-rebase--interactive.sh +++ b/git-rebase--interactive.sh @@ -286,6 +286,34 @@ pick_one () { fi } +merge_one () { + cmd="merge $*" + test "$1" = parents && shift + parents= + while test "original" != "$1" + do + parents="$parents $(parse_commit $1)" + shift + done + + test "original" != "$1" && + die "Could not determine original merge commit from $cmd" + + sha1=$2; shift; shift + + # the command was "merge parents ...", so "parents" was recorded +# TODO: detect non-fast-forwards properly + ORIGINAL_HEAD=$(git rev-parse HEAD) && + git merge $parents && + if test $ORIGINAL_HEAD = "$(git rev-parse HEAD^)" + then + git commit --amend -m "$*" && + echo "$sha1" > "$REWRITTEN"/original && + add_rewritten + fi || + die_with_patch $sha1 "Could not redo merge $sha1 with parents $parents" +} + pick_one_preserving_merges () { fast_forward=t case "$1" in @@ -554,6 +582,13 @@ do_next () { output git reset --hard $(parse_commit $sha1) || die "Could not reset to $sha1" ;; + merge|m) + comment_for_reflog merge + mark_action_done + # this already dies with patch on error + output merge_one $sha1 $rest || # $sha1 is not the real sha1... + exit + ;; *) warn "Unknown command: $command $sha1 $rest" if git rev-parse --verify -q "$sha1" >/dev/null @@ -946,6 +981,8 @@ first and then run 'git rebase --continue' again." # s, squash = use commit, but meld into previous commit # f, fixup = like "squash", but discard this commit's log message # g, goto = reset the current state to the given commit +# m, merge parents original +# = redo the given merge commit # # If you remove a line here THAT COMMIT WILL BE LOST. # However, if you remove everything, the rebase will be aborted. -- 2.11.4.GIT