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> {
77
77
CachedCommit ( gix_commitgraph:: file:: Commit < ' cache > ) ,
78
78
}
79
79
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
+
80
91
/// Find information about a commit by either getting it from a [`gix_commitgraph::Graph`], if
81
92
/// present, or a [`gix_object::CommitRefIter`] otherwise.
82
93
pub fn find < ' cache , ' buf , Find > (
You can’t perform that action at this time.
0 commit comments