@@ -53,22 +53,43 @@ pub(crate) mod function {
53
53
}
54
54
PathsOrPatterns :: Patterns ( patterns) => {
55
55
let mut pathspec = repo. pathspec (
56
- patterns,
56
+ patterns. iter ( ) ,
57
57
true ,
58
58
& index,
59
59
gix:: worktree:: stack:: state:: attributes:: Source :: WorktreeThenIdMapping
60
60
. adjust_for_bare ( repo. is_bare ( ) ) ,
61
61
) ?;
62
+ let mut pathspec_matched_entry = false ;
62
63
for ( path, _entry) in pathspec
63
64
. index_entries_with_paths ( & index)
64
65
. ok_or_else ( || anyhow ! ( "Pathspec didn't match a single path in the index" ) ) ?
65
66
{
67
+ pathspec_matched_entry = true ;
66
68
let entry = cache. at_entry ( path, Some ( false ) ) ?;
67
69
if !entry. matching_attributes ( & mut matches) {
68
70
continue ;
69
71
}
70
72
print_match ( & matches, path, & mut out) ?;
71
73
}
74
+
75
+ if !pathspec_matched_entry {
76
+ // TODO(borrowchk): this shouldn't be necessary at all, but `pathspec` stays borrowed mutably for some reason.
77
+ // It's probably due to the strange lifetimes of `index_entries_with_paths()`.
78
+ let pathspec = repo. pathspec (
79
+ patterns. iter ( ) ,
80
+ true ,
81
+ & index,
82
+ gix:: worktree:: stack:: state:: attributes:: Source :: WorktreeThenIdMapping
83
+ . adjust_for_bare ( repo. is_bare ( ) ) ,
84
+ ) ?;
85
+ for pattern in pathspec. search ( ) . patterns ( ) {
86
+ let entry = cache. at_entry ( pattern. path ( ) , Some ( false ) ) ?;
87
+ if !entry. matching_attributes ( & mut matches) {
88
+ continue ;
89
+ }
90
+ print_match ( & matches, pattern. path ( ) , & mut out) ?;
91
+ }
92
+ }
72
93
}
73
94
}
74
95
0 commit comments