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
27 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
35 [ -z "$head_from" ] || die
"-i and -w are mutually exclusive"
66 [ -n "${1#--exclude=}" ] || die
"--exclude= requires a branch name"
67 exclude
="$exclude ${1#--exclude=}";;
70 [ -n "$1" -a "$1" != "--all" ] || die
"--exclude requires a branch name"
71 exclude
="$exclude $1";;
79 [ $# -eq 0 ] || defwithdeps
=1
80 [ -z "$exclude" ] || exclude
="$exclude "
81 if [ "$1" = "--all" ]; then
82 [ -z "$withdeps" ] || die
"mutually exclusive options given"
88 [ "$heads$rdeps" != "11" ] ||
head=
89 [ $# -ne 0 -o -z "$head" ] ||
set -- "$head"
91 [ "$terse$heads$headsonly$graphviz$sort$deps$depsonly" = "" ] ||
92 [ "$terse$heads$headsonly$graphviz$sort$deps$depsonly$rdeps" = "1" ] ||
93 [ "$terse$heads$headsonly$graphviz$sort$deps$depsonly$rdeps" = "11" -a "$heads$rdeps" = "11" ] ||
94 die
"mutually exclusive options given"
95 [ -z "$withdeps" -o -z "$rdeps$depsonly$heads$headsonly" ] ||
96 die
"mutually exclusive options given"
99 [ "$b" != "--all" ] || usage
100 branches
="$branches $(verify_topgit_branch "$b")"
105 if [ -n "$branches" ]; then
106 printf '%s\n' $branches
108 non_annihilated_branches
114 topics
="$(get_temp topics)"
115 get_branch_list |
sed -e 's,^\(.*\)$,refs/heads/\1 \1,' |
116 git cat-file
--batch-check='%(objectname) %(rest)' |
117 sort -u -b -k1,1 >"$topics"
118 git merge-base
--independent $
(cut
-d ' ' -f 1 <"$topics") |
119 sort -u -b -k1,1 |
join - "$topics" |
sort -u -b -k2,2 |
120 while read rev name
; do
121 case "$exclude" in *" $name "*) continue; esac
122 printf '%s\n' "$name"
126 if [ -n "$heads" -a -z "$rdeps" ]; then
133 case "$exclude" in *" $_dep "*) return; esac
134 case " $seen_deps " in *" $_dep "*) return 0; esac
135 seen_deps
="${seen_deps:+$seen_deps }$_dep"
136 [ -z "$tgish" -o -n "$_dep_is_tgish" ] ||
return 0
137 [ -z "$skip_ann" ] ||
! branch_annihilated
"$_dep" && printf '%s\n' "$_dep"
144 recurse_deps_exclude
=
145 get_branch_list |
while read _b
; do
146 case "$exclude" in *" $_b "*) continue; esac
147 case " $recurse_deps_exclude " in *" $_b "*) continue; esac
149 save_skip
="$skip_ann"
150 _dep
="$_b"; _dep_is_tgish
=1; skip_ann
=; show_dep
; skip_ann
="$save_skip"
151 recurse_deps show_dep
"$_b"
152 recurse_deps_exclude
="$recurse_deps_exclude $seen_deps"
156 if [ -n "$depsonly" ]; then
157 show_deps | LC_ALL
=C
sort -u -b -k1,1
163 case "$exclude" in *" $_dep "*) return; esac
164 [ -z "$tgish" -o -n "$_dep_is_tgish" ] ||
return 0
165 printf '%s %s\n' "$_depchain" "$_dep"
168 if [ -n "$rdeps" ]; then
172 if [ -n "$heads" ]; then
178 case "$exclude" in *" $b "*) continue; esac
179 [ -z "$showbreak" ] ||
echo
181 ref_exists
"refs/heads/$b" ||
continue
185 recurse_deps show_rdeps
"$b"
186 } |
sed -e 's/[^ ][^ ]*[ ]/ /g'
191 if [ -n "$headsonly" ]; then
193 branches
="$(show_heads)"
196 [ -n "$withdeps" ] || withdeps
="$defwithdeps"
197 [ "$withdeps" != "0" ] || withdeps
=
198 if [ -n "$withdeps" ]; then
201 branches
="$(skip_ann=1; show_deps | LC_ALL=C sort -u -b -k1,1)"
205 curname
="$(strip_ref "$
(git symbolic-ref
-q HEAD
)")" ||
:
207 if [ -n "$graphviz" ]; then
209 # GraphViz output; pipe to:
210 # | dot -Tpng -o <output>
218 label="TopGit Layout\n\n\n"
227 if [ -n "$sort" ]; then
228 tsort_input
="$(get_temp tg-summary-sort)"
240 [ "$name" != "$curname" ] || current
='>'
242 [ "$name" = "$curname" ] ||
245 ! branch_empty
"$name" $from || nonempty
='0'
247 [ -z "$base_remote" ] || remote
='l'
248 ! has_remote
"$name" || remote
='r'
250 [ "$remote" != 'r' ] ||
! ref_exists
"refs/remotes/$base_remote/${topbases#heads/}/$name" ||
{
251 branch_contains
"refs/$topbases/$name" "refs/remotes/$base_remote/${topbases#heads/}/$name" &&
252 branch_contains
"refs/heads/$name" "refs/remotes/$base_remote/$name"
254 [ "$remote" != 'r' -o "$rem_update" = 'R' ] ||
{
255 branch_contains
"refs/remotes/$base_remote/$name" "refs/heads/$name" 2>/dev
/null
258 needs_update
"$name" >/dev
/null || deps_update
='D'
260 [ -z "$missing_deps" ] || deps_missing
='!'
262 branch_contains
"refs/heads/$name" "refs/$topbases/$name" || base_update
='B'
264 if [ "$(ref_exists_rev "refs
/heads
/$name")" != "$(ref_exists_rev "refs
/$topbases/$name")" ]; then
265 subject
="$(cat_file "refs
/heads
/$name:.topmsg
" $from | sed -n 's/^Subject: //p')"
268 subject
="(No commits)"
271 printf '%s\t%-31s\t%s\n' "$current$nonempty$remote$rem_update$deps_update$deps_missing$base_update" \
275 if [ -n "$deps" ]; then
276 if [ -n "$branches" ]; then
279 case "$exclude" in *" $b "*) continue; esac
280 list_deps
$head_from $b |
281 while read name dep
; do
282 case "$exclude" in *" $dep "*) continue; esac
283 [ -z "$tgish" ] || ref_exists
"refs/$topbases/$dep" ||
continue
288 list_deps
$head_from |
289 while read name dep
; do
290 case "$exclude" in *" $dep "*) continue; esac
291 [ -z "$tgish" ] || ref_exists
"refs/$topbases/$dep" ||
continue
300 case "$exclude" in *" $name "*) continue; esac
301 if [ -n "$terse" ]; then
303 elif [ -n "$graphviz$sort" ]; then
305 [ "$name" = "$curname" ] ||
307 cat_file
"refs/heads/$name:.topdeps" $from |
while read dep
; do
309 ref_exists
"refs/$topbases/$dep" ||
311 [ -z "$tgish" ] ||
[ "$dep_is_tgish" = "true" ] ||
continue
312 if ! "$dep_is_tgish" ||
! branch_annihilated
$dep; then
313 if [ -n "$graphviz" ]; then
314 echo "\"$name\" -> \"$dep\";"
315 if [ "$name" = "$curname" ] ||
[ "$dep" = "$curname" ]; then
316 echo "\"$curname\" [style=filled,fillcolor=yellow];"
319 echo "$name $dep" >&4
328 if [ -n "$graphviz" ]; then
332 if [ -n "$sort" ]; then