-
Notifications
You must be signed in to change notification settings - Fork 7
/
tg-log.sh
70 lines (63 loc) · 1.48 KB
/
tg-log.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
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/sh
# TopGit - A different patch queue manager
# (c) Petr Baudis <[email protected]> 2008
# (c) Bert Wesarg <[email protected]> 2009
# GPLv2
name=
## Parse options
logcmd="log"
while [ -n "$1" ]; do
arg="$1"
case "$arg" in
--)
case "$2" in
-*)
shift; break;;
*)
break;;
esac;;
-|-h|--help)
echo "Usage: ${tgname:-tg} [...] log [--compact] [<name>] [--] [<git-log-option>...]" >&2
exit 1;;
--compact)
logcmd="log-compact";;
--command=?*)
logcmd="${arg#--command=}";;
-?*)
if v_verify_topgit_branch test "$arg" -f; then
[ -z "$name" ] || die "name already specified ($name)"
name="$arg"
else
break
fi;;
*)
[ -z "$name" ] || die "name already specified ($name)"
name="$arg";;
esac
shift
done
v_verify_topgit_branch name "${name:-HEAD}"
base_rev="$(git rev-parse --short --verify "refs/$topbases/$name^0" -- 2>/dev/null)" ||
die "not a TopGit-controlled branch"
depcnt="$(git cat-file blob "refs/heads/$name:.topdeps" 2>/dev/null | awk 'END {print NR}')"
nomerges=--no-merges
[ "$depcnt" -gt 0 ] || nomerges=
hasdd=
for a; do
[ "$a" != "--" ] || { hasdd=1; break; }
done
if [ -z "$hasdd" ]; then
git $logcmd --first-parent $nomerges "$@" "refs/$topbases/$name".."$name"
else
cmd='git $logcmd --first-parent $nomerges'
while [ $# -gt 0 ] && [ "$1" != "--" ]; do
cmd="$cmd $(quotearg "$1")"
shift
done
cmd="$cmd $(quotearg "refs/$topbases/$name".."$name")"
while [ $# -gt 0 ]; do
cmd="$cmd $(quotearg "$1")"
shift
done
eval "$cmd"
fi