Merge pull request #1540 from tmccombs/revert-git-ignore
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Stop ignore .git folders by default
authored by Thayne McCombs · committed by GitHub · parents 8eb0479, e10a4ea · Browse files · 6 files·+40 added−13 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+40 added−13 removed
- tests:+8 added−1 removed
- other:+32 added−12 removed
Provenance
- Commit
31f2839- Tree
abf36ac- Author
Thayne McCombs <astrothayne@gmail.com>- Committer
GitHub <noreply@github.com>- Parent 1
8eb0479- Parent 2
e10a4ea
6 files changed+40 added−13 removed
modified:doc/fd.1+23 added-5 removed
31 unmodified lines32 .P33 By default34 .B fd35 will exclude hidden files and directories, as well as any files that match gitignore rules36-or ignore rules in .ignore or .fdignore files. For convenenience, '.git' is treated as if it37-was always included in gitignore rules. These files can be included with options such as38-'\-\-hidden' and '\-\-no\-ignore'.36+or ignore rules in .ignore or .fdignore files.37 .SH OPTIONS38 .TP39 .B \-H, \-\-hidden40 Include hidden files and directories in the search results41 (default: hidden files and directories are skipped). The flag can be overridden with '--no-hidden'.42 .IP45-Ignored files and .git/ are still excluded unless \-\-no\-ignore or \-\-no\-ignore\-vcs43+Ignored files are still excluded unless \-\-no\-ignore or \-\-no\-ignore\-vcs44 is also used.45 .TP46 .B \-I, \-\-no\-ignore47 Show search results from files and directories that would otherwise be ignored by28 unmodified lines76 and the global gitignore configuration77 .RI ( core.excludesFile78 git setting, which defaults to79 .IR $HOME/.config/git/ignore ).82-The pattern ".git/" is automatically added to the list of VCS ignore rules.80 The flag can be overridden with '--ignore-vcs'.81 .TP82 .B \-\-no\-require\-git83 Do not require a git repository to respect gitignores. By default, fd will only406 unmodified lines490 is set, use491 .IR $XDG_CONFIG_HOME/fd/ignore .492 Otherwise, use493 .IR $HOME/.config/fd/ignore .494+.SH FILES495+.TP496+.B .fdignore497+This file works similarly to a .gitignore file anywhere in the searched tree and specifies patterns498+that should be excluded from the search. However, this file is specific to fd, and will be used even499+if the --no-ignore-vcs option is used.500+.TP501+.B $XDG_CONFIG_HOME/fd/ignore502+Global ignore file. Unless ignore mode is turned off (such as with --no-ignore)503+ignore entries in this file will be ignored, as if it was an .fdignore file in the504+current directory.505 .SH EXAMPLES506 .TP507 .RI "Find files and directories that match the pattern '" needle "':"508 $ fd needle5 unmodified lines514 $ fd -e py515 .TP516 .RI "Open all search results with vim:"517 $ fd pattern -X vim518+.SH Tips and Tricks519+.IP \[bu]520+If you add ".git/" to your global ignore file ($XDG_CONFIG_HOME/fd/ignore), then521+".git" folders will be ignored by default, even when the --hidden option is used.522+.IP \[bu]523+You can use a shell alias or a wrapper script in order to pass desired flags to fd524+by default. For example if you do not like the default behavior of respecting gitignore,525+you can use526+`alias fd="/usr/bin/fd --no-ignore-vcs"`527+in your .bashrc to create an alias for fd that doesn't ignore git files by default.528 .SH BUGS529 Bugs can be reported on GitHub: https://github.com/sharkdp/fd/issues530 .SH SEE ALSO531 .BR find (1)modified:src/cli.rs+2 added-3 removed
47 unmodified lines48 #[arg(long, overrides_with = "hidden", hide = true, action = ArgAction::SetTrue)]49 no_hidden: (),50 51 /// Show search results from files and directories that would otherwise be52- /// ignored by '.gitignore', '.ignore', '.fdignore', the global ignore file,53- /// or the default rule that excludes .git/.52+ /// ignored by '.gitignore', '.ignore', '.fdignore', or the global ignore file,53 /// The flag can be overridden with --ignore.54 #[arg(55 long,56 short = 'I',5 unmodified lines62 /// Overrides --no-ignore63 #[arg(long, overrides_with = "no_ignore", hide = true, action = ArgAction::SetTrue)]64 ignore: (),65 67- ///Show search results from '.git/' folders and files and directories that66+ ///Show search results from files and directories that67 ///would otherwise be ignored by '.gitignore' files.68 ///The flag can be overridden with --ignore-vcs.69 #[arg(70 long,803 unmodified linesmodified:src/walk.rs-4 removed
332 unmodified lines333 .add(pattern)334 .map_err(|e| anyhow!("Malformed exclude pattern: {}", e))?;335 }336 337- if config.read_vcsignore {338- builder.add("!.git/").expect("Invalid exclude pattern");339- }340-337 builder338 .build()339 .map_err(|_| anyhow!("Mismatch in exclude patterns"))340 }328 unmodified linesmodified:tests/tests.rs+8 added-1 removed
2571 unmodified lines2572 "nested/dir/.git/foo2",2573 ],2574 );2575 2576- te.assert_output(&["--hidden", "foo"], "");2576+ te.assert_output(2577+ &["--hidden", "foo"],2578+ ".git/one/foo.a2579+ .git/.foo2580+ .git/a.foo2581+ other_dir/.git/foo12582+ nested/dir/.git/foo2",2583+ );2584 te.assert_output(&["--no-ignore", "foo"], "");2585 te.assert_output(2586 &["--hidden", "--no-ignore", "foo"],2587 ".git/one/foo.a14 unmodified linesmodified:CHANGELOG.md+4 added
2 unmodified lines3 ## Features4 5 - Add `dir` as an alias to `directory` when using `-t` \ `--type`, see #1460 and #1464 (@Ato2207).6 - Add support for @%s date format in time filters similar to GNU date (seconds since Unix epoch for --older/--newer), see #1493 (@nabellows)7+- Breaking: No longer automatically ignore `.git` when using `--hidden` with vcs ignore enabled. This reverts the change in v9.0.0. While this feature8+ was often useful, it also broke some existing workflows, and there wasn't a good way to opt out of it. And there isn't really a good way for us to add9+ a way to opt out of it. And you can easily get similar behavior by adding `.git/` to your global fdignore file.10+ See #1457.11 12 ## Bugfixes13 14 - Respect NO_COLOR environment variable with `--list-details` option. (#1455)740 unmodified linesmodified:README.md+3 added
280 unmodified lines281 If you want `fd` to ignore these patterns globally, you can put them in `fd`'s global ignore file.282 This is usually located in `~/.config/fd/ignore` in macOS or Linux, and `%APPDATA%\fd\ignore` in283 Windows.284 285+You may wish to include `.git/` in your `fd/ignore` file so that `.git` directories, and their contents286+are not included in output if you use the `--hidden` option.287+288 ### Deleting files289 290 You can use `fd` to remove all files and directories that are matched by your search pattern.291 If you only want to remove files, you can use the `--exec-batch`/`-X` option to call `rm`. For425 unmodified lines