1
1
use anyhow:: bail;
2
2
use gitbutler_project:: Project ;
3
+ use gix:: bstr:: ByteSlice ;
3
4
use std:: collections:: BTreeSet ;
4
5
use std:: path:: { Path , PathBuf } ;
5
6
@@ -217,14 +218,16 @@ fn warn_about_filters_and_git_lfs(repo: gix::Repository) -> anyhow::Result<Optio
217
218
) ?;
218
219
let mut attrs = cache. selected_attribute_matches ( Some ( "filter" ) ) ;
219
220
let mut all_filters = BTreeSet :: < String > :: new ( ) ;
221
+ let mut files_with_filter = Vec :: new ( ) ;
220
222
for entry in index. entries ( ) {
221
- let entry = cache. at_entry ( entry. path ( & index) , None ) ?;
222
- if entry. matching_attributes ( & mut attrs) {
223
- all_filters. extend (
224
- attrs
225
- . iter ( )
226
- . filter_map ( |attr| attr. assignment . state . as_bstr ( ) . map ( |s| s. to_string ( ) ) ) ,
227
- ) ;
223
+ let cache_entry = cache. at_entry ( entry. path ( & index) , None ) ?;
224
+ if cache_entry. matching_attributes ( & mut attrs) {
225
+ all_filters. extend ( attrs. iter ( ) . filter_map ( |attr| {
226
+ attr. assignment . state . as_bstr ( ) . map ( |s| {
227
+ files_with_filter. push ( entry. path ( & index) . to_str_lossy ( ) ) ;
228
+ s. to_string ( )
229
+ } )
230
+ } ) ) ;
228
231
}
229
232
}
230
233
@@ -235,17 +238,18 @@ fn warn_about_filters_and_git_lfs(repo: gix::Repository) -> anyhow::Result<Optio
235
238
let has_lfs = all_filters. contains ( "lfs" ) ;
236
239
let mut msg = format ! (
237
240
"Worktree filter(s) detected: {comma_separated}\n \
238
- These will silently not be applied during workspace operations.\n \
239
- Assure these aren't touched by GitButler or avoid using it in this repository.\n \
240
- See https://github.com/gitbutlerapp/gitbutler/issues/2595#issuecomment-3036097607 for details.",
241
+ Filters will silently not be applied during workspace operations to the files listed below.\n \
242
+ Assure these aren't touched by GitButler or avoid using it in this repository.",
241
243
comma_separated = Vec :: from_iter( all_filters) . join( ", " )
242
244
) ;
243
245
if has_lfs {
244
246
msg. push_str (
245
247
r#"
246
248
247
- Use `git lfs pull --include="*" to restore git-lfs files.`"#,
249
+ `git lfs pull --include="*" to restore git-lfs files.` can be used to restore git-lfs files after GitButler touched them. "# ,
248
250
) ;
249
251
}
252
+ msg. push_str ( "\n \n " ) ;
253
+ msg. push_str ( & files_with_filter. join ( "\n " ) ) ;
250
254
Ok ( Some ( msg) )
251
255
}
0 commit comments