Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adds (no-)ignore-vsc-exclude #1652

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 4 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ 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
Loading