diff options
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 9dfc00ea..f5abc27a 100644 --- a/git/repo/fun.py +++ b/git/repo/fun.py @@ -45,6 +45,17 @@ def find_git_dir(d): return find_git_dir(d) return None +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 |