All of lore.kernel.org
 help / color / mirror / Atom feed
* [StGit PATCH 0/2] stg delete --spill
@ 2008-09-21 19:07 Karl Hasselström
  2008-09-21 19:07 ` [StGit PATCH 1/2] Add a new flag, --spill, to stg delete Karl Hasselström
  2008-09-21 19:07 ` [StGit PATCH 2/2] Test the new stg delete --spill flag Karl Hasselström
  0 siblings, 2 replies; 3+ messages in thread
From: Karl Hasselström @ 2008-09-21 19:07 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git

---

Karl Hasselström (2):
      Test the new stg delete --spill flag
      Add a new flag, --spill, to stg delete


 stgit/commands/delete.py |   13 +++++++++++++
 t/t1602-delete-spill.sh  |   47 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 60 insertions(+), 0 deletions(-)
 create mode 100755 t/t1602-delete-spill.sh

-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [StGit PATCH 1/2] Add a new flag, --spill, to stg delete
  2008-09-21 19:07 [StGit PATCH 0/2] stg delete --spill Karl Hasselström
@ 2008-09-21 19:07 ` Karl Hasselström
  2008-09-21 19:07 ` [StGit PATCH 2/2] Test the new stg delete --spill flag Karl Hasselström
  1 sibling, 0 replies; 3+ messages in thread
From: Karl Hasselström @ 2008-09-21 19:07 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git

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:

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [StGit PATCH 2/2] Test the new stg delete --spill flag
  2008-09-21 19:07 [StGit PATCH 0/2] stg delete --spill Karl Hasselström
  2008-09-21 19:07 ` [StGit PATCH 1/2] Add a new flag, --spill, to stg delete Karl Hasselström
@ 2008-09-21 19:07 ` Karl Hasselström
  1 sibling, 0 replies; 3+ messages in thread
From: Karl Hasselström @ 2008-09-21 19:07 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git

Signed-off-by: Karl Hasselström <kha@treskal.com>

---

 t/t1602-delete-spill.sh |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 47 insertions(+), 0 deletions(-)
 create mode 100755 t/t1602-delete-spill.sh


diff --git a/t/t1602-delete-spill.sh b/t/t1602-delete-spill.sh
new file mode 100755
index 0000000..1ddec53
--- /dev/null
+++ b/t/t1602-delete-spill.sh
@@ -0,0 +1,47 @@
+#!/bin/sh
+test_description='Test "stg delete --spill"'
+. ./test-lib.sh
+
+test_expect_success 'Initialize the StGIT repository' '
+    stg init
+'
+
+test_expect_success 'Create five applied and three unapplied patches' '
+    for i in 0 1 2 3 4 5 6 7; do
+        echo $i >> foo &&
+        git add foo &&
+        git commit -m p$i
+    done
+    stg uncommit -n 8 &&
+    stg pop -n 3
+'
+
+test_expect_success 'Try to delete --spill an unapplied patch' '
+    command_error stg delete --spill p7 &&
+    test "$(echo $(stg series))" = "+ p0 + p1 + p2 + p3 > p4 - p5 - p6 - p7" &&
+    test "$(echo $(cat foo))" = "0 1 2 3 4" &&
+    test "$(echo $(git diff-files))" = ""
+'
+
+test_expect_success 'Try to delete --spill a non-top patch' '
+    command_error stg delete --spill p2 &&
+    test "$(echo $(stg series))" = "+ p0 + p1 + p2 + p3 > p4 - p5 - p6 - p7" &&
+    test "$(echo $(cat foo))" = "0 1 2 3 4" &&
+    test "$(echo $(git diff-files))" = ""
+'
+
+test_expect_success 'Delete --spill one patch' '
+    stg delete --spill p4 &&
+    test "$(echo $(stg series))" = "+ p0 + p1 + p2 > p3 - p5 - p6 - p7" &&
+    test "$(echo $(cat foo))" = "0 1 2 3 4" &&
+    test "$(echo $(git diff-files))" = ""
+'
+
+test_expect_success 'Delete --spill several patches' '
+    stg delete --spill p2 p3 p1 &&
+    test "$(echo $(stg series))" = "> p0 - p5 - p6 - p7" &&
+    test "$(echo $(cat foo))" = "0 1 2 3 4" &&
+    test "$(echo $(git diff-files))" = ""
+'
+
+test_done

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-09-21 19:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-21 19:07 [StGit PATCH 0/2] stg delete --spill Karl Hasselström
2008-09-21 19:07 ` [StGit PATCH 1/2] Add a new flag, --spill, to stg delete Karl Hasselström
2008-09-21 19:07 ` [StGit PATCH 2/2] Test the new stg delete --spill flag Karl Hasselström

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.