diff options
author | Brock Peabody <bpeabody@twosigma.com> | 2016-11-23 18:32:55 -0500 |
---|---|---|
committer | David Turner <dturner@twosigma.com> | 2017-01-20 17:33:56 -0500 |
commit | 673dff88a2c78766609a7023167acb5a882fb84d (patch) | |
tree | 3602334a046f314170be9d49ea48ac0e69f6b531 | |
parent | 4d99c4cfc604bb141fd4e1423e934ebd3fb7e2a7 (diff) | |
download | libgit2-673dff88a2c78766609a7023167acb5a882fb84d.tar.gz |
Skip submodule head/index update when caching.
`git_submodule_status` is very slow, bottlenecked on
`git_repository_head_tree`, which it uses through `submodule_update_head`. If
the user has requested submodule caching, assume that they want this status
cached too and skip it.
Signed-off-by: David Turner <dturner@twosigma.com>
-rw-r--r-- | src/submodule.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/submodule.c b/src/submodule.c index 6996006dc..3099db6cf 100644 --- a/src/submodule.c +++ b/src/submodule.c @@ -1544,13 +1544,22 @@ int git_submodule__status( return 0; } - /* refresh the index OID */ - if (submodule_update_index(sm) < 0) - return -1; + /* If the user has requested caching submodule state, performing these + * expensive operations (especially `submodule_update_head`, which is + * bottlenecked on `git_repository_head_tree`) eliminates much of the + * advantage. We will, therefore, interpret the request for caching to + * apply here to and skip them. + */ - /* refresh the HEAD OID */ - if (submodule_update_head(sm) < 0) - return -1; + if (sm->repo->submodule_cache == NULL) { + /* refresh the index OID */ + if (submodule_update_index(sm) < 0) + return -1; + + /* refresh the HEAD OID */ + if (submodule_update_head(sm) < 0) + return -1; + } /* for ignore == dirty, don't scan the working directory */ if (ign == GIT_SUBMODULE_IGNORE_DIRTY) { |