Add support for checking if a path would be ignored #204
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds support for libgit2's ignore parsing functions (https://libgit2.org/libgit2/#HEAD/group/ignore/git_ignore_path_is_ignored), to test if for a given repo a path would be ignored. This felt simple enough to implement before checking whether or not you'd be happy to support it - don't feel obliged to accept.
I've just reflected the C lib name here, as I think that's what you're mostly doing. This one does not really have a cli equivalent (you can get there with some options), so it might be worth renaming. Something like
git_path_is_ignored
would be snappier and avoid the unfortunate spacing issues ininit.c
.My use case, in case you're curious, is that people use .gitignore files to indicate "generated" files quite often, so if we have access to files that are marked this way we can clean them out of source trees more easily within our workflow tooling.