Skip to content

Commit 832b345

Browse files
committed
doc: improve documentation of common_prefix() and pattern_matching_relative_path().
1 parent 5197196 commit 832b345

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

gix-pathspec/src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,12 @@ pub struct Pattern {
9393
pub attributes: Vec<gix_attributes::Assignment>,
9494
/// If `true`, we are a special Nil pattern and always match.
9595
nil: bool,
96-
/// The length of bytes in `path` that belong to the prefix, which will always be matched case-insensitively.
96+
/// The length of bytes in `path` that belong to the prefix, which will always be matched case-sensitively
97+
/// on case-sensitive filesystems.
98+
///
9799
/// That way, even though pathspecs are applied from the top, we can emulate having changed directory into
98-
/// a specific sub-directory in a case-sensitive file-system.
100+
/// a specific sub-directory in a case-sensitive file-system, even if the rest of the pathspec can be set to
101+
/// match case-insensitively.
99102
/// Is set by [Pattern::normalize()].
100103
prefix_len: usize,
101104
}

gix-pathspec/src/search/matching.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::{
88

99
impl Search {
1010
/// Return the first [`Match`] of `relative_path`, or `None`.
11-
/// `is_dir` is true if `relative_path` is a directory.
11+
/// `is_dir` is `true` if `relative_path` is a directory.
1212
/// `attributes` is called as `attributes(relative_path, case, is_dir, outcome) -> has_match` to obtain for attributes for `relative_path`, if
1313
/// the underlying pathspec defined an attribute filter, to be stored in `outcome`, returning true if there was a match.
1414
/// All attributes of the pathspec have to be present in the defined value for the pathspec to match.

gix-pathspec/src/search/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ impl Search {
3030
/// Return the portion of the prefix among all of the pathspecs involved in this search, or an empty string if
3131
/// there is none. It doesn't have to end at a directory boundary though, nor does it denote a directory.
3232
///
33-
/// Note that the common_prefix can be matched case-insensitively, which makes it useful to skip large portions of input.
34-
/// Further, excluded pathspecs don't participate which makes this common prefix inclusive.
33+
/// Note that the common_prefix is always matched case-sensitively, and it is useful to skip large portions of input.
34+
/// Further, excluded pathspecs don't participate which makes this common prefix inclusive. To work correclty though,
35+
/// one will have to additionally match paths that have the common prefix with that pathspec itself to assure it is
36+
/// not excluded.
3537
pub fn common_prefix(&self) -> &BStr {
3638
self.patterns
3739
.iter()

0 commit comments

Comments
 (0)