chiark / gitweb /
git: cache insteadof disable for all protocols
[ian-dotfiles.git] / scripts / gitk+
1 #!/bin/bash
2 set -e
3
4 defshow=' '
5 showopt () {
6         eval "showopt_$1=$2"
7 }
8 defshow () {
9         showopt $1 $2
10         eval "defshow+='$2 '"
11 }
12 defshow B --branches
13 defshow R --remotes
14 showopt T --tags
15 showopt A --all
16
17 opts=()
18
19 getshowopt () {
20         eval "showopt=\$showopt_$1"
21 }
22
23 while [ $# -ge 1 ]; do case "$1" in
24
25         +)      shift; defshow=''; break ;; # disable defshow
26
27         --)
28                 # remaining args are paths, but we want default showing
29                 break
30                 ;;
31         -*)
32                 # some gitk option, stop parsing
33                 # user may have to say + to disable default showing
34                 break
35                 ;;
36
37         +*)
38                 arg="$1"; shift
39                 while true; do
40
41                         case "$arg" in
42         
43                         +[BRTA]*)
44                                 getshowopt ${arg:1:1}
45                                 defshow=''; opts+=($showopt)
46                         ;;
47                         +-[BRTA]*)
48                                 getshowopt ${arg:2:1}
49                                 defshow="${defshow/ $showopt / }"
50                                 arg="${arg#+-?}"; continue
51                                 ;;
52
53                         +d*)    opts+=(--date-order) ;;
54                         +f*)    opts+=(--first-parent) ;;       
55
56                         +)      break ;;
57
58                         *)      echo >&2 "gitk wrapper: unknown + option $arg"
59                                 exit 127
60                                 ;;
61
62                         esac
63
64                         arg="+${arg#+?}"
65                 done
66                 ;;
67
68         *)      defshow=''; break ;; # some instruction to gitk
69
70         esac
71 done
72
73 exec /usr/bin/gitk "${opts[@]}" $defshow "$@"