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;
77pub mod query {
88 use crate :: OutputFormat ;
99 use git_repository as git;
10+ use std:: ffi:: OsString ;
1011
1112 pub struct Options {
1213 pub format : OutputFormat ,
1314 pub pathspecs : Vec < git:: path:: Spec > ,
15+ pub overrides : Vec < OsString > ,
1416 }
1517}
1618
1719pub fn query (
1820 repo : git:: Repository ,
1921 _out : impl io:: Write ,
20- query:: Options { format, pathspecs : _ } : query:: Options ,
22+ query:: Options {
23+ overrides,
24+ format,
25+ pathspecs : _,
26+ } : query:: Options ,
2127) -> anyhow:: Result < ( ) > {
2228 if format != OutputFormat :: Human {
2329 bail ! ( "JSON output isn't implemented yet" ) ;
@@ -28,7 +34,10 @@ pub fn query(
2834 . current ( )
2935 . with_context ( || "Cannot check excludes without a current worktree" ) ?;
3036 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+ ) ?;
3241
3342 todo ! ( "impl" ) ;
3443}
Original file line number Diff line number Diff line change @@ -195,7 +195,7 @@ pub fn main() -> Result<()> {
195195 ) ,
196196 } ,
197197 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 (
199199 "repository-exclude-query" ,
200200 verbose,
201201 progress,
@@ -205,7 +205,11 @@ pub fn main() -> Result<()> {
205205 core:: repository:: exclude:: query (
206206 repository. into ( ) ,
207207 out,
208- core:: repository:: exclude:: query:: Options { format, pathspecs } ,
208+ core:: repository:: exclude:: query:: Options {
209+ format,
210+ pathspecs,
211+ overrides : patterns,
212+ } ,
209213 )
210214 } ,
211215 ) ,
Original file line number Diff line number Diff line change @@ -379,11 +379,17 @@ pub mod repo {
379379
380380 pub mod exclude {
381381 use git_repository as git;
382+ use std:: ffi:: OsString ;
382383
383384 #[ derive( Debug , clap:: Subcommand ) ]
384385 pub enum Subcommands {
385386 /// Check if path-specs are excluded and print the result similar to `git check-ignore`.
386387 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 > ,
387393 /// The git path specifications to check for exclusion.
388394 pathspecs : Vec < git:: path:: Spec > ,
389395 } ,
You can’t perform that action at this time.
0 commit comments