diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2015-01-15 16:03:47 +0100 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2015-01-15 16:03:47 +0100 |
commit | 27c31e2fde54c0587c032ccffdaa7c4ddf5b2ae5 (patch) | |
tree | 28fef0f6b88b6a1e82e4193868c44ee7625e0e48 | |
parent | a41a8b93167a59cd074eb3175490cd61c45b6f6a (diff) | |
download | gitpython-27c31e2fde54c0587c032ccffdaa7c4ddf5b2ae5.tar.gz |
Added the first submodule will no longer cause an IOError.
This is verified by the respective test.
Fixes #117
-rw-r--r-- | git/objects/submodule/base.py | 2 | ||||
-rw-r--r-- | git/test/test_submodule.py | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/git/objects/submodule/base.py b/git/objects/submodule/base.py index 0ec6f656..0bd34999 100644 --- a/git/objects/submodule/base.py +++ b/git/objects/submodule/base.py @@ -159,7 +159,7 @@ class Submodule(util.IndexObject, Iterable, Traversable): if not repo.bare and parent_matches_head: fp_module = cls.k_modules_file fp_module_path = os.path.join(repo.working_tree_dir, fp_module) - if not os.path.isfile(fp_module_path): + if read_only and not os.path.isfile(fp_module_path): raise IOError("%s file was not accessible" % fp_module_path) # END handle existance fp_module = fp_module_path diff --git a/git/test/test_submodule.py b/git/test/test_submodule.py index 99996ce3..524a69bf 100644 --- a/git/test/test_submodule.py +++ b/git/test/test_submodule.py @@ -582,3 +582,10 @@ class TestSubmodule(TestBase): # gitdb: has either 1 or 2 submodules depending on the version assert len(nsm.children()) >= 1 and nsmc.module_exists() + + @with_rw_repo(k_no_subm_tag, bare=False) + def test_first_submodule(self, rwrepo): + assert len(list(rwrepo.iter_submodules())) == 0 + sm = rwrepo.create_submodule('first', 'submodules/first', rwrepo.git_dir, no_checkout=True) + assert sm.exists() and sm.module_exists() + rwrepo.index.commit("Added submodule") |