Skip to content

Commit

Permalink
feat: adds (no-)ignore-vsc-exclude
Browse files Browse the repository at this point in the history
  • Loading branch information
AckslD committed Dec 26, 2024
1 parent 331daf1 commit e59ab54
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,22 @@ pub struct Opts {
#[arg(long, overrides_with = "no_ignore_vcs", hide = true, action = ArgAction::SetTrue)]
ignore_vcs: (),

///Show search results from files and directories that
///would otherwise be ignored by '.git/info/exclude'.
///Git ignore files are still respected unless --no-ignore-vsc is given.
///The flag can be overridden with --ignore-vcs.
#[arg(
long,
hide_short_help = true,
help = "Do not respect .git/info/exclude",
long_help
)]
pub no_ignore_vcs_exclude: bool,

/// Overrides --no-ignore-vcs-exclude
#[arg(long, overrides_with = "no_ignore_vcs_exclude", hide = true, action = ArgAction::SetTrue)]
ignore_vcs_exclude: (),

/// Do not require a git repository to respect gitignores.
/// By default, fd will only respect global gitignore rules, .gitignore rules,
/// and local exclude rules if fd detects that you are searching inside a
Expand Down
3 changes: 3 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ pub struct Config {
/// Whether to respect VCS ignore files (`.gitignore`, ..) or not.
pub read_vcsignore: bool,

/// Whether to respect VCS exclude files (`.git/info/exclude`, ..) or not.
pub read_vcsexclude: bool,

/// Whether to require a `.git` directory to respect gitignore files.
pub require_git_to_read_vcsignore: bool,

Expand Down
6 changes: 6 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,12 @@ fn construct_config(mut opts: Opts, pattern_regexps: &[String]) -> Result<Config
ignore_hidden: !(opts.hidden || opts.rg_alias_ignore()),
read_fdignore: !(opts.no_ignore || opts.rg_alias_ignore()),
read_vcsignore: !(opts.no_ignore || opts.rg_alias_ignore() || opts.no_ignore_vcs),
read_vcsexclude: !(
opts.no_ignore
|| opts.rg_alias_ignore()
|| opts.no_ignore_vcs
|| opts.no_ignore_vcs_exclude
),
require_git_to_read_vcsignore: !opts.no_require_git,
read_parent_ignore: !opts.no_ignore_parent,
read_global_ignore: !(opts.no_ignore
Expand Down
2 changes: 1 addition & 1 deletion src/walk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ impl WorkerState {
.parents(config.read_parent_ignore && (config.read_fdignore || config.read_vcsignore))
.git_ignore(config.read_vcsignore)
.git_global(config.read_vcsignore)
.git_exclude(config.read_vcsignore)
.git_exclude(config.read_vcsexclude)
.require_git(config.require_git_to_read_vcsignore)
.overrides(overrides)
.follow_links(config.follow_links)
Expand Down

0 comments on commit e59ab54

Please sign in to comment.