Git development
 help / color / mirror / Atom feed
From: Yann Dirson <ydirson@altern.org>
To: Catalin Marinas <catalin.marinas@gmail.com>
Cc: git@vger.kernel.org
Subject: [StGIT RFC PATCH] Add contrib/stg-k script.
Date: Thu, 31 May 2007 20:54:29 +0200	[thread overview]
Message-ID: <20070531184957.16258.55617.stgit@gandelf.nowhere.earth> (raw)


Signed-off-by: Yann Dirson <ydirson@altern.org>
---

This patch mainly adds a contrib script that allows to execute given
StGIT command while preserving local changes.  It is surely not
fool-proof in itself yet.

It relies on another small script which removes the current patch from
the stack, keeping its contents as uncommitted changes.  I named it
"stg-unnew" because under a very particular angle it may look like
reversing the "stg new" operation - but I'm highly dissatisfied with
that name, and would gladly accept any sensible suggestion to rename
it :)

 contrib/stg-k     |   32 ++++++++++++++++++++++++++++++++
 contrib/stg-unnew |   15 +++++++++++++++
 2 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/contrib/stg-k b/contrib/stg-k
new file mode 100755
index 0000000..0134c25
--- /dev/null
+++ b/contrib/stg-k
@@ -0,0 +1,32 @@
+#!/bin/sh
+set -e
+
+# stg-k - execute given StGIT command while preserving local changes
+
+# Uses a temporary patch to save local changes, then execute the given
+# command, and restore local changes from the saved patch.  In
+# essence, "stg-k pop" is a "stg pop -k" that works better, hence its
+# name.
+
+# CAVEAT: this script relies on the operation to run ignoring hidden
+# patches, so in 0.12 (where "stg push" can push an hidden patch)
+# "stg-k push" will fail midway, albeit with no information loss -
+# you'll just have to finish manually.  Luckilly this appears to work
+# on master branch.
+
+# Copyright (c) 2007 Yann Dirson <ydirson@altern.org>
+# Subject to the GNU GPL, version 2.
+
+stg new __local -m " - local changes (internal patch)"
+stg refresh
+stg pop
+
+# avoid bad interactions like "stg-k push" not behaving as expected
+stg hide __local
+
+stg "$@"
+
+stg unhide __local
+
+stg push __local
+stg-unnew
diff --git a/contrib/stg-unnew b/contrib/stg-unnew
new file mode 100755
index 0000000..5ac8781
--- /dev/null
+++ b/contrib/stg-unnew
@@ -0,0 +1,15 @@
+#!/bin/sh
+set -e
+
+# stg-unnew - sort of "reverse an 'stg new'"
+
+# Remove the current patch from the stack, keeping its contents as
+# uncommitted changes.
+
+# Copyright (c) 2007 Yann Dirson <ydirson@altern.org>
+# Subject to the GNU GPL, version 2.
+
+patch=$(stg top)
+stg pop
+stg pick --fold $patch
+stg delete $patch

                 reply	other threads:[~2007-05-31 18:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20070531184957.16258.55617.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