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
7 USAGE
="Usage: ${tgname:-tg} [...] info [--heads | --leaves] [<name>]"
11 if [ "${1:-0}" != 0 ]; then
12 printf '%s\n' "$USAGE" >&2
14 printf '%s\n' "$USAGE"
25 while [ $# -gt 0 ]; do case "$1" in
36 verbose
=$
(( ${verbose:-0} + 1 ))
38 -vv|
-vvv|
-vvvv|
-vvvvv)
39 verbose
=$
(( ${verbose:-0} + ${#1} - 1 ))
42 echo "Unknown option: $1" >&2
49 [ "$heads$leaves" != "11" ] || die
"mutually exclusive options --heads and --leaves"
50 [ $# -gt 0 ] ||
set -- HEAD
51 [ $# -eq 1 ] || die
"name already specified ($1)"
56 if [ -n "$_dep_is_tgish" ] && [ -z "$_dep_missing$_dep_annihilated" ]; then
57 printf '%s\n' "$_dep ${_depchain##* }"
61 if [ -n "$heads" ]; then
65 ! test="$(verify_topgit_branch "${name:-HEAD}" -f)" || verify
="refs/heads/$test"
66 hash="$(git rev-parse --verify --quiet "$verify" --)" || die
"no such ref: $name"
67 depslist
="$(get_temp depslist)"
68 $tg summary
--topgit-heads |
69 while read -r onetghead
; do
70 printf '%s %s\n' "$onetghead" "$onetghead"
71 recurse_deps process_dep
"$onetghead"
72 done | LC_ALL
=C
sort -u >"$depslist"
73 git branch
--no-color --contains "$hash" | LC_ALL
=C cut
-c 3- |
74 LC_ALL
=C
join -o 2.2 - "$depslist" |
79 name
="$(verify_topgit_branch "${name:-HEAD}")"
80 if [ -n "$leaves" ]; then
84 base_rev
="$(git rev-parse --short --verify "refs
/$topbases/$name" -- 2>/dev/null)" ||
85 die
"not a TopGit-controlled branch"
87 measure
="$(measure_branch "refs
/heads
/$name" "$base_rev")"
89 echo "Topic Branch: $name ($measure)"
92 [ "$(git rev-parse --verify --short "refs
/heads
/$name" --)" != "$base_rev" ] || nocommits
=1
94 [ -n "$nocommits" ] || git cat-file blob
"$name:.topmsg" |
grep ^Subject
: ||
:
96 # true if $1 is contained by (or the same as) $2
99 [ "$(git rev-list --count --max-count=1 "$1" --not "$2" --)" = "0" ]
102 if [ "${verbose:-0}" -ge 1 ]; then
103 scratch
="$(get_temp scratch)"
104 printf '%s\n' "$name" >"$scratch"
105 dependents
="$(get_temp dependents_list)"
106 $tg summary
--deps |
sort -k2,2 |
join -1 2 - "$scratch" | cut
-d ' ' -f 2 |
sort -u >"$dependents"
107 if ! [ -s "$dependents" ]; then
108 echo "Dependents: [none]"
110 if [ "${verbose:-0}" -le 1 ]; then
111 sed '1{ s/^/Dependents: /; n; }; s/^/ /;' <"$dependents"
114 while read -r endent
; do
115 [ ${#endent} -le $minwidth ] || minwidth
=${#endent}
118 while read -r endent
; do
120 contained_by
"refs/heads/$name" "refs/$topbases/$endent" || ood
=1
121 if [ -n "$ood" ]; then
122 printf '%s %-*s [needs merge]\n' "$prefix" $minwidth "$endent"
124 printf '%s %s\n' "$prefix" "$endent"
132 if [ -n "$nocommits" ]; then
137 echo "Base: $base_rev"
138 branch_contains
"refs/heads/$name" "refs/$topbases/$name" ||
139 echo "* Base is newer than head! Please run \`$tgdisplay update\`."
141 if has_remote
"$name"; then
142 echo "Remote Mate: $base_remote/$name"
143 branch_contains
"refs/$topbases/$name" "refs/remotes/$base_remote/${topbases#heads/}/$name" ||
144 echo "* Local base is out of date wrt. the remote base."
145 branch_contains
"refs/heads/$name" "refs/remotes/$base_remote/$name" ||
146 echo "* Local head is out of date wrt. the remote head."
147 branch_contains
"refs/remotes/$base_remote/$name" "refs/heads/$name" ||
148 echo "* Local head is ahead of the remote head."
151 git cat-file blob
"$name:.topdeps" 2>/dev
/null |
152 sed '1{ s/^/Depends: /; n; }; s/^/ /;'
154 depcheck
="$(get_temp tg-depcheck)"
156 needs_update
"$name" >"$depcheck" ||
:
157 if [ -n "$missing_deps" ]; then
158 echo "MISSING: $missing_deps"
160 depcheck2
="$(get_temp tg-depcheck2)"
161 sed '/^!/d' <"$depcheck" >"$depcheck2"
162 if [ -s "$depcheck2" ]; then
163 echo "Needs update from:"
164 # 's/ [^ ]* *$//' -- last is $name
165 # 's/^[:] /:/' -- don't distinguish base updates
166 <"$depcheck2" sed -e 's/ [^ ]* *$//' -e 's/^[:] /:/' |
167 while read dep chain
; do
171 fulldep
="refs/heads/$dep"
172 extradep
="refs/$topbases/$dep"
180 fulldep
="refs/heads/$dep";;
185 [ -n "$chain" ] && printf '%s' "(<= $(echol "$chain" | sed 's/ / <= /')) "
186 printf '%s' "($(eval measure_branch '"$fulldep"' '"refs
/heads
/$name"' ${extradep:+\"\$extradep\"}))"
190 echo "Up-to-date${missing_deps:+ (except for missing dependencies)}."