From 57d70dcb5e9bf66b79e8c6e4146ea50eba28c71a Mon Sep 17 00:00:00 2001 From: Justin Spahr-Summers Date: Tue, 18 Feb 2014 16:05:29 -0800 Subject: Reload config in git_submodule_lookup() if not found MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the submodule config is already in memory, and we can’t find the desired name in there, check back on disk for it. This is especially important when diffing, since it’s possible that further changes could have occurred since the configuration was reloaded. --- src/submodule.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/submodule.c b/src/submodule.c index 2388bd144..608242b1d 100644 --- a/src/submodule.c +++ b/src/submodule.c @@ -113,11 +113,17 @@ int git_submodule_lookup( assert(repo && name); - if ((error = load_submodule_config(repo)) < 0) + if (repo->submodules) { + pos = git_strmap_lookup_index(repo->submodules, name); + if (git_strmap_valid_index(repo->submodules, pos)) { + goto found; + } + } + + if ((error = git_submodule_reload_all(repo)) < 0) return error; pos = git_strmap_lookup_index(repo->submodules, name); - if (!git_strmap_valid_index(repo->submodules, pos)) { error = GIT_ENOTFOUND; @@ -141,6 +147,7 @@ int git_submodule_lookup( return error; } +found: if (sm_ptr) *sm_ptr = git_strmap_value_at(repo->submodules, pos); -- cgit v1.2.1