Skip to content

Commit 08c42d7

Browse files
committed
feat: adds (no-)ignore-vsc-exclude
1 parent 331daf1 commit 08c42d7

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

Diff for: src/cli.rs

+16
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,22 @@ pub struct Opts {
7878
#[arg(long, overrides_with = "no_ignore_vcs", hide = true, action = ArgAction::SetTrue)]
7979
ignore_vcs: (),
8080

81+
///Show search results from files and directories that
82+
///would otherwise be ignored by '.git/info/exclude'.
83+
///Git ignore files are still respected unless --no-ignore-vsc is given.
84+
///The flag can be overridden with --ignore-vcs.
85+
#[arg(
86+
long,
87+
hide_short_help = true,
88+
help = "Do not respect .git/info/exclude",
89+
long_help
90+
)]
91+
pub no_ignore_vcs_exclude: bool,
92+
93+
/// Overrides --no-ignore-vcs-exclude
94+
#[arg(long, overrides_with = "no_ignore_vcs_exclude", hide = true, action = ArgAction::SetTrue)]
95+
ignore_vcs_exclude: (),
96+
8197
/// Do not require a git repository to respect gitignores.
8298
/// By default, fd will only respect global gitignore rules, .gitignore rules,
8399
/// and local exclude rules if fd detects that you are searching inside a

Diff for: src/config.rs

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ pub struct Config {
3131
/// Whether to respect VCS ignore files (`.gitignore`, ..) or not.
3232
pub read_vcsignore: bool,
3333

34+
/// Whether to respect VCS exclude files (`.git/info/exclude`, ..) or not.
35+
pub read_vcsexclude: bool,
36+
3437
/// Whether to require a `.git` directory to respect gitignore files.
3538
pub require_git_to_read_vcsignore: bool,
3639

Diff for: src/main.rs

+4
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,10 @@ fn construct_config(mut opts: Opts, pattern_regexps: &[String]) -> Result<Config
249249
ignore_hidden: !(opts.hidden || opts.rg_alias_ignore()),
250250
read_fdignore: !(opts.no_ignore || opts.rg_alias_ignore()),
251251
read_vcsignore: !(opts.no_ignore || opts.rg_alias_ignore() || opts.no_ignore_vcs),
252+
read_vcsexclude: !(opts.no_ignore
253+
|| opts.rg_alias_ignore()
254+
|| opts.no_ignore_vcs
255+
|| opts.no_ignore_vcs_exclude),
252256
require_git_to_read_vcsignore: !opts.no_require_git,
253257
read_parent_ignore: !opts.no_ignore_parent,
254258
read_global_ignore: !(opts.no_ignore

Diff for: src/walk.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ impl WorkerState {
356356
.parents(config.read_parent_ignore && (config.read_fdignore || config.read_vcsignore))
357357
.git_ignore(config.read_vcsignore)
358358
.git_global(config.read_vcsignore)
359-
.git_exclude(config.read_vcsignore)
359+
.git_exclude(config.read_vcsexclude)
360360
.require_git(config.require_git_to_read_vcsignore)
361361
.overrides(overrides)
362362
.follow_links(config.follow_links)

0 commit comments

Comments
 (0)