@@ -709,18 +709,12 @@ static int maybe_modified_submodule(
709709 } else {
710710 if (!info -> submodule_cache_initialized ) {
711711 info -> submodule_cache_initialized = true;
712- /* Cache the submodule information to avoid having to parse it for every submodule. */
713- if (git_strmap_new (& info -> submodule_cache ) == 0 ) {
714- if (git_submodule__map (diff -> base .repo , info -> submodule_cache ) < 0 ) {
715- /* If the caching failed for whatever reason, bail out and clean up. */
716- git_submodule * sm = NULL ;
717- git_strmap_foreach_value (info -> submodule_cache , sm , {
718- git_submodule_free (sm );
719- });
720- git_strmap_free (info -> submodule_cache );
721- info -> submodule_cache = NULL ;
722- }
723- }
712+ /*
713+ * Try to cache the submodule information to avoid having to parse it for
714+ * every submodule. It is okay if it fails, the cache will still be NULL
715+ * and the submodules will be attempted to be looked up individually.
716+ */
717+ git_submodule_cache_init (& info -> submodule_cache , diff -> base .repo );
724718 }
725719 submodule_cache = info -> submodule_cache ;
726720 }
@@ -1284,13 +1278,8 @@ int git_diff__from_iterators(
12841278 * out = & diff -> base ;
12851279 else
12861280 git_diff_free (& diff -> base );
1287- if (info .submodule_cache ) {
1288- git_submodule * sm = NULL ;
1289- git_strmap_foreach_value (info .submodule_cache , sm , {
1290- git_submodule_free (sm );
1291- });
1292- git_strmap_free (info .submodule_cache );
1293- }
1281+ if (info .submodule_cache )
1282+ git_submodule_cache_free (info .submodule_cache );
12941283
12951284 return error ;
12961285}
0 commit comments