-
-
Notifications
You must be signed in to change notification settings - Fork 849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add flag --no-require-git to always respect gitignore files #1216
Conversation
I think I'd rather have a separate option for this. In particular, because changing the semantics of --ignore-vcs would mean there is no longer a way to exactly negate --no-ignore-vcs |
Good point. @tmccombs what do you think about using the same name as ripgrep's option: |
That seems ok to me |
9a59a79
to
303caa1
Compare
@tmccombs done ✅! |
b0278dd
to
960ee2a
Compare
I should add |
src/cli.rs
Outdated
long_help = "By default, fd will only respect global gitignore rules, .gitignore rules,\ | ||
and local exclude rules if fd detects that you are searching inside a\ | ||
git repository. This flag allows you to relax this restriction such that\ | ||
fd will respect all git related ignore rules regardless of whether you're\ | ||
searching in a git repository or not.\n\n\ | ||
This flag behaves the same as --no-require-git flag from ripgrep.\n\n\ | ||
This flag can be disabled with --require-git." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI this is the same description as --no-require-git
for ripgrep https://github.com/BurntSushi/ripgrep/blob/3bb71b0cb8727ac43237af78ba5c707298de0128/crates/core/app.rs#L2216-L2225
In your opinion does this port require a more formal attribution?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fd isn't my project, but I personally wouldn't describe behavior in public docs by referencing other tools like this.
In your opinion does this port require a more formal attribution?
On my end, no. It's probably good sense to mention it in a commit message or perhaps a source code comment so that others looking at it in the future have proper context, but I don't think there's any need for anything more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I did already mention this in a source code comment and the commit message 👍
d10c05d
to
8e1c2f9
Compare
src/cli.rs
Outdated
long_help = "By default, fd will only respect global gitignore rules, .gitignore rules,\ | ||
and local exclude rules if fd detects that you are searching inside a\ | ||
git repository. This flag allows you to relax this restriction such that\ | ||
fd will respect all git related ignore rules regardless of whether you're\ | ||
searching in a git repository or not.\n\n\ | ||
This flag can be disabled with --require-git." | ||
)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This contains several missing whitespace errors due to how you placed those backslashes (there should be a space in front). Please check the rendered version using cargo run -- --help
or fd --help
:
--no-require-git
By default, fd will only respect global gitignore rules, .gitignore rules,and local
exclude rules if fd detects that you are searching inside agit repository. This flag
allows you to relax this restriction such thatfd will respect all git related ignore
rules regardless of whether you'researching in a git repository or not.
This flag can be disabled with --require-git.
Also, I would prefer if we could put that long help text in the doc comment, like for most other options.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How's this look?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much. Added two comments. Also, please read this section: https://github.com/sharkdp/fd/blob/master/CONTRIBUTING.md#add-an-entry-to-the-changelog
ee4da74
to
29db2ea
Compare
Summary: Currently, `--ignore-vcs` only serves to unset `--no-ignore-vcs`. There is currently no way to tell fd to respect gitignore files when not in a git repository. This commit adds the flag `--no-require-git` to make fd always respect all gitignore files. This behaves the same as the `--no-require-git` option in [ripgrep](https://github.com/BurntSushi/ripgrep/blob/3bb71b0cb8727ac43237af78ba5c707298de0128/crates/core/app.rs#L2214-L2226) This commit also contains an unrelated wording fix to CONTRIBUTING.md Test Plan: `tests/tests.rs` Background: I am using [Sapling](https://sapling-scm.com/docs/introduction/) for working with git repositories (including this commit☺️ ). Since Sapling uses `.sl` instead of `.git`, tools using the `ignore` crate (rg and fd) would show gitignored files. I made a patch (vegerot/ripgrep@ebf17ee) to `ignore` to respect gitignores with _either_ `.git` or `.sl`. However, @BurntSushi said he did not want to merge that patch and instead suggested I use `--no-require-git` (BurntSushi/ripgrep#2374). This works fine, but I couldn't use this workaround for my other favorite tool! That's what this patch is for 😁 (a follow-up patch will add a similar `FD_CONFIG_PATH` environment variable like `RG_CONFIG_PATH`)
done ✅! I also noticed in the doc you called it "Unreleased" but in CHANGELOG.md you called it "Upcoming release" so I updated that in CONTRIBUTING |
@tmccombs thank you! I don't have permission to merge this PR, so please do it for me (or make me a maintainer c: ) |
Merging is blocked for me. I think @sharkdp needs to approve because he requested changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the updates!
This commit neglected to update the man page |
@jpcirrus thanks for pointing this out! Would you mind contributing a patch? |
sharkdp#1216 omitted to add the flag to the man page.
Add flag --no-require-git to always respect gitignore files
Summary: Currently,
--ignore-vcs
only serves to unset--no-ignore-vcs
.There is currently no way to tell fd to respect gitignore files when not in a
git repository. This commit adds the flag
--no-require-git
to make fd alwaysrespect all gitignore files.
This behaves the same as the
--no-require-git
option in ripgrepThis commit also contains an unrelated wording fix to CONTRIBUTING.md
Test Plan:
tests/tests.rs
Background: I am using Sapling☺️ ). Since Sapling
for working with git repositories (including this commit
uses
.sl
instead of.git
, tools using theignore
crate (rg and fd) would show gitignored files.I made a patch (vegerot/ripgrep@ebf17ee)
to
ignore
to respect gitignores with either.git
or.sl
. However,@BurntSushi said he did not want to merge that patch and instead suggested I
use
--no-require-git
(BurntSushi/ripgrep#2374).This works fine, but I couldn't use this workaround for my other favorite tool!
That's what this patch is for 😁
(a follow-up patch will add a similar
FD_CONFIG_PATH
environment variablelike
RG_CONFIG_PATH
)Stack created with Sapling. Best reviewed with ReviewStack.