Comments (16)
@raphael-ratepay in the example you gave I don't think adding --no-ignore-vcs
would work, unless you had a .git
directory inside a directory that was itself gitignored. Although, it would still search ignored files like node_modules
which could hurt performance.
One possible way we could address is this add a --ignore-pattern
option that lets you add ignore patterns inline (like the inverse of the --glob
option in ripgrep), and then you could do fd --ignore-pattern '!.git' ...
to add it back.
p.s. what you currently have would also find something like a dir/.github
directory and change it to dirhub
you probably want a $
at the end of your pattern.
from fd.
Make fd -H include .git itself, but nothing under it.
That actually sounds like a good option, that does not break anybody else workflow?
from fd.
@mehalter that does not work as expected.
Using -I includes all node_modules, .terraform, .... folders as well - so it returns all hidden dependencies. Which is not the case in version 8.7 if used without -I
from fd.
I expect that most of the users are in favour of the new behaviour, so I think rollback is not the best option. If nobody obliges I would add --no-ignore-vcs-dirs as PR.
from fd.
I'm torn on this.
Reasons I think automatically ignoring .git is good:
- It is consistent with the behavior of git commands. For example,
git ls-files --cached --others --exclude-standard
doesn't inlcude.git
. In fact, even without--exclude-standard
it doesn't include .git. - The only use cases I've seen brought up are specifically looking for .git folders, which is somewhat niche.
- This is something that has been requested by a few people: #1387
Reasons it is bad:
- We don't currently have a way to opt out of it, and I don't none of the options seem very clean to me.
- It is pretty simple to add
.git
to your~/.config/fd/ignore
global ignore file. - It's inconsistent with ripgrep. and from @BurntSushi's comments on BurntSushi/ripgrep#2705 (comment) I think that is unlikely to change.
Maybe we should revert, but add some documentation about the workaround of adding .git
to your ignore file?
from fd.
@skoriop FYI
from fd.
I was just bitten by this as well. Would like to be able to discover the paths of git repositories, whilst still honouring their respective .gitignore
files, please. 🙏
from fd.
Any update on this, I could provide an MR for --ignore-pattern
if that is desired?
from fd.
Actually fd already has an option like --ignore-pattern
: --exclude
.
Unfortunately, using --exclude !.git
doesn't work, due to how overrides are implemented in the ignore
crate (since it takes a list of "include" rules, we prefix the input with "!" to get an exclude rule).
I tried implementing an --include
option that negates a previous exclude or ignore rule, but ran into two problems:
- The excluded !.git rule is higher priority than the included .git priority. I can sort of hack around this by checking if ".git" was given, and if so, don't add "!.git"
- If I add a non-negated pattern to the overrides, then it restricts results to only directories, and files that match that pattern.
I'm not sure what the best path forward is with the current API of the ignore
crate.
See also BurntSushi/ripgrep#2705.
from fd.
None of the options sounds Great, could a flag like --legacy-git-handling
be implement that is checked here (this clutters configuration, and is not ideal either)
from fd.
I also tried for a bit to make something like -E '!.git'
work but I don't think it's possible. I think the two options are:
- Add an option to restore the old behaviour, something like
--no-ignore-vcs-dirs
- Revert the breaking change, and just tell people to add
-E .git
if they need the 9.0.0 behaviour
I also thought of this compromise, which might work for the people in this thread but is semantically kinda weird:
- Make
fd -H
include.git
itself, but nothing under it
By the way, this line is also wrong because .git
may be a regular file, not a directory, for things like submodules and worktrees.
Line 338 in 0dc3342
from fd.
@raphael-ratepay you can achieve this with:
fd -HI '^.git$' --type d --base-directory ~/Source | sed 's|/.git||'
from fd.
Oh yeah that's true @raphael-ratepay ! My bad!
from fd.
Any updates / Ideas? I can propose a PR if I know in which direction :D
from fd.
I agree we should fix this rather sooner than later, especially if we want to revert the breaking change.
I think the two options are:
* Add an option to restore the old behaviour, something like--no-ignore-vcs-dirs
* Revert the breaking change, and just tell people to add-E .git
if they need the 9.0.0 behaviour
A third option might be to make the -E '!.git'
thing work, that several people have tried. It doesn't work out-of-the box, but we could probably special-case it? In the sense that we would not add the .git
pattern to the ignore builder in the first place.
I'm personally okay with all options, but if we can make -E '!.git'
work, I'd favor that over introducing yet another flag, I think.
Given that this new behavior has a risk for confusion (.git
is a hidden folder and it is not gitignored by default), I might be slightly in favor of reverting the breaking change. Other thoughts?
from fd.
I'm also fine with any of those options.
from fd.
Related Issues (20)
- fdexclude/exclude configuration file, similar to fdignore/ignore configuration file HOT 2
- Adding an output mode with network-absolute paths HOT 2
- Filter files based on command output HOT 1
- [BUG] Incorrect application of `.gitignore` rules when using `fd` from a nested directory HOT 3
- [BUG] fd --glob seems wrong HOT 3
- Add clippy check to github actions CI HOT 2
- [BUG] Wrong result when --full-path and .. HOT 3
- `--all` argument HOT 2
- Ignore top level .gitignore HOT 3
- Chinese version of fd project HOT 2
- The file name containing "-- " could not be found HOT 3
- fd? fdfind? fdclone? HOT 1
- Ignore cache directories by default HOT 2
- [BUG] Redirected stdout (pipe or file) on windows has wrong encoding HOT 2
- [BUG] fd -e o not works. HOT 2
- [BUG] search strings containing umlaut fails to find any results HOT 11
- find a file upwards HOT 2
- conda-forge package HOT 6
- FD version 10 stopped working on Windows 7 HOT 10
- Binary for Armv8 (RPI 5) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fd.