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

Commit53b65e0

Browse files
committed
Added support for separeted git dir.
1 parent0b820e6 commit53b65e0

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

‎git/repo/base.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
fromfunimport (
3333
rev_parse,
3434
is_git_dir,
35+
read_gitfile,
3536
touch
3637
)
3738

@@ -113,6 +114,11 @@ def __init__(self, path=None, odbt = DefaultDBType):
113114
self.git_dir=gitpath
114115
self._working_tree_dir=curpath
115116
break
117+
gitpath=read_gitfile(gitpath)
118+
ifgitpath:
119+
self.git_dir=gitpath
120+
self._working_tree_dir=curpath
121+
break
116122
curpath,dummy=os.path.split(curpath)
117123
ifnotdummy:
118124
break

‎git/repo/fun.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,17 @@ def is_git_dir(d):
3030
os.readlink(headref).startswith('refs'))
3131
returnFalse
3232

33+
defread_gitfile(f):
34+
""" This is taken from the git setup.c:read_gitfile function.
35+
:return gitdir path or None if gitfile is invalid."""
36+
37+
ifnotisfile(f):
38+
returnNone
39+
line=open(f,'r').readline().rstrip()
40+
ifline[0:8]!='gitdir: ':
41+
returnNone
42+
path=os.path.realpath(line[8:])
43+
returnpathifis_git_dir(path)elseNone
3344

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp