From b00ad00130389f5b00da9dbfd89c3e02319d2999 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Fri, 19 Nov 2010 20:57:38 +0100 Subject: submodule: When adding an existing submodule, when retrieving the binsha, we will now consider not only the tree, but the index too --- lib/git/objects/submodule/base.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'lib/git') 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) -- cgit v1.2.1