Skip to content

Commit 3c95ea0

Browse files
committed
Add Graph::object_hash
1 parent 79fda22 commit 3c95ea0

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

gix-commitgraph/src/access.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,20 @@ impl Graph {
1111
r.file.commit_at(r.pos)
1212
}
1313

14+
/// The kind of hash used in this `Graph`.
15+
///
16+
/// Note that it is always conforming to the hash used in the owning repository.
17+
///
18+
/// # Panics
19+
///
20+
/// If the graph does not contain any `File`.
21+
pub fn object_hash(&self) -> gix_hash::Kind {
22+
self.files
23+
.first()
24+
.map(super::File::object_hash)
25+
.expect("graph to have at least one file")
26+
}
27+
1428
/// Returns the commit matching the given `id`.
1529
pub fn commit_by_id(&self, id: impl AsRef<gix_hash::oid>) -> Option<Commit<'_>> {
1630
let r = self.lookup_by_id(id.as_ref())?;

0 commit comments

Comments
 (0)