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

[StGIT PATCH 2/6] New contrib scripts: stg-dispatch and stg-show.

From
Yann Dirson <ydirson@altern.org>
Date
Aug 2, 2007, 20:18 UTC
Message-ID
<20070802201821.16614.87841.stgit@gandelf.nowhere.earth>
In-Reply-To
<20070802200704.16614.57993.stgit@gandelf.nowhere.earth>
From: Yann Dirson <yann.dirson@sagem.com>
Signed-off-by: Yann Dirson <ydirson@altern.org>
---
 contrib/stg-dispatch |   34 ++++++++++++++++++++++++++++++++++
 contrib/stg-show     |   27 +++++++++++++++++++++++++++
 2 files changed, 61 insertions(+), 0 deletions(-)
diff --git a/contrib/stg-dispatch b/contrib/stg-dispatch
new file mode 100755
index 0000000..8911946
--- /dev/null
+++ b/contrib/stg-dispatch
@@ -0,0 +1,34 @@
+#!/bin/sh
+set -e
+
+# stg-dispatch - percollates files matching a pattern down to another patch.
+# It does the same job as stg-fold-files-from (and makes use of it to
+# do so), but from the patch containing the changes to migrate,
+# instead of doing so from the target patch.
+
+# usage: stg-dispatch <topatch> [-#<n>[-<n>][,<n>]...] <file-pattern>
+
+# Copyright (c) 2007 Yann Dirson <ydirson@altern.org>
+# Subject to the GNU GPL, version 2.
+
+die()
+{
+    echo >&2 "$(basename $0) error: $*"
+    exit 1
+}
+
+TOPATCH="$1"
+shift
+
+stg applied | grep "^$TOPATCH\$" >/dev/null ||
+    die "cannot dispatch to unapplied patch '$TOPATCH'"
+
+CURRENTPATCH=$(stg top)
+
+[ "x$TOPATCH" != "x$CURRENTPATCH" ] ||
+    die "dispatching to current patch ($CURRENTPATCH) makes no sense"
+
+stg goto "$TOPATCH"
+stg-fold-files-from "$CURRENTPATCH" "$@"
+stg refresh
+stg goto "$CURRENTPATCH"
diff --git a/contrib/stg-show b/contrib/stg-show
new file mode 100755
index 0000000..8c61540
--- /dev/null
+++ b/contrib/stg-show
@@ -0,0 +1,27 @@
+#!/bin/bash
+set -e
+
+# stg-show - unlike "stg show", just "git show" with knowledge of stg refs
+
+# Ex:
+# stg-show --color-words -- files
+
+# Copyright (c) 2007 Yann Dirson <ydirson@altern.org>
+# Subject to the GNU GPL, version 2.
+
+command=(git show)
+
+# subsitute git id's for stg ones until --
+endofpatches=0
+while [ "$#" -gt 0 ]; do
+    case "$1" in
+	--) endofpatches=1; break ;;
+	-*) command+=("$1"); shift ;;
+	*) command+=( $(stg id "$1" 2>/dev/null || echo "$1") ); shift ;;
+    esac
+done
+
+# append remaining args
+command+=("$@")
+
+eval "${command[@]}"
Previous: Yann DirsonNext: Yann Dirson
Message 3 of 8 in “Various contrib/ updates”
  1. 0/6 Various contrib/ updatesYann Dirson, Aug 2, 2007
  2. 1/6 Improve stg-fold-files-from doc.Yann Dirson, Aug 2, 2007
  3. 2/6 New contrib scripts: stg-dispatch and stg-show.Yann Dirson, Aug 2, 2007
  4. 3/6 Add -O flag to stg-fold-files-from.Yann Dirson, Aug 2, 2007
  5. 4/6 Add a no-act flag to stg-dispatch and stg-fold-file-from.Yann Dirson, Aug 2, 2007
  6. 5/6 Provide file completion for add/resolved/refresh based on status.Yann Dirson, Aug 2, 2007
  7. 6/6 Fixed completion function hardcoding .git/.Yann Dirson, Aug 2, 2007
  8. Catalin MarinasAug 20, 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.