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

[PATCH v2 2/4] show-ref: Allow -d to work with --verify

From
Vladimir Panteleev <git@thecybershadow.net>
Date
Jan 21, 2017, 01:08 UTC
Message-ID
<20170121010821.25046-3-git@thecybershadow.net>
In-Reply-To
<20170121010821.25046-1-git@thecybershadow.net>

Use the same output machinery when --verify is absent or present, which allows tag dereferencing (-d) to work with --verify. This is useful when the user wishes to avoid the costly iteration of refs.

Signed-off-by: Vladimir Panteleev <git@thecybershadow.net>
---
 builtin/show-ref.c  | 3 +--
 t/t1403-show-ref.sh | 9 +++++++++
 2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/builtin/show-ref.c b/builtin/show-ref.c
index 945a483e3..bcdc1a95e 100644
--- a/builtin/show-ref.c
+++ b/builtin/show-ref.c
@@ -205,8 +205,7 @@ int cmd_show_ref(int argc, const char **argv, const char *prefix)
 			if ((starts_with(*pattern, "refs/") ||
 			     (show_head && !strcmp(*pattern, "HEAD"))) &&
 			    !read_ref(*pattern, oid.hash)) {
-				if (!quiet)
-					show_one(*pattern, &oid);
+				show_ref(*pattern, &oid, 0, NULL);
 			}
 			else if (!quiet)
 				die("'%s' - not a valid ref", *pattern);
diff --git a/t/t1403-show-ref.sh b/t/t1403-show-ref.sh
index 2fb5dc879..5c540e67f 100755
--- a/t/t1403-show-ref.sh
+++ b/t/t1403-show-ref.sh
@@ -97,6 +97,9 @@ test_expect_success 'show-ref -d' '
 	git show-ref -d refs/tags/A refs/tags/C >actual &&
 	test_cmp expect actual &&
 
+	git show-ref --verify -d refs/tags/A refs/tags/C >actual &&
+	test_cmp expect actual &&
+
 	echo $(git rev-parse refs/heads/master) refs/heads/master >expect &&
 	git show-ref -d master >actual &&
 	test_cmp expect actual &&
@@ -116,6 +119,12 @@ test_expect_success 'show-ref -d' '
 	test_cmp expect actual &&
 
 	test_must_fail git show-ref -d --verify heads/master >actual &&
+	test_cmp expect actual &&
+
+	test_must_fail git show-ref --verify -d A C >actual &&
+	test_cmp expect actual &&
+
+	test_must_fail git show-ref --verify -d tags/A tags/C >actual &&
 	test_cmp expect actual
 
 '
-- 
2.11.0
Previous: Vladimir Panteleev
Message 7 of 7 in “show-ref: Allow -d, --head to work with --verify”
  1. show-ref: Allow -d, --head to work with --verifyVladimir Panteleev, Jan 21, 2017
  2. 4/4 show-ref: Inline show_oneVladimir Panteleev, Jan 21, 2017
  3. 3/4 show-ref: Optimize show_ref a bitVladimir Panteleev, Jan 21, 2017
  4. Junio C HamanoJan 22, 2017
  5. Junio C HamanoJan 22, 2017
  6. 1/4 show-ref: Allow --head to work with --verifyVladimir Panteleev, Jan 21, 2017
  7. 2/4 show-ref: Allow -d to work with --verifyVladimir Panteleev, Jan 21, 2017

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.