free_ref_entry(): do not trigger reading of loose refs

Do not call get_ref_dir() from within free_ref_entry(), because that triggers the reading of loose refs, only for them to be freed immediately. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael Haggerty committed May 20, 2012 at 08:49 UTC 27b5587c7610515832cf39cd0c3792e7655bdd9a
1 file changed +7 -2
refs.c
+7 -2
@@ -259,8 +259,13 @@ static void clear_ref_dir(struct ref_dir *dir);
259
260 static void free_ref_entry(struct ref_entry *entry)
261 {
262 - if (entry->flag & REF_DIR)
263 - clear_ref_dir(get_ref_dir(entry));
262 + if (entry->flag & REF_DIR) {
263 + /*
264 + * Do not use get_ref_dir() here, as that might
265 + * trigger the reading of loose refs.
266 + */
267 + clear_ref_dir(&entry->u.subdir);
268 + }
269 free(entry);
270 }
271