Skip to content

Commit 3870a0d

Browse files
mhaggergitster
authored andcommitted
invalidate_ref_cache(): take the submodule as parameter
Instead of invalidating the ref cache on an all-or-nothing basis, invalidate the cache for a specific submodule. Signed-off-by: Michael Haggerty <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 79c7ca5 commit 3870a0d

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

refs.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,9 @@ static struct ref_cache *get_ref_cache(const char *submodule)
202202
return refs;
203203
}
204204

205-
static void invalidate_ref_cache(void)
205+
static void invalidate_ref_cache(const char *submodule)
206206
{
207-
struct ref_cache *refs = ref_cache;
208-
while (refs) {
209-
clear_ref_cache(refs);
210-
refs = refs->next;
211-
}
207+
clear_ref_cache(get_ref_cache(submodule));
212208
}
213209

214210
static void read_packed_refs(FILE *f, struct ref_array *array)
@@ -1228,7 +1224,7 @@ int delete_ref(const char *refname, const unsigned char *sha1, int delopt)
12281224
ret |= repack_without_ref(refname);
12291225

12301226
unlink_or_warn(git_path("logs/%s", lock->ref_name));
1231-
invalidate_ref_cache();
1227+
invalidate_ref_cache(NULL);
12321228
unlock_ref(lock);
12331229
return ret;
12341230
}
@@ -1527,7 +1523,7 @@ int write_ref_sha1(struct ref_lock *lock,
15271523
unlock_ref(lock);
15281524
return -1;
15291525
}
1530-
invalidate_ref_cache();
1526+
invalidate_ref_cache(NULL);
15311527
if (log_ref_write(lock->ref_name, lock->old_sha1, sha1, logmsg) < 0 ||
15321528
(strcmp(lock->ref_name, lock->orig_ref_name) &&
15331529
log_ref_write(lock->orig_ref_name, lock->old_sha1, sha1, logmsg) < 0)) {

0 commit comments

Comments
 (0)