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

Commitd48ed95

Browse files
committed
Merge branch 'niyaton-separate-git-dir' into 0.3
2 parents6fc9e61 +706d3a2 commitd48ed95

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

‎git/repo/base.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@
3535
rev_parse,
3636
is_git_dir,
3737
find_git_dir,
38-
touch
39-
)
38+
read_gitfile,
39+
touch,
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(curpath)
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: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
)
1414
fromstringimportdigits
1515

16-
__all__= ('rev_parse','is_git_dir','touch')
16+
__all__= ('rev_parse','is_git_dir','touch','read_gitfile','find_git_dir','name_to_object',
17+
'short_to_long','deref_tag','to_commit')
1718

1819

1920
deftouch(filename):
@@ -45,6 +46,21 @@ def find_git_dir(d):
4546
returnfind_git_dir(d)
4647
returnNone
4748

49+
defread_gitfile(f):
50+
""" This is taken from the git setup.c:read_gitfile function.
51+
:return gitdir path or None if gitfile is invalid."""
52+
iffisNone:
53+
returnNone
54+
try:
55+
line=open(f,'r').readline().rstrip()
56+
except (OSError,IOError):
57+
# File might not exist or is unreadable - ignore
58+
returnNone
59+
# end handle file access
60+
ifline[0:8]!='gitdir: ':
61+
returnNone
62+
path=os.path.realpath(line[8:])
63+
returnpathifis_git_dir(path)elseNone
4864

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp