git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/3] Fix infinite recursion on absolute paths

From
Karl Hasselström <kha@treskal.com>
Date
May 24, 2006, 06:06 UTC
Message-ID
<20060524060643.GA1490@diana.vm.bytemark.co.uk>
In-Reply-To
<20060524060537.GA1173@diana.vm.bytemark.co.uk>

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)
Previous: Karl HasselströmNext: Karl Hasselström
Message 2 of 5 in “A few stgit bugfixes”
  1. Karl HasselströmMay 24, 2006
  2. 1/3 Fix infinite recursion on absolute pathsKarl Hasselström, May 24, 2006
  3. 2/3 Fix indexing error during "diff -r/"Karl Hasselström, May 24, 2006
  4. 3/3 Explicitly specify utf-8 coding in fileKarl Hasselström, May 24, 2006
  5. Catalin MarinasMay 24, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.