Thread (1 message) 1 message, 1 author, 2017-01-20

Re: [PATCH] show-ref: Allow --head to work with --verify

From: Junio C Hamano <hidden>
Date: 2017-01-20 23:20:10
Subsystem: the rest · Maintainer: Linus Torvalds

Possibly related (same subject, not in this thread)

Vladimir Panteleev [off-list ref] writes:
--quiet will still work correctly with the current patch, because
show_ref already checks quiet. Granted, the original --verify code
used show_one and not show_ref; however, I don't see a meaningful
difference between calling show_ref and show_one for HEAD, other than
a bit of overhead, so adding a new function may not be worthwhile. I
will still add tests for this; however, in light of this, would you
still like me to perform the change you requested?
If two codepaths are called "I don't see a meaningful difference",
then it is really better to share the same code.  Today, they may
happen to behave identically.  When we need to update the behaviour
of one, we'd be forced to update the other one to match.

IOW, something along this line, perhaps (not even compile tested so
take it with grain of salt).

Thanks.

 builtin/show-ref.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/builtin/show-ref.c b/builtin/show-ref.c
index 6d4e669002..57491152b7 100644
--- a/builtin/show-ref.c
+++ b/builtin/show-ref.c
@@ -202,7 +202,8 @@ int cmd_show_ref(int argc, const char **argv, const char *prefix)
 		while (*pattern) {
 			struct object_id oid;
 
-			if (starts_with(*pattern, "refs/") &&
+			if (((show_head && !strcmp(*pattern, "HEAD")) ||
+			     starts_with(*pattern, "refs/")) &&
 			    !read_ref(*pattern, oid.hash)) {
 				if (!quiet)
 					show_one(*pattern, &oid);


Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help