File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -77,6 +77,17 @@ pub enum Either<'buf, 'cache> {
7777 CachedCommit ( gix_commitgraph:: file:: Commit < ' cache > ) ,
7878}
7979
80+ impl Either < ' _ , ' _ > {
81+ /// Get a commits `tree_id` by either getting it from a [`gix_commitgraph::Graph`], if
82+ /// present, or a [`gix_object::CommitRefIter`] otherwise.
83+ pub fn tree_id ( self ) -> Result < ObjectId , gix_object:: decode:: Error > {
84+ match self {
85+ Self :: CommitRefIter ( mut commit_ref_iter) => commit_ref_iter. tree_id ( ) ,
86+ Self :: CachedCommit ( commit) => Ok ( commit. root_tree_id ( ) . into ( ) ) ,
87+ }
88+ }
89+ }
90+
8091/// Find information about a commit by either getting it from a [`gix_commitgraph::Graph`], if
8192/// present, or a [`gix_object::CommitRefIter`] otherwise.
8293pub fn find < ' cache , ' buf , Find > (
You can’t perform that action at this time.
0 commit comments