X-Git-Url: https://git.distorted.org.uk/~mdw/stgit/blobdiff_plain/cdd071ff33c6197a7c860b44be04c0614c4a0dab..d0c5824b591c3e99d693cffbefc777d6bd7c2ccb:/contrib/stg-gitk diff --git a/contrib/stg-gitk b/contrib/stg-gitk index dd01ef0..6ddcfb1 100755 --- a/contrib/stg-gitk +++ b/contrib/stg-gitk @@ -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 @@ -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