What's cooking
[git/spearce.git] / Reintegrate
blobdfc51842260a0356c74667a1534539cbd0ffbc7d
1 #!/bin/sh
3 merge_msg="Merge branch '\(.*\)'"
4 x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
5 x40="$x40$x40$x40$x40$x40$x40$x40$x40"
6 LF='
9 echo '#!/bin/sh
10 accept_rerere=t
11 while case "$#,$1" in 0,*) break;; *,-*) ;; *) break ;; esac
13 case "$1" in
14 -n) accept_rerere= ;;
15 *) echo "$0 [-n]"; exit 1 ;;
16 esac
17 shift
18 done
20 accept_rerere () {
21 if test -z "$accept_rerere"
22 then
23 return 1
25 if git diff |
26 grep -e "^.+" -e "^+." |
27 grep -e "^..<<<<<<<" -e "^..=======" -e "^..>>>>>>>" >/dev/null
28 then
29 return 1
30 else
31 EDITOR=: git commit -a
32 return 0
36 while read branch eh
38 case "$eh" in
39 "")
40 echo >&2 "* $branch"
41 git merge "$branch" || accept_rerere || exit ;;
42 pick" "*)
43 echo >&2 "* $eh"
44 git cherry-pick "$branch" || exit ;;
45 *) echo >&2 "Eh? $branch $eh"; exit ;;
46 esac
47 done <<EOF'
49 show_merge () {
50 branch=$(expr "$msg" : "$merge_msg") &&
51 tip=$(git rev-parse --verify "refs/heads/$branch" 2>/dev/null) &&
52 merged=$(git name-rev --refs="refs/heads/$branch" "$other" 2>/dev/null) &&
53 merged=$(expr "$merged" : "$x40 \(.*\)") &&
54 test "$merged" != undefined || {
55 other=$(git log -1 --pretty='format:%s' $other) &&
56 merged="$branch :rebased? $other"
60 show_pick () {
61 merged="$(git rev-parse --verify "$commit") pick $msg"
64 git log --pretty=oneline --first-parent "$1" |
66 series=
67 while read commit msg
69 if other=$(git rev-parse -q --verify "$commit^2")
70 then
71 show_merge
72 else
73 show_pick
76 if test -z "$series"
77 then
78 series="$merged"
79 else
80 series="$merged$LF$series"
82 done
83 echo "$series"
86 echo 'EOF'