summaryrefslogtreecommitdiff
path: root/lib/git/objects/submodule.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2010-11-17 00:28:57 +0100
committerSebastian Thiel <byronimo@gmail.com>2010-11-17 00:28:57 +0100
commitef48ca5f54fe31536920ec4171596ff8468db5fe (patch)
treea2540d1aad914b68b94e8d34f0490d906f77ac84 /lib/git/objects/submodule.py
parent7b3ef45167e1c2f7d1b7507c13fcedd914f87da9 (diff)
downloadgitpython-ef48ca5f54fe31536920ec4171596ff8468db5fe.tar.gz
Added rest of submodule.add test code which should be pretty much 100% coverage for it
Diffstat (limited to 'lib/git/objects/submodule.py')
-rw-r--r--lib/git/objects/submodule.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/git/objects/submodule.py b/lib/git/objects/submodule.py
index 586ebeab..e07117a6 100644
--- a/lib/git/objects/submodule.py
+++ b/lib/git/objects/submodule.py
@@ -85,7 +85,7 @@ class Submodule(base.IndexObject, Iterable, Traversable):
k_modules_file = '.gitmodules'
k_head_option = 'branch'
k_head_default = 'master'
- k_def_mode = stat.S_IFDIR | stat.S_IFLNK # submodules are directories with link-status
+ k_default_mode = stat.S_IFDIR | stat.S_IFLNK # submodules are directories with link-status
# this is a bogus type for base class compatability
type = 'submodule'
@@ -244,7 +244,7 @@ class Submodule(base.IndexObject, Iterable, Traversable):
# END handle trailing slash
# INSTANTIATE INTERMEDIATE SM
- sm = cls(repo, cls.NULL_BIN_SHA, cls.k_def_mode, path, name)
+ 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]
@@ -712,10 +712,17 @@ class Submodule(base.IndexObject, Iterable, Traversable):
# END handle optional information
# get the binsha
+ index = repo.index
try:
sm = rt[p]
except KeyError:
- raise InvalidGitRepositoryError("Gitmodule path %r did not exist in revision of parent commit %s" % (p, parent_commit))
+ # try the index, maybe it was just added
+ try:
+ entry = index.entries[index.entry_key(p, 0)]
+ sm = cls(repo, entry.binsha, entry.mode, entry.path)
+ except KeyError:
+ raise InvalidGitRepositoryError("Gitmodule path %r did not exist in revision of parent commit %s" % (p, parent_commit))
+ # END handle keyerror
# END handle critical error
# fill in remaining info - saves time as it doesn't have to be parsed again
@@ -743,7 +750,7 @@ class RootModule(Submodule):
super(RootModule, self).__init__(
repo,
binsha = self.NULL_BIN_SHA,
- mode = self.k_def_mode,
+ mode = self.k_default_mode,
path = '',
name = self.k_root_name,
parent_commit = repo.head.commit,