]> git.ipfire.org Git - thirdparty/git.git/commitdiff
builtin/cat-file.c: simplify calling `report_object_status()`
authorTaylor Blau <me@ttaylorr.com>
Mon, 13 Oct 2025 21:56:01 +0000 (17:56 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 13 Oct 2025 22:15:57 +0000 (15:15 -0700)
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/cat-file.c

index 4b23fcecbd8e7ae6bd971e3bcd6266761b1b8a72..71b94c8b3fb34fb71b73d1a104acd9d7518c2b5e 100644 (file)
@@ -497,7 +497,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;