diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2010-11-19 20:57:38 +0100 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2010-11-19 20:57:38 +0100 |
commit | b00ad00130389f5b00da9dbfd89c3e02319d2999 (patch) | |
tree | 106d97b2283ecf27497348044550842a996f1941 /lib/git/objects/submodule/base.py | |
parent | 2ab454f0ccf09773a4f51045329a69fd73559414 (diff) | |
download | gitpython-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.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) |