{"thread":{"id":"43114","subject":"[PATCH] Fixes \"stg goto `stg top`\" to no-op & test","startedAt":"2006-10-27T23:15:42Z","lastAt":"2006-10-28T10:52:42Z","messageCount":2,"participants":["Ilpo Järvinen"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"293864","messageId":"Pine.LNX.4.64.0610280156320.26765@kivilampi-30.cs.helsinki.fi","threadId":"43114","inReplyTo":null,"subject":"[PATCH] Fixes \"stg goto `stg top`\" to no-op & test","fromName":"Ilpo Järvinen","fromEmail":"ilpo.jarvinen@helsinki.fi","sentAt":"2006-10-27T23:15:42Z","receivedAt":"2006-10-27T23:15:42Z","isPatch":true,"sender":{"key":"ilpo.jarvinen@helsinki.fi","avatar":null},"body":"StGIT tried to access index that is not valid when goto'ing to\nthe current patch. Adds also a test for it.\n\nSigned-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>\n---\n stgit/commands/common.py |   17 ++++++++++-------\n t/t1600-goto-top.sh      |   32 ++++++++++++++++++++++++++++++++\n 2 files changed, 42 insertions(+), 7 deletions(-)\n\ndiff --git a/stgit/commands/common.py b/stgit/commands/common.py\nindex 1ea6025..88b1b94 100644\n--- a/stgit/commands/common.py\n+++ b/stgit/commands/common.py\n@@ -200,16 +200,19 @@ def pop_patches(patches, keep = False):\n     \"\"\"Pop the patches in the list from the stack. It is assumed that\n     the patches are listed in the stack reverse order.\n     \"\"\"\n-    p = patches[-1]\n-    if len(patches) == 1:\n-        print 'Popping patch \"%s\"...' % p,\n+    if len(patches) == 0:\n+        print 'nothing to push/pop'\n     else:\n-        print 'Popping \"%s\" - \"%s\" patches...' % (patches[0], p),\n-    sys.stdout.flush()\n+        p = patches[-1]\n+        if len(patches) == 1:\n+            print 'Popping patch \"%s\"...' % p,\n+        else:\n+            print 'Popping \"%s\" - \"%s\" patches...' % (patches[0], p),\n+        sys.stdout.flush()\n \n-    crt_series.pop_patch(p, keep)\n+        crt_series.pop_patch(p, keep)\n \n-    print 'done'\n+        print 'done'\n \n def parse_patches(patch_args, patch_list):\n     \"\"\"Parse patch_args list for patch names in patch_list and return\ndiff --git a/t/t1600-goto-top.sh b/t/t1600-goto-top.sh\nnew file mode 100755\nindex 0000000..94a88cf\n--- /dev/null\n+++ b/t/t1600-goto-top.sh\n@@ -0,0 +1,32 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2006 Catalin Marinas\n+#\n+\n+test_description='Test the uncommit command.\n+\n+'\n+\n+. ./test-lib.sh\n+\n+test_expect_success \\\n+\t'Initialize the StGIT repository' \\\n+\t'stg init\n+'\n+\n+test_expect_success \\\n+\t'Create the first patch' \\\n+\t'\n+\tstg new foo -m \"Foo Patch\" &&\n+\techo foo > test &&\n+\tstg add test &&\n+\tstg refresh\n+\t'\n+\n+test_expect_success \\\n+\t'Goto current patch' \\\n+\t'\n+\tstg goto `stg top`\n+\t'\n+\n+test_done\n-- \n1.4.2\n"},{"id":"296672","messageId":"Pine.LNX.4.64.0610281348270.27259@kivilampi-30.cs.helsinki.fi","threadId":"43114","inReplyTo":"Pine.LNX.4.64.0610280156320.26765@kivilampi-30.cs.helsinki.fi","subject":"[PATCH v2] Fixes \"stg goto `stg top`\" to no-op & adds test","fromName":"Ilpo Järvinen","fromEmail":"ilpo.jarvinen@helsinki.fi","sentAt":"2006-10-28T10:52:42Z","receivedAt":"2006-10-28T10:52:42Z","isPatch":true,"sender":{"key":"ilpo.jarvinen@helsinki.fi","avatar":null},"body":"Please forgive me that didn't read the test metadata through while \nproducing the last patch. This time also it should be correct...\n\nStGIT tried to access index that is not valid when goto'ing to\nthe current patch. Adds also a test for it.\n\nSigned-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>\n---\n stgit/commands/common.py |   17 ++++++++++-------\n t/t1600-goto-top.sh      |   32 ++++++++++++++++++++++++++++++++\n 2 files changed, 42 insertions(+), 7 deletions(-)\n\ndiff --git a/stgit/commands/common.py b/stgit/commands/common.py\nindex 1ea6025..88b1b94 100644\n--- a/stgit/commands/common.py\n+++ b/stgit/commands/common.py\n@@ -200,16 +200,19 @@ def pop_patches(patches, keep = False):\n     \"\"\"Pop the patches in the list from the stack. It is assumed that\n     the patches are listed in the stack reverse order.\n     \"\"\"\n-    p = patches[-1]\n-    if len(patches) == 1:\n-        print 'Popping patch \"%s\"...' % p,\n+    if len(patches) == 0:\n+        print 'nothing to push/pop'\n     else:\n-        print 'Popping \"%s\" - \"%s\" patches...' % (patches[0], p),\n-    sys.stdout.flush()\n+        p = patches[-1]\n+        if len(patches) == 1:\n+            print 'Popping patch \"%s\"...' % p,\n+        else:\n+            print 'Popping \"%s\" - \"%s\" patches...' % (patches[0], p),\n+        sys.stdout.flush()\n \n-    crt_series.pop_patch(p, keep)\n+        crt_series.pop_patch(p, keep)\n \n-    print 'done'\n+        print 'done'\n \n def parse_patches(patch_args, patch_list):\n     \"\"\"Parse patch_args list for patch names in patch_list and return\ndiff --git a/t/t1600-goto-top.sh b/t/t1600-goto-top.sh\nnew file mode 100755\nindex 0000000..618ebc7\n--- /dev/null\n+++ b/t/t1600-goto-top.sh\n@@ -0,0 +1,32 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2006 Ilpo Järvinen\n+#\n+\n+test_description='Test goto to the current patch.\n+\n+'\n+\n+. ./test-lib.sh\n+\n+test_expect_success \\\n+\t'Initialize the StGIT repository' \\\n+\t'stg init\n+'\n+\n+test_expect_success \\\n+\t'Create the first patch' \\\n+\t'\n+\tstg new foo -m \"Foo Patch\" &&\n+\techo foo > test &&\n+\tstg add test &&\n+\tstg refresh\n+\t'\n+\n+test_expect_success \\\n+\t'Goto current patch' \\\n+\t'\n+\tstg goto `stg top`\n+\t'\n+\n+test_done\n-- \n1.4.2\n"}]}