Re: [PATCH] tag: add tag.createReflog option

2 messages, 2 authors, 2017-01-25 · open the first message on its own page

Re: [PATCH] tag: add tag.createReflog option

From: Junio C Hamano <hidden>
Date: 2017-01-25 22:56:47

Junio C Hamano [off-list ref] writes:
Jeff King [off-list ref] writes:
quoted
+enum log_refs_config {
+	LOG_REFS_UNSET = -1,
+	LOG_REFS_NONE = 0,
+	LOG_REFS_NORMAL, /* see should_create_reflog for rules */
+	LOG_REFS_ALWAYS
+};
+extern enum log_refs_config log_all_ref_updates;
+...
+int should_create_reflog(const char *refname)
+{
+	switch (log_all_ref_updates) {
+	case LOG_REFS_ALWAYS:
+		return 1;
+	case LOG_REFS_NORMAL:
+		return !prefixcmp(refname, "refs/heads/") ||
+		       !prefixcmp(refname, "refs/remotes/") ||
+		       !prefixcmp(refname, "refs/notes/") ||
+		       !strcmp(refname, "HEAD");
+	default:
+		return 0;
+	}
+}
Yup, this is how I expected for the feature to be done.

Just a hint for Cornelius; prefixcmp() is an old name for what is
called starts_with() these days.
It may have been obvious, but to be explicit for somebody new,
!prefixcmp() corresponds to starts_with().  IOW, we changed the
meaning of the return value when moving from cmp-lookalike (where 0
means "equal") to "does it start with this string?" bool (where 1
means "yes").

Re: [PATCH] tag: add tag.createReflog option

From: Cornelius Weig <hidden>
Date: 2017-01-25 23:40:53

It may have been obvious, but to be explicit for somebody new,
!prefixcmp() corresponds to starts_with().  IOW, we changed the
meaning of the return value when moving from cmp-lookalike (where 0
means "equal") to "does it start with this string?" bool (where 1
means "yes").
I see. It reads much better that way!

I re-did all the changes from Jeff's patch, but some tests are breaking
now. I will have to mend that tomorrow, because it's already too late in
my timezone.

Thanks a lot for your support m(_ _)m
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help