X-Git-Url: https://git.distorted.org.uk/~mdw/stgit/blobdiff_plain/170f576bb9eac1dafc139de7b51226d78d31cbbe..896afcc92d6dc5772b090e0e299d82e2c80a577d:/stgit/basedir.py diff --git a/stgit/basedir.py b/stgit/basedir.py index 5abe0ff..3e078f5 100644 --- a/stgit/basedir.py +++ b/stgit/basedir.py @@ -19,16 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """ import os - -class BaseDirException(Exception): - pass - -def __output(cmd): - f = os.popen(cmd, 'r') - string = f.readline().rstrip() - if f.close(): - raise BaseDirException, 'Error: failed to execute "%s"' % cmd - return string +from stgit.run import * # GIT_DIR value cached __base_dir = None @@ -42,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') + 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