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
30 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
38 [ -z "$head_from" ] || die
"-i and -w are mutually exclusive"
44 --heads|
--topgit-heads)
55 --without-deps|
--no-with-deps)
81 [ -n "${1#--exclude=}" ] || die
"--exclude= requires a branch name"
82 exclude
="$exclude ${1#--exclude=}";;
85 [ -n "$1" -a "$1" != "--all" ] || die
"--exclude requires a branch name"
86 exclude
="$exclude $1";;
94 [ $# -eq 0 ] || defwithdeps
=1
95 [ -z "$exclude" ] || exclude
="$exclude "
97 if [ "$1" = "--all" ]; then
98 [ -z "$withdeps" ] || die
"mutually exclusive options given"
105 [ "$heads$rdeps" != "11" ] ||
head=
106 [ $# -ne 0 -o -z "$head" ] ||
set -- "$head"
108 [ "$terse$heads$headsonly$graphviz$sort$deps$depsonly" = "" ] ||
109 [ "$terse$heads$headsonly$graphviz$sort$deps$depsonly$rdeps" = "1" ] ||
110 [ "$terse$heads$headsonly$graphviz$sort$deps$depsonly$rdeps" = "11" -a "$heads$rdeps" = "11" ] ||
111 die
"mutually exclusive options given"
112 [ -z "$withdeps" -o -z "$rdeps$depsonly$heads$headsonly" ] ||
113 die
"mutually exclusive options given"
116 [ "$b" != "--all" ] || usage
117 branches
="$branches $(verify_topgit_branch "$b")"
122 if [ -n "$branches" ]; then
124 printf '%s\n' $branches |
sort -u
126 printf '%s\n' $branches
129 non_annihilated_branches
133 show_heads_independent
()
135 topics
="$(get_temp topics)"
136 get_branch_list |
sed -e 's,^\(.*\)$,refs/heads/\1 \1,' |
137 git cat-file
--batch-check='%(objectname) %(rest)' |
138 sort -u -b -k1,1 >"$topics"
139 git merge-base
--independent $
(cut
-d ' ' -f 1 <"$topics") |
140 sort -u -b -k1,1 |
join - "$topics" |
sort -u -b -k2,2 |
141 while read rev name
; do
142 case "$exclude" in *" $name "*) continue; esac
143 printf '%s\n' "$name"
149 if [ -n "$branches" ]; then
150 navigate_deps
-s=-1 -1 -- "$branches" |
sort
154 while read -r name
; do
155 case "$exclude" in *" $name "*) continue; esac
156 printf '%s\n' "$name"
162 if [ -n "$headsindep" ]; then
163 show_heads_independent
"$@"
165 show_heads_topgit
"$@"
169 if [ -n "$heads" -a -z "$rdeps" ]; then
176 case "$exclude" in *" $_dep "*) return; esac
177 case " $seen_deps " in *" $_dep "*) return 0; esac
178 seen_deps
="${seen_deps:+$seen_deps }$_dep"
179 [ -z "$tgish" -o -n "$_dep_is_tgish" ] ||
return 0
180 [ -z "$skip_ann" ] ||
[ -z "$_dep_annihilated" ] && printf '%s\n' "$_dep"
187 recurse_deps_exclude
=
188 get_branch_list |
while read _b
; do
189 case "$exclude" in *" $_b "*) continue; esac
190 case " $recurse_deps_exclude " in *" $_b "*) continue; esac
192 save_skip
="$skip_ann"
193 _dep
="$_b"; _dep_is_tgish
=1; skip_ann
=; show_dep
; skip_ann
="$save_skip"
194 recurse_deps show_dep
"$_b"
195 recurse_deps_exclude
="$recurse_deps_exclude $seen_deps"
199 if [ -n "$depsonly" ]; then
200 show_deps |
sort -u -b -k1,1
206 case "$exclude" in *" $_dep "*) return; esac
207 [ -z "$tgish" -o -n "$_dep_is_tgish" ] ||
return 0
208 printf '%s %s\n' "$_depchain" "$_dep"
211 if [ -n "$rdeps" ]; then
215 if [ -n "$heads" ]; then
221 case "$exclude" in *" $b "*) continue; esac
222 [ -z "$showbreak" ] ||
echo
224 ref_exists
"refs/heads/$b" ||
continue
228 recurse_deps
${rdepsonce:+-o=-o=-1} show_rdeps
"$b"
229 } |
sed -e 's/[^ ][^ ]*[ ]/ /g'
234 if [ -n "$deps" ]; then
235 if [ -n "$branches" ]; then
237 recurse_deps_exclude
="$exclude"
238 recurse_deps_internal
-n -t -m -e=2 -- $branches |
sort -u
241 [ -z "$tg_read_only" ] ||
[ -z "$tg_ref_cache" ] ||
! [ -s "$tg_ref_cache" ] ||
242 refslist
="-r=\"$tg_ref_cache\""
244 v_get_tdopt tdopt
"$head_from"
245 eval run_awk_topgit_deps
"$refslist" "$tdopt" '-n -t -x="$exclude" "refs/$topbases"'
250 if [ -n "$headsonly" ]; then
252 branches
="$(show_heads)"
255 [ -n "$withdeps" ] || withdeps
="$defwithdeps"
256 if [ -z "$doingall$terse$graphviz$sort$withdeps$branches" ]; then
257 branches
="$(tg info --heads 2>/dev/null | paste -d " " -s -)" ||
:
258 [ -z "$branches" ] || withdeps
=1
260 [ "$withdeps" != "0" ] || withdeps
=
261 if [ -n "$withdeps" ]; then
264 origbranches
="$branches"
265 branches
="$(skip_ann=1; show_deps | sort -u -b -k1,1 | paste -d " " -s -)"
269 curname
="$(strip_ref "$
(git symbolic-ref
-q HEAD
)")" ||
:
271 if [ -n "$graphviz" ]; then
273 # GraphViz output; pipe to:
274 # | dot -Tpng -o <output>
282 label="TopGit Layout\n\n\n"
291 if [ -n "$sort" ]; then
292 tsort_input
="$(get_temp tg-summary-sort)"
304 [ -z "$branches" ] ||
[ -n "$withdeps" ] ||
return 0
305 [ -n "$withdeps" ] || origbranches
="$(tg summary --topgit-heads | paste -d ' ' -s -)"
306 aheadfile
="$(get_temp aheadlist)"
307 savebr
="$base_remote"
311 for onehead
in $origbranches; do
312 case "$exclude" in *" $onehead "*) continue; esac
313 case "$processed" in *" $onehead "*) continue; esac
314 processed
="${processed}$onehead "
315 needs_update
"$onehead" || needslist
="${needslist}$onehead "
318 base_remote
="$savebr"
319 aheadlist
=" $(cut -d ' ' -f 1 <"$aheadfile" | sort -u | paste -d ' ' -s -) "
327 [ "$name" != "$curname" ] || current
='>'
329 [ "$name" = "$curname" ] ||
332 ! branch_empty
"$name" $from || nonempty
='0'
334 [ -z "$base_remote" ] || remote
='l'
335 ! has_remote
"$name" || remote
='r'
337 [ "$remote" != 'r' ] ||
! ref_exists
"refs/remotes/$base_remote/${topbases#heads/}/$name" ||
{
338 branch_contains
"refs/$topbases/$name" "refs/remotes/$base_remote/${topbases#heads/}/$name" &&
339 branch_contains
"refs/heads/$name" "refs/remotes/$base_remote/$name"
341 [ "$remote" != 'r' -o "$rem_update" = 'R' ] ||
{
342 branch_contains
"refs/remotes/$base_remote/$name" "refs/heads/$name" 2>/dev
/null
347 case "$needslist" in *" $name "*) deps_update
='D'; esac;;
349 needs_update
"$name" >/dev
/null || deps_update
='D';;
352 [ -z "$missing_deps" ] || deps_missing
='!'
354 branch_contains
"refs/heads/$name" "refs/$topbases/$name" || base_update
='B'
356 case "$aheadlist" in *" $name "*) ahead
='*'; esac
358 if [ "$(ref_exists_rev "refs
/heads
/$name")" != "$(ref_exists_rev "refs
/$topbases/$name")" ]; then
359 subject
="$(cat_file "refs
/heads
/$name:.topmsg
" $from | sed -n 's/^Subject: //p')"
362 subject
="(No commits)"
365 printf '%-8s %-30s\t%s\n' "$current$nonempty$remote$rem_update$deps_update$deps_missing$base_update$ahead" \
369 if [ -n "$terse" ]; then
371 [ -z "$tg_read_only" ] ||
[ -z "$tg_ref_cache" ] ||
! [ -s "$tg_ref_cache" ] ||
372 refslist
="-r=\"$tg_ref_cache\""
373 cmd
="run_awk_topgit_msg --list"
374 [ "${verbose:-0}" != "0" ] || cmd
="run_awk_topgit_branches -n"
375 eval "$cmd" "$refslist" '-i="$branches" -x="$exclude" "refs/$topbases"'
379 [ -n "$graphviz$sort" ] || compute_ahead_list
382 case "$exclude" in *" $name "*) continue; esac
383 if [ -n "$graphviz$sort" ]; then
385 [ "$name" = "$curname" ] ||
387 cat_file
"refs/heads/$name:.topdeps" $from |
while read -r dep ||
[ -n "$dep" ]; do
389 ref_exists
"refs/$topbases/$dep" ||
391 [ -z "$tgish" ] ||
[ "$dep_is_tgish" = "true" ] ||
continue
392 if ! "$dep_is_tgish" ||
! branch_annihilated
$dep; then
393 if [ -n "$graphviz" ]; then
394 echo "\"$name\" -> \"$dep\";"
395 if [ "$name" = "$curname" ] ||
[ "$dep" = "$curname" ]; then
396 echo "\"$curname\" [style=filled,fillcolor=yellow];"
399 echo "$name $dep" >&4
408 if [ -n "$graphviz" ]; then
412 if [ -n "$sort" ]; then