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=
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 --pretty=oneline ^master "$topic" |
59 sed -e 's/^[0-9a-f]* //'
61 test -z "$not_in_master" &&
62 done="${LF}Fully merged -- delete."
66 git-rev-list --pretty=oneline ^${next} "$topic" |
67 sed -e 's/^[0-9a-f]* / - /'
69 if test -n "$not_in_next"
73 trouble="${LF}### MODIFIED AFTER COOKED ###"
75 not_done="${LF}Still not merged in ${next}$rebase.$LF$not_in_next"
80 not_done="${LF}Up to date."
83 echo "*** $topic ***$trouble$done$not_done"
85 if test -z "$trouble$not_done" &&
89 git branch -d "$topic"
95 ################################################################
98 Some important disciplines first.
100 * Once a topic branch forks from "master", never merge "master"
101 updates into the topic branch.
103 * Once a topic branch is fully cooked and merged into "master",
104 delete it. If you need to build on top of it to correct
105 earlier mistakes, create a new topic branch by forking at the
106 tip of the "master". This is not strictly necessary, but it
107 makes it easier to keep your history simple.
109 * Whenever you need to test or publish your changes to topic
110 branches, merge them into "next" branch.
112 So, you would want to know:
114 (1) ... if a topic branch has ever been merged to "next". Young
115 topic branches can have stupid mistakes you would rather
116 clean up, and things that have not been merged into other
117 branches can be easily rebased without affecting others.
119 (2) ... if a topic branch has been fully merged to "master".
120 Then you can delete it. More importantly, you can tell you
121 should not build on top of it.
123 (3) ... if a topic branch has commits unmerged to "next". You
124 need to merge them to test and/or publish.
126 Let's look at this example:
128 o---o---o---o---o---o---o---o---o---o "next"
132 / / c---c---c---c B /
136 ---o---o---o---o---o---o---o---o---o---o---o "master"
139 A, B and C are topic branches.
141 * A has one fix since it was merged up to "next".
143 * B has finished. It has been fully merged up to "master" and "next",
144 and is ready to be deleted.
146 * C has not merged to "next" at all.
150 git-rev-list ^master ^topic next
151 git-rev-list ^master next
153 if these match, topic has not merged in next at all.
157 git-rev-list master..topic
159 if this is empty, it is fully merged to "master".
163 git-rev-list next..topic
165 if this is empty, there is nothing to merge to "next".