From: Yann Dirson <ydirson@altern.org>
To: Catalin Marinas <catalin.marinas@gmail.com>
Cc: git@vger.kernel.org
Subject: [StGIT PATCH 2/6] New contrib scripts: stg-dispatch and stg-show.
Date: Thu, 02 Aug 2007 22:18:21 +0200 [thread overview]
Message-ID: <20070802201821.16614.87841.stgit@gandelf.nowhere.earth> (raw)
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[@]}"
next prev parent reply other threads:[~2007-08-02 20:19 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-02 20:18 [StGIT PATCH 0/6] Various contrib/ updates Yann Dirson
2007-08-02 20:18 ` [StGIT PATCH 1/6] Improve stg-fold-files-from doc Yann Dirson
2007-08-02 20:18 ` Yann Dirson [this message]
2007-08-02 20:18 ` [StGIT PATCH 3/6] Add -O flag to stg-fold-files-from Yann Dirson
2007-08-02 20:18 ` [StGIT PATCH 4/6] Add a no-act flag to stg-dispatch and stg-fold-file-from Yann Dirson
2007-08-02 20:18 ` [StGIT PATCH 5/6] Provide file completion for add/resolved/refresh based on status Yann Dirson
2007-08-02 20:18 ` [StGIT PATCH 6/6] Fixed completion function hardcoding .git/ Yann Dirson
2007-08-20 17:24 ` [StGIT PATCH 0/6] Various contrib/ updates Catalin Marinas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070802201821.16614.87841.stgit@gandelf.nowhere.earth \
--to=ydirson@altern.org \
--cc=catalin.marinas@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).