git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[StGIT PATCH 7/7] If available, use gitk --argscmd in contrib/stg-gitk.

From
Yann Dirson <ydirson@altern.org>
Date
Jun 25, 2007, 21:24 UTC
Message-ID
<20070625212456.17189.87831.stgit@gandelf.nowhere.earth>
In-Reply-To
<20070625212229.17189.79919.stgit@gandelf.nowhere.earth>

This allows to ask gitk to recompute the list of patches to show at every refresh. Before this, we had problems with 'stg-gitk --all':

 - deleting a patch that was existing at startup time would trigger an
 "unknown ref" error from gitk and force to quit/restart manually;
 - patches created since startup were only visible when applied, or
 when below one of the startup patches.

Note that --argscmd is not in official gitk yet, so we don't try to use it if it's not available.

Signed-off-by: Yann Dirson <ydirson@altern.org>
---
 contrib/stg-gitk |   36 +++++++++++++++++++++++++++++-------
 1 files changed, 29 insertions(+), 7 deletions(-)
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 <ydirson@altern.org>
@@ -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
Previous: Yann Dirson
Message 8 of 8 in “My patchqueue for 0.13.”
  1. 0/7 My patchqueue for 0.13.Yann Dirson, Jun 25, 2007
  2. 1/7 Fix contrib/stg-whatchanged way of identifying a conflict.Yann Dirson, Jun 25, 2007
  3. 2/7 stg-cvs: update doc, and use correct setting for parent branch.Yann Dirson, Jun 25, 2007
  4. 3/7 Revert part of the reverted commit that we want to keep.Yann Dirson, Jun 25, 2007
  5. 4/7 Fixed thinko in error message.Yann Dirson, Jun 25, 2007
  6. 5/7 Changed sync not to use -b which has other semantics.Yann Dirson, Jun 25, 2007
  7. 6/7 Fix t1200 to catch intermediate errors.Yann Dirson, Jun 25, 2007
  8. 7/7 If available, use gitk --argscmd in contrib/stg-gitk.Yann Dirson, Jun 25, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.