Open al-yisun opened 4 years ago
I'll mark this as an desirable enhancement for now, but I'm still unsure about this. I'm unsure about trying more of ripgrep's behavior to git. Particularly since there are some fairly accessible work-arounds, such as putting said files into your .gitignore
or .ignore
.
But especially with helpers such as git-lfs
, one often does not want to ignore binary files in a git repo (anymore).
There are no workaround for this. I have minifed files in git repo and there is no way to ignore them. They are marked as binary to don't show but they are not ignored by ignore
.
There are no workaround for this. I have minifed files in git repo and there is no way to ignore them. They are marked as binary to don't show but they are not ignored by
ignore
.
Why can't you add them to a .rgignore
file?
Does it work outside of ripgrep
. I was looking into Guide was testing .ignore
and .rgignore
but it doesn't work with difftastic which uses ignore
crate.
Yes it works. The support for .ignore and .rgignore is in the ignore crate.
In which version it was added? Because when I installed difftastic it didn't work.
Does it work out of the box, or do you need to configure the ignore
library to obey the ignore files?
This isn't difftastic's issue tracker. Support for .rgignore
has been there since the beginning. Support for .ignore
was added shortly thereafter.
I cannot tell you why difftastic doesn't work, especially when there are zero details about what is being tried. I've never even heard of difftastic before.
I'm just trying to figure out what is needed to use .ignore
file. This is bug tracker for riggrep
and ignore
so I don't see any other place where I can find help for those packages.
The issue of ignoring binary files in difftastic was created a year ago and no one noticed that there is a library that can handle this. So I don't think they can help figure it out.
Difftastic use this code:
use ignore::WalkBuilder;
WalkBuilder::new(dir)
.hidden(false)
.build()
.filter_map(Result::ok)
.map(|entry| Path::new(entry.path()).to_owned())
.filter(|path| !path.is_dir())
.map(|path| path.strip_prefix(dir).unwrap().to_path_buf())
.collect()
Will it work when I add:
ignore(true)
to the chain?
It would be much better if there was binary(true)
method that would ignore binary files from .gitattributes
, so users don't need to create extra files just to ignore minifed files.
It would be much better if there was
binary(true)
method that would ignore binary files from.gitattributes
, so users don't need to create extra files just to ignore minifed files.
Hence why this is an open issue labeled as an enhancement. What you said is that there is no work around and no way to ignore files. But this is false.
If ignorr(true)
isn't working in a minimal Rust program then open a new bug issue with full reproduction details, as that is unrelated to this feature request. It should be a reasonably minimal reproduction, not "difftastic doesn't work."
Please keep this issue related to gitattributes support. This issue isn't about general ignore rules or debugging specific scenarios where it isn't working like you expect.
Ripgrep usually ignores binary files quickly and correctly. Sometimes a versioned file may be tagged as binary in
.gitattributes
, because it contains binary data only towards the end of the file, because the file is text but noisy/meaningless (e.g. some postscript files), or because the file is generated and meant to be (typically) ignored.git
will treat such files as binary for the purposes of displaying in diff/grep/etc,rg
does not.Ripgrep should treat such files as binary unless
--text
is passed, the same asgit grep
.