What's cooking (2010/12 #02)
[alt-git.git] / GRADUATED
blob12f17933940d6545ac1744bf1493b11b0625f0ad
1 #!/bin/sh
3 # Older first!
4 old_maint=$(
5 git for-each-ref --format='%(refname)' 'refs/heads/maint-*' |
6 sed -e 's|^refs/heads/||'
9 _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
10 _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
11 LF='
14 # disable pager
15 GIT_PAGER=cat
16 export GIT_PAGER
18 find_last_tip () {
19 topic="$(git rev-parse --verify "$1")" integrate="$2"
20 git rev-list --first-parent --parents "$2" |
21 sed -n -e "
22 /^$_x40 $_x40 $topic$/{
23 s/^\($_x40\) $_x40 $topic$/\1/p
30 tmp=/tmp/GR.$$
32 trap 'rm -f "$tmp".*' 0
34 git branch --merged master | sed -n -e '/\//s/^. //p' | sort >"$tmp.master"
36 >"$tmp.known"
37 for m in $old_maint maint
39 git branch --merged $m | sed -n -e '/\//s/^. //p' | sort >"$tmp.$m"
40 comm -12 "$tmp.$m" "$tmp.master" >"$tmp.both0"
41 comm -23 "$tmp.both0" "$tmp.known" >"$tmp.both"
42 if test -s "$tmp.both"
43 then
44 echo "# Graduated to both $m and master"
45 while read branch
47 d=$(git describe $branch)
48 echo "$(git show -s --format='%ct' "$branch") $branch ;# $d"
49 done <"$tmp.both" |
50 sort -r -n |
51 sed -e 's/^[0-9]* //' \
52 -e 's/^/git branch -d /'
53 echo
54 cat "$tmp.known" "$tmp.both" | sort >"$tmp.next"
55 mv "$tmp.next" "$tmp.known"
57 done
59 comm -13 "$tmp.maint" "$tmp.master" |
61 while read topic
63 t=$(find_last_tip $topic master) &&
64 test -n "$t" &&
65 m=$(git rev-parse --verify "$t^1") &&
66 test -n "$m" || continue
68 # NEEDSWORK: this misses repeated merges
70 # o---o---maint
71 # /
72 # .---o---o topic
73 # / \ \
74 # ---o---o---*---*---master
76 tsize=$(git rev-list "$m..$topic" | wc -l)
77 rsize=$(git rev-list "maint..$topic" | wc -l)
79 if test $tsize -eq $rsize
80 then
81 s=$(git show -s --pretty="tformat:%ct %H" $t)
82 echo "$s $topic"
83 else
84 s=$(git show -s --pretty="tformat:%ct %H" $t)
85 echo >&3 "$s $topic"
87 done 3>"$tmp.unmergeable" >"$tmp.mergeable"
89 if test -s "$tmp.unmergeable"
90 then
91 echo ": # Graduated to master; unmergeable to maint"
92 sort -n "$tmp.unmergeable" |
93 while read timestamp merge topic
95 git show -s --pretty="format:: # %h %cd" $merge
96 echo "git branch -d $topic"
97 done
98 echo
100 if test -s "$tmp.mergeable"
101 then
102 sort -n "$tmp.mergeable" |
103 while read timestamp merge topic
106 git show -s --pretty="format:%h %cd" $merge
107 git log --pretty=oneline --abbrev-commit maint..$topic
109 sed -e 's/^/: # /'
110 echo "git checkout maint && git merge $topic"
111 echo
112 done