diff options
Diffstat (limited to 'lib/git')
-rw-r--r-- | lib/git/objects/submodule/base.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/git/objects/submodule/base.py b/lib/git/objects/submodule/base.py index b72eac82..3f8fea40 100644 --- a/lib/git/objects/submodule/base.py +++ b/lib/git/objects/submodule/base.py @@ -215,7 +215,15 @@ class Submodule(util.IndexObject, Iterable, Traversable): sm = cls(repo, cls.NULL_BIN_SHA, cls.k_default_mode, path, name) if sm.exists(): # reretrieve submodule from tree - return repo.head.commit.tree[path] + try: + return repo.head.commit.tree[path] + except KeyError: + # could only be in index + index = repo.index + entry = index.entries[index.entry_key(path, 0)] + sm.binsha = entry.binsha + return sm + # END handle exceptions # END handle existing br = mkhead(repo, branch or cls.k_head_default) |