@@ -69,8 +69,9 @@ impl State {
6969 } )
7070 }
7171
72- /// Find the entry index in [`entries()`][State::entries()] matching the given repository-relative
73- /// `path` and `stage`, or `None`.
72+ /// Find the entry index in [`entries()`][State::entries()] matching the given `path` and `stage`, or `None`.
73+ ///
74+ /// The `path` must use the repository-relative, slash-separated [`State`] path format.
7475 ///
7576 /// Use the index for accessing multiple stages if they exists, but at least the single matching entry.
7677 pub fn entry_index_by_path_and_stage ( & self , path : & BStr , stage : entry:: Stage ) -> Option < usize > {
@@ -194,6 +195,8 @@ impl State {
194195 /// Return the entry at `path` that is at the lowest available stage, using `lookup` for acceleration.
195196 /// It must have been created from this instance, and was ideally kept up-to-date with it.
196197 ///
198+ /// The `path` must use the repository-relative, slash-separated [`State`] path format.
199+ ///
197200 /// If `ignore_case` is `true`, a case-insensitive (ASCII-folding only) search will be performed.
198201 pub fn entry_by_path_icase < ' a > (
199202 & ' a self ,
@@ -219,6 +222,8 @@ impl State {
219222 /// Return the entry (at any stage) that is inside `directory`, or `None`,
220223 /// or a directory itself like a submodule or sparse directory, using `lookup` for acceleration.
221224 ///
225+ /// The `directory` must use the repository-relative, slash-separated [`State`] path format.
226+ ///
222227 /// If `ignore_case` is set, a case-insensitive (ASCII-folding only) search will be performed.
223228 pub fn entry_closest_to_directory_or_directory_icase < ' a > (
224229 & ' a self ,
@@ -244,6 +249,8 @@ impl State {
244249 /// Return the entry (at any stage) that is inside `directory`, or `None`,
245250 /// or that is a directory itself like a submodule or sparse directory.
246251 ///
252+ /// The `directory` must use the repository-relative, slash-separated [`State`] path format.
253+ ///
247254 /// Note that this is a *case-sensitive* search.
248255 pub fn entry_closest_to_directory_or_directory ( & self , directory : & BStr ) -> Option < & Entry > {
249256 let idx = match self . entry_index_by_path ( directory) {
@@ -272,6 +279,8 @@ impl State {
272279
273280 /// Check if `path` is a directory that contains entries in the index, or is a submodule.
274281 ///
282+ /// The `path` must use the repository-relative, slash-separated [`State`] path format.
283+ ///
275284 /// Returns `true` if there is at least one entry in the index whose path starts with `path/`,
276285 /// indicating that `path` is a directory containing indexed files.
277286 ///
@@ -286,6 +295,8 @@ impl State {
286295 /// Check if `path` is a directory that contains entries in the index or is a submodule,
287296 /// with optional case-insensitive matching.
288297 ///
298+ /// The `path` must use the repository-relative, slash-separated [`State`] path format.
299+ ///
289300 /// Returns `true` if there is at least one entry in the index whose path starts with `path/`,
290301 /// indicating that `path` is a directory containing indexed files.
291302 ///
@@ -304,8 +315,10 @@ impl State {
304315 . is_some ( )
305316 }
306317
307- /// Find the entry index in [`entries()[..upper_bound]`][State::entries()] matching the given repository-relative
308- /// `path` and `stage`, or `None`.
318+ /// Find the entry index in [`entries()[..upper_bound]`][State::entries()] matching the given `path` and `stage`,
319+ /// or `None`.
320+ ///
321+ /// The `path` must use the repository-relative, slash-separated [`State`] path format.
309322 ///
310323 /// Use the index for accessing multiple stages if they exists, but at least the single matching entry.
311324 ///
@@ -325,13 +338,17 @@ impl State {
325338
326339 /// Like [`entry_index_by_path_and_stage()`](State::entry_index_by_path_and_stage()),
327340 /// but returns the entry instead of the index.
341+ ///
342+ /// The `path` must use the repository-relative, slash-separated [`State`] path format.
328343 pub fn entry_by_path_and_stage ( & self , path : & BStr , stage : entry:: Stage ) -> Option < & Entry > {
329344 self . entry_index_by_path_and_stage ( path, stage)
330345 . map ( |idx| & self . entries [ idx] )
331346 }
332347
333348 /// Return the entry at `path` that is either at stage 0, or at stage 2 (ours) in case of a merge conflict.
334349 ///
350+ /// The `path` must use the repository-relative, slash-separated [`State`] path format.
351+ ///
335352 /// Using this method is more efficient in comparison to doing two searches, one for stage 0 and one for stage 2.
336353 pub fn entry_by_path ( & self , path : & BStr ) -> Option < & Entry > {
337354 let mut stage_at_index = 0 ;
@@ -355,19 +372,25 @@ impl State {
355372
356373 /// Return the index at `Ok(index)` where the entry matching `path` (in any stage) can be found, or return
357374 /// `Err(index)` to indicate the insertion position at which an entry with `path` would fit in.
375+ ///
376+ /// The `path` must use the repository-relative, slash-separated [`State`] path format.
358377 pub fn entry_index_by_path ( & self , path : & BStr ) -> Result < usize , usize > {
359378 self . entries . binary_search_by ( |e| e. path ( self ) . cmp ( path) )
360379 }
361380
362381 /// Return the slice of entries which all share the same `prefix`, or `None` if there isn't a single such entry.
363382 ///
383+ /// The `prefix` must use the repository-relative, slash-separated [`State`] path format.
384+ ///
364385 /// If `prefix` is empty, all entries are returned.
365386 pub fn prefixed_entries ( & self , prefix : & BStr ) -> Option < & [ Entry ] > {
366387 self . prefixed_entries_range ( prefix) . map ( |range| & self . entries [ range] )
367388 }
368389
369390 /// Return the range of entries which all share the same `prefix`, or `None` if there isn't a single such entry.
370391 ///
392+ /// The `prefix` must use the repository-relative, slash-separated [`State`] path format.
393+ ///
371394 /// If `prefix` is empty, the range will include all entries.
372395 pub fn prefixed_entries_range ( & self , prefix : & BStr ) -> Option < Range < usize > > {
373396 if prefix. is_empty ( ) {
@@ -415,6 +438,8 @@ impl State {
415438 /// Return the range of entries that exactly match the given `path`, in all available stages, or `None` if no entry with such
416439 /// path exists.
417440 ///
441+ /// The `path` must use the repository-relative, slash-separated [`State`] path format.
442+ ///
418443 /// The range can be used to access the respective entries via [`entries()`](Self::entries()) or [`entries_mut()](Self::entries_mut()).
419444 pub fn entry_range ( & self , path : & BStr ) -> Option < Range < usize > > {
420445 let mut stage_at_index = 0 ;
@@ -506,6 +531,8 @@ impl State {
506531
507532 /// Like [`entry_index_by_path_and_stage()`][State::entry_index_by_path_and_stage()],
508533 /// but returns the mutable entry instead of the index.
534+ ///
535+ /// The `path` must use the repository-relative, slash-separated [`State`] path format.
509536 pub fn entry_mut_by_path_and_stage ( & mut self , path : & BStr , stage : entry:: Stage ) -> Option < & mut Entry > {
510537 self . entry_index_by_path_and_stage ( path, stage)
511538 . map ( |idx| & mut self . entries [ idx] )
@@ -515,6 +542,8 @@ impl State {
515542 /// any sanity checks. This means it's possible to push a new entry to the same path on the same stage and even after sorting
516543 /// the entries lookups may still return the wrong one of them unless the correct binary search criteria is chosen.
517544 ///
545+ /// The `path` must use the repository-relative, slash-separated [`State`] path format.
546+ ///
518547 /// Note that this *is likely* to break invariants that will prevent further lookups by path unless
519548 /// [`entry_index_by_path_and_stage_bounded()`][State::entry_index_by_path_and_stage_bounded()] is used with
520549 /// the `upper_bound` being the amount of entries before the first call to this method.
0 commit comments