tg-summary.sh: default to HEAD for --rdeps but allow --all
[topgit/pro.git] / tg-log.sh
blob500c4841780856fc136264d4304d083ac743ae88
1 #!/bin/sh
2 # TopGit - A different patch queue manager
3 # (c) Petr Baudis <pasky@suse.cz> 2008
4 # (c) Bert Wesarg <Bert.Wesarg@googlemail.com> 2009
5 # GPLv2
7 name=
10 ## Parse options
12 while [ -n "$1" ]; do
13 arg="$1"
14 case "$arg" in
15 --)
16 case "$2" in
17 -*)
18 shift; break;;
20 break;;
21 esac;;
22 -|-h|--help)
23 echo "Usage: ${tgname:-tg} [...] log [<name>] [--] [<git-log-option>...]" >&2
24 exit 1;;
25 -?*)
26 if test="$(verify_topgit_branch "$arg" -f)"; then
27 [ -z "$name" ] || die "name already specified ($name)"
28 name="$arg"
29 else
30 break
31 fi;;
33 [ -z "$name" ] || die "name already specified ($name)"
34 name="$arg";;
35 esac
36 shift
37 done
39 quotearg() {
40 printf '%s' "$1" | sed 's/\(['\''!]\)/'\'\\\\\\1\''/g'
43 name="$(verify_topgit_branch "${name:-HEAD}")"
44 base_rev="$(git rev-parse --short --verify "refs/top-bases/$name" 2>/dev/null)" ||
45 die "not a TopGit-controlled branch"
47 hasdd=
48 for a; do
49 [ "$a" != "--" ] || { hasdd=1; break; }
50 done
51 if [ -z "$hasdd" ]; then
52 git log --first-parent --no-merges "$@" "refs/top-bases/$name".."$name"
53 else
54 cmd='git log --first-parent --no-merges'
55 while [ $# -gt 0 -a "$1" != "--" ]; do
56 cmd="$cmd '$(quotearg "$1")'"
57 shift
58 done
59 cmd="$cmd '$(quotearg "refs/top-bases/$name".."$name")'"
60 while [ $# -gt 0 ]; do
61 cmd="$cmd '$(quotearg "$1")'"
62 shift
63 done
64 eval "$cmd"