summaryrefslogtreecommitdiff
path: root/lib/git/objects/submodule/base.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2010-11-19 20:57:38 +0100
committerSebastian Thiel <byronimo@gmail.com>2010-11-19 20:57:38 +0100
commitb00ad00130389f5b00da9dbfd89c3e02319d2999 (patch)
tree106d97b2283ecf27497348044550842a996f1941 /lib/git/objects/submodule/base.py
parent2ab454f0ccf09773a4f51045329a69fd73559414 (diff)
downloadgitpython-b00ad00130389f5b00da9dbfd89c3e02319d2999.tar.gz
submodule: When adding an existing submodule, when retrieving the binsha, we will now consider not only the tree, but the index too
Diffstat (limited to 'lib/git/objects/submodule/base.py')
-rw-r--r--lib/git/objects/submodule/base.py10
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)