diff options
author | niyaton <niyaton@gmail.com> | 2013-02-25 01:22:30 +0900 |
---|---|---|
committer | niyaton <niyaton@gmail.com> | 2013-02-27 15:55:24 +0900 |
commit | 53b65e074e4d62ea5d0251b37c35fd055e403110 (patch) | |
tree | 3032d352cf8493e32eed1f911730f1081eefa5d5 /git/repo/fun.py | |
parent | 0b820e617ab21b372394bf12129c30174f57c5d7 (diff) | |
download | gitpython-53b65e074e4d62ea5d0251b37c35fd055e403110.tar.gz |
Added support for separeted git dir.
Diffstat (limited to 'git/repo/fun.py')
-rw-r--r-- | git/repo/fun.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/git/repo/fun.py b/git/repo/fun.py index 03d55716..86d3c6a9 100644 --- a/git/repo/fun.py +++ b/git/repo/fun.py @@ -30,6 +30,17 @@ def is_git_dir(d): os.readlink(headref).startswith('refs')) return False +def read_gitfile(f): + """ This is taken from the git setup.c:read_gitfile function. + :return gitdir path or None if gitfile is invalid.""" + + if not isfile(f): + return None + line = open(f, 'r').readline().rstrip() + if line[0:8] != 'gitdir: ': + return None + path = os.path.realpath(line[8:]) + return path if is_git_dir(path) else None def short_to_long(odb, hexsha): """:return: long hexadecimal sha1 from the given less-than-40 byte hexsha |