-
Notifications
You must be signed in to change notification settings - Fork 7
/
tg-base.sh
57 lines (50 loc) · 1.09 KB
/
tg-base.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/sh
# TopGit - A different patch queue manager
# (C) Petr Baudis <[email protected]> 2008
# (C) Per Cederqvist <[email protected]> 2010
# (C) Kyle J. McKay <[email protected]> 2017, 2021
# All rights reserved
# GPLv2
USAGE="\
Usage: ${tgname:-tg} [...] base [--short[=<n>] | --no-short] [--] [branch...]
Options:
--short[=<n>] display shortened hashes (default)
--no-short display full hashes"
usage()
{
if [ "${1:-0}" != 0 ]; then
printf '%s\n' "$USAGE" >&2
else
printf '%s\n' "$USAGE"
fi
exit ${1:-0}
}
## Parse options
short="--short"
while [ $# -gt 0 ]; do case "$1" in
-h|--help)
usage;;
--short|--short=*|--no-short)
short="$1";;
--)
shift
break;;
-?*)
die "unrecognized option: $1";;
*)
break;;
esac; shift; done
if [ "$#" -eq 0 ]; then
set -- HEAD
fi
rv=0
for rev in "$@"; do
[ "$rev" != "@" ] || rev="HEAD"
name="$(git symbolic-ref -q "$rev" 2>/dev/null)" || name="$rev"
v_strip_ref name "$name"
git rev-parse --verify $short "refs/$topbases/$name^0" -- 2>/dev/null || {
rv=1
echo "$rev is not a TopGit branch" >&2
}
done
exit $rv