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

[PATCH] builtin/cat-file.c: simplify calling `report_object_status()`

From
Taylor Blau <me@ttaylorr.com>
Date
Oct 13, 2025, 21:56 UTC
Message-ID
<9236fa6e654a59337266430a2a8807da21210cd4.1760392502.git.me@ttaylorr.com>

In b0b910e052 (cat-file.c: add batch handling for submodules, 2025-06-02), we began handling submodule entries specially when batching cat-file like so:

  $ echo :sha1collisiondetection | git.compile cat-file --batch-check
  855827c583bc30645ba427885caa40c5b81764d2 submodule

Commit b0b910e052 notes that submodules are handled differently than non-existent objects, which print "<given-name> <type>", since there is (a) no object to resolve the OID of in the first place, and as commit b0b910e052 notes, (b) for submodules in particular, it is useful to know what commit it points at without having to spawn another Git process.

That commit does so by calling report_object_status() and passing in "oid_to_hex(&data->oid)" for the "obj_name" parameter. This is unnecessary, however, since report_object_status() will do the same automatically if given a NULL "obj_name" argument.

That behavior dates back to 6a951937ae (cat-file: add --batch-all-objects option, 2015-06-22), so rely on that instead of having the caller open-code that part of report_object_status().

Signed-off-by: Taylor Blau <me@ttaylorr.com>
---
I noticed this while merging v2.50.1 into GitHub's private fork, and
thought it was a good opportunity for some light clean-up.
 builtin/cat-file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index ee6715fa52..5ca2ca3852 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -495,7 +495,7 @@ static void batch_object_write(const char *obj_name,
 							    OBJECT_INFO_LOOKUP_REPLACE);
 		if (ret < 0) {
 			if (data->mode == S_IFGITLINK)
-				report_object_status(opt, oid_to_hex(&data->oid), &data->oid, "submodule");
+				report_object_status(opt, NULL, &data->oid, "submodule");
 			else
 				report_object_status(opt, obj_name, &data->oid, "missing");
 			return;

base-commit: 4b71b294773cc4f7fe48ec3a70079aa8783f373d
--
2.51.0.491.g4b71b294773.dirty
Next: Jeff King
Message 1 of 2 in “builtin/cat-file.c: simplify calling `report_object_status()`”
  1. builtin/cat-file.c: simplify calling `report_object_status()`Taylor Blau, Oct 13, 2025
  2. Jeff KingOct 14, 2025

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.