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

Commitec0b85e

Browse files
committed
Fixes creating a Repo for a submodule
Fixes#155.
1 parente6a2942 commitec0b85e

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

‎git/repo/base.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
from fun import (
3333
rev_parse,
3434
is_git_dir,
35+
find_git_dir,
3536
touch
3637
)
3738

@@ -108,8 +109,8 @@ def __init__(self, path=None, odbt = DefaultDBType):
108109
self.git_dir = curpath
109110
self._working_tree_dir = os.path.dirname(curpath)
110111
break
111-
gitpath = join(curpath, '.git')
112-
ifis_git_dir(gitpath):
112+
gitpath =find_git_dir(join(curpath, '.git'))
113+
if gitpath is not None:
113114
self.git_dir = gitpath
114115
self._working_tree_dir = curpath
115116
break
@@ -119,7 +120,7 @@ def __init__(self, path=None, odbt = DefaultDBType):
119120
# END while curpath
120121

121122
if self.git_dir is None:
122-
raise InvalidGitRepositoryError(epath)
123+
raise InvalidGitRepositoryError(epath)
123124

124125
self._bare = False
125126
try:

‎git/repo/fun.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
join,
88
isdir,
99
isfile,
10+
dirname,
1011
hex_to_bin,
1112
bin_to_hex
1213
)
@@ -31,6 +32,18 @@ def is_git_dir(d):
3132
return False
3233

3334

35+
def find_git_dir(d):
36+
if is_git_dir(d):
37+
return d
38+
elif isfile(d):
39+
with open(d) as fp:
40+
content = fp.read().rstrip()
41+
if content.startswith('gitdir: '):
42+
d = join(dirname(d), content[8:])
43+
return find_git_dir(d)
44+
return None
45+
46+
3447
def short_to_long(odb, hexsha):
3548
""":return: long hexadecimal sha1 from the given less-than-40 byte hexsha
3649
or None if no candidate could be found.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp