Repository: sharkdp/fd (language: rust)

Issue:
Include `.git/` folder in the "gitignored" filtering
I mostly use `fd` in repositories, and I love having the ability of gitignoring pollution from build folders.

However, I keep getting tons of stuff from `.git/`.

I consider `.git/` to be _"gitignored by default"_, but that might just be my POV, any thoughts on this?

I imagine the odds of someone intentionally looking for stuff in the `.git/` directory should be low, but in that case, they can resort to `-I/--no-ignore` (or `--no-ignore-vcs`).


Discussion / hints:
Hi, I'd like to work on this if it's still up :)
Awesome! Take your shot :) .

`fd` uses `WalkBuilder` from the library `ignore`, take a look at
https://github.com/sharkdp/fd/blob/93cdb2628e89dd5831eee22b8df697aea00eca3b/src/walk.rs#L75 and https://docs.rs/ignore/latest/ignore/struct.WalkBuilder.html.

You might want to check if `WalkBuilder` supports doing this, maybe there's an issue to support this in the `ignore` crate repo?


Oh, be aware that this wasn't officially approved by maintainers, so there is some chance they'll close your PR, in case they are opposed to this change, I imagine they're not, but it's good to gather confirmation before.

(btw, I'm not a maintainer xD just an user.)

If you want to be 100% safe that you won't waste your time, you should probably wait for official approval.

@tmccombs made a favorable comment at https://github.com/sharkdp/fd/issues/1317#issuecomment-1745507259, I don't know if that counts.
I am in favor of this change.

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index be6cf5d7e..c7a5f0815 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,9 @@
 
 ## Features
 
+- Breaking: `.git/` is now ignored by default when using `--hidden` / `-H`, use `--no-ignore` / `-I` or 
+  `--no-ignore-vcs` to override, see #1387 and #1396 (@skoriop)
+
 ## Bugfixes
 
 ## Changes
diff --git a/src/walk.rs b/src/walk.rs
index 9b9213825..8d904bde4 100644
--- a/src/walk.rs
+++ b/src/walk.rs
@@ -66,6 +66,13 @@ pub fn scan(paths: &[PathBuf], patterns: Arc<Vec<Regex>>, config: Arc<Config>) -
             .add(pattern)
             .map_err(|e| anyhow!("Malformed exclude pattern: {}", e))?;
     }
+
+    if config.read_vcsignore {
+        override_builder
+            .add("!.git")
+            .expect("Invalid exclude pattern");
+    }
+
     let overrides = override_builder
         .build()
         .map_err(|_| anyhow!("Mismatch in exclude patterns"))?;


Test patch: