Skip to content

cli: default hash-object validation to the default OID type - #7370

Open
Alb3e3 wants to merge 1 commit into
libgit2:mainfrom
Alb3e3:fix/hash-object-default-oid
Open

Alb3e3 wants to merge 1 commit into
libgit2:mainfrom
Alb3e3:fix/hash-object-default-oid

Conversation

@Alb3e3

@Alb3e3 Alb3e3 commented Sep 7, 2026

Copy link
Copy Markdown

Fixes #7306.

Without -w, hash-object does not open a repository. Passing the resulting
zero object-ID type to content validation rejects valid commit and tag objects.
Use GIT_OID_DEFAULT when no repository is open, matching the default already
used to compute their IDs. Repository-specific types remain unchanged with -w.

Add a CLI CTest regression covering known blob/tree/commit/tag hashes through
both files and stdin, plus rejection of malformed non-blob contents. The valid
commit test fails on current main and passes with the fix. Unlike the original
report, current main reports a bad commit object instead of an unknown OID type;
the missing default is still reproducible.

Validation on Linux: offline, utility and new CLI CTest suites all pass.
Writing valid commit/tag objects with -w in both SHA1 and SHA256 repositories
also produces the same IDs as Git, with the resulting objects readable by Git.
The test registration uses target availability (including the iOS CLI exclusion)
and fixtures are normalized to LF for consistent hashes. Non-Linux execution
remains for upstream CI.

AI assistance was used to investigate, implement, and run local validation.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cli: hash-object -t <non-blob> <file> reports "unknown oid type" in GIT_EXPERIMENTAL_SHA256 builds when -w is not given

1 participant