diff options
author | Justin Spahr-Summers <Justin.SpahrSummers@gmail.com> | 2014-02-18 16:05:29 -0800 |
---|---|---|
committer | Justin Spahr-Summers <Justin.SpahrSummers@gmail.com> | 2014-02-18 16:05:29 -0800 |
commit | 57d70dcb5e9bf66b79e8c6e4146ea50eba28c71a (patch) | |
tree | a123b7733a2284acdff86431df5e3d5858e64ef9 | |
parent | e0ebaaa53ea1154a1f392dae463453ac6c428d78 (diff) | |
download | libgit2-refresh-submodule-on-lookup.tar.gz |
Reload config in git_submodule_lookup() if not foundrefresh-submodule-on-lookup
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.
-rw-r--r-- | src/submodule.c | 11 |
1 files 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); |