Skip to content

No more check function #968

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

Merged
merged 4 commits into from
Feb 26, 2015
Merged

Conversation

ammeep
Copy link
Member

@ammeep ammeep commented Feb 20, 2015

This PR removes the need to supply the check callback when registering a Filter with the library.

For example if you want to install a filter with libgit2 with the name foo you would register that filter with libgit2sharp and it would be applied to any file that matched the path spec found in the gitattributes file. For example *.txt filter=foo

I naively thought that we needed to implement custom check logic for filters (the piece that actually matches the entry in the attributes file to the file being filtered) but it turns out this is already implemented in libgit2 https://github.com/libgit2/libgit2/blob/master/src/filter.c#L403 and if we simply do not provide the optional check callback, everything just works ™️

I've added an object FilterAttribute which allows you to define and register a filter in the correct format filter=name

@ammeep
Copy link
Member Author

ammeep commented Feb 21, 2015

I would love some eyes on this @nulltoken.

Want to make sure it is sane before I merge it, squash down the register filter PR, and update libgit2 to the latest 💅


this.name = name;
this.attributes = attributes;
var attributesAsString = string.Join(",", this.attributes.Select(attr => attr.FilterDefinition));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Just use the linq inside the initializer list?

ammeep pushed a commit that referenced this pull request Feb 26, 2015
@ammeep ammeep merged commit f0f5a46 into register-custom-filters Feb 26, 2015
@ammeep ammeep deleted the no-more-check-function branch February 26, 2015 23:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants