git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC/PATCH] Enhance core.logallrefupdates
@ 2006-10-08  8:02 Junio C Hamano
  2006-10-08 10:03 ` Jakub Narebski
  0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2006-10-08  8:02 UTC (permalink / raw)
  To: git

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);

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [RFC/PATCH] Enhance core.logallrefupdates
  2006-10-08  8:02 [RFC/PATCH] Enhance core.logallrefupdates Junio C Hamano
@ 2006-10-08 10:03 ` Jakub Narebski
  2006-10-08 19:52   ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Jakub Narebski @ 2006-10-08 10:03 UTC (permalink / raw)
  To: git

Junio C Hamano wrote:

> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC/PATCH] Enhance core.logallrefupdates
  2006-10-08 10:03 ` Jakub Narebski
@ 2006-10-08 19:52   ` Junio C Hamano
  2006-10-08 20:15     ` Jakub Narebski
  0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2006-10-08 19:52 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: git

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".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC/PATCH] Enhance core.logallrefupdates
  2006-10-08 19:52   ` Junio C Hamano
@ 2006-10-08 20:15     ` Jakub Narebski
  0 siblings, 0 replies; 4+ messages in thread
From: Jakub Narebski @ 2006-10-08 20:15 UTC (permalink / raw)
  To: git

Junio C Hamano wrote:

> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-10-08 20:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-08  8:02 [RFC/PATCH] Enhance core.logallrefupdates Junio C Hamano
2006-10-08 10:03 ` Jakub Narebski
2006-10-08 19:52   ` Junio C Hamano
2006-10-08 20:15     ` Jakub Narebski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).