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-deps] [--exclude branch]... [--all | branch...]" >&2
34 [ -z "$head_from" ] || die
"-i and -w are mutually exclusive"
60 [ -n "${1#--exclude=}" ] || die
"--exclude= requires a branch name"
61 exclude
="$exclude ${1#--exclude=}";;
64 [ -n "$1" -a "$1" != "--all" ] || die
"--exclude requires a branch name"
65 exclude
="$exclude $1";;
73 [ -z "$exclude" ] || exclude
="$exclude "
74 if [ "$1" = "--all" ]; then
75 [ -z "$withdeps" ] || die
"mutually exclusive options given"
80 [ "$heads$rdeps" != "11" ] ||
head=
81 [ $# -ne 0 -o -z "$head" ] ||
set -- "$head"
83 [ "$terse$heads$graphviz$sort$deps$depsonly" = "" ] ||
84 [ "$terse$heads$graphviz$sort$deps$depsonly$rdeps" = "1" ] ||
85 [ "$terse$heads$graphviz$sort$deps$depsonly$rdeps" = "11" -a "$heads$rdeps" = "11" ] ||
86 die
"mutually exclusive options given"
87 [ -z "$withdeps" -o -z "$rdeps$depsonly$heads" ] ||
88 die
"mutually exclusive options given"
91 [ "$b" != "--all" ] || usage
92 branches
="$branches $(verify_topgit_branch "$b")"
97 if [ -n "$branches" ]; then
98 printf '%s\n' $branches
100 non_annihilated_branches
106 topics
="$(get_temp topics)"
107 get_branch_list |
sed -e 's,^\(.*\)$,refs/heads/\1 \1,' |
108 git cat-file
--batch-check='%(objectname) %(rest)' |
109 sort -u -b -k1,1 >"$topics"
110 git merge-base
--independent $
(cut
-d ' ' -f 1 <"$topics") |
111 sort -u -b -k1,1 |
join - "$topics" |
sort -u -b -k2,2 |
112 while read rev name
; do
113 case "$exclude" in *" $name "*) continue; esac
114 printf '%s\n' "$name"
118 if [ -n "$heads" -a -z "$rdeps" ]; then
124 case "$exclude" in *" $_dep "*) return; esac
125 case " $seen_deps " in *" $_dep "*) return 0; esac
126 seen_deps
="${seen_deps:+$seen_deps }$_dep"
127 [ -z "$tgish" -o -n "$_dep_is_tgish" ] ||
return 0
128 printf '%s\n' "$_dep"
134 recurse_deps_exclude
=
135 get_branch_list |
while read _b
; do
136 case "$exclude" in *" $_b "*) continue; esac
137 case " $recurse_deps_exclude " in *" $_b "*) continue; esac
139 _dep
="$_b"; _dep_is_tgish
=1; show_dep
140 recurse_deps show_dep
"$_b"
141 recurse_deps_exclude
="$recurse_deps_exclude $seen_deps"
145 if [ -n "$depsonly" ]; then
146 show_deps | LC_ALL
=C
sort -u -b -k1,1
152 case "$exclude" in *" $_dep "*) return; esac
153 [ -z "$tgish" -o -n "$_dep_is_tgish" ] ||
return 0
154 printf '%s %s\n' "$_depchain" "$_dep"
157 if [ -n "$rdeps" ]; then
161 if [ -n "$heads" ]; then
167 case "$exclude" in *" $b "*) continue; esac
168 [ -z "$showbreak" ] ||
echo
170 ref_exists
"refs/heads/$b" ||
continue
174 recurse_deps show_rdeps
"$b"
175 } |
sed -e 's/[^ ][^ ]*[ ]/ /g'
180 if [ -n "$withdeps" ]; then
183 branches
="$(show_deps | LC_ALL=C sort -u -b -k1,1)"
187 curname
="$(strip_ref "$
(git symbolic-ref
-q HEAD
)")" ||
:
189 if [ -n "$graphviz" ]; then
191 # GraphViz output; pipe to:
192 # | dot -Tpng -o <output>
200 label="TopGit Layout\n\n\n"
209 if [ -n "$sort" ]; then
210 tsort_input
="$(get_temp tg-summary-sort)"
222 [ "$name" != "$curname" ] || current
='>'
224 [ "$name" = "$curname" ] ||
227 ! branch_empty
"$name" $from || nonempty
='0'
229 [ -z "$base_remote" ] || remote
='l'
230 ! has_remote
"$name" || remote
='r'
232 [ "$remote" != 'r' ] ||
! ref_exists
"refs/remotes/$base_remote/$topbases/$name" ||
{
233 branch_contains
"refs/$topbases/$name" "refs/remotes/$base_remote/$topbases/$name" &&
234 branch_contains
"refs/heads/$name" "refs/remotes/$base_remote/$name"
236 [ "$remote" != 'r' -o "$rem_update" = 'R' ] ||
{
237 branch_contains
"refs/remotes/$base_remote/$name" "refs/heads/$name" 2>/dev
/null
240 needs_update
"$name" >/dev
/null || deps_update
='D'
242 [ -z "$missing_deps" ] || deps_missing
='!'
244 branch_contains
"refs/heads/$name" "refs/$topbases/$name" || base_update
='B'
246 if [ "$(ref_exists_rev "refs
/heads
/$name")" != "$(ref_exists_rev "refs
/$topbases/$name")" ]; then
247 subject
="$(cat_file "refs
/heads
/$name:.topmsg
" $from | sed -n 's/^Subject: //p')"
250 subject
="(No commits)"
253 printf '%s\t%-31s\t%s\n' "$current$nonempty$remote$rem_update$deps_update$deps_missing$base_update" \
257 if [ -n "$deps" ]; then
258 if [ -n "$branches" ]; then
261 case "$exclude" in *" $b "*) continue; esac
262 list_deps
$head_from $b |
263 while read name dep
; do
264 case "$exclude" in *" $dep "*) continue; esac
265 [ -z "$tgish" ] || ref_exists
"refs/$topbases/$dep" ||
continue
270 list_deps
$head_from |
271 while read name dep
; do
272 case "$exclude" in *" $dep "*) continue; esac
273 [ -z "$tgish" ] || ref_exists
"refs/$topbases/$dep" ||
continue
282 case "$exclude" in *" $name "*) continue; esac
283 if [ -n "$terse" ]; then
285 elif [ -n "$graphviz$sort" ]; then
287 [ "$name" = "$curname" ] ||
289 cat_file
"refs/heads/$name:.topdeps" $from |
while read dep
; do
291 ref_exists
"refs/$topbases/$dep" ||
293 [ -z "$tgish" ] ||
[ "$dep_is_tgish" = "true" ] ||
continue
294 if ! "$dep_is_tgish" ||
! branch_annihilated
$dep; then
295 if [ -n "$graphviz" ]; then
296 echo "\"$name\" -> \"$dep\";"
297 if [ "$name" = "$curname" ] ||
[ "$dep" = "$curname" ]; then
298 echo "\"$curname\" [style=filled,fillcolor=yellow];"
301 echo "$name $dep" >&4
310 if [ -n "$graphviz" ]; then
314 if [ -n "$sort" ]; then