chiark / gitweb /
Don't set the default authdate if none specified
[stgit] / stgit / basedir.py
index c394572a81d9b3322a7a7cdccec0c1846d445dcc..3e078f51b29d95baf3793f203086d3ec5fd8be1e 100644 (file)
@@ -19,13 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 """
 
 import os
-
-def __output(cmd):
-    f = os.popen(cmd, 'r')
-    string = f.readline().rstrip()
-    if f.close():
-        return ''
-    return string
+from stgit.run import *
 
 # GIT_DIR value cached
 __base_dir = None
@@ -39,6 +33,15 @@ def get():
         if 'GIT_DIR' in os.environ:
             __base_dir = os.environ['GIT_DIR']
         else:
-            __base_dir = __output('git-rev-parse --git-dir 2> /dev/null')
+            try:
+                __base_dir = Run('git', 'rev-parse', '--git-dir').output_one_line()
+            except RunException:
+                __base_dir = ''
 
     return __base_dir
+
+def clear_cache():
+    """Clear the cached location of .git
+    """
+    global __base_dir
+    __base_dir = None