Merge branch 'mh/ref-api-lazy-loose'
authorJunio C Hamano <gitster@pobox.com>
Tue, 29 May 2012 20:08:35 +0000 (13:08 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 29 May 2012 20:08:35 +0000 (13:08 -0700)
The code to lazily read loose refs unnecessarily read the refs in a
subhierarchy by mistake when we free the data for the subhierarchy.

By Michael Haggerty
* mh/ref-api-lazy-loose:
free_ref_entry(): do not trigger reading of loose refs

refs.c
diff --git a/refs.c b/refs.c
index 010ed07e33d90cbdae4511013319a129c1201ca9..51c8825acf6435da1f2ee0adcd616aeec24d5ed9 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);
 }