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

Request: support a sift-specific ignore file #78

Open
Deewiant opened this Issue Sep 18, 2016 · 7 comments

Comments

Projects
None yet
3 participants
@Deewiant

Deewiant commented Sep 18, 2016

ag supports .agignore files, which basically work similarly to .gitignore or .hgignore files but are used only by ag. This is useful for example if you have large auto-generated files in your repository (so you can't use sift's .gitignore functionality because you can't have the VCS ignore them) that are matched all too often by accident, resulting in sift outputting useless lines several kilobytes long. It'd be useful if sift had similar functionality.

@svent

This comment has been minimized.

Show comment
Hide comment
@svent

svent Sep 18, 2016

Owner

This is an interesting use case.
You could solve this with a small local sift config (.sift.conf) in that directory, e.g.:

{
    "ExcludeFiles": [
        "*.cpp",
        "*.pl"
    ]
}

But I understand that using something like .siftignore with the .gitignore syntax would be more convenient, I will look into this.

Owner

svent commented Sep 18, 2016

This is an interesting use case.
You could solve this with a small local sift config (.sift.conf) in that directory, e.g.:

{
    "ExcludeFiles": [
        "*.cpp",
        "*.pl"
    ]
}

But I understand that using something like .siftignore with the .gitignore syntax would be more convenient, I will look into this.

@Deewiant

This comment has been minimized.

Show comment
Hide comment
@Deewiant

Deewiant Sep 18, 2016

Good point, I forgot about local .sift.conf files. Unfortunately they're restricted to the current working directory. If .sift.conf were picked up from parent directories similarly to .gitignore it'd be a perfectly fine solution.

Deewiant commented Sep 18, 2016

Good point, I forgot about local .sift.conf files. Unfortunately they're restricted to the current working directory. If .sift.conf were picked up from parent directories similarly to .gitignore it'd be a perfectly fine solution.

@svent

This comment has been minimized.

Show comment
Hide comment
@svent

svent Sep 18, 2016

Owner

Early versions only respected a .sift.conf in the current working directory, but since version 0.3.3 sift searches the parent directories for a .sift.conf file and uses that.
So it should work, please let me know if you have a case where it does not using the latest version.

Owner

svent commented Sep 18, 2016

Early versions only respected a .sift.conf in the current working directory, but since version 0.3.3 sift searches the parent directories for a .sift.conf file and uses that.
So it should work, please let me know if you have a case where it does not using the latest version.

@Deewiant

This comment has been minimized.

Show comment
Hide comment
@Deewiant

Deewiant Sep 19, 2016

Ah, I didn't spot that in the documentation. Using the ExcludeFiles option in a parent directory's .sift.conf indeed works.

But I can't figure out a way of excluding an entire directory or directories. I'd imagine ExcludePath is the way to go but for it to work for this use case, it would need to be applied relative to the location of the config file, similarly to .gitignore. For instance, if I want to exclude a directory repo/sub/dir with .gitignore I have a number of choices:

  1. /sub/dir in repo/.gitignore
  2. /dir in repo/sub/.gitignore
  3. sub/dir in repo/.gitignore, if I'm happy with excluding sub/dir at any level
  4. dir in repo/sub/.gitignore, if I'm happy with excluding dir at any level below sub/
  5. dir in repo/.gitignore, if I'm happy with excluding dir at any level

With a .sift.conf in a parent directory I can only replicate the fifth alternative, I think. Ideally something like .siftignore would allow for all of the above.

Deewiant commented Sep 19, 2016

Ah, I didn't spot that in the documentation. Using the ExcludeFiles option in a parent directory's .sift.conf indeed works.

But I can't figure out a way of excluding an entire directory or directories. I'd imagine ExcludePath is the way to go but for it to work for this use case, it would need to be applied relative to the location of the config file, similarly to .gitignore. For instance, if I want to exclude a directory repo/sub/dir with .gitignore I have a number of choices:

  1. /sub/dir in repo/.gitignore
  2. /dir in repo/sub/.gitignore
  3. sub/dir in repo/.gitignore, if I'm happy with excluding sub/dir at any level
  4. dir in repo/sub/.gitignore, if I'm happy with excluding dir at any level below sub/
  5. dir in repo/.gitignore, if I'm happy with excluding dir at any level

With a .sift.conf in a parent directory I can only replicate the fifth alternative, I think. Ideally something like .siftignore would allow for all of the above.

@svent

This comment has been minimized.

Show comment
Hide comment
@svent

svent Sep 22, 2016

Owner

I agree that something like .siftignore would be much more practical and flexible in such cases.
I will implement something like it - thanks for sharing your thoughts on this!

Owner

svent commented Sep 22, 2016

I agree that something like .siftignore would be much more practical and flexible in such cases.
I will implement something like it - thanks for sharing your thoughts on this!

@svent

This comment has been minimized.

Show comment
Hide comment
@svent

svent Sep 24, 2016

Owner

@ggreer and @BurntSushi just suggested that search tools should use the same file for custom ignore patterns - I think that is a great idea (see BurntSushi/ripgrep#40 / https://news.ycombinator.com/item?id=12568822).
I will implement this as discussed here: add an option to process .ignore files and treat the content like gitignore patterns.
I'd suggest that .ignore has a higher precedence than .gitignore.

Owner

svent commented Sep 24, 2016

@ggreer and @BurntSushi just suggested that search tools should use the same file for custom ignore patterns - I think that is a great idea (see BurntSushi/ripgrep#40 / https://news.ycombinator.com/item?id=12568822).
I will implement this as discussed here: add an option to process .ignore files and treat the content like gitignore patterns.
I'd suggest that .ignore has a higher precedence than .gitignore.

@mpictor

This comment has been minimized.

Show comment
Hide comment
@mpictor

mpictor Sep 28, 2016

What about a config option to allow specifying name(s) for ignore files? That would cover @Deewiant 's use case, as well as .p4ignore, .cvsignore, etc. I'm confident that the syntax of .*ignore files is similar enough that the existing parse functionality would work well.

Something similar has been done by tar, which has options --exclude-vcs-ignores and --exclude-ignore=file.

mpictor commented Sep 28, 2016

What about a config option to allow specifying name(s) for ignore files? That would cover @Deewiant 's use case, as well as .p4ignore, .cvsignore, etc. I'm confident that the syntax of .*ignore files is similar enough that the existing parse functionality would work well.

Something similar has been done by tar, which has options --exclude-vcs-ignores and --exclude-ignore=file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment