{"thread":{"id":"8377","subject":"[StGIT RFC PATCH] Add contrib/stg-k script.","startedAt":"2007-05-31T18:54:29Z","lastAt":"2007-05-31T18:54:29Z","messageCount":1,"participants":["Yann Dirson"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"43690","messageId":"20070531184957.16258.55617.stgit@gandelf.nowhere.earth","threadId":"8377","inReplyTo":null,"subject":"[StGIT RFC PATCH] Add contrib/stg-k script.","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2007-05-31T18:54:29Z","receivedAt":"2007-05-31T18:54:29Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"\nSigned-off-by: Yann Dirson <ydirson@altern.org>\n---\n\nThis patch mainly adds a contrib script that allows to execute given\nStGIT command while preserving local changes.  It is surely not\nfool-proof in itself yet.\n\nIt relies on another small script which removes the current patch from\nthe stack, keeping its contents as uncommitted changes.  I named it\n\"stg-unnew\" because under a very particular angle it may look like\nreversing the \"stg new\" operation - but I'm highly dissatisfied with\nthat name, and would gladly accept any sensible suggestion to rename\nit :)\n\n contrib/stg-k     |   32 ++++++++++++++++++++++++++++++++\n contrib/stg-unnew |   15 +++++++++++++++\n 2 files changed, 47 insertions(+), 0 deletions(-)\n\ndiff --git a/contrib/stg-k b/contrib/stg-k\nnew file mode 100755\nindex 0000000..0134c25\n--- /dev/null\n+++ b/contrib/stg-k\n@@ -0,0 +1,32 @@\n+#!/bin/sh\n+set -e\n+\n+# stg-k - execute given StGIT command while preserving local changes\n+\n+# Uses a temporary patch to save local changes, then execute the given\n+# command, and restore local changes from the saved patch.  In\n+# essence, \"stg-k pop\" is a \"stg pop -k\" that works better, hence its\n+# name.\n+\n+# CAVEAT: this script relies on the operation to run ignoring hidden\n+# patches, so in 0.12 (where \"stg push\" can push an hidden patch)\n+# \"stg-k push\" will fail midway, albeit with no information loss -\n+# you'll just have to finish manually.  Luckilly this appears to work\n+# on master branch.\n+\n+# Copyright (c) 2007 Yann Dirson <ydirson@altern.org>\n+# Subject to the GNU GPL, version 2.\n+\n+stg new __local -m \" - local changes (internal patch)\"\n+stg refresh\n+stg pop\n+\n+# avoid bad interactions like \"stg-k push\" not behaving as expected\n+stg hide __local\n+\n+stg \"$@\"\n+\n+stg unhide __local\n+\n+stg push __local\n+stg-unnew\ndiff --git a/contrib/stg-unnew b/contrib/stg-unnew\nnew file mode 100755\nindex 0000000..5ac8781\n--- /dev/null\n+++ b/contrib/stg-unnew\n@@ -0,0 +1,15 @@\n+#!/bin/sh\n+set -e\n+\n+# stg-unnew - sort of \"reverse an 'stg new'\"\n+\n+# Remove the current patch from the stack, keeping its contents as\n+# uncommitted changes.\n+\n+# Copyright (c) 2007 Yann Dirson <ydirson@altern.org>\n+# Subject to the GNU GPL, version 2.\n+\n+patch=$(stg top)\n+stg pop\n+stg pick --fold $patch\n+stg delete $patch\n"}]}