From cd65a83bcf40b7c991b359099d9a9a894ae7a696 Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Mon, 30 Jun 2008 00:36:24 +0200 Subject: [PATCH] Fix "stg sink" with no applied patches (bug 11887) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Organization: Straylight/Edgeware From: Karl Hasselström 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 --- 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" ' -- [mdw]