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

[PATCH] grep: avoid using oid_to_hex() with parse_object_or_die()

From
René Scharfe <l.s.r@web.de>
Date
Jul 28, 2020, 21:40 UTC
Message-ID
<551da4ae-c75a-0f2b-7786-2fee32939b2b@web.de>

parse_object_or_die() is passed an object ID and a name to show if the object cannot be parsed. If the name is NULL then it shows the hexadecimal object ID. Use that feature instead of preparing and passing the hexadecimal representation to the function proactively. That's shorter and a bit more efficient.

Signed-off-by: René Scharfe <l.s.r@web.de>
---
 builtin/grep.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/grep.c b/builtin/grep.c
index a5056f395a..5975cf5ef2 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -466,7 +466,7 @@ static int grep_submodule(struct grep_opt *opt,
 		struct strbuf base = STRBUF_INIT;

 		obj_read_lock();
-		object = parse_object_or_die(oid, oid_to_hex(oid));
+		object = parse_object_or_die(oid, NULL);
 		obj_read_unlock();
 		data = read_object_with_reference(&subrepo,
 						  &object->oid, tree_type,
--
2.28.0
Next: Matheus Tavares Bernardino
Message 1 of 3 in “grep: avoid using oid_to_hex() with parse_object_or_die()”
  1. grep: avoid using oid_to_hex() with parse_object_or_die()René Scharfe, Jul 28, 2020
  2. Matheus Tavares BernardinoJul 28, 2020
  3. Junio C HamanoJul 28, 2020

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.