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

Make -u idempotent #986

Merged
merged 3 commits into from
May 15, 2022
Merged
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


## Changes

- Changed `-u` flag to be equivalent to `-HI`. Multiple `-u` flags still allowed but do nothing, see #840 (@jacksontheel)

## Other

Expand Down
2 changes: 1 addition & 1 deletion doc/fd.1
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ The global fd ignore file (usually
The flag can be overridden with '--ignore'.
.TP
.B \-u, \-\-unrestricted
Alias for '--no-ignore'. Can be repeated; '-uu' is an alias for '--no-ignore --hidden'.
Perform an unrestricted search, including ignored and hidden files. This is an alias for '--hidden --no-ignore'.
.TP
.B \-\-no\-ignore\-vcs
Show search results from files and directories that would otherwise be ignored by gitignore files
Expand Down
8 changes: 4 additions & 4 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ pub fn build_app() -> Command<'static> {
.short('u')
.long("unrestricted")
.overrides_with_all(&["ignore", "no-hidden"])
.multiple_occurrences(true)
.multiple_occurrences(true) // Allowed for historical reasons
.hide_short_help(true)
.help("Alias for '--no-ignore', and '--hidden' when given twice")
.help("Unrestricted search, alias for '--no-ignore --hidden'")
.long_help(
"Alias for '--no-ignore'. Can be repeated. '-uu' is an alias for \
'--no-ignore --hidden'.",
"Perform an unrestricted search, including ignored and hidden files. This is \
an alias for '--no-ignore --hidden'."
),
)
.arg(
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ fn construct_config(matches: clap::ArgMatches, pattern_regex: &str) -> Result<Co
case_sensitive,
search_full_path: matches.is_present("full-path"),
ignore_hidden: !(matches.is_present("hidden")
|| matches.occurrences_of("rg-alias-hidden-ignore") >= 2),
|| matches.is_present("rg-alias-hidden-ignore")),
read_fdignore: !(matches.is_present("no-ignore")
|| matches.is_present("rg-alias-hidden-ignore")),
read_vcsignore: !(matches.is_present("no-ignore")
Expand Down
14 changes: 1 addition & 13 deletions tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -656,18 +656,6 @@ fn test_no_ignore_aliases() {

te.assert_output(
&["-u", "foo"],
"./a.foo
./fdignored.foo
./gitignored.foo
./one/b.foo
./one/two/c.foo
./one/two/C.Foo2
./one/two/three/d.foo
./one/two/three/directory_foo",
);

te.assert_output(
&["-uu", "foo"],
"./.hidden.foo
./a.foo
./fdignored.foo
Expand Down Expand Up @@ -2039,7 +2027,7 @@ fn test_number_parsing_errors() {
#[test_case("--no-ignore-vcs", &["--ignore-vcs"] ; "no-ignore-vcs")]
#[test_case("--follow", &["--no-follow"] ; "follow")]
#[test_case("--absolute-path", &["--relative-path"] ; "absolute-path")]
#[test_case("-u", &["--ignore"] ; "u")]
#[test_case("-u", &["--ignore", "--no-hidden"] ; "u")]
#[test_case("-uu", &["--ignore", "--no-hidden"] ; "uu")]
fn test_opposing(flag: &str, opposing_flags: &[&str]) {
let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES);
Expand Down