From: Karl Hasselström Date: Sun, 29 Jun 2008 22:45:47 GMT Subject: [StGit PATCH 2/2] Fix "stg sink" with no applied patches (bug 11887) 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 --- 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" '