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

[StGit PATCH 1/2] Add a new flag, --spill, to stg delete

From
Karl Hasselström <kha@treskal.com>
Date
Sep 21, 2008, 19:07 UTC
Message-ID
<20080921190730.4503.52714.stgit@yoghurt>
In-Reply-To
<20080921190708.4503.20574.stgit@yoghurt>

It deletes the patches as usual, but doesn't touch index+worktree. Useful for splitting up a patch, or undoing an "stg refresh".

Signed-off-by: Karl Hasselström <kha@treskal.com>
---
 stgit/commands/delete.py |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/stgit/commands/delete.py b/stgit/commands/delete.py
index 1b59cdd..015fb49 100644
--- a/stgit/commands/delete.py
+++ b/stgit/commands/delete.py
@@ -30,6 +30,13 @@ Delete the patches passed as arguments."""
 args = [argparse.patch_range(argparse.applied_patches,
                              argparse.unapplied_patches)]
 options = [
+    opt('--spill', action = 'store_true',
+        short = 'Spill patch contents to worktree and index', long = """
+        Delete the patches, but do not touch the index and worktree.
+        This only works with applied patches at the top of the stack.
+        The effect is to "spill" the patch contents into the index and
+        worktree. This can be useful e.g. if you want to split a patch
+        into several smaller pieces."""),
     opt('-b', '--branch', args = [argparse.stg_branches],
         short = 'Use BRANCH instead of the default branch')]
 
@@ -46,6 +53,12 @@ def func(parser, options, args):
         patches = set(common.parse_patches(args, list(stack.patchorder.all)))
     else:
         parser.error('No patches specified')
+
+    if options.spill:
+        if set(stack.patchorder.applied[-len(patches):]) != patches:
+            parser.error('Can only spill topmost applied patches')
+        iw = None # don't touch index+worktree
+
     def allow_conflicts(trans):
         # Allow conflicts if the topmost patch stays the same.
         if stack.patchorder.applied:
Previous: Karl HasselströmNext: Karl Hasselström
Message 2 of 3 in “stg delete --spill”
  1. 0/2 stg delete --spillKarl Hasselström, Sep 21, 2008
  2. 1/2 Add a new flag, --spill, to stg deleteKarl Hasselström, Sep 21, 2008
  3. 2/2 Test the new stg delete --spill flagKarl Hasselström, Sep 21, 2008

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.