2 # TopGit - A different patch queue manager
3 # Copyright (C) Petr Baudis <pasky@suse.cz> 2008
4 # Copyright (C) Kyle J. McKay <mackyle@gmail.com> 2015
26 echo "Usage: ${tgname:-tg} [...] summary [-t | --list | --heads | --sort | --deps | --deps-only | --rdeps | --graphviz] [-i | -w] [--tgish-only] [--with[out]-deps] [--exclude branch]... [--all | branch...]" >&2
34 [ -z "$head_from" ] || die
"-i and -w are mutually exclusive"
63 [ -n "${1#--exclude=}" ] || die
"--exclude= requires a branch name"
64 exclude
="$exclude ${1#--exclude=}";;
67 [ -n "$1" -a "$1" != "--all" ] || die
"--exclude requires a branch name"
68 exclude
="$exclude $1";;
77 [ -z "$exclude" ] || exclude
="$exclude "
78 if [ "$1" = "--all" ]; then
79 [ -z "$withdeps" ] || die
"mutually exclusive options given"
85 [ "$heads$rdeps" != "11" ] ||
head=
86 [ $# -ne 0 -o -z "$head" ] ||
set -- "$head"
88 [ "$terse$heads$graphviz$sort$deps$depsonly" = "" ] ||
89 [ "$terse$heads$graphviz$sort$deps$depsonly$rdeps" = "1" ] ||
90 [ "$terse$heads$graphviz$sort$deps$depsonly$rdeps" = "11" -a "$heads$rdeps" = "11" ] ||
91 die
"mutually exclusive options given"
92 [ -z "$withdeps" -o -z "$rdeps$depsonly$heads" ] ||
93 die
"mutually exclusive options given"
96 [ "$b" != "--all" ] || usage
97 branches
="$branches $(verify_topgit_branch "$b")"
102 if [ -n "$branches" ]; then
103 printf '%s\n' $branches
105 non_annihilated_branches
111 topics
="$(get_temp topics)"
112 get_branch_list |
sed -e 's,^\(.*\)$,refs/heads/\1 \1,' |
113 git cat-file
--batch-check='%(objectname) %(rest)' |
114 sort -u -b -k1,1 >"$topics"
115 git merge-base
--independent $
(cut
-d ' ' -f 1 <"$topics") |
116 sort -u -b -k1,1 |
join - "$topics" |
sort -u -b -k2,2 |
117 while read rev name
; do
118 case "$exclude" in *" $name "*) continue; esac
119 printf '%s\n' "$name"
123 if [ -n "$heads" -a -z "$rdeps" ]; then
129 case "$exclude" in *" $_dep "*) return; esac
130 case " $seen_deps " in *" $_dep "*) return 0; esac
131 seen_deps
="${seen_deps:+$seen_deps }$_dep"
132 [ -z "$tgish" -o -n "$_dep_is_tgish" ] ||
return 0
133 printf '%s\n' "$_dep"
139 recurse_deps_exclude
=
140 get_branch_list |
while read _b
; do
141 case "$exclude" in *" $_b "*) continue; esac
142 case " $recurse_deps_exclude " in *" $_b "*) continue; esac
144 _dep
="$_b"; _dep_is_tgish
=1; show_dep
145 recurse_deps show_dep
"$_b"
146 recurse_deps_exclude
="$recurse_deps_exclude $seen_deps"
150 if [ -n "$depsonly" ]; then
151 show_deps | LC_ALL
=C
sort -u -b -k1,1
157 case "$exclude" in *" $_dep "*) return; esac
158 [ -z "$tgish" -o -n "$_dep_is_tgish" ] ||
return 0
159 printf '%s %s\n' "$_depchain" "$_dep"
162 if [ -n "$rdeps" ]; then
166 if [ -n "$heads" ]; then
172 case "$exclude" in *" $b "*) continue; esac
173 [ -z "$showbreak" ] ||
echo
175 ref_exists
"refs/heads/$b" ||
continue
179 recurse_deps show_rdeps
"$b"
180 } |
sed -e 's/[^ ][^ ]*[ ]/ /g'
185 [ -n "$withdeps" ] || withdeps
="$defwithdeps"
186 [ "$withdeps" != "0" ] || withdeps
=
187 if [ -n "$withdeps" ]; then
190 branches
="$(show_deps | LC_ALL=C sort -u -b -k1,1)"
194 curname
="$(strip_ref "$
(git symbolic-ref
-q HEAD
)")" ||
:
196 if [ -n "$graphviz" ]; then
198 # GraphViz output; pipe to:
199 # | dot -Tpng -o <output>
207 label="TopGit Layout\n\n\n"
216 if [ -n "$sort" ]; then
217 tsort_input
="$(get_temp tg-summary-sort)"
229 [ "$name" != "$curname" ] || current
='>'
231 [ "$name" = "$curname" ] ||
234 ! branch_empty
"$name" $from || nonempty
='0'
236 [ -z "$base_remote" ] || remote
='l'
237 ! has_remote
"$name" || remote
='r'
239 [ "$remote" != 'r' ] ||
! ref_exists
"refs/remotes/$base_remote/$topbases/$name" ||
{
240 branch_contains
"refs/$topbases/$name" "refs/remotes/$base_remote/$topbases/$name" &&
241 branch_contains
"refs/heads/$name" "refs/remotes/$base_remote/$name"
243 [ "$remote" != 'r' -o "$rem_update" = 'R' ] ||
{
244 branch_contains
"refs/remotes/$base_remote/$name" "refs/heads/$name" 2>/dev
/null
247 needs_update
"$name" >/dev
/null || deps_update
='D'
249 [ -z "$missing_deps" ] || deps_missing
='!'
251 branch_contains
"refs/heads/$name" "refs/$topbases/$name" || base_update
='B'
253 if [ "$(ref_exists_rev "refs
/heads
/$name")" != "$(ref_exists_rev "refs
/$topbases/$name")" ]; then
254 subject
="$(cat_file "refs
/heads
/$name:.topmsg
" $from | sed -n 's/^Subject: //p')"
257 subject
="(No commits)"
260 printf '%s\t%-31s\t%s\n' "$current$nonempty$remote$rem_update$deps_update$deps_missing$base_update" \
264 if [ -n "$deps" ]; then
265 if [ -n "$branches" ]; then
268 case "$exclude" in *" $b "*) continue; esac
269 list_deps
$head_from $b |
270 while read name dep
; do
271 case "$exclude" in *" $dep "*) continue; esac
272 [ -z "$tgish" ] || ref_exists
"refs/$topbases/$dep" ||
continue
277 list_deps
$head_from |
278 while read name dep
; do
279 case "$exclude" in *" $dep "*) continue; esac
280 [ -z "$tgish" ] || ref_exists
"refs/$topbases/$dep" ||
continue
289 case "$exclude" in *" $name "*) continue; esac
290 if [ -n "$terse" ]; then
292 elif [ -n "$graphviz$sort" ]; then
294 [ "$name" = "$curname" ] ||
296 cat_file
"refs/heads/$name:.topdeps" $from |
while read dep
; do
298 ref_exists
"refs/$topbases/$dep" ||
300 [ -z "$tgish" ] ||
[ "$dep_is_tgish" = "true" ] ||
continue
301 if ! "$dep_is_tgish" ||
! branch_annihilated
$dep; then
302 if [ -n "$graphviz" ]; then
303 echo "\"$name\" -> \"$dep\";"
304 if [ "$name" = "$curname" ] ||
[ "$dep" = "$curname" ]; then
305 echo "\"$curname\" [style=filled,fillcolor=yellow];"
308 echo "$name $dep" >&4
317 if [ -n "$graphviz" ]; then
321 if [ -n "$sort" ]; then