4 while case $# in 0) break ;; esac
8 branch=`git symbolic-ref HEAD` &&
9 test refs/heads/master = "$branch" || {
10 echo >&2 Not on master
17 echo >&2 "Need argument"
21 git rev-parse --verify "$next" >/dev/null || exit
25 echo >&2 "$0 [--clean | --next test-next ]"
34 (cd .git/refs/heads && find -type f) |
37 -e '/^[^\/][^\/]\//p' |
40 rebase= done= not_done= trouble= date=
43 only_next_1=`git-rev-list ^master "^$topic" ${next} | sort`
44 only_next_2=`git-rev-list ^master ${next} | sort`
45 if test "$only_next_1" = "$only_next_2"
47 not_in_topic=`git-rev-list "^$topic" master`
48 if test -z "$not_in_topic"
52 rebase=" (can be rebased)"
58 git-rev-list ^master "$topic"
60 test -z "$not_in_master" &&
61 done="${LF}Fully merged -- delete."
65 git-rev-list --pretty=oneline ^${next} "$topic"
67 if test -n "$not_in_next"
71 trouble="${LF}### MODIFIED AFTER COOKED ###"
73 last=`expr "$not_in_next" : '\([0-9a-f]*\) '`
75 git-rev-list -1 --pretty "$last" |
76 sed -ne 's/^Date: *\(.*\)/ (\1)/p'
78 not_in_next=`echo "$not_in_next" | sed -e 's/^[0-9a-f]* / - /'`
79 not_done="${LF}Still not merged in ${next}$rebase.$LF$not_in_next"
84 not_done="${LF}Up to date."
87 echo "*** $topic ***$date$trouble$done$not_done"
89 if test -z "$trouble$not_done" &&
93 git branch -d "$topic"
99 ################################################################
102 Some important disciplines first.
104 * Once a topic branch forks from "master", never merge "master"
105 updates into the topic branch.
107 * Once a topic branch is fully cooked and merged into "master",
108 delete it. If you need to build on top of it to correct
109 earlier mistakes, create a new topic branch by forking at the
110 tip of the "master". This is not strictly necessary, but it
111 makes it easier to keep your history simple.
113 * Whenever you need to test or publish your changes to topic
114 branches, merge them into "next" branch.
116 So, you would want to know:
118 (1) ... if a topic branch has ever been merged to "next". Young
119 topic branches can have stupid mistakes you would rather
120 clean up, and things that have not been merged into other
121 branches can be easily rebased without affecting others.
123 (2) ... if a topic branch has been fully merged to "master".
124 Then you can delete it. More importantly, you can tell you
125 should not build on top of it.
127 (3) ... if a topic branch has commits unmerged to "next". You
128 need to merge them to test and/or publish.
130 Let's look at this example:
132 o---o---o---o---o---o---o---o---o---o "next"
136 / / c---c---c---c B /
140 ---o---o---o---o---o---o---o---o---o---o---o "master"
143 A, B and C are topic branches.
145 * A has one fix since it was merged up to "next".
147 * B has finished. It has been fully merged up to "master" and "next",
148 and is ready to be deleted.
150 * C has not merged to "next" at all.
154 git-rev-list ^master ^topic next
155 git-rev-list ^master next
157 if these match, topic has not merged in next at all.
161 git-rev-list master..topic
163 if this is empty, it is fully merged to "master".
167 git-rev-list next..topic
169 if this is empty, there is nothing to merge to "next".