threads / rfc / 5853

RFC patchEnhance core.logallrefupdates

Subject: [RFC/PATCH] Enhance core.logallrefupdates

## tl;dr

4 messages between Oct 8, 2006 and Oct 8, 2006. Diffs are folded; open one to read it.

replies: 3people: 2as markdown or json

Junio C Hamano· Oct 8, 2006, 08:02 UTC · lore

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(-)
Show changes to 3 files +16 −2

cache.h, config.c, refs.c

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);
Jakub Narebski· Oct 8, 2006, 10:03 UTC · re: Junio C Hamano · lore

Re: [RFC/PATCH] Enhance core.logallrefupdates

Junio C Hamano wrote:
Show 18 quoted lines
> 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.

If we change meaning of "true", perhaps (just in case in case) we should add "all" value?

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
Junio C Hamano· Oct 8, 2006, 19:52 UTC · re: Jakub Narebski · lore

Re: [RFC/PATCH] Enhance core.logallrefupdates

Jakub Narebski <jnareb@gmail.com> writes:
Show 7 quoted lines
>>    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.
>
> If we change meaning of "true", perhaps (just in case in case) we
> should add "all" value?
Didn't I just say that I do not think of reasons to do so ;-)?

Saying "just in case" is not enough. You need to say at least "this hypothetical workflow which requires to update refs/xxx and doing automated reflog creation only under refs/heads makes that workflow less convenient".

Jakub Narebski· Oct 8, 2006, 20:15 UTC · re: Junio C Hamano · lore

Re: [RFC/PATCH] Enhance core.logallrefupdates

Junio C Hamano wrote:
Show 16 quoted lines
> Jakub Narebski <jnareb@gmail.com> writes:
> 
>>>    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.
>>
>> If we change meaning of "true", perhaps (just in case in case) we
>> should add "all" value?
> 
> Didn't I just say that I do not think of reasons to do so ;-)?
> 
> Saying "just in case" is not enough.  You need to say at least
> "this hypothetical workflow which requires to update refs/xxx
> and doing automated reflog creation only under refs/heads makes
> that workflow less convenient".

If I remember correctly there was example of workflow which did fetch remote heads to local tags. But I'm not sure if this reflog made sense with that workflow.

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

← back to recent threads