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"
24 while [ $# -gt 0 ]; do case "$1" in
35 echo "Unknown option: $1" >&2
42 [ "$heads$leaves" != "11" ] || die
"mutually exclusive options --heads and --leaves"
43 [ $# -gt 0 ] ||
set -- HEAD
44 [ $# -eq 1 ] || die
"name already specified ($1)"
47 # true if $1 is an ancestor of (or the same as) $2
50 [ "$(git rev-list --count --max-count=1 "$1" --not "$2" --)" = "0" ]
53 if [ -n "$heads" ]; then
55 ! test="$(verify_topgit_branch "${name:-HEAD}" -f)" || verify
="refs/heads/$test"
56 hash="$(git rev-parse --verify --quiet "$verify" --)" || die
"no such ref: $name"
57 $tg summary
--tgish-only --heads |
58 while read -r head; do
59 if is_ancestor
"$hash" "refs/heads/$head"; then
66 name
="$(verify_topgit_branch "${name:-HEAD}")"
67 if [ -n "$leaves" ]; then
71 base_rev
="$(git rev-parse --short --verify "refs
/$topbases/$name" -- 2>/dev/null)" ||
72 die
"not a TopGit-controlled branch"
74 measure
="$(measure_branch "refs
/heads
/$name" "$base_rev")"
76 echo "Topic Branch: $name ($measure)"
77 if [ "$(git rev-parse --verify --short "refs
/heads
/$name" --)" = "$base_rev" ]; then
82 git cat-file blob
"$name:.topmsg" |
grep ^Subject
: ||
:
84 echo "Base: $base_rev"
85 branch_contains
"refs/heads/$name" "refs/$topbases/$name" ||
86 echo "* Base is newer than head! Please run \`$tgdisplay update\`."
88 if has_remote
"$name"; then
89 echo "Remote Mate: $base_remote/$name"
90 branch_contains
"refs/$topbases/$name" "refs/remotes/$base_remote/${topbases#heads/}/$name" ||
91 echo "* Local base is out of date wrt. the remote base."
92 branch_contains
"refs/heads/$name" "refs/remotes/$base_remote/$name" ||
93 echo "* Local head is out of date wrt. the remote head."
94 branch_contains
"refs/remotes/$base_remote/$name" "refs/heads/$name" ||
95 echo "* Local head is ahead of the remote head."
98 git cat-file blob
"$name:.topdeps" 2>/dev
/null |
99 sed '1{ s/^/Depends: /; n; }; s/^/ /;'
101 depcheck
="$(get_temp tg-depcheck)"
103 needs_update
"$name" >"$depcheck" ||
:
104 if [ -n "$missing_deps" ]; then
105 echo "MISSING: $missing_deps"
107 depcheck2
="$(get_temp tg-depcheck2)"
108 sed '/^!/d' <"$depcheck" >"$depcheck2"
109 if [ -s "$depcheck2" ]; then
110 echo "Needs update from:"
111 # 's/ [^ ]* *$//' -- last is $name
112 # 's/^[:] /:/' -- don't distinguish base updates
113 <"$depcheck2" sed -e 's/ [^ ]* *$//' -e 's/^[:] /:/' |
114 while read dep chain
; do
118 fulldep
="refs/heads/$dep"
119 extradep
="refs/$topbases/$dep"
127 fulldep
="refs/heads/$dep";;
132 [ -n "$chain" ] && printf '%s' "(<= $(echol "$chain" | sed 's/ / <= /')) "
133 printf '%s' "($(eval measure_branch '"$fulldep"' '"refs
/heads
/$name"' ${extradep:+\"\$extradep\"}))"
137 echo "Up-to-date${missing_deps:+ (except for missing dependencies)}."