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

Commit706d3a2

Browse files
committed
Minor fix to make read_gitfile work .
1 parent22c4671 commit706d3a2

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

‎git/repo/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
rev_parse,
3636
is_git_dir,
3737
find_git_dir,
38-
touch
39-
read_gitfile,
38+
read_gitfile,
39+
touch,
4040
)
4141

4242
importos
@@ -117,7 +117,7 @@ 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)
120+
gitpath=read_gitfile(curpath)
121121
ifgitpath:
122122
self.git_dir=gitpath
123123
self._working_tree_dir=curpath

‎git/repo/fun.py

Lines changed: 16 additions & 11 deletions
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):
@@ -46,16 +47,20 @@ def find_git_dir(d):
4647
returnNone
4748

4849
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
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
5964

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp