{"thread":{"id":"4272","subject":"A few stgit bugfixes","startedAt":"2006-05-24T06:05:37Z","lastAt":"2006-05-24T21:10:16Z","messageCount":5,"participants":["Karl Hasselström","Catalin Marinas"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"20608","messageId":"20060524060537.GA1173@diana.vm.bytemark.co.uk","threadId":"4272","inReplyTo":null,"subject":"A few stgit bugfixes","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2006-05-24T06:05:37Z","receivedAt":"2006-05-24T06:05:37Z","isPatch":false,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"Fixes for a few bugs recently introduced in stgit by yours truly.\n\n-- \nKarl Hasselström, kha@treskal.com\n      www.treskal.com/kalle\n"},{"id":"20609","messageId":"20060524060643.GA1490@diana.vm.bytemark.co.uk","threadId":"4272","inReplyTo":"20060524060537.GA1173@diana.vm.bytemark.co.uk","subject":"[PATCH 1/3] Fix infinite recursion on absolute paths","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2006-05-24T06:06:43Z","receivedAt":"2006-05-24T06:06:43Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"Calling create_dirs with an absolute path caused infinite recursion,\nsince os.path.dirname('/') == '/'. Fix this by exiting early if the\ngiven path already is a directory.\n---\n\n stgit/utils.py |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/stgit/utils.py b/stgit/utils.py\nindex 68b8f58..ed6e43c 100644\n--- a/stgit/utils.py\n+++ b/stgit/utils.py\n@@ -130,7 +130,7 @@ def remove_file_and_dirs(basedir, file):\n \n def create_dirs(directory):\n     \"\"\"Create the given directory, if the path doesn't already exist.\"\"\"\n-    if directory:\n+    if directory and not os.path.isdir(directory):\n         create_dirs(os.path.dirname(directory))\n         try:\n             os.mkdir(directory)\n"},{"id":"20610","messageId":"20060524060658.GB1490@diana.vm.bytemark.co.uk","threadId":"4272","inReplyTo":"20060524060537.GA1173@diana.vm.bytemark.co.uk","subject":"[PATCH 2/3] Fix indexing error during \"diff -r/\"","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2006-05-24T06:06:58Z","receivedAt":"2006-05-24T06:06:58Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"The string indexing when decoding the -r argument for diff made an\nimplicit assumption that the revision string was at least two\ncharacters long, which broke on the simple invocation \"diff -r/\".\n---\n\n stgit/commands/diff.py |    8 ++++----\n stgit/utils.py         |    6 ++++++\n 2 files changed, 10 insertions(+), 4 deletions(-)\n\ndiff --git a/stgit/commands/diff.py b/stgit/commands/diff.py\nindex d765784..caa3c5b 100644\n--- a/stgit/commands/diff.py\n+++ b/stgit/commands/diff.py\n@@ -56,11 +56,11 @@ def func(parser, options, args):\n         rev_list_len = len(rev_list)\n         if rev_list_len == 1:\n             rev = rev_list[0]\n-            if rev[-1] == '/':\n+            if rev.endswith('/'):\n                 # the whole patch\n-                rev = rev[:-1]\n-                if rev[-1] == '/':\n-                    rev = rev[:-1]\n+                rev = strip_suffix('/', rev)\n+                if rev.endswith('/'):\n+                    rev = strip_suffix('/', rev)\n                 rev1 = rev + '//bottom'\n                 rev2 = rev + '//top'\n             else:\ndiff --git a/stgit/utils.py b/stgit/utils.py\nindex ed6e43c..67431ec 100644\n--- a/stgit/utils.py\n+++ b/stgit/utils.py\n@@ -109,6 +109,12 @@ def strip_prefix(prefix, string):\n     assert string.startswith(prefix)\n     return string[len(prefix):]\n \n+def strip_suffix(suffix, string):\n+    \"\"\"Return string, without the suffix. Blow up if string doesn't\n+    end with suffix.\"\"\"\n+    assert string.endswith(suffix)\n+    return string[:-len(suffix)]\n+\n def remove_dirs(basedir, dirs):\n     \"\"\"Starting at join(basedir, dirs), remove the directory if empty,\n     and try the same with its parent, until we find a nonempty\n"},{"id":"20611","messageId":"20060524060721.GC1490@diana.vm.bytemark.co.uk","threadId":"4272","inReplyTo":"20060524060537.GA1173@diana.vm.bytemark.co.uk","subject":"[PATCH 3/3] Explicitly specify utf-8 coding in file","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2006-05-24T06:07:21Z","receivedAt":"2006-05-24T06:07:21Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"uncommit.py has a non-ascii character in it (in my name in the\ncopyright line). Without this coding: comment, I get an error like the\nfollowing when I run stgit:\n\n  /home/kha/git/stgit/stgit/main.py:61: DeprecationWarning: Non-ASCII\n  character '\\xc3' in file\n  /home/kha/git/stgit/stgit/commands/uncommit.py on line 3, but no\n  encoding declared; see http://www.python.org/peps/pep-0263.html for\n  details\n---\n\n stgit/commands/uncommit.py |    2 ++\n 1 files changed, 2 insertions(+), 0 deletions(-)\n\ndiff --git a/stgit/commands/uncommit.py b/stgit/commands/uncommit.py\nindex e03d207..52ce5a8 100644\n--- a/stgit/commands/uncommit.py\n+++ b/stgit/commands/uncommit.py\n@@ -1,3 +1,5 @@\n+# -*- coding: utf-8 -*-\n+\n __copyright__ = \"\"\"\n Copyright (C) 2006, Karl Hasselström <kha@treskal.com>\n \n"},{"id":"20648","messageId":"4474CBB8.9000509@gmail.com","threadId":"4272","inReplyTo":"20060524060537.GA1173@diana.vm.bytemark.co.uk","subject":"Re: A few stgit bugfixes","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@gmail.com","sentAt":"2006-05-24T21:10:16Z","receivedAt":"2006-05-24T21:10:16Z","isPatch":false,"sender":{"key":"catalin.marinas@gmail.com","avatar":null},"body":"Karl Hasselström wrote:\n> Fixes for a few bugs recently introduced in stgit by yours truly.\n\nApplied. Thanks,\n\nCatalin\n"}]}