Skip to content

Commit 9236fa6

Browse files
committed
builtin/cat-file.c: simplify calling report_object_status()
In b0b910e (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 b0b910e 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 b0b910e 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 6a95193 (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 <[email protected]>
1 parent 4b71b29 commit 9236fa6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

builtin/cat-file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ static void batch_object_write(const char *obj_name,
495495
OBJECT_INFO_LOOKUP_REPLACE);
496496
if (ret < 0) {
497497
if (data->mode == S_IFGITLINK)
498-
report_object_status(opt, oid_to_hex(&data->oid), &data->oid, "submodule");
498+
report_object_status(opt, NULL, &data->oid, "submodule");
499499
else
500500
report_object_status(opt, obj_name, &data->oid, "missing");
501501
return;

0 commit comments

Comments
 (0)