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";;
76 [ $# -eq 0 ] || defwithdeps
=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
130 case "$exclude" in *" $_dep "*) return; esac
131 case " $seen_deps " in *" $_dep "*) return 0; esac
132 seen_deps
="${seen_deps:+$seen_deps }$_dep"
133 [ -z "$tgish" -o -n "$_dep_is_tgish" ] ||
return 0
134 [ -z "$skip_ann" ] ||
! branch_annihilated
"$_dep" && printf '%s\n' "$_dep"
141 recurse_deps_exclude
=
142 get_branch_list |
while read _b
; do
143 case "$exclude" in *" $_b "*) continue; esac
144 case " $recurse_deps_exclude " in *" $_b "*) continue; esac
146 save_skip
="$skip_ann"
147 _dep
="$_b"; _dep_is_tgish
=1; skip_ann
=; show_dep
; skip_ann
="$save_skip"
148 recurse_deps show_dep
"$_b"
149 recurse_deps_exclude
="$recurse_deps_exclude $seen_deps"
153 if [ -n "$depsonly" ]; then
154 show_deps | LC_ALL
=C
sort -u -b -k1,1
160 case "$exclude" in *" $_dep "*) return; esac
161 [ -z "$tgish" -o -n "$_dep_is_tgish" ] ||
return 0
162 printf '%s %s\n' "$_depchain" "$_dep"
165 if [ -n "$rdeps" ]; then
169 if [ -n "$heads" ]; then
175 case "$exclude" in *" $b "*) continue; esac
176 [ -z "$showbreak" ] ||
echo
178 ref_exists
"refs/heads/$b" ||
continue
182 recurse_deps show_rdeps
"$b"
183 } |
sed -e 's/[^ ][^ ]*[ ]/ /g'
188 [ -n "$withdeps" ] || withdeps
="$defwithdeps"
189 [ "$withdeps" != "0" ] || withdeps
=
190 if [ -n "$withdeps" ]; then
193 branches
="$(skip_ann=1; show_deps | LC_ALL=C sort -u -b -k1,1)"
197 curname
="$(strip_ref "$
(git symbolic-ref
-q HEAD
)")" ||
:
199 if [ -n "$graphviz" ]; then
201 # GraphViz output; pipe to:
202 # | dot -Tpng -o <output>
210 label="TopGit Layout\n\n\n"
219 if [ -n "$sort" ]; then
220 tsort_input
="$(get_temp tg-summary-sort)"
232 [ "$name" != "$curname" ] || current
='>'
234 [ "$name" = "$curname" ] ||
237 ! branch_empty
"$name" $from || nonempty
='0'
239 [ -z "$base_remote" ] || remote
='l'
240 ! has_remote
"$name" || remote
='r'
242 [ "$remote" != 'r' ] ||
! ref_exists
"refs/remotes/$base_remote/${topbases#heads/}/$name" ||
{
243 branch_contains
"refs/$topbases/$name" "refs/remotes/$base_remote/${topbases#heads/}/$name" &&
244 branch_contains
"refs/heads/$name" "refs/remotes/$base_remote/$name"
246 [ "$remote" != 'r' -o "$rem_update" = 'R' ] ||
{
247 branch_contains
"refs/remotes/$base_remote/$name" "refs/heads/$name" 2>/dev
/null
250 needs_update
"$name" >/dev
/null || deps_update
='D'
252 [ -z "$missing_deps" ] || deps_missing
='!'
254 branch_contains
"refs/heads/$name" "refs/$topbases/$name" || base_update
='B'
256 if [ "$(ref_exists_rev "refs
/heads
/$name")" != "$(ref_exists_rev "refs
/$topbases/$name")" ]; then
257 subject
="$(cat_file "refs
/heads
/$name:.topmsg
" $from | sed -n 's/^Subject: //p')"
260 subject
="(No commits)"
263 printf '%s\t%-31s\t%s\n' "$current$nonempty$remote$rem_update$deps_update$deps_missing$base_update" \
267 if [ -n "$deps" ]; then
268 if [ -n "$branches" ]; then
271 case "$exclude" in *" $b "*) continue; esac
272 list_deps
$head_from $b |
273 while read name dep
; do
274 case "$exclude" in *" $dep "*) continue; esac
275 [ -z "$tgish" ] || ref_exists
"refs/$topbases/$dep" ||
continue
280 list_deps
$head_from |
281 while read name dep
; do
282 case "$exclude" in *" $dep "*) continue; esac
283 [ -z "$tgish" ] || ref_exists
"refs/$topbases/$dep" ||
continue
292 case "$exclude" in *" $name "*) continue; esac
293 if [ -n "$terse" ]; then
295 elif [ -n "$graphviz$sort" ]; then
297 [ "$name" = "$curname" ] ||
299 cat_file
"refs/heads/$name:.topdeps" $from |
while read dep
; do
301 ref_exists
"refs/$topbases/$dep" ||
303 [ -z "$tgish" ] ||
[ "$dep_is_tgish" = "true" ] ||
continue
304 if ! "$dep_is_tgish" ||
! branch_annihilated
$dep; then
305 if [ -n "$graphviz" ]; then
306 echo "\"$name\" -> \"$dep\";"
307 if [ "$name" = "$curname" ] ||
[ "$dep" = "$curname" ]; then
308 echo "\"$curname\" [style=filled,fillcolor=yellow];"
311 echo "$name $dep" >&4
320 if [ -n "$graphviz" ]; then
324 if [ -n "$sort" ]; then