File tree Expand file tree Collapse file tree 2 files changed +8
-6
lines changed
Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,9 @@ use bstr::BStr;
44
55use crate :: Path ;
66
7+ /// The prefix used to mark a path as optional in Git configuration files.
8+ const OPTIONAL_PREFIX : & [ u8 ] = b":(optional)" ;
9+
710///
811pub mod interpolate {
912 use std:: path:: PathBuf ;
@@ -108,8 +111,6 @@ impl AsRef<BStr> for Path<'_> {
108111
109112impl < ' a > From < Cow < ' a , BStr > > for Path < ' a > {
110113 fn from ( value : Cow < ' a , BStr > ) -> Self {
111- const OPTIONAL_PREFIX : & [ u8 ] = b":(optional)" ;
112-
113114 // Check if the value starts with ":(optional)" prefix
114115 if value. starts_with ( OPTIONAL_PREFIX ) {
115116 // Strip the prefix while preserving the Cow variant to avoid unnecessary allocations
@@ -122,12 +123,12 @@ impl<'a> From<Cow<'a, BStr>> for Path<'a> {
122123 } ;
123124 Path {
124125 value : stripped,
125- is_optional : true ,
126+ optional : true ,
126127 }
127128 } else {
128129 Path {
129130 value,
130- is_optional : false ,
131+ optional : false ,
131132 }
132133 }
133134 }
@@ -140,7 +141,7 @@ impl<'a> Path<'a> {
140141 /// This is typically used for configuration like `blame.ignorerevsfile` where
141142 /// the file might not exist in all repositories.
142143 pub fn is_optional ( & self ) -> bool {
143- self . is_optional
144+ self . optional
144145 }
145146
146147 /// Interpolates this path into a path usable on the file system.
Original file line number Diff line number Diff line change @@ -46,5 +46,6 @@ pub struct Path<'a> {
4646 /// The path string, un-interpolated
4747 pub value : std:: borrow:: Cow < ' a , bstr:: BStr > ,
4848 /// Whether this path was prefixed with `:(optional)`, indicating it's acceptable if the file doesn't exist.
49- pub is_optional : bool ,
49+ /// Use `is_optional()` method to check this value.
50+ pub ( crate ) optional : bool ,
5051}
You can’t perform that action at this time.
0 commit comments