]> git.ipfire.org Git - thirdparty/git.git/commit
cat-file.c: add batch handling for submodules
authorVictoria Dye <vdye@github.com>
Mon, 2 Jun 2025 18:55:55 +0000 (18:55 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 3 Jun 2025 19:08:58 +0000 (12:08 -0700)
commitb0b910e052b2c5a8036343c0475dbbb01add6be8
treeb97adf8e2a2e2da7f860278dd35501523e415913
parentaba14384354c6f722c127962bc756a542078f3e3
cat-file.c: add batch handling for submodules

When an object specification is passed to 'cat-file --batch[-check]'
referring to a submodule (e.g. 'HEAD:path/to/my/submodule'), the current
behavior of the command is to print the "missing" error message. However, it
is often valuable for callers to distinguish between paths that are actually
missing and "the submodule tree entry exists, but the object does not exist
in the repository".

To disambiguate without needing to invoke a separate Git process (e.g.
'ls-tree'), print the message "<oid> submodule" for such objects instead of
"<object> missing". In addition to the change from "missing" to "submodule",
the new message differs from the old in that it always prints the resolved
tree entry's OID, rather than the input object specification.

Note that this implementation maintains a distinction between submodules
where the commit OID is not present in the repo, and submodules where the
commit OID *is* present; the former will now print "<object> submodule", but
the latter will still print the full object content.

Signed-off-by: Victoria Dye <vdye@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-cat-file.adoc
builtin/cat-file.c
t/t1006-cat-file.sh