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

[PATCH 1/5] ref-filter: reject arguments to %(HEAD)

From
Jeff King <peff@peff.net>
Date
Dec 14, 2022, 16:18 UTC
Message-ID
<Y5n3aePWhM0/MlJm@coredump.intra.peff.net>
In-Reply-To
<Y5n3S7cnD7s/AIRL@coredump.intra.peff.net>

The %(HEAD) atom doesn't take any arguments, but unlike other atoms in the same boat (objecttype, deltabase, etc), it does not detect this situation and complain. Let's make it consistent with the others.

Signed-off-by: Jeff King <peff@peff.net>
---
 ref-filter.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/ref-filter.c b/ref-filter.c
index caf10ab23e..08ac5f886e 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -571,8 +571,10 @@ static int rest_atom_parser(struct ref_format *format, struct used_atom *atom,
 }
 
 static int head_atom_parser(struct ref_format *format, struct used_atom *atom,
-			    const char *arg, struct strbuf *unused_err)
+			    const char *arg, struct strbuf *err)
 {
+	if (arg)
+		return strbuf_addf_ret(err, -1, _("%%(HEAD) does not take arguments"));
 	atom->u.head = resolve_refdup("HEAD", RESOLVE_REF_READING, NULL, NULL);
 	return 0;
 }
-- 
2.39.0.550.g5015380a67
Previous: Jeff KingNext: Jeff King
Message 2 of 12 in “minor ref-filter error-reporting bug-fixes”
  1. 0/5 minor ref-filter error-reporting bug-fixesJeff King, Dec 14, 2022
  2. 1/5 ref-filter: reject arguments to %(HEAD)Jeff King, Dec 14, 2022
  3. 2/5 ref-filter: factor out "%(foo) does not take arguments" errorsJeff King, Dec 14, 2022
  4. Taylor BlauDec 14, 2022
  5. Taylor BlauDec 14, 2022
  6. Jeff KingDec 14, 2022
  7. 3/5 ref-filter: factor out "unrecognized %(foo) arg" errorsJeff King, Dec 14, 2022
  8. 4/5 ref-filter: truncate atom names in error messagesJeff King, Dec 14, 2022
  9. Taylor BlauDec 14, 2022
  10. Jeff KingDec 14, 2022
  11. 5/5 ref-filter: convert email atom parser to use err_bad_arg()Jeff King, Dec 14, 2022
  12. Taylor BlauDec 14, 2022

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.