File tree Expand file tree Collapse file tree 3 files changed +23
-4
lines changed
gitoxide-core/src/repository Expand file tree Collapse file tree 3 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -7,17 +7,23 @@ use git_repository as git;
7
7
pub mod query {
8
8
use crate :: OutputFormat ;
9
9
use git_repository as git;
10
+ use std:: ffi:: OsString ;
10
11
11
12
pub struct Options {
12
13
pub format : OutputFormat ,
13
14
pub pathspecs : Vec < git:: path:: Spec > ,
15
+ pub overrides : Vec < OsString > ,
14
16
}
15
17
}
16
18
17
19
pub fn query (
18
20
repo : git:: Repository ,
19
21
_out : impl io:: Write ,
20
- query:: Options { format, pathspecs : _ } : query:: Options ,
22
+ query:: Options {
23
+ overrides,
24
+ format,
25
+ pathspecs : _,
26
+ } : query:: Options ,
21
27
) -> anyhow:: Result < ( ) > {
22
28
if format != OutputFormat :: Human {
23
29
bail ! ( "JSON output isn't implemented yet" ) ;
@@ -28,7 +34,10 @@ pub fn query(
28
34
. current ( )
29
35
. with_context ( || "Cannot check excludes without a current worktree" ) ?;
30
36
let index = worktree. open_index ( ) ?;
31
- worktree. excludes ( & index. state , None ) ?; // TODO: support CLI overrides
37
+ worktree. excludes (
38
+ & index. state ,
39
+ Some ( git:: attrs:: MatchGroup :: < git:: attrs:: Ignore > :: from_overrides ( overrides) ) ,
40
+ ) ?;
32
41
33
42
todo ! ( "impl" ) ;
34
43
}
Original file line number Diff line number Diff line change @@ -195,7 +195,7 @@ pub fn main() -> Result<()> {
195
195
) ,
196
196
} ,
197
197
repo:: Subcommands :: Exclude { cmd } => match cmd {
198
- repo:: exclude:: Subcommands :: Query { pathspecs } => prepare_and_run (
198
+ repo:: exclude:: Subcommands :: Query { patterns , pathspecs } => prepare_and_run (
199
199
"repository-exclude-query" ,
200
200
verbose,
201
201
progress,
@@ -205,7 +205,11 @@ pub fn main() -> Result<()> {
205
205
core:: repository:: exclude:: query (
206
206
repository. into ( ) ,
207
207
out,
208
- core:: repository:: exclude:: query:: Options { format, pathspecs } ,
208
+ core:: repository:: exclude:: query:: Options {
209
+ format,
210
+ pathspecs,
211
+ overrides : patterns,
212
+ } ,
209
213
)
210
214
} ,
211
215
) ,
Original file line number Diff line number Diff line change @@ -379,11 +379,17 @@ pub mod repo {
379
379
380
380
pub mod exclude {
381
381
use git_repository as git;
382
+ use std:: ffi:: OsString ;
382
383
383
384
#[ derive( Debug , clap:: Subcommand ) ]
384
385
pub enum Subcommands {
385
386
/// Check if path-specs are excluded and print the result similar to `git check-ignore`.
386
387
Query {
388
+ /// Additional patterns to use for exclusions. They have the highest priority.
389
+ ///
390
+ /// Useful for undoing previous patterns using the '!' prefix.
391
+ #[ clap( long, short = 'p' ) ]
392
+ patterns : Vec < OsString > ,
387
393
/// The git path specifications to check for exclusion.
388
394
pathspecs : Vec < git:: path:: Spec > ,
389
395
} ,
You can’t perform that action at this time.
0 commit comments