From aa5e366889103172a9829730de1ba26d3dcbc01b Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Tue, 20 Oct 2009 10:11:16 +0200 Subject: Moved specialized methods like dashify, touch and is_git_dir to module to the respective modules that use them fixed repo.daemon_export which did not work anymore due to incorrect touch implementation and wrong property names --- lib/git/repo.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'lib/git/repo.py') 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, -- cgit v1.2.1