Skip to content
Myr

Merge pull request #817 from will459/add_no_ignore_parent

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Add --no-ignore-parent flag

authored by Tavian Barnes · committed by GitHub · parents 3ba90dd, 43f5c8a · Browse files · 6 files+92 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

6 files+92 added−1 removed

  • tests:+72 added−0 removed
  • other:+20 added−1 removed

6 files+92 added−1 removed

modified:src/app.rs+10 added
48 unmodified lines
49 ignored by '.gitignore' files.",50 ),51 )52 .arg(53 Arg::with_name("no-ignore-parent")54 .long("no-ignore-parent")55 .overrides_with("no-ignore-parent")56 .hidden_short_help(true)57 .long_help(58 "Show search results from files and directories that would otherwise be \59 ignored by '.gitignore', '.ignore', or '.fdignore' files in parent directories.",60 ),61 )62 .arg(63 Arg::with_name("no-global-ignore-file")64 .long("no-global-ignore-file")65 .hidden(true)66 .long_help("Do not respect the global ignore file."),
573 unmodified lines
modified:src/main.rs+4 added
338 unmodified lines
339 || matches.is_present("rg-alias-hidden-ignore")),340 read_vcsignore: !(matches.is_present("no-ignore")341 || matches.is_present("rg-alias-hidden-ignore")342 || matches.is_present("no-ignore-vcs")),343 read_parent_ignore: !(matches.is_present("no-ignore")344 || matches.is_present("rg-alias-hidden-ignore")345 || matches.is_present("no-ignore-vcs")346 || matches.is_present("no-ignore-parent")),347 read_global_ignore: !(matches.is_present("no-ignore")348 || matches.is_present("rg-alias-hidden-ignore")349 || matches.is_present("no-global-ignore-file")),350 follow_links: matches.is_present("follow"),
148 unmodified lines
modified:src/options.rs+3 added
22 unmodified lines
2324 /// Whether to respect `.fdignore` files or not.25 pub read_fdignore: bool,2627 /// Whether to respect ignore files in parent directories or not.28 pub read_parent_ignore: bool,2930 /// Whether to respect VCS ignore files (`.gitignore`, ..) or not.31 pub read_vcsignore: bool,3233 /// Whether to respect the global ignore file or not.
79 unmodified lines
modified:src/walk.rs+1 added-1 removed
66 unmodified lines
67 let mut walker = WalkBuilder::new(first_path_buf.as_path());68 walker69 .hidden(config.ignore_hidden)70 .ignore(config.read_fdignore)71 .parents(config.read_fdignore || config.read_vcsignore)71 .parents(config.read_parent_ignore)72 .git_ignore(config.read_vcsignore)73 .git_global(config.read_vcsignore)74 .git_exclude(config.read_vcsignore)75 .overrides(overrides)
428 unmodified lines
modified:tests/tests.rs+72 added
496 unmodified lines
497 ignored-by-both",498 );499}500501/// Ignore parent ignore files (--no-ignore-parent)502#[test]503fn test_no_ignore_parent() {504 let dirs = &["inner"];505 let files = &[506 "inner/parent-ignored",507 "inner/child-ignored",508 "inner/not-ignored",509 ];510 let te = TestEnv::new(dirs, files);511512 // Ignore 'parent-ignored' in root513 fs::File::create(te.test_root().join(".gitignore"))514 .unwrap()515 .write_all(b"parent-ignored")516 .unwrap();517 // Ignore 'child-ignored' in inner518 fs::File::create(te.test_root().join("inner/.gitignore"))519 .unwrap()520 .write_all(b"child-ignored")521 .unwrap();522523 te.assert_output_subdirectory("inner", &[], "not-ignored");524525 te.assert_output_subdirectory(526 "inner",527 &["--no-ignore-parent"],528 "parent-ignored529 not-ignored",530 );531}532533/// Ignore parent ignore files (--no-ignore-parent) with an inner git repo534#[test]535fn test_no_ignore_parent_inner_git() {536 let dirs = &["inner"];537 let files = &[538 "inner/parent-ignored",539 "inner/child-ignored",540 "inner/not-ignored",541 ];542 let te = TestEnv::new(dirs, files);543544 // Make the inner folder also appear as a git repo545 fs::create_dir_all(te.test_root().join("inner/.git")).unwrap();546547 // Ignore 'parent-ignored' in root548 fs::File::create(te.test_root().join(".gitignore"))549 .unwrap()550 .write_all(b"parent-ignored")551 .unwrap();552 // Ignore 'child-ignored' in inner553 fs::File::create(te.test_root().join("inner/.gitignore"))554 .unwrap()555 .write_all(b"child-ignored")556 .unwrap();557558 te.assert_output_subdirectory(559 "inner",560 &[],561 "not-ignored562 parent-ignored",563 );564565 te.assert_output_subdirectory(566 "inner",567 &["--no-ignore-parent"],568 "not-ignored569 parent-ignored",570 );571}572573/// Precedence of .fdignore files574#[test]575fn test_custom_ignore_precedence() {576 let dirs = &["inner"];
1313 unmodified lines
modified:CHANGELOG.md+2 added
3 unmodified lines
4- Don't buffer command output from `--exec` when using a single thread. See #52256- Add new `-q, --quiet` flag, see #303 (@Asha20)78- Add new `--no-ignore-parent` flag, see #787 (@will459)910## Bugfixes1112- Set default path separator to `/` in MSYS, see #537 and #730 (@aswild)13- fd cannot search files under a RAM disk, see #752
517 unmodified lines