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

[PATCH v4 3/7] invalidate_ref_cache(): expose this function in the refs API

From
mhagger@alum.mit.edu <mhagger@alum.mit.edu>
Date
Oct 17, 2011, 02:38 UTC
Message-ID
<1318819091-7066-4-git-send-email-mhagger@alum.mit.edu>
In-Reply-To
<1318819091-7066-1-git-send-email-mhagger@alum.mit.edu>
From: Michael Haggerty <mhagger@alum.mit.edu>

Make invalidate_ref_cache() an official part of the refs API. It is currently a fact of life that code outside of refs.c mucks about with references. This change gives such code a way of informing the refs module that it should no longer trust its cache.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
 refs.c |    2 +-
 refs.h |    8 ++++++++
 2 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/refs.c b/refs.c
index 68b73aa..ddd799e 100644
--- a/refs.c
+++ b/refs.c
@@ -202,7 +202,7 @@ static struct ref_cache *get_ref_cache(const char *submodule)
 	return refs;
 }
 
-static void invalidate_ref_cache(const char *submodule)
+void invalidate_ref_cache(const char *submodule)
 {
 	clear_ref_cache(get_ref_cache(submodule));
 }
diff --git a/refs.h b/refs.h
index 0229c57..f439c54 100644
--- a/refs.h
+++ b/refs.h
@@ -80,6 +80,14 @@ extern void unlock_ref(struct ref_lock *lock);
 /** Writes sha1 into the ref specified by the lock. **/
 extern int write_ref_sha1(struct ref_lock *lock, const unsigned char *sha1, const char *msg);
 
+/*
+ * Invalidate the reference cache for the specified submodule.  Use
+ * submodule=NULL to invalidate the cache for the main module.  This
+ * function must be called if references are changed via a mechanism
+ * other than the refs API.
+ */
+extern void invalidate_ref_cache(const char *submodule);
+
 /** Setup reflog before using. **/
 int log_ref_setup(const char *ref_name, char *logfile, int bufsize);
 
-- 
1.7.7.rc2
Previous: mhagger@alum.mit.eduNext: mhagger@alum.mit.edu
Message 4 of 11 in “Provide API to invalidate refs cache”
  1. 0/7 Provide API to invalidate refs cachemhagger@alum.mit.edu, Oct 17, 2011
  2. 1/7 invalidate_ref_cache(): rename function from invalidate_cached_refs()mhagger@alum.mit.edu, Oct 17, 2011
  3. 2/7 invalidate_ref_cache(): take the submodule as parametermhagger@alum.mit.edu, Oct 17, 2011
  4. 3/7 invalidate_ref_cache(): expose this function in the refs APImhagger@alum.mit.edu, Oct 17, 2011
  5. 4/7 clear_ref_cache(): rename parametermhagger@alum.mit.edu, Oct 17, 2011
  6. 5/7 clear_ref_cache(): extract two new functionsmhagger@alum.mit.edu, Oct 17, 2011
  7. 6/7 write_ref_sha1(): only invalidate the loose ref cachemhagger@alum.mit.edu, Oct 17, 2011
  8. 7/7 clear_ref_cache(): inline functionmhagger@alum.mit.edu, Oct 17, 2011
  9. Junio C HamanoOct 17, 2011
  10. Heiko VoigtOct 17, 2011
  11. Michael HaggertyOct 17, 2011

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.