What's in
[git/spearce.git] / GRADUATED
blobc6a427fb483b73c778270618c506593bbac0bd52
1 #!/bin/sh
3 # Older first!
4 old_maint='maint-1.6.0 maint-1.6.1'
6 _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
7 _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
8 LF='
11 # disable pager
12 GIT_PAGER=cat
13 export GIT_PAGER
15 find_last_tip () {
16 topic="$(git rev-parse --verify "$1")" integrate="$2"
17 git rev-list --first-parent --parents "$2" |
18 sed -n -e "
19 /^$_x40 $_x40 $topic$/{
20 s/^\($_x40\) $_x40 $topic$/\1/p
27 tmp=/tmp/GR.$$
29 trap 'rm -f "$tmp".*' 0
31 git branch --merged master | sed -n -e '/\//s/^. //p' | sort >"$tmp.master"
33 >"$tmp.known"
34 for m in $old_maint maint
36 git branch --merged $m | sed -n -e '/\//s/^. //p' | sort >"$tmp.$m"
37 comm -12 "$tmp.$m" "$tmp.master" >"$tmp.both0"
38 comm -23 "$tmp.both0" "$tmp.known" >"$tmp.both"
39 if test -s "$tmp.both"
40 then
41 echo "# Graduated to both $m and master"
42 while read branch
44 echo "$(git show -s --format='%ct' "$branch") $branch"
45 done <"$tmp.both" |
46 sort -r -n |
47 sed -e 's/^[0-9]* //' \
48 -e 's/^/git branch -d /'
49 echo
50 cat "$tmp.known" "$tmp.both" | sort >"$tmp.next"
51 mv "$tmp.next" "$tmp.known"
53 done
55 comm -13 "$tmp.maint" "$tmp.master" |
57 while read topic
59 t=$(find_last_tip $topic master) &&
60 test -n "$t" &&
61 m=$(git rev-parse --verify "$t^1") &&
62 test -n "$m" || continue
64 # NEEDSWORK: this misses repeated merges
66 # o---o---maint
67 # /
68 # .---o---o topic
69 # / \ \
70 # ---o---o---*---*---master
72 tsize=$(git rev-list "$m..$topic" | wc -l)
73 rsize=$(git rev-list "maint..$topic" | wc -l)
75 if test $tsize -eq $rsize
76 then
77 s=$(git show -s --pretty="tformat:%ct %H" $t)
78 echo "$s $topic"
79 else
80 s=$(git show -s --pretty="tformat:%ct %H" $t)
81 echo >&3 "$s $topic"
83 done 3>"$tmp.unmergeable" >"$tmp.mergeable"
85 if test -s "$tmp.unmergeable"
86 then
87 echo "# Graduated to master; unmergeable to maint"
88 sort -n "$tmp.unmergeable" |
89 while read timestamp merge topic
91 git show -s --pretty="format:# %h %cd" $merge
92 echo "git branch -d $topic"
93 done
94 echo
96 if test -s "$tmp.mergeable"
97 then
98 sort -n "$tmp.mergeable" |
99 while read timestamp merge topic
102 git show -s --pretty="format:%h %cd" $merge
103 git log --pretty=oneline --abbrev-commit maint..$topic
105 sed -e 's/^/# /'
106 echo "git checkout maint && git merge $topic"
107 echo
108 done