4 # stg-gitk - helper script to graphically display an StGIT stack
6 # Displays given branches and stacks, without getting disturbed by
10 # - asking gitk to "update" won't detect any new ref
11 # - no support for spaces in branch names
13 # Copyright (c) 2007 Yann Dirson <ydirson@altern.org>
14 # Subject to the GNU GPL, version 2.
18 echo "Usage: $(basename $0) [<branches>|--all]"
24 --all) allbranches
=1; shift ;;
29 if [ $allbranches = 1 ] && [ "$#" -gt 0 ]; then
33 GIT_DIR
=$
(git-rev-parse
--git-dir)
34 GIT_DIR_SPKIPLEN
=$
(printf "$GIT_DIR/X" |
wc -c)
37 if [ $allbranches = 1 ]; then
38 refdirs
="$GIT_DIR/refs"
41 set -- "$(stg branch)"
45 if [ -e "$GIT_DIR/refs/patches/$b" ]; then
46 # StGIT branch: show all patches
47 refdirs
="$refdirs $GIT_DIR/refs/heads/$b $GIT_DIR/refs/patches/$b"
48 elif [ -e "$GIT_DIR/refs/heads/$b" ]; then
50 refdirs
="$refdirs $GIT_DIR/refs/heads/$b"
51 elif [ $
(git-for-each-ref
"refs/$b" |
wc -l) != 0 ]; then
53 refdirs
="$refdirs $(git-for-each-ref --format="$GIT_DIR/%(refname
)" "refs
/$b")"
55 echo >&2 "ERROR: no such ref '$b'"
61 gitk $
(find $refdirs -type f
-not -name '*.log' | cut
-c${GIT_DIR_SPKIPLEN}- )