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

[RFC/PATCH] Enhance core.logallrefupdates

From
Junio C Hamano <junkio@cox.net>
Date
Oct 8, 2006, 08:02 UTC
Message-ID
<7vbqonkzfe.fsf@assigned-by-dhcp.cox.net>

This enhances core.logallrefupdates by allowing it to take "heads" as the value as well, which causes git to create missing reflog files automatically only for branch heads. Usually tags are create-once-and-live-forever, and it is irritating to see reflog files created automatically every time a new tag is made.

As before, boolean "true" means create missing reflog files for all refs.

---
 * Setting it to "tags" is not supported, as it does not make
   much sense wanting to log only tag updates.
   Come to think of it, it might make sense to change the
   meaning of "true" to do what this patch does.  I do not think
   of reasons to create missing reflog for tags automatically
   anyway.
   Opinions?
 cache.h  |    2 ++
 config.c |    9 ++++++++-
 refs.c   |    7 ++++++-
 3 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/cache.h b/cache.h
index 0565333..6029a1d 100644
--- a/cache.h
+++ b/cache.h
@@ -186,6 +186,8 @@ extern int use_legacy_headers;
 extern int trust_executable_bit;
 extern int assume_unchanged;
 extern int prefer_symlink_refs;
+#define REF_LOG_ALL 1
+#define REF_LOG_HEADS 2
 extern int log_all_ref_updates;
 extern int warn_ambiguous_refs;
 extern int shared_repository;
diff --git a/config.c b/config.c
index e8f0caf..c254a57 100644
--- a/config.c
+++ b/config.c
@@ -270,7 +270,14 @@ int git_default_config(const char *var, 
 	}
 
 	if (!strcmp(var, "core.logallrefupdates")) {
-		log_all_ref_updates = git_config_bool(var, value);
+		if (!strcasecmp(value, "heads"))
+			log_all_ref_updates = REF_LOG_HEADS;
+		else if (!strcasecmp(value, "all"))
+			log_all_ref_updates = REF_LOG_ALL;
+		else if (git_config_bool(var, value))
+			log_all_ref_updates = REF_LOG_ALL;
+		else
+			log_all_ref_updates = 0;
 		return 0;
 	}
 
diff --git a/refs.c b/refs.c
index 305c1a9..fa3c3d7 100644
--- a/refs.c
+++ b/refs.c
@@ -720,8 +720,13 @@ static int log_ref_write(struct ref_lock
 	unsigned maxlen, len;
 	char *logrec;
 	const char *committer;
+	int create_missing = log_all_ref_updates;
 
-	if (log_all_ref_updates) {
+	if ((log_all_ref_updates == REF_LOG_HEADS) &&
+	    strncmp(lock->ref_name, "refs/heads/", 11))
+		create_missing = 0;
+
+	if (create_missing) {
 		if (safe_create_leading_directories(lock->log_file) < 0)
 			return error("unable to create directory for %s",
 				lock->log_file);
Next: Jakub Narebski
Message 1 of 4 in “Enhance core.logallrefupdates”
  1. Enhance core.logallrefupdatesJunio C Hamano, Oct 8, 2006
  2. Jakub NarebskiOct 8, 2006
  3. Junio C HamanoOct 8, 2006
  4. Jakub NarebskiOct 8, 2006

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.