{"thread":{"id":"8545","subject":"[StGIT PATCH not for master, v2] Use gitk --argscmd in contrib/stg-gitk.","startedAt":"2007-06-10T21:40:02Z","lastAt":"2007-06-10T21:40:02Z","messageCount":1,"participants":["Yann Dirson"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"44646","messageId":"20070610213717.11427.26780.stgit@gandelf.nowhere.earth","threadId":"8545","inReplyTo":null,"subject":"[StGIT PATCH not for master, v2] Use gitk --argscmd in contrib/stg-gitk.","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2007-06-10T21:40:02Z","receivedAt":"2007-06-10T21:40:02Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"This allows to ask gitk to recompute the list of patches to show at\nevery refresh.  Before this, we had problems with 'stg-gitk --all':\n\n - deleting a patch that was existing at startup time would trigger an\n \"unknown ref\" error from gitk and force to quit/restart manually;\n - patches created since startup were only visible when applied, or\n when below one of the startup patches.\n---\n\nThis version fixes a couple of glitches when using stg-gitk to display\nseveral branches simultaneously, introduced by the 1st version.  This\nis a sure sign that this script should be pythonized soon :)\n\nStill not to apply to master, since the gitk patch it depends has not\nbeen applied.\n\n contrib/stg-gitk |   32 +++++++++++++++++++++++++-------\n 1 files changed, 25 insertions(+), 7 deletions(-)\n\ndiff --git a/contrib/stg-gitk b/contrib/stg-gitk\nindex dd01ef0..c258caf 100755\n--- a/contrib/stg-gitk\n+++ b/contrib/stg-gitk\n@@ -7,7 +7,6 @@ set -e\n # patch logs.\n \n # LIMITATIONS:\n-# - asking gitk to \"update\" won't detect any new ref\n # - no support for spaces in branch names\n \n # Copyright (c) 2007 Yann Dirson <ydirson@altern.org>\n@@ -20,11 +19,16 @@ usage()\n }\n \n allbranches=0\n-case \"$1\" in\n---all) allbranches=1; shift ;;\n---*) usage ;;\n-*) break ;;\n-esac\n+refsonly=0\n+while [ \"$#\" -gt 0 ]; do\n+    case \"$1\" in\n+\t--refs) refsonly=1 ;;\n+\t--all) allbranches=1 ;;\n+\t--*) usage ;;\n+\t*) break ;;\n+    esac\n+    shift\n+done\n \n if [ $allbranches = 1 ] && [ \"$#\" -gt 0 ]; then\n     usage\n@@ -58,4 +62,18 @@ else\n     done\n fi\n \n-gitk $(find $refdirs -type f -not -name '*.log' | cut -c${GIT_DIR_SPKIPLEN}- )\n+printrefs()\n+{\n+    find $refdirs -type f -not -name '*.log' | cut -c${GIT_DIR_SPKIPLEN}-\n+}\n+\n+if [ $refsonly = 1 ]; then\n+    printrefs\n+else\n+    # let's use a hack to pass --all, which was consumed during command-line parsing\n+    if [ $allbranches = 1 ]; then\n+\tgitk --argscmd=\"$0 --refs --all\"\n+    else\n+\tgitk --argscmd=\"$0 --refs $*\"\n+    fi\n+fi\n"}]}