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,2016,2017
28 echo "Usage: ${tgname:-tg} [...] summary [-t | --list | --heads[-only] | --sort | --deps[-only] | --rdeps | --graphviz] [-i | -w] [--tgish-only] [--with[out]-deps] [--exclude branch]... [--all | branch...]" >&2
36 [ -z "$head_from" ] || die
"-i and -w are mutually exclusive"
40 --heads|
--topgit-heads)
71 [ -n "${1#--exclude=}" ] || die
"--exclude= requires a branch name"
72 exclude
="$exclude ${1#--exclude=}";;
75 [ -n "$1" -a "$1" != "--all" ] || die
"--exclude requires a branch name"
76 exclude
="$exclude $1";;
84 [ $# -eq 0 ] || defwithdeps
=1
85 [ -z "$exclude" ] || exclude
="$exclude "
86 if [ "$1" = "--all" ]; then
87 [ -z "$withdeps" ] || die
"mutually exclusive options given"
93 [ "$heads$rdeps" != "11" ] ||
head=
94 [ $# -ne 0 -o -z "$head" ] ||
set -- "$head"
96 [ "$terse$heads$headsonly$graphviz$sort$deps$depsonly" = "" ] ||
97 [ "$terse$heads$headsonly$graphviz$sort$deps$depsonly$rdeps" = "1" ] ||
98 [ "$terse$heads$headsonly$graphviz$sort$deps$depsonly$rdeps" = "11" -a "$heads$rdeps" = "11" ] ||
99 die
"mutually exclusive options given"
100 [ -z "$withdeps" -o -z "$rdeps$depsonly$heads$headsonly" ] ||
101 die
"mutually exclusive options given"
104 [ "$b" != "--all" ] || usage
105 branches
="$branches $(verify_topgit_branch "$b")"
110 if [ -n "$branches" ]; then
112 printf '%s\n' $branches |
sort -u
114 printf '%s\n' $branches
117 non_annihilated_branches
121 show_heads_independent
()
123 topics
="$(get_temp topics)"
124 get_branch_list |
sed -e 's,^\(.*\)$,refs/heads/\1 \1,' |
125 git cat-file
--batch-check='%(objectname) %(rest)' |
126 sort -u -b -k1,1 >"$topics"
127 git merge-base
--independent $
(cut
-d ' ' -f 1 <"$topics") |
128 sort -u -b -k1,1 |
join - "$topics" |
sort -u -b -k2,2 |
129 while read rev name
; do
130 case "$exclude" in *" $name "*) continue; esac
131 printf '%s\n' "$name"
137 topics
="$(get_temp topics)"
139 [ -z "$branches" ] || topics2
="$(get_temp topics2)"
140 deplist
="$(get_temp deplist)"
141 get_branch_list
1 >"$topics"
142 while read -r onetopic
; do
143 if [ -n "$branches" ]; then
144 ! branch_annihilated
"$onetopic" ||
continue
145 echol
"$onetopic" >>"$topics2"
148 done <"$topics" |
sort -u >"$deplist"
149 [ -z "$branches" ] || topics
="$topics2"
150 join -v 1 "$topics" "$deplist" |
151 while read -r name
; do
152 case "$exclude" in *" $name "*) continue; esac
153 printf '%s\n' "$name"
159 if [ -n "$headsindep" ]; then
160 show_heads_independent
"$@"
162 show_heads_topgit
"$@"
166 if [ -n "$heads" -a -z "$rdeps" ]; then
173 case "$exclude" in *" $_dep "*) return; esac
174 case " $seen_deps " in *" $_dep "*) return 0; esac
175 seen_deps
="${seen_deps:+$seen_deps }$_dep"
176 [ -z "$tgish" -o -n "$_dep_is_tgish" ] ||
return 0
177 [ -z "$skip_ann" ] ||
! branch_annihilated
"$_dep" && printf '%s\n' "$_dep"
184 recurse_deps_exclude
=
185 get_branch_list |
while read _b
; do
186 case "$exclude" in *" $_b "*) continue; esac
187 case " $recurse_deps_exclude " in *" $_b "*) continue; esac
189 save_skip
="$skip_ann"
190 _dep
="$_b"; _dep_is_tgish
=1; skip_ann
=; show_dep
; skip_ann
="$save_skip"
191 recurse_deps show_dep
"$_b"
192 recurse_deps_exclude
="$recurse_deps_exclude $seen_deps"
196 if [ -n "$depsonly" ]; then
197 show_deps |
sort -u -b -k1,1
203 case "$exclude" in *" $_dep "*) return; esac
204 [ -z "$tgish" -o -n "$_dep_is_tgish" ] ||
return 0
205 printf '%s %s\n' "$_depchain" "$_dep"
208 if [ -n "$rdeps" ]; then
212 if [ -n "$heads" ]; then
218 case "$exclude" in *" $b "*) continue; esac
219 [ -z "$showbreak" ] ||
echo
221 ref_exists
"refs/heads/$b" ||
continue
225 recurse_deps show_rdeps
"$b"
226 } |
sed -e 's/[^ ][^ ]*[ ]/ /g'
231 if [ -n "$headsonly" ]; then
233 branches
="$(show_heads)"
236 [ -n "$withdeps" ] || withdeps
="$defwithdeps"
237 [ "$withdeps" != "0" ] || withdeps
=
238 if [ -n "$withdeps" ]; then
241 origbranches
="$branches"
242 branches
="$(skip_ann=1; show_deps | sort -u -b -k1,1)"
246 curname
="$(strip_ref "$
(git symbolic-ref
-q HEAD
)")" ||
:
248 if [ -n "$graphviz" ]; then
250 # GraphViz output; pipe to:
251 # | dot -Tpng -o <output>
259 label="TopGit Layout\n\n\n"
268 if [ -n "$sort" ]; then
269 tsort_input
="$(get_temp tg-summary-sort)"
281 [ -z "$branches" ] ||
[ -n "$withdeps" ] ||
return 0
282 [ -n "$withdeps" ] || origbranches
="$(tg summary --topgit-heads | paste -d ' ' -s -)"
283 aheadfile
="$(get_temp aheadlist)"
284 savebr
="$base_remote"
288 for onehead
in $origbranches; do
289 case "$exclude" in *" $onehead "*) continue; esac
290 case "$processed" in *" $onehead "*) continue; esac
291 processed
="${processed}$onehead "
292 needs_update
"$onehead" || needslist
="${needslist}$onehead "
295 base_remote
="$savebr"
296 aheadlist
=" $(cut -d ' ' -f 1 <"$aheadfile" | sort -u | paste -d ' ' -s -) "
304 [ "$name" != "$curname" ] || current
='>'
306 [ "$name" = "$curname" ] ||
309 ! branch_empty
"$name" $from || nonempty
='0'
311 [ -z "$base_remote" ] || remote
='l'
312 ! has_remote
"$name" || remote
='r'
314 [ "$remote" != 'r' ] ||
! ref_exists
"refs/remotes/$base_remote/${topbases#heads/}/$name" ||
{
315 branch_contains
"refs/$topbases/$name" "refs/remotes/$base_remote/${topbases#heads/}/$name" &&
316 branch_contains
"refs/heads/$name" "refs/remotes/$base_remote/$name"
318 [ "$remote" != 'r' -o "$rem_update" = 'R' ] ||
{
319 branch_contains
"refs/remotes/$base_remote/$name" "refs/heads/$name" 2>/dev
/null
324 case "$needslist" in *" $name "*) deps_update
='D'; esac;;
326 needs_update
"$name" >/dev
/null || deps_update
='D';;
329 [ -z "$missing_deps" ] || deps_missing
='!'
331 branch_contains
"refs/heads/$name" "refs/$topbases/$name" || base_update
='B'
333 case "$aheadlist" in *" $name "*) ahead
='*'; esac
335 if [ "$(ref_exists_rev "refs
/heads
/$name")" != "$(ref_exists_rev "refs
/$topbases/$name")" ]; then
336 subject
="$(cat_file "refs
/heads
/$name:.topmsg
" $from | sed -n 's/^Subject: //p')"
339 subject
="(No commits)"
342 printf '%-8s %-30s\t%s\n' "$current$nonempty$remote$rem_update$deps_update$deps_missing$base_update$ahead" \
346 if [ -n "$deps" ]; then
347 if [ -n "$branches" ]; then
350 case "$exclude" in *" $b "*) continue; esac
351 list_deps
$head_from $b |
352 while read name dep
; do
353 case "$exclude" in *" $dep "*) continue; esac
354 [ -z "$tgish" ] || ref_exists
"refs/$topbases/$dep" ||
continue
359 list_deps
$head_from |
360 while read name dep
; do
361 case "$exclude" in *" $dep "*) continue; esac
362 [ -z "$tgish" ] || ref_exists
"refs/$topbases/$dep" ||
continue
369 [ -n "$terse$graphviz$sort" ] || compute_ahead_list
372 case "$exclude" in *" $name "*) continue; esac
373 if [ -n "$terse" ]; then
375 elif [ -n "$graphviz$sort" ]; then
377 [ "$name" = "$curname" ] ||
379 cat_file
"refs/heads/$name:.topdeps" $from |
while read dep
; do
381 ref_exists
"refs/$topbases/$dep" ||
383 [ -z "$tgish" ] ||
[ "$dep_is_tgish" = "true" ] ||
continue
384 if ! "$dep_is_tgish" ||
! branch_annihilated
$dep; then
385 if [ -n "$graphviz" ]; then
386 echo "\"$name\" -> \"$dep\";"
387 if [ "$name" = "$curname" ] ||
[ "$dep" = "$curname" ]; then
388 echo "\"$curname\" [style=filled,fillcolor=yellow];"
391 echo "$name $dep" >&4
400 if [ -n "$graphviz" ]; then
404 if [ -n "$sort" ]; then