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

[PATCH] stgit: fix clone

From
PRPavel Roskin <proski@gnu.org>
Date
Jan 11, 2006, 22:19 UTC
Message-ID
<1137017966.10975.8.camel@dv>
"stg clone" is currently broken:

$ stg clone http://homepage.ntlworld.com/cmarinas/stgit.git stg clone: git-rev-parse --git-dir failed

This happens with current git. "git-rev-parse --git-dir" doesn't work in an empty directory. The patch avoids running "git-rev-parse --git-dir" when the requested command doesn't assume existence of git repository.

Signed-off-by: Pavel Roskin <proski@gnu.org>
---
Warning: this is my first non-trivial patch to StGIT and the first patch
to a Python program.
diff --git a/stgit/git.py b/stgit/git.py
index a7b1c3f..0e63f69 100644
--- a/stgit/git.py
+++ b/stgit/git.py
@@ -82,13 +82,16 @@ __commits = dict()
 # Functions
 #
 
-def get_base_dir():
+def get_base_dir(assume_top = False):
     """Different start-up variables read from the environment
     """
     if 'GIT_DIR' in os.environ:
         return os.environ['GIT_DIR']
     else:
-        return _output_one_line('git-rev-parse --git-dir')
+        if assume_top:
+            return '.git'
+        else:
+            return _output_one_line('git-rev-parse --git-dir')
 
 def get_commit(id_hash):
     """Commit objects factory. Save/look-up them in the __commits
diff --git a/stgit/stack.py b/stgit/stack.py
index 8b7c296..1c080b3 100644
--- a/stgit/stack.py
+++ b/stgit/stack.py
@@ -263,7 +263,7 @@ class Series:
             self.__name = git.get_head_file()
 
         if self.__name:
-            base_dir = git.get_base_dir()
+            base_dir = git.get_base_dir(assume_top = (name == 'master'))
             self.__patch_dir = os.path.join(base_dir, 'patches',
                                             self.__name)
             self.__base_file = os.path.join(base_dir, 'refs', 'bases',
-- 
Regards,
Pavel Roskin
Next: Chuck Lever
Message 1 of 6 in “stgit: fix clone”
  1. stgit: fix clonePavel Roskin, Jan 11, 2006
  2. Chuck LeverJan 11, 2006
  3. Chuck LeverJan 11, 2006
  4. Catalin MarinasJan 12, 2006
  5. Chuck LeverJan 12, 2006
  6. Pavel RoskinJan 13, 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.