Skip to content

Commit 2cebca0

Browse files
ttaylorrgitster
authored andcommitted
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 <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent b0b910e commit 2cebca0

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
@@ -497,7 +497,7 @@ static void batch_object_write(const char *obj_name,
497497
OBJECT_INFO_LOOKUP_REPLACE);
498498
if (ret < 0) {
499499
if (data->mode == S_IFGITLINK)
500-
report_object_status(opt, oid_to_hex(&data->oid), &data->oid, "submodule");
500+
report_object_status(opt, NULL, &data->oid, "submodule");
501501
else
502502
report_object_status(opt, obj_name, &data->oid, "missing");
503503
return;

0 commit comments

Comments
 (0)