File tree 3 files changed +7
-4
lines changed
3 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ use crate::fs::PathOidMapping;
3
3
use bstr:: { BStr , BString , ByteSlice } ;
4
4
use git_glob:: pattern:: Case ;
5
5
use git_hash:: oid;
6
+ use std:: borrow:: Cow ;
6
7
use std:: path:: Path ;
7
8
8
9
type AttributeMatchGroup = git_attributes:: MatchGroup < git_attributes:: Attributes > ;
@@ -150,7 +151,7 @@ impl Ignore {
150
151
let ignore_path_relative = rela_dir. join ( ".gitignore" ) ;
151
152
let ignore_path_relative = git_path:: to_unix_separators_on_windows ( git_path:: into_bstr ( ignore_path_relative) ) ;
152
153
let ignore_file_in_index =
153
- attribute_files_in_index. binary_search_by ( |t| t. 0 . cmp ( ignore_path_relative. as_ref ( ) ) ) ;
154
+ attribute_files_in_index. binary_search_by ( |t| t. 0 . as_ref ( ) . cmp ( ignore_path_relative. as_ref ( ) ) ) ;
154
155
let follow_symlinks = ignore_file_in_index. is_err ( ) ;
155
156
if !self
156
157
. stack
@@ -267,7 +268,7 @@ impl State {
267
268
if is_ignore && !entry. flags . contains ( git_index:: entry:: Flags :: SKIP_WORKTREE ) {
268
269
return None ;
269
270
}
270
- Some ( ( path, entry. id ) )
271
+ Some ( ( Cow :: Borrowed ( path) , entry. id ) )
271
272
} else {
272
273
None
273
274
}
Original file line number Diff line number Diff line change 1
1
use bstr:: BStr ;
2
+ use std:: borrow:: Cow ;
2
3
use std:: path:: PathBuf ;
3
4
4
5
/// Common knowledge about the worktree that is needed across most interactions with the work tree
@@ -69,7 +70,7 @@ pub struct Cache<'paths> {
69
70
attribute_files_in_index : Vec < PathOidMapping < ' paths > > ,
70
71
}
71
72
72
- pub ( crate ) type PathOidMapping < ' paths > = ( & ' paths BStr , git_hash:: ObjectId ) ;
73
+ pub ( crate ) type PathOidMapping < ' paths > = ( Cow < ' paths , BStr > , git_hash:: ObjectId ) ;
73
74
74
75
///
75
76
pub mod cache;
Original file line number Diff line number Diff line change @@ -118,6 +118,7 @@ mod create_directory {
118
118
#[ allow( unused) ]
119
119
mod ignore_and_attributes {
120
120
use bstr:: { BStr , ByteSlice } ;
121
+ use std:: borrow:: Cow ;
121
122
use std:: path:: Path ;
122
123
123
124
use git_glob:: pattern:: Case ;
@@ -180,7 +181,7 @@ mod ignore_and_attributes {
180
181
assert_eq ! (
181
182
attribute_files_in_index,
182
183
vec![ (
183
- "other-dir-with-ignore/.gitignore" . as_bytes( ) . as_bstr( ) ,
184
+ Cow :: Borrowed ( "other-dir-with-ignore/.gitignore" . as_bytes( ) . as_bstr( ) ) ,
184
185
hex_to_id( "5c7e0ed672d3d31d83a3df61f13cc8f7b22d5bfd" )
185
186
) ]
186
187
) ;
You can’t perform that action at this time.
0 commit comments