4 # stg-gitk - helper script to graphically display an StGIT stack
6 # Displays given branches and stacks, without getting disturbed by
10 # - no support for spaces in branch names
12 # Copyright (c) 2007 Yann Dirson <ydirson@altern.org>
13 # Subject to the GNU GPL, version 2.
17 echo "Usage: $(basename $0) [<branches>|--all]"
23 while [ "$#" -gt 0 ]; do
26 --all) allbranches
=1 ;;
33 if [ $allbranches = 1 ] && [ "$#" -gt 0 ]; then
37 GIT_DIR
=$
(git-rev-parse
--git-dir)
38 GIT_DIR_SPKIPLEN
=$
(printf "$GIT_DIR/X" |
wc -c)
41 if [ $allbranches = 1 ]; then
42 refdirs
="$GIT_DIR/refs"
45 set -- "$(stg branch)"
49 if [ -e "$GIT_DIR/refs/patches/$b" ]; then
50 # StGIT branch: show all patches
51 refdirs
="$refdirs $GIT_DIR/refs/heads/$b $GIT_DIR/refs/patches/$b"
52 elif [ -e "$GIT_DIR/refs/heads/$b" ]; then
54 refdirs
="$refdirs $GIT_DIR/refs/heads/$b"
55 elif [ $
(git-for-each-ref
"refs/$b" |
wc -l) != 0 ]; then
57 refdirs
="$refdirs $(git-for-each-ref --format="$GIT_DIR/%(refname
)" "refs
/$b")"
59 echo >&2 "ERROR: no such ref '$b'"
67 find $refdirs -type f
-not -name '*.log' | cut
-c${GIT_DIR_SPKIPLEN}-
70 if [ $refsonly = 1 ]; then
72 elif grep -q -- --argscmd $
(which gitk
); then
73 # This gitk supports --argscmd.
74 # Let's use a hack to pass --all, which was consumed during command-line parsing
75 if [ $allbranches = 1 ]; then
76 gitk
--argscmd="$0 --refs --all"
78 gitk
--argscmd="$0 --refs $*"
81 # This gitk does not support --argscmd, just compute refs onces