+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 $branches" "$@"
+ fi
+else
+ # This gitk does not support --argscmd, just compute refs onces
+ gitk $(printrefs) "$@"
+fi