From 4b47c11f09c642b2bda30fb11c33991f49df1bdb Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 11 Jun 2010 16:27:25 +0200 Subject: [PATCH] Fix rebasing-merge script Signed-off-by: Johannes Schindelin --- share/msysGit/rebasing-merge.sh | 152 +++++++++++++++++----------------------- 1 file changed, 64 insertions(+), 88 deletions(-) rewrite share/msysGit/rebasing-merge.sh (75%) diff --git a/share/msysGit/rebasing-merge.sh b/share/msysGit/rebasing-merge.sh dissimilarity index 75% index 10183272..49ec68cf 100644 --- a/share/msysGit/rebasing-merge.sh +++ b/share/msysGit/rebasing-merge.sh @@ -1,88 +1,64 @@ -#!/bin/sh - -TO=junio/next - -# Act as editor, to filter out commits with Junio as committer; This should -# work around the problems of junio/next rebasing every once in a while. - -test $# -gt 0 && { - case "$1" in - */git-rebase-todo) - if test -n "$MY_EXCLUDE" - then - git rev-list $TO..$MY_EXCLUDE > "$1".exclude - else - touch "$1".exclude - fi && - mv "$1" "$1".bup && - while read command sha1 oneline - do - # skip history obsoleted by a previous rebasing merge - if grep ^$sha1 "$1".exclude > /dev/null - then - continue - fi && - case "$command" in - \#*|'') - echo "$command $sha1 $oneline" - continue - ;; - esac - committer="$(git show -s --format=%cn $sha1)" && - case "$committer" in - "Junio C Hamano"|"Junio Hamano"|"Shawn O. Pearce"|"Eric Wong"|"Thomas Rast"|"Jeff King"|"Paul Mackerras") ;; # skip - *) echo "$command $sha1 (committer: $committer) $oneline" - esac || break - done > "$1" < "$1".bup - ;; - esac && - unset GIT_EDITOR && - "$(git var GIT_EDITOR)" "$@" - exit -} - -# Rebase 'devel' on top of 'junio/next', the merging the old state of -# 'devel' with the merge strategy 'ours' to enable a fast-forward. - -this="$(cd "$(dirname "$0")" && pwd)/$(basename "$0")" && -cd /git && -case "$(git rev-parse --symbolic-full-name HEAD)" in -refs/heads/devel) - test "$(git rev-parse HEAD)" = "$(git rev-parse origin/devel)" || - test "$(git rev-parse devel@{1})" = "$(git rev-parse origin/devel)" || { - echo "Your 'devel' is not up-to-date!" >&2 - exit 1 - } - ;; # okay -HEAD) ;; # okay -*) - echo "Not on 'devel'!" >&2 - exit 1 - ;; -esac && -git fetch junio && -JUNIOS_HEAD=$(git rev-parse $TO) && -if test $JUNIOS_HEAD != $(git merge-base HEAD $JUNIOS_HEAD) -then - rebasing_merge="$(git rev-list --parents $TO..HEAD | - while read commit parent1 parent2 - do - test -n "$parent2" && - commit_tree="$(git rev-parse $commit:)" && - parent1_tree="$(git rev-parse $parent1:)" && - test "$commit_tree" = "$parent1_tree" || - continue - echo "$commit" - break - done)" && - if test -z "$rebasing_merge" - then - GIT_EDITOR="$this" MY_EXCLUDE= git rebase -i $TO - else - GIT_EDITOR="$this" \ - MY_EXCLUDE=$rebasing_merge^2 \ - git rebase -i --onto $TO \ - $(git merge-base $rebasing_merge^ $TO) - fi -fi && -git merge -s ours -m "Rebasing merge to $TO" origin/devel +#!/bin/sh + +TO=junio/next + +TODO_EXTRA="$(git rev-parse --git-dir)/todo-extra" + +# Rebase 'devel' on top of 'junio/next', the merging the old state of +# 'devel' with the merge strategy 'ours' to enable a fast-forward. + +THIS="$(cd "$(dirname "$0")" && pwd)/$(basename "$0")" && +cd /git && +case "$(git rev-parse --symbolic-full-name HEAD)" in +refs/heads/devel) + test "$(git rev-parse HEAD)" = "$(git rev-parse origin/devel)" || + test "$(git rev-parse devel@{1})" = "$(git rev-parse origin/devel)" || { + echo "Your 'devel' is not up-to-date!" >&2 + exit 1 + } + ;; # okay +HEAD) ;; # okay +*) + echo "Not on 'devel'!" >&2 + exit 1 + ;; +esac + +# Find old rebasing merge, if any + +rm -f "$TODO_EXTRA" + +MERGE=$(git rev-list --parents $TO.. | sed -n 's/ .* .*//p' | head -n 1) +if test "$(git rev-parse $MERGE:)" = "$(git rev-parse "$MERGE^:")" +then + ORIG_HEAD=$(git rev-parse HEAD) && + # Find prior merges to $TO + EXCLUDE=$(git rev-list --parents $TO..$MERGE^ | + sed -n 's/^\([^ ]*\) .* .*/^\1/p') && + # Get commits from previous rebasing merge + git rev-list --pretty=oneline --abbrev-commit --abbrev=7 --reverse \ + --no-merges $TO..$MERGE^ $EXCLUDE | + sed 's/^/pick /' > "$TODO_EXTRA" && + TMP_EDITOR="$(git rev-parse --git-dir)/rebasing-editor.sh" && + cat > "$TMP_EDITOR" << EOF && +#!/bin/sh +case "\$1" in +*/git-rebase-todo) + cat "\$1" >> "$TODO_EXTRA" && + mv "$TODO_EXTRA" "\$1" +esac && +exec "$(git var GIT_EDITOR)" "\$@" +EOF + if GIT_EDITOR="$TMP_EDITOR" git rebase -i $MERGE --onto $TO + then + git merge -s ours -m "Rebasing merge to $TO" $ORIG_HEAD + else + cat << EOF + +After the rebase, call 'git merge -s ours $ORIG_HEAD' manually +EOF + fi + +else + git rebase -i $TO +fi -- 2.11.4.GIT