tg.sh: avoid modifying a symbolic link pre-commit hook
[topgit/pro.git] / tg-log.sh
blobdc3de571405ecb17cef607e963047cda4832386a
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 name="$(verify_topgit_branch "${name:-HEAD}")"
40 base_rev="$(git rev-parse --short --verify "refs/$topbases/$name" -- 2>/dev/null)" ||
41 die "not a TopGit-controlled branch"
43 hasdd=
44 for a; do
45 [ "$a" != "--" ] || { hasdd=1; break; }
46 done
47 if [ -z "$hasdd" ]; then
48 git log --first-parent --no-merges "$@" "refs/$topbases/$name".."$name"
49 else
50 cmd='git log --first-parent --no-merges'
51 while [ $# -gt 0 -a "$1" != "--" ]; do
52 cmd="$cmd $(quotearg "$1")"
53 shift
54 done
55 cmd="$cmd $(quotearg "refs/$topbases/$name".."$name")"
56 while [ $# -gt 0 ]; do
57 cmd="$cmd $(quotearg "$1")"
58 shift
59 done
60 eval "$cmd"