chiark / gitweb /
Add 2 new contrib scripts.
authorYann Dirson <ydirson@altern.org>
Thu, 31 May 2007 22:34:23 +0000 (00:34 +0200)
committerCatalin Marinas <catalin.marinas@gmail.com>
Sat, 2 Jun 2007 22:41:14 +0000 (23:41 +0100)
Signed-off-by: Yann Dirson <ydirson@altern.org>
contrib/stg-k [new file with mode: 0755]
contrib/stg-unnew [new file with mode: 0755]

diff --git a/contrib/stg-k b/contrib/stg-k
new file mode 100755 (executable)
index 0000000..0134c25
--- /dev/null
@@ -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 (executable)
index 0000000..5ac8781
--- /dev/null
@@ -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