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

[PATCH] rev-parse: make --quiet really be quiet

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Jun 13, 2021, 02:57 UTC
Message-ID
<20210613025702.43619-1-felipe.contreras@gmail.com>

Currently `git rev-parse --quiet --verify @{upstream}` throws an error, when it clearly shouldn't.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 object-name.c               | 7 ++++---
 t/t1503-rev-parse-verify.sh | 2 ++
 2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/object-name.c b/object-name.c
index 64202de60b..b45369baab 100644
--- a/object-name.c
+++ b/object-name.c
@@ -806,10 +806,11 @@ static int get_oid_basic(struct repository *r, const char *str, int len,
 	char *real_ref = NULL;
 	int refs_found = 0;
 	int at, reflog_len, nth_prior = 0;
+	int quiet = !!(flags & GET_OID_QUIETLY);
 
 	if (len == r->hash_algo->hexsz && !get_oid_hex(str, oid)) {
 		if (warn_ambiguous_refs && warn_on_object_refname_ambiguity) {
-			refs_found = repo_dwim_ref(r, str, len, &tmp_oid, &real_ref, 0);
+			refs_found = repo_dwim_ref(r, str, len, &tmp_oid, &real_ref, quiet);
 			if (refs_found > 0) {
 				warning(warn_msg, len, str);
 				if (advice_object_name_warning)
@@ -860,11 +861,11 @@ static int get_oid_basic(struct repository *r, const char *str, int len,
 
 	if (!len && reflog_len)
 		/* allow "@{...}" to mean the current branch reflog */
-		refs_found = repo_dwim_ref(r, "HEAD", 4, oid, &real_ref, 0);
+		refs_found = repo_dwim_ref(r, "HEAD", 4, oid, &real_ref, quiet);
 	else if (reflog_len)
 		refs_found = repo_dwim_log(r, str, len, oid, &real_ref);
 	else
-		refs_found = repo_dwim_ref(r, str, len, oid, &real_ref, 0);
+		refs_found = repo_dwim_ref(r, str, len, oid, &real_ref, quiet);
 
 	if (!refs_found)
 		return -1;
diff --git a/t/t1503-rev-parse-verify.sh b/t/t1503-rev-parse-verify.sh
index bf08102391..688c5abdc9 100755
--- a/t/t1503-rev-parse-verify.sh
+++ b/t/t1503-rev-parse-verify.sh
@@ -83,6 +83,8 @@ test_expect_success 'fails silently when using -q' '
 	test_must_fail git rev-parse --quiet --verify baz HEAD 2>error &&
 	test_must_be_empty error &&
 	test_must_fail git rev-parse -q --verify $HASH2 HEAD 2>error &&
+	test_must_be_empty error &&
+	test_must_fail git rev-parse -q --verify @{upstream} 2>error &&
 	test_must_be_empty error
 '
 
-- 
2.32.0
Message 1 of 1 in “rev-parse: make --quiet really be quiet”
  1. rev-parse: make --quiet really be quietFelipe Contreras, Jun 13, 2021

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.