rebasing-merge: really ignore obsolete history
[msysgit/mtrensch.git] / share / msysGit / rebasing-merge.sh
blob10183272a183508550aa7d6c5a4a378f345b9ea5
1 #!/bin/sh
3 TO=junio/next
5 # Act as editor, to filter out commits with Junio as committer; This should
6 # work around the problems of junio/next rebasing every once in a while.
8 test $# -gt 0 && {
9 case "$1" in
10 */git-rebase-todo)
11 if test -n "$MY_EXCLUDE"
12 then
13 git rev-list $TO..$MY_EXCLUDE > "$1".exclude
14 else
15 touch "$1".exclude
16 fi &&
17 mv "$1" "$1".bup &&
18 while read command sha1 oneline
20 # skip history obsoleted by a previous rebasing merge
21 if grep ^$sha1 "$1".exclude > /dev/null
22 then
23 continue
24 fi &&
25 case "$command" in
26 \#*|'')
27 echo "$command $sha1 $oneline"
28 continue
30 esac
31 committer="$(git show -s --format=%cn $sha1)" &&
32 case "$committer" in
33 "Junio C Hamano"|"Junio Hamano"|"Shawn O. Pearce"|"Eric Wong"|"Thomas Rast"|"Jeff King"|"Paul Mackerras") ;; # skip
34 *) echo "$command $sha1 (committer: $committer) $oneline"
35 esac || break
36 done > "$1" < "$1".bup
38 esac &&
39 unset GIT_EDITOR &&
40 "$(git var GIT_EDITOR)" "$@"
41 exit
44 # Rebase 'devel' on top of 'junio/next', the merging the old state of
45 # 'devel' with the merge strategy 'ours' to enable a fast-forward.
47 this="$(cd "$(dirname "$0")" && pwd)/$(basename "$0")" &&
48 cd /git &&
49 case "$(git rev-parse --symbolic-full-name HEAD)" in
50 refs/heads/devel)
51 test "$(git rev-parse HEAD)" = "$(git rev-parse origin/devel)" ||
52 test "$(git rev-parse devel@{1})" = "$(git rev-parse origin/devel)" || {
53 echo "Your 'devel' is not up-to-date!" >&2
54 exit 1
56 ;; # okay
57 HEAD) ;; # okay
59 echo "Not on 'devel'!" >&2
60 exit 1
62 esac &&
63 git fetch junio &&
64 JUNIOS_HEAD=$(git rev-parse $TO) &&
65 if test $JUNIOS_HEAD != $(git merge-base HEAD $JUNIOS_HEAD)
66 then
67 rebasing_merge="$(git rev-list --parents $TO..HEAD |
68 while read commit parent1 parent2
70 test -n "$parent2" &&
71 commit_tree="$(git rev-parse $commit:)" &&
72 parent1_tree="$(git rev-parse $parent1:)" &&
73 test "$commit_tree" = "$parent1_tree" ||
74 continue
75 echo "$commit"
76 break
77 done)" &&
78 if test -z "$rebasing_merge"
79 then
80 GIT_EDITOR="$this" MY_EXCLUDE= git rebase -i $TO
81 else
82 GIT_EDITOR="$this" \
83 MY_EXCLUDE=$rebasing_merge^2 \
84 git rebase -i --onto $TO \
85 $(git merge-base $rebasing_merge^ $TO)
87 fi &&
88 git merge -s ours -m "Rebasing merge to $TO" origin/devel