git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] free_ref_entry(): do not trigger reading of loose refs

From
mhagger@alum.mit.edu <mhagger@alum.mit.edu>
Date
May 20, 2012, 06:49 UTC
Message-ID
<1337496572-11258-1-git-send-email-mhagger@alum.mit.edu>
From: Michael Haggerty <mhagger@alum.mit.edu>

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>
---
Fix a silly inefficiency from the lazy-loose changes.
 refs.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/refs.c b/refs.c
index d6bdb47..26c8fcd 100644
--- 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);
 }
 
-- 
1.7.10
Message 1 of 1 in “free_ref_entry(): do not trigger reading of loose refs”
  1. free_ref_entry(): do not trigger reading of loose refsmhagger@alum.mit.edu, May 20, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.