chiark / gitweb /
If available, use gitk --argscmd in contrib/stg-gitk.
authorYann Dirson <ydirson@altern.org>
Mon, 25 Jun 2007 21:24:56 +0000 (23:24 +0200)
committerCatalin Marinas <catalin.marinas@gmail.com>
Mon, 25 Jun 2007 21:50:08 +0000 (22:50 +0100)
This allows to ask gitk to recompute the list of patches to show at
every refresh.  Before this, we had problems with 'stg-gitk --all':

 - deleting a patch that was existing at startup time would trigger an
 "unknown ref" error from gitk and force to quit/restart manually;
 - patches created since startup were only visible when applied, or
 when below one of the startup patches.

Note that --argscmd is not in official gitk yet, so we don't try to
use it if it's not available.

Signed-off-by: Yann Dirson <ydirson@altern.org>
contrib/stg-gitk

index dd01ef08811dee7c1625d5737524016551b80c92..6ddcfb1c321342eb6657eb2979dcd66f150abeab 100755 (executable)
@@ -7,7 +7,6 @@ set -e
 # patch logs.
 
 # LIMITATIONS:
-# - asking gitk to "update" won't detect any new ref
 # - no support for spaces in branch names
 
 # Copyright (c) 2007 Yann Dirson <ydirson@altern.org>
@@ -20,11 +19,16 @@ usage()
 }
 
 allbranches=0
-case "$1" in
---all) allbranches=1; shift ;;
---*) usage ;;
-*) break ;;
-esac
+refsonly=0
+while [ "$#" -gt 0 ]; do
+    case "$1" in
+       --refs) refsonly=1 ;;
+       --all) allbranches=1 ;;
+       --*) usage ;;
+       *) break ;;
+    esac
+    shift
+done
 
 if [ $allbranches = 1 ] && [ "$#" -gt 0 ]; then
     usage
@@ -58,4 +62,22 @@ else
     done
 fi
 
-gitk $(find $refdirs -type f -not -name '*.log' | cut -c${GIT_DIR_SPKIPLEN}- )
+printrefs()
+{
+    find $refdirs -type f -not -name '*.log' | cut -c${GIT_DIR_SPKIPLEN}-
+}
+
+if [ $refsonly = 1 ]; then
+    printrefs
+elif grep -q -- --argscmd $(which gitk); then
+    # This gitk supports --argscmd.
+    # Let's use a hack to pass --all, which was consumed during command-line parsing
+    if [ $allbranches = 1 ]; then
+       gitk --argscmd="$0 --refs --all"
+    else
+       gitk --argscmd="$0 --refs $*"
+    fi
+else
+    # This gitk does not support --argscmd, just compute refs onces
+    gitk $(printrefs)
+fi