6 branch=`git symbolic-ref HEAD` &&
7 test refs/heads/master = "$branch" || {
18 (cd .git/refs/heads && find -type f) |
21 -e '/^[^\/][^\/]\//p' |
24 rebase= done= not_done= trouble=
27 only_next_1=`git-rev-list ^master "^$topic" next | sort`
28 only_next_2=`git-rev-list ^master next | sort`
29 if test "$only_next_1" = "$only_next_2"
31 not_in_topic=`git-rev-list "^$topic" master`
32 if test -z "$not_in_topic"
36 rebase=" (can be rebased)"
42 git-rev-list --pretty=oneline ^master "$topic" |
43 sed -e 's/^[0-9a-f]* //'
45 test -z "$not_in_master" &&
46 done="${LF}Fully merged -- delete."
50 git-rev-list --pretty=oneline ^next "$topic" |
51 sed -e 's/^[0-9a-f]* / - /'
53 if test -n "$not_in_next"
57 trouble="${LF}### MODIFIED AFTER COOKED ###"
59 not_done="${LF}Still not merged in next$rebase.$LF$not_in_next"
64 not_done="${LF}Up to date."
67 echo "*** $topic ***$trouble$done$not_done"
69 if test -z "$trouble$not_done" &&
73 git branch -d "$topic"
79 ################################################################
82 Some important disciplines first.
84 * Once a topic branch forks from "master", never merge "master"
85 updates into the topic branch.
87 * Once a topic branch is fully cooked and merged into "master",
88 delete it. If you need to build on top of it to correct
89 earlier mistakes, create a new topic branch by forking at the
90 tip of the "master". This is not strictly necessary, but it
91 makes it easier to keep your history simple.
93 * Whenever you need to test or publish your changes to topic
94 branches, merge them into "next" branch.
96 So, you would want to know:
98 (1) ... if a topic branch has ever been merged to "next". Young
99 topic branches can have stupid mistakes you would rather
100 clean up, and things that have not been merged into other
101 branches can be easily rebased without affecting others.
103 (2) ... if a topic branch has been fully merged to "master".
104 Then you can delete it. More importantly, you can tell you
105 should not build on top of it.
107 (3) ... if a topic branch has commits unmerged to "next". You
108 need to merge them to test and/or publish.
110 Let's look at this example:
112 o---o---o---o---o---o---o---o---o---o "next"
116 / / c---c---c---c B /
120 ---o---o---o---o---o---o---o---o---o---o---o "master"
123 A, B and C are topic branches.
125 * A has one fix since it was merged up to "next".
127 * B has finished. It has been fully merged up to "master" and "next",
128 and is ready to be deleted.
130 * C has not merged to "next" at all.
134 git-rev-list ^master ^topic next
135 git-rev-list ^master next
137 if these match, topic has not merged in next at all.
141 git-rev-list master..topic
143 if this is empty, it is fully merged to "master".
147 git-rev-list next..topic
149 if this is empty, there is nothing to merge to "next".