Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 27c31e2

Browse files
committed
Added the first submodule will no longer cause an IOError.
This is verified by the respective test. Fixes gitpython-developers#117
1 parent a41a8b9 commit 27c31e2

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

git/objects/submodule/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def _config_parser(cls, repo, parent_commit, read_only):
159159
if not repo.bare and parent_matches_head:
160160
fp_module = cls.k_modules_file
161161
fp_module_path = os.path.join(repo.working_tree_dir, fp_module)
162-
if not os.path.isfile(fp_module_path):
162+
if read_only and not os.path.isfile(fp_module_path):
163163
raise IOError("%s file was not accessible" % fp_module_path)
164164
# END handle existance
165165
fp_module = fp_module_path

git/test/test_submodule.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,3 +582,10 @@ def test_root_module(self, rwrepo):
582582

583583
# gitdb: has either 1 or 2 submodules depending on the version
584584
assert len(nsm.children()) >= 1 and nsmc.module_exists()
585+
586+
@with_rw_repo(k_no_subm_tag, bare=False)
587+
def test_first_submodule(self, rwrepo):
588+
assert len(list(rwrepo.iter_submodules())) == 0
589+
sm = rwrepo.create_submodule('first', 'submodules/first', rwrepo.git_dir, no_checkout=True)
590+
assert sm.exists() and sm.module_exists()
591+
rwrepo.index.commit("Added submodule")

0 commit comments

Comments
 (0)