docs: Document exclusion of .git/

This commit is contained in:
Thayne McCombs 2023-10-22 00:24:34 -06:00 committed by David Peter
parent 5e0018fb1f
commit 53fd416c47
3 changed files with 19 additions and 3 deletions

12
doc/fd.1 vendored
View File

@ -29,11 +29,22 @@ By default
.B fd
uses regular expressions for the pattern. However, this can be changed to use simple glob patterns
with the '\-\-glob' option.
.P
By default
.B fd
will exclude hidden files and directories, as well as any files that match gitignore rules
or ignore rules in .ignore or .fdignore files. For convenenience, '.git' is treated as if it
was always included in gitignore rules. These files can be included with options such as
'\-\-hidden' and '\-\-no\-ignore'.
.SH OPTIONS
.TP
.B \-H, \-\-hidden
Include hidden files and directories in the search results
(default: hidden files and directories are skipped). The flag can be overridden with '--no-hidden'.
.IP
Ignored files and .git/ are still excluded unless \-\-no\-ignore or \-\-no\-ignore\-vcs
is also used. The .git directory is excluded, because that is usually what is wanted if excluding vcs
ignored files, and is more consistent with the output of most git commands.
.TP
.B \-I, \-\-no\-ignore
Show search results from files and directories that would otherwise be ignored by
@ -69,6 +80,7 @@ and the global gitignore configuration
.RI ( core.excludesFile
git setting, which defaults to
.IR $HOME/.config/git/ignore ).
The pattern ".git/" is automatically added to the list of VCS ignore rules.
The flag can be overridden with '--ignore-vcs'.
.TP
.B \-\-no\-require\-git

View File

@ -32,6 +32,8 @@ pub struct Opts {
/// Include hidden directories and files in the search results (default:
/// hidden files and directories are skipped). Files and directories are
/// considered to be hidden if their name starts with a `.` sign (dot).
/// Any files or directories that are ignored due to the rules described by
/// --no-ignore are still ignored unless otherwise specified.
/// The flag can be overridden with --no-hidden.
#[arg(
long,
@ -46,7 +48,8 @@ pub struct Opts {
no_hidden: (),
/// Show search results from files and directories that would otherwise be
/// ignored by '.gitignore', '.ignore', '.fdignore', or the global ignore file.
/// ignored by '.gitignore', '.ignore', '.fdignore', the global ignore file,
/// or the rule to exclude .git/.
/// The flag can be overridden with --ignore.
#[arg(
long,
@ -61,7 +64,8 @@ pub struct Opts {
ignore: (),
///Show search results from files and directories that would otherwise be
/// ignored by '.gitignore' files. The flag can be overridden with --ignore-vcs.
/// ignored by '.gitignore' files or the rule to exclude .git/.
/// The flag can be overridden with --ignore-vcs.
#[arg(
long,
hide_short_help = true,

View File

@ -69,7 +69,7 @@ pub fn scan(paths: &[PathBuf], patterns: Arc<Vec<Regex>>, config: Arc<Config>) -
if config.read_vcsignore {
override_builder
.add("!.git")
.add("!.git/")
.expect("Invalid exclude pattern");
}