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 <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael Haggerty committed Oct 17, 2011 at 04:38 UTC 3870a0d1d88e2e42b70c2586d3a1fda63226953c
1 file changed +4 -8
refs.c
+4 -8
@@ -202,13 +202,9 @@ static struct ref_cache *get_ref_cache(const char *submodule)
202 return refs;
203 }
204
205 -static void invalidate_ref_cache(void)
205 +static void invalidate_ref_cache(const char *submodule)
206 {
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));
208 }
209
210 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)
1224 ret |= repack_without_ref(refname);
1225
1226 unlink_or_warn(git_path("logs/%s", lock->ref_name));
1231 - invalidate_ref_cache();
1227 + invalidate_ref_cache(NULL);
1228 unlock_ref(lock);
1229 return ret;
1230 }
@@ -1527,7 +1523,7 @@ int write_ref_sha1(struct ref_lock *lock,
1523 unlock_ref(lock);
1524 return -1;
1525 }
1530 - invalidate_ref_cache();
1526 + invalidate_ref_cache(NULL);
1527 if (log_ref_write(lock->ref_name, lock->old_sha1, sha1, logmsg) < 0 ||
1528 (strcmp(lock->ref_name, lock->orig_ref_name) &&
1529 log_ref_write(lock->orig_ref_name, lock->old_sha1, sha1, logmsg) < 0)) {