Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit22c4671

Browse files
committed
Merge branch 'separate-git-dir' ofhttps://github.com/niyaton/GitPython into niyaton-separate-git-dir
Conflicts:git/repo/base.py
2 parents6fc9e61 +53b65e0 commit22c4671

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

‎git/repo/base.py‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
is_git_dir,
3737
find_git_dir,
3838
touch
39-
)
39+
read_gitfile,
40+
)
4041

4142
importos
4243
importsys
@@ -52,7 +53,6 @@
5253

5354

5455
classRepo(object):
55-
5656
"""Represents a git repository and allows you to query references,
5757
gather commit information, generate diffs, create and clone repositories query
5858
the log.
@@ -117,6 +117,11 @@ def __init__(self, path=None, odbt=DefaultDBType):
117117
self.git_dir=gitpath
118118
self._working_tree_dir=curpath
119119
break
120+
gitpath=read_gitfile(gitpath)
121+
ifgitpath:
122+
self.git_dir=gitpath
123+
self._working_tree_dir=curpath
124+
break
120125
curpath,dummy=os.path.split(curpath)
121126
ifnotdummy:
122127
break

‎git/repo/fun.py‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,17 @@ def find_git_dir(d):
4545
returnfind_git_dir(d)
4646
returnNone
4747

48+
defread_gitfile(f):
49+
""" This is taken from the git setup.c:read_gitfile function.
50+
:return gitdir path or None if gitfile is invalid."""
51+
52+
ifnotisfile(f):
53+
returnNone
54+
line=open(f,'r').readline().rstrip()
55+
ifline[0:8]!='gitdir: ':
56+
returnNone
57+
path=os.path.realpath(line[8:])
58+
returnpathifis_git_dir(path)elseNone
4859

4960
defshort_to_long(odb,hexsha):
5061
""":return: long hexadecimal sha1 from the given less-than-40 byte hexsha

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp