commit: use read_header

The `Odb::reader` method states:

    Note that most backends do not support streaming reads because
    they store their objects as compressed/delta’ed blobs. If the
    backend does not support streaming reads, use the read method
    instead.

This can lead to objects not being found when verifying for
commits. Instead use `read_header` to determine the `ObjectType` of
the `Oid`.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
This commit is contained in:
Fintan Halpenny
2023-05-04 17:27:47 +01:00
parent 956bf070d4
commit 24e27f6e87
+2 -2
View File
@@ -149,8 +149,8 @@ impl Commit {
fn verify_object(odb: &git2::Odb, oid: &Oid, expected: ObjectType) -> Result<(), error::Write> {
use git2::{Error, ErrorClass, ErrorCode};
let (_, _, kind) = odb
.reader(*oid)
let (_, kind) = odb
.read_header(*oid)
.map_err(|err| error::Write::OdbRead { oid: *oid, err })?;
if kind != expected {
Err(error::Write::NotCommit {