- if (!submodule) {
- if (!cached_refs)
- cached_refs = create_cached_refs(submodule);
- return cached_refs;
- } else {
- if (!submodule_refs)
- submodule_refs = create_cached_refs(submodule);
- else
- /* For now, don't reuse the refs cache for submodules. */
- clear_cached_refs(submodule_refs);
- return submodule_refs;
+ struct cached_refs *refs = cached_refs;
+ if (!submodule)
+ submodule = "";
+ while (refs) {
+ if (!strcmp(submodule, refs->name))
+ return refs;
+ refs = refs->next;