Skip to content

Register custom filters #854

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

Closed
wants to merge 3 commits into from
Closed

Register custom filters #854

wants to merge 3 commits into from

Conversation

ammeep
Copy link
Member

@ammeep ammeep commented Oct 29, 2014

I want to expose an API for registering custom clean and smudge filters via libgit2.

My knowledge of C is rusty, and this is the first time I have looked at libgit2sharp in any great detail. So, I'm going to open this PR early, in the hopes that if anyone has time to spot anything terrible I do along the way they will be able to point me in the right direction 🙏

Todo

  • Register and deregsiter a filter
  • Define apply callback
  • Define check callback
  • Define shutdown/init callbacks
  • Tests

@ammeep ammeep force-pushed the register-custom-filters branch from b1df1be to c4777d3 Compare November 3, 2014 00:26
@ammeep ammeep force-pushed the register-custom-filters branch from 233b14d to 18085bc Compare November 15, 2014 02:10
[StructLayout(LayoutKind.Sequential)]
internal class GitFilter
{
public uint version;
Copy link
Member

Choose a reason for hiding this comment

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

I think we should set this to 1. It's not supposed to be passed in by the user.

using LibGit2Sharp.Core;
using LibGit2Sharp.Core.Handles;

namespace LibGit2Sharp
Copy link
Member

Choose a reason for hiding this comment

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

Cheating.... 😜

Copy link
Member Author

Choose a reason for hiding this comment

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

lol.

I think I might wait until your branches have been merged to fix these build failures up properly. That sound ok?

@ammeep
Copy link
Member Author

ammeep commented Feb 13, 2015

Ok, I think this is all the outstanding feedback addressed. Would love some more 👀 on this

/// </summary>
/// <param name="filterForAttributes">The filterForAttributes that this filter was created for.</param>
/// <param name="filterSource">The source of the filter</param>
/// <returns>0 if successful and -30 to skip and pass through</returns>
Copy link
Member

Choose a reason for hiding this comment

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

Maybe the comments could refer to GitErrorCode.PassThrough instead of an actual number?

@nulltoken
Copy link
Member

Looks clean to me. I'll take a (fresher) look tomorrow.

We'd still need libgit2/libgit2#2892 to be merged (and update the libgit2 binaries) before pulling this in .

Very awesome job for someone with a "rusty knowledge of C" who stated "this is the first time I have looked at libgit2sharp in any great detail" 😜

/// </summary>
Clean = (1 << 0),
}
}
Copy link
Member

Choose a reason for hiding this comment

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

nit: trailing newline

@nulltoken
Copy link
Member

See #958 for a potential improvement proposal

this.gitBufPointer = gitBufPointer;

//Preallocate the buffer
Proxy.git_buf_grow(gitBufPointer, 1024);
Copy link
Member

Choose a reason for hiding this comment

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

As pointed out by @carlosmn , let's make this 4096

@ammeep ammeep force-pushed the register-custom-filters branch from f0f5a46 to b2639f6 Compare February 27, 2015 00:11
@ammeep ammeep force-pushed the register-custom-filters branch from 9d2ca7b to 17dd29e Compare February 27, 2015 00:41
@ammeep ammeep force-pushed the register-custom-filters branch from 17dd29e to c1036eb Compare February 27, 2015 01:55
@nulltoken
Copy link
Member

@ammeep I've added a tiny commit to get the feedback from AppVeyor when time's ready.

When updating libgit2 binaries, we tend to stick to a convention that ease further troubleshooting and use this kind of message

Update libgit2 to fb2f3a7

https://github.com/libgit2/libgit2/compare/e0902fb...fb2f3a7

@ammeep
Copy link
Member Author

ammeep commented Mar 3, 2015

Ooops, sorry @nulltoken I'll fix that up 🔜

Right now I'm trying to figure out the support for our ✨ new streaming bindings. Once that's one I'll rebase the whole thing again 👍

@nulltoken
Copy link
Member

@ammeep No need to be sorry! It's an (undocumented) convention 😉

Thanks for this amazing work!

@nulltoken
Copy link
Member

IT'S IN! @ammeep All you wonderful hard work has made it in #1030! 😻

@nulltoken nulltoken closed this Jun 10, 2015
@nulltoken nulltoken deleted the register-custom-filters branch June 11, 2015 15:59
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.

9 participants