@@ -177,6 +177,21 @@ impl<'repo> Cursor<'_, 'repo> {
177
177
pub fn write ( & mut self ) -> Result < Id < ' repo > , write:: Error > {
178
178
write_cursor ( self )
179
179
}
180
+
181
+ /// Obtain the entry at `rela_path` or return `None` if none was found, or the tree wasn't yet written
182
+ /// to that point.
183
+ /// The root tree is always available.
184
+ /// Note that after [writing](Self::write) only the root path remains, all other intermediate trees are removed.
185
+ /// The entry can be anything that can be stored in a tree, but may have a null-id if it's a newly
186
+ /// inserted tree. Also, ids of trees might not be accurate as they may have been changed in memory.
187
+ pub fn get ( & self , rela_path : impl ToComponents ) -> Option < crate :: object:: tree:: EntryRef < ' repo , ' _ > > {
188
+ self . inner
189
+ . get ( rela_path. to_components ( ) )
190
+ . map ( |entry| crate :: object:: tree:: EntryRef {
191
+ inner : entry. into ( ) ,
192
+ repo : self . repo ,
193
+ } )
194
+ }
180
195
}
181
196
182
197
/// Operations
@@ -242,6 +257,21 @@ impl<'repo> super::Editor<'repo> {
242
257
pub fn write ( & mut self ) -> Result < Id < ' repo > , write:: Error > {
243
258
write_cursor ( & mut self . to_cursor ( ) )
244
259
}
260
+
261
+ /// Obtain the entry at `rela_path` or return `None` if none was found, or the tree wasn't yet written
262
+ /// to that point.
263
+ /// The root tree is always available.
264
+ /// Note that after [writing](Self::write) only the root path remains, all other intermediate trees are removed.
265
+ /// The entry can be anything that can be stored in a tree, but may have a null-id if it's a newly
266
+ /// inserted tree. Also, ids of trees might not be accurate as they may have been changed in memory.
267
+ pub fn get ( & self , rela_path : impl ToComponents ) -> Option < crate :: object:: tree:: EntryRef < ' repo , ' _ > > {
268
+ self . inner
269
+ . get ( rela_path. to_components ( ) )
270
+ . map ( |entry| crate :: object:: tree:: EntryRef {
271
+ inner : entry. into ( ) ,
272
+ repo : self . repo ,
273
+ } )
274
+ }
245
275
}
246
276
247
277
fn write_cursor < ' repo > ( cursor : & mut Cursor < ' _ , ' repo > ) -> Result < Id < ' repo > , write:: Error > {
0 commit comments