free_ref_entry(): do not trigger reading of loose refs
authorMichael Haggerty <mhagger@alum.mit.edu>
Sun, 20 May 2012 06:49:32 +0000 (08:49 +0200)
committerJunio C Hamano <gitster@pobox.com>
Sun, 20 May 2012 22:10:49 +0000 (15:10 -0700)
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>
refs.c

diff --git a/refs.c b/refs.c
index af5da5f1c1c3f756a5488c4c45332925bbf65e77..c9f48735fc732b2012a9df4966940d804309d9ef 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -259,8 +259,13 @@ static void clear_ref_dir(struct ref_dir *dir);
 
 static void free_ref_entry(struct ref_entry *entry)
 {
-       if (entry->flag & REF_DIR)
-               clear_ref_dir(get_ref_dir(entry));
+       if (entry->flag & REF_DIR) {
+               /*
+                * Do not use get_ref_dir() here, as that might
+                * trigger the reading of loose refs.
+                */
+               clear_ref_dir(&entry->u.subdir);
+       }
        free(entry);
 }