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

[StGit PATCH 2/2] Fix "stg sink" with no applied patches (bug 11887)

From
Karl Hasselström <kha@treskal.com>
Date
Jun 29, 2008, 22:45 UTC
Message-ID
<20080629224547.9267.92299.stgit@yoghurt>
In-Reply-To
<20080629224440.9267.3591.stgit@yoghurt>

There were two separate things to fix: bail out if we need a current patch and there isn't one (because there are no applied patches), and make sure we don't try to pop patches that don't exist.

Signed-off-by: Karl Hasselström <kha@treskal.com>
---
 stgit/commands/sink.py |    8 ++++++--
 t/t1501-sink.sh        |    2 +-
 2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/stgit/commands/sink.py b/stgit/commands/sink.py
index 2167d87..d8f79b4 100644
--- a/stgit/commands/sink.py
+++ b/stgit/commands/sink.py
@@ -58,9 +58,13 @@ def func(parser, options, args):
     if len(args) > 0:
         patches = parse_patches(args, all)
     else:
-        patches = [ crt_series.get_current() ]
+        current = crt_series.get_current()
+        if not current:
+            raise CmdException('No patch applied')
+        patches = [current]
 
-    crt_series.pop_patch(options.to or oldapplied[0])
+    if oldapplied:
+        crt_series.pop_patch(options.to or oldapplied[0])
     push_patches(crt_series, patches)
 
     if not options.nopush:
diff --git a/t/t1501-sink.sh b/t/t1501-sink.sh
index 3872c4b..6af45fe 100755
--- a/t/t1501-sink.sh
+++ b/t/t1501-sink.sh
@@ -20,7 +20,7 @@ test_expect_success 'sink without applied patches' '
     ! stg sink
 '
 
-test_expect_failure 'sink a specific patch without applied patches' '
+test_expect_success 'sink a specific patch without applied patches' '
     stg sink y &&
     test $(echo $(stg applied)) = "y"
 '
Previous: Karl Hasselström
Message 5 of 5 in “Test+fix for bug 11887 (stg sink)”
  1. 0/2 Test+fix for bug 11887 (stg sink)Karl Hasselström, Jun 29, 2008
  2. 1/2 Try "stg sink" without applied patchesKarl Hasselström, Jun 29, 2008
  3. Sverre RabbelierJun 30, 2008
  4. Karl HasselströmJun 30, 2008
  5. 2/2 Fix "stg sink" with no applied patches (bug 11887)Karl Hasselström, Jun 29, 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.