git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* A few stgit bugfixes
@ 2006-05-24  6:05 Karl Hasselström
  2006-05-24  6:06 ` [PATCH 1/3] Fix infinite recursion on absolute paths Karl Hasselström
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Karl Hasselström @ 2006-05-24  6:05 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git

Fixes for a few bugs recently introduced in stgit by yours truly.

-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] Fix infinite recursion on absolute paths
  2006-05-24  6:05 A few stgit bugfixes Karl Hasselström
@ 2006-05-24  6:06 ` Karl Hasselström
  2006-05-24  6:06 ` [PATCH 2/3] Fix indexing error during "diff -r/" Karl Hasselström
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Karl Hasselström @ 2006-05-24  6:06 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git

Calling create_dirs with an absolute path caused infinite recursion,
since os.path.dirname('/') == '/'. Fix this by exiting early if the
given path already is a directory.
---

 stgit/utils.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/stgit/utils.py b/stgit/utils.py
index 68b8f58..ed6e43c 100644
--- a/stgit/utils.py
+++ b/stgit/utils.py
@@ -130,7 +130,7 @@ def remove_file_and_dirs(basedir, file):
 
 def create_dirs(directory):
     """Create the given directory, if the path doesn't already exist."""
-    if directory:
+    if directory and not os.path.isdir(directory):
         create_dirs(os.path.dirname(directory))
         try:
             os.mkdir(directory)

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] Fix indexing error during "diff -r/"
  2006-05-24  6:05 A few stgit bugfixes Karl Hasselström
  2006-05-24  6:06 ` [PATCH 1/3] Fix infinite recursion on absolute paths Karl Hasselström
@ 2006-05-24  6:06 ` Karl Hasselström
  2006-05-24  6:07 ` [PATCH 3/3] Explicitly specify utf-8 coding in file Karl Hasselström
  2006-05-24 21:10 ` A few stgit bugfixes Catalin Marinas
  3 siblings, 0 replies; 5+ messages in thread
From: Karl Hasselström @ 2006-05-24  6:06 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git

The string indexing when decoding the -r argument for diff made an
implicit assumption that the revision string was at least two
characters long, which broke on the simple invocation "diff -r/".
---

 stgit/commands/diff.py |    8 ++++----
 stgit/utils.py         |    6 ++++++
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/stgit/commands/diff.py b/stgit/commands/diff.py
index d765784..caa3c5b 100644
--- a/stgit/commands/diff.py
+++ b/stgit/commands/diff.py
@@ -56,11 +56,11 @@ def func(parser, options, args):
         rev_list_len = len(rev_list)
         if rev_list_len == 1:
             rev = rev_list[0]
-            if rev[-1] == '/':
+            if rev.endswith('/'):
                 # the whole patch
-                rev = rev[:-1]
-                if rev[-1] == '/':
-                    rev = rev[:-1]
+                rev = strip_suffix('/', rev)
+                if rev.endswith('/'):
+                    rev = strip_suffix('/', rev)
                 rev1 = rev + '//bottom'
                 rev2 = rev + '//top'
             else:
diff --git a/stgit/utils.py b/stgit/utils.py
index ed6e43c..67431ec 100644
--- a/stgit/utils.py
+++ b/stgit/utils.py
@@ -109,6 +109,12 @@ def strip_prefix(prefix, string):
     assert string.startswith(prefix)
     return string[len(prefix):]
 
+def strip_suffix(suffix, string):
+    """Return string, without the suffix. Blow up if string doesn't
+    end with suffix."""
+    assert string.endswith(suffix)
+    return string[:-len(suffix)]
+
 def remove_dirs(basedir, dirs):
     """Starting at join(basedir, dirs), remove the directory if empty,
     and try the same with its parent, until we find a nonempty

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] Explicitly specify utf-8 coding in file
  2006-05-24  6:05 A few stgit bugfixes Karl Hasselström
  2006-05-24  6:06 ` [PATCH 1/3] Fix infinite recursion on absolute paths Karl Hasselström
  2006-05-24  6:06 ` [PATCH 2/3] Fix indexing error during "diff -r/" Karl Hasselström
@ 2006-05-24  6:07 ` Karl Hasselström
  2006-05-24 21:10 ` A few stgit bugfixes Catalin Marinas
  3 siblings, 0 replies; 5+ messages in thread
From: Karl Hasselström @ 2006-05-24  6:07 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git

uncommit.py has a non-ascii character in it (in my name in the
copyright line). Without this coding: comment, I get an error like the
following when I run stgit:

  /home/kha/git/stgit/stgit/main.py:61: DeprecationWarning: Non-ASCII
  character '\xc3' in file
  /home/kha/git/stgit/stgit/commands/uncommit.py on line 3, but no
  encoding declared; see http://www.python.org/peps/pep-0263.html for
  details
---

 stgit/commands/uncommit.py |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/stgit/commands/uncommit.py b/stgit/commands/uncommit.py
index e03d207..52ce5a8 100644
--- a/stgit/commands/uncommit.py
+++ b/stgit/commands/uncommit.py
@@ -1,3 +1,5 @@
+# -*- coding: utf-8 -*-
+
 __copyright__ = """
 Copyright (C) 2006, Karl Hasselström <kha@treskal.com>
 

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: A few stgit bugfixes
  2006-05-24  6:05 A few stgit bugfixes Karl Hasselström
                   ` (2 preceding siblings ...)
  2006-05-24  6:07 ` [PATCH 3/3] Explicitly specify utf-8 coding in file Karl Hasselström
@ 2006-05-24 21:10 ` Catalin Marinas
  3 siblings, 0 replies; 5+ messages in thread
From: Catalin Marinas @ 2006-05-24 21:10 UTC (permalink / raw)
  To: Karl Hasselström; +Cc: git

Karl Hasselström wrote:
> Fixes for a few bugs recently introduced in stgit by yours truly.

Applied. Thanks,

Catalin

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-05-24 21:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-24  6:05 A few stgit bugfixes Karl Hasselström
2006-05-24  6:06 ` [PATCH 1/3] Fix infinite recursion on absolute paths Karl Hasselström
2006-05-24  6:06 ` [PATCH 2/3] Fix indexing error during "diff -r/" Karl Hasselström
2006-05-24  6:07 ` [PATCH 3/3] Explicitly specify utf-8 coding in file Karl Hasselström
2006-05-24 21:10 ` A few stgit bugfixes Catalin Marinas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).