{"thread":{"id":"14213","subject":"[StGit PATCH 1/2] Try \"stg sink\" without applied patches","startedAt":"2008-06-29T22:45:35Z","lastAt":"2008-06-30T08:44:33Z","messageCount":5,"participants":["Karl Hasselström","Sverre Rabbelier"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"81680","messageId":"20080629224440.9267.3591.stgit@yoghurt","threadId":"14213","inReplyTo":null,"subject":"[StGit PATCH 0/2] Test+fix for bug 11887 (stg sink)","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2008-06-29T22:45:35Z","receivedAt":"2008-06-29T22:45:35Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"This should go on the stable branch, of course.\n\n---\n\nKarl Hasselström (2):\n      Fix \"stg sink\" with no applied patches (bug 11887)\n      Try \"stg sink\" without applied patches\n\n\n stgit/commands/sink.py |    8 ++++++--\n t/t1501-sink.sh        |   28 ++++++++++++++++++++++++++++\n 2 files changed, 34 insertions(+), 2 deletions(-)\n create mode 100755 t/t1501-sink.sh\n\n-- \nKarl Hasselström, kha@treskal.com\n      www.treskal.com/kalle\n"},{"id":"81679","messageId":"20080629224541.9267.19258.stgit@yoghurt","threadId":"14213","inReplyTo":"20080629224440.9267.3591.stgit@yoghurt","subject":"[StGit PATCH 1/2] Try \"stg sink\" without applied patches","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2008-06-29T22:45:41Z","receivedAt":"2008-06-29T22:45:41Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"It doesn't work, neither with an implicit nor an explicit patch to\nsink. This is bug 11887 in the bug tracker.\n\n(The implicit sink testcase actually passes, but that's just because\nthe test suite can't distinguish between a program bug and an orderly\nabort.)\n\nThe test was adapted from the script attached to the bug report,\nwritten by Erik Sandberg.\n\nSigned-off-by: Karl Hasselström <kha@treskal.com>\n\n---\n\n t/t1501-sink.sh |   28 ++++++++++++++++++++++++++++\n 1 files changed, 28 insertions(+), 0 deletions(-)\n create mode 100755 t/t1501-sink.sh\n\n\ndiff --git a/t/t1501-sink.sh b/t/t1501-sink.sh\nnew file mode 100755\nindex 0000000..3872c4b\n--- /dev/null\n+++ b/t/t1501-sink.sh\n@@ -0,0 +1,28 @@\n+#!/bin/sh\n+\n+test_description='Test \"stg sink\"'\n+\n+. ./test-lib.sh\n+\n+test_expect_success 'Initialize StGit stack' '\n+    echo 000 >> x &&\n+    git add x &&\n+    git commit -m initial &&\n+    echo 000 >> y &&\n+    git add y &&\n+    git commit -m y &&\n+    stg init &&\n+    stg uncommit &&\n+    stg pop\n+'\n+\n+test_expect_success 'sink without applied patches' '\n+    ! stg sink\n+'\n+\n+test_expect_failure 'sink a specific patch without applied patches' '\n+    stg sink y &&\n+    test $(echo $(stg applied)) = \"y\"\n+'\n+\n+test_done\n"},{"id":"81681","messageId":"20080629224547.9267.92299.stgit@yoghurt","threadId":"14213","inReplyTo":"20080629224440.9267.3591.stgit@yoghurt","subject":"[StGit PATCH 2/2] Fix \"stg sink\" with no applied patches (bug 11887)","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2008-06-29T22:45:47Z","receivedAt":"2008-06-29T22:45:47Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"There were two separate things to fix: bail out if we need a current\npatch and there isn't one (because there are no applied patches), and\nmake sure we don't try to pop patches that don't exist.\n\nSigned-off-by: Karl Hasselström <kha@treskal.com>\n\n---\n\n stgit/commands/sink.py |    8 ++++++--\n t/t1501-sink.sh        |    2 +-\n 2 files changed, 7 insertions(+), 3 deletions(-)\n\n\ndiff --git a/stgit/commands/sink.py b/stgit/commands/sink.py\nindex 2167d87..d8f79b4 100644\n--- a/stgit/commands/sink.py\n+++ b/stgit/commands/sink.py\n@@ -58,9 +58,13 @@ def func(parser, options, args):\n     if len(args) > 0:\n         patches = parse_patches(args, all)\n     else:\n-        patches = [ crt_series.get_current() ]\n+        current = crt_series.get_current()\n+        if not current:\n+            raise CmdException('No patch applied')\n+        patches = [current]\n \n-    crt_series.pop_patch(options.to or oldapplied[0])\n+    if oldapplied:\n+        crt_series.pop_patch(options.to or oldapplied[0])\n     push_patches(crt_series, patches)\n \n     if not options.nopush:\ndiff --git a/t/t1501-sink.sh b/t/t1501-sink.sh\nindex 3872c4b..6af45fe 100755\n--- a/t/t1501-sink.sh\n+++ b/t/t1501-sink.sh\n@@ -20,7 +20,7 @@ test_expect_success 'sink without applied patches' '\n     ! stg sink\n '\n \n-test_expect_failure 'sink a specific patch without applied patches' '\n+test_expect_success 'sink a specific patch without applied patches' '\n     stg sink y &&\n     test $(echo $(stg applied)) = \"y\"\n '\n"},{"id":"81728","messageId":"bd6139dc0806300053m4325104dx145cd8840c630453@mail.gmail.com","threadId":"14213","inReplyTo":"20080629224541.9267.19258.stgit@yoghurt","subject":"Re: [StGit PATCH 1/2] Try \"stg sink\" without applied patches","fromName":"Sverre Rabbelier","fromEmail":"alturin@gmail.com","sentAt":"2008-06-30T07:53:22Z","receivedAt":"2008-06-30T07:53:22Z","isPatch":true,"sender":{"key":"alturin@gmail.com","avatar":null},"body":"On Mon, Jun 30, 2008 at 12:45 AM, Karl Hasselström <kha@treskal.com> wrote:\n> (The implicit sink testcase actually passes, but that's just because\n> the test suite can't distinguish between a program bug and an orderly\n> abort.)\n\nYes it can, that's where \"test_must_fail\" comes in.\n\n<snip>\n\n> +test_expect_success 'sink without applied patches' '\n> +    test_must_fail stg sink\n> +'\n> +\n\nLike that.\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"81730","messageId":"20080630084433.GA20712@diana.vm.bytemark.co.uk","threadId":"14213","inReplyTo":"bd6139dc0806300053m4325104dx145cd8840c630453@mail.gmail.com","subject":"Re: [StGit PATCH 1/2] Try \"stg sink\" without applied patches","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2008-06-30T08:44:33Z","receivedAt":"2008-06-30T08:44:33Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"On 2008-06-30 09:53:22 +0200, Sverre Rabbelier wrote:\n\n> On Mon, Jun 30, 2008 at 12:45 AM, Karl Hasselström <kha@treskal.com> wrote:\n>\n> > (The implicit sink testcase actually passes, but that's just\n> > because the test suite can't distinguish between a program bug and\n> > an orderly abort.)\n>\n> Yes it can, that's where \"test_must_fail\" comes in.\n>\n> > +test_expect_success 'sink without applied patches' '\n> > +    test_must_fail stg sink\n> > +'\n> > +\n>\n> Like that.\n\nWell, except that\n\n  1. test_must_fail doesn't even exist in StGit's test-lib.sh, because\n     I've omitted it on purpose when stealing good stuff from git's\n     test-lib.sh, because\n\n  2. StGit is written in Python, so random bugs virtually never cause\n     segfaults and stuff, they just raise various exceptions.\n\nThat said, StGit (especially in the master branch -- but this patch\nwas against stable, where this is much less true) does exit with\ndifferent exit codes depending on what kind of exception interrupted\nthe program, and all exceptions not on a certain list cause it to exit\nwith an exit code that means there's a bug (see the end of\nstgit/main.py for details). So writing a test_must_fail with sane\nbehavior is perfectly doable and not actually all that hard.\n\nPatch? :-)\n\n-- \nKarl Hasselström, kha@treskal.com\n      www.treskal.com/kalle\n"}]}