Skip to content

Commit 09f904b

Browse files
committed
Add --show-ignore-patterns to gix repo exclude query (#301)
1 parent e4f4c4b commit 09f904b

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

gitoxide-core/src/repository/exclude.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub mod query {
1414
pub format: OutputFormat,
1515
pub pathspecs: Vec<git::path::Spec>,
1616
pub overrides: Vec<OsString>,
17+
pub show_ignore_patterns: bool,
1718
}
1819
}
1920

@@ -24,6 +25,7 @@ pub fn query(
2425
overrides,
2526
format,
2627
pathspecs,
28+
show_ignore_patterns,
2729
}: query::Options,
2830
) -> anyhow::Result<()> {
2931
if format != OutputFormat::Human {
@@ -50,7 +52,7 @@ pub fn query(
5052
let entry = cache.at_entry(path, is_dir, |oid, buf| repo.objects.find_blob(oid, buf))?;
5153
let match_ = entry
5254
.matching_exclude_pattern()
53-
.and_then(|m| (!m.pattern.is_negative()).then(|| m));
55+
.and_then(|m| (show_ignore_patterns || !m.pattern.is_negative()).then(|| m));
5456
match match_ {
5557
Some(m) => writeln!(
5658
out,

src/plumbing/main.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,11 @@ pub fn main() -> Result<()> {
195195
),
196196
},
197197
repo::Subcommands::Exclude { cmd } => match cmd {
198-
repo::exclude::Subcommands::Query { patterns, pathspecs } => prepare_and_run(
198+
repo::exclude::Subcommands::Query {
199+
patterns,
200+
pathspecs,
201+
show_ignore_patterns,
202+
} => prepare_and_run(
199203
"repository-exclude-query",
200204
verbose,
201205
progress,
@@ -208,6 +212,7 @@ pub fn main() -> Result<()> {
208212
core::repository::exclude::query::Options {
209213
format,
210214
pathspecs,
215+
show_ignore_patterns,
211216
overrides: patterns,
212217
},
213218
)

src/plumbing/options.rs

+5
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,11 @@ pub mod repo {
385385
pub enum Subcommands {
386386
/// Check if path-specs are excluded and print the result similar to `git check-ignore`.
387387
Query {
388+
/// Show actual ignore patterns instead of un-excluding an entry.
389+
///
390+
/// That way one can understand why an entry might not be excluded.
391+
#[clap(long, short = 'i')]
392+
show_ignore_patterns: bool,
388393
/// Additional patterns to use for exclusions. They have the highest priority.
389394
///
390395
/// Useful for undoing previous patterns using the '!' prefix.

0 commit comments

Comments
 (0)