diff options
Diffstat (limited to 'lib/git/repo.py')
-rw-r--r-- | lib/git/repo.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/git/repo.py b/lib/git/repo.py index 8126bff4..966edf9d 100644 --- a/lib/git/repo.py +++ b/lib/git/repo.py @@ -11,7 +11,6 @@ import gzip import StringIO from errors import InvalidGitRepositoryError, NoSuchPathError -from utils import touch, is_git_dir from cmd import Git from actor import Actor from refs import * @@ -19,6 +18,23 @@ from objects import * from config import GitConfigParser from remote import Remote +def touch(filename): + fp = open(filename, "w") + fp.close() + +def is_git_dir(d): + """ This is taken from the git setup.c:is_git_directory + function.""" + + if os.path.isdir(d) and \ + os.path.isdir(os.path.join(d, 'objects')) and \ + os.path.isdir(os.path.join(d, 'refs')): + headref = os.path.join(d, 'HEAD') + return os.path.isfile(headref) or \ + (os.path.islink(headref) and + os.readlink(headref).startswith('refs')) + return False + class Repo(object): """ Represents a git repository and allows you to query references, |