Meta/Reintegrate: omit cut mark if no topics were merged from the group
[alt-git.git] / GRADUATED
blob89a8b845628c22249b9d03b2a176fdd61f999ce3
1 #!/bin/sh
3 base=
4 while :
5 do
6 case "$1" in
7 --base=*)
8 base=${1#*=} ;;
9 -*)
10 echo >&2 "Eh? $1"
11 exit 1 ;;
13 break ;;
14 esac
15 shift
16 done
18 if test -z "$base"
19 then
20 describe=$(git describe "master")
21 base=$(expr "$describe" : '\(.*\)-\([0-9]*\)-g[0-9a-f]*$') ||
22 base="$describe"
24 git rev-parse --verify "$base^0" >/dev/null 2>/dev/null || {
25 echo >&2 "Eh? where is your base?"
26 exit 1
30 topics=
31 leftover=
32 dothis=
33 LF='
36 defer () {
37 leftover="$leftover$1$LF"
40 dothis () {
41 dothis="$1$LF$LF$dothis"
44 one_topic () {
45 topic="$1" tip="$2" date="$3"
46 case " $topics" in *" $topic "*) return ;; esac
47 topics="$topic$topic "
49 mergeable=no ready=no label=
51 master_count=$(git rev-list "$base..$tip" | wc -l)
52 maint_count=$(git rev-list "maint..$tip" | wc -l)
54 test $master_count = $maint_count && mergeable=yes
56 if current=$(git rev-parse --verify -q "$topic^0") &&
57 test "$current" = "$tip"
58 then
59 ready=yes
60 label="$topic"
61 elif test -z "$current"
62 then
63 ready=yes
64 label="$tip"
67 case "$mergeable,$ready" in
68 no,*)
69 defer "# $topic: not mergeable ($master_count vs $maint_count)"
71 yes,no)
72 topic_count=$(git rev-list "$base..$current" | wc -l)
73 defer "# $topic: not ready ($master_count vs $topic_count)"
75 yes,yes)
76 insn="$label # $master_count ($date)"
77 insn="$insn$LF$(git log --oneline "maint..$tip" | sed -e "s/^/# /")"
78 dothis "$insn"
80 esac
83 git log --first-parent --min-parents=2 --max-parents=2 \
84 --format='%ci %H %P %s' "$base..master" | {
85 while read date time zone commit parent tip subject
87 topic=$(expr "$subject" : "Merge branch '\(.*\)'$") || {
88 echo >&2 "Cannot parse $commit ($subject)"
89 continue
91 one_topic "$topic" "$tip" "$date"
92 done
93 echo "$leftover"
94 echo "$dothis"