From 53fd416c47e0d1a5311c4a2217c7c0ccbe444505 Mon Sep 17 00:00:00 2001 From: Thayne McCombs Date: Sun, 22 Oct 2023 00:24:34 -0600 Subject: [PATCH] docs: Document exclusion of .git/ --- doc/fd.1 | 12 ++++++++++++ src/cli.rs | 8 ++++++-- src/walk.rs | 2 +- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/doc/fd.1 b/doc/fd.1 index 03b86f6..5f76b46 100644 --- a/doc/fd.1 +++ b/doc/fd.1 @@ -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 diff --git a/src/cli.rs b/src/cli.rs index 0a2c54e..4b1ef5e 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -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, diff --git a/src/walk.rs b/src/walk.rs index 8d904bd..01fe38c 100644 --- a/src/walk.rs +++ b/src/walk.rs @@ -69,7 +69,7 @@ pub fn scan(paths: &[PathBuf], patterns: Arc>, config: Arc) - if config.read_vcsignore { override_builder - .add("!.git") + .add("!.git/") .expect("Invalid exclude pattern"); }