chiark / gitweb /
gitk wrapper
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 11 Aug 2018 08:44:05 +0000 (09:44 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 11 Aug 2018 08:44:05 +0000 (09:44 +0100)
scripts/gitk [new file with mode: 0755]

diff --git a/scripts/gitk b/scripts/gitk
new file mode 100755 (executable)
index 0000000..8b84b3b
--- /dev/null
@@ -0,0 +1,74 @@
+#!/bin/bash
+set -e
+
+defshow=' '
+showopt () {
+       eval "showopt_$1=$2"
+}
+defshow () {
+       showopt $1 $2
+       eval "defshow+='$2 '"
+}
+defshow        B --branches
+defshow        R --remotes
+showopt        T --tags
+showopt        A --all
+
+opts=()
+
+getshowopt () {
+       eval "showopt=\$showopt_$1"
+}
+
+while [ $# -ge 1 ]; do case "$1" in
+
+       +)      shift; defshow=''; break ;; # disable defshow
+
+       --)
+               # remaining args are paths, but we want default showing
+               break
+               ;;
+       -*)
+               # some gitk option, stop parsing
+               # user may have to say + to disable default showing
+               break
+               ;;
+
+       +*)
+               arg="$1"; shift
+               while true; do
+
+                       case "$arg" in
+       
+                       +[BRTA]*)
+                               getshowopt ${arg:1:1}
+                               defshow=''; opts+=($showopt)
+                       ;;
+                       +-[BRTA]*)
+                               getshowopt ${arg:2:1}
+                               defshow="${defshow/ $showopt / }"
+                               arg="${arg#+-?}"; continue
+                               ;;
+
+                       +d*)    opts+=(--date-order) ;;
+                       +f*)    opts+=(--first-parent) ;;       
+
+                       +)      break ;;
+
+                       *)      echo >&2 "gitk wrapper: unknown + option $arg"
+                               exit 127
+                               ;;
+
+                       esac
+
+                       arg="+${arg#+?}"
+               done
+               ;;
+
+       *)      defshow=''; break ;; # some instruction to gitk
+
+       esac
+done
+
+set -x
+exec /usr/bin/gitk "${opts[@]}" $defshow "$@"