`git_merge` should only ever return `GIT_ENOTFOUND` in an error case.  I
wouldn't check the error code, I would just let it throw back to the
caller.  (Unless you're seeing this in a case where you don't expect to!)

Actually, the same is true of `git_merge_head_from_oid`, I think the
pattern in libgit2# is to let that throw and not return `null`, but I may
be mistaken?  I


On Fri, Dec 6, 2013 at 9:38 AM, crumblycake <notifications@github.com>wrote:

> In LibGit2Sharp/Core/Proxy.cs:
>
> > +        {
> > +            using (ThreadAffinity())
> > +            {
> > +                GitMergeHeadHandle their_heads;
> > +
> > +                int res1 = NativeMethods.git_merge_head_
> from_oid(out their_heads, repo, ref oid);
> > +                if (res1 == (int)GitErrorCode.NotFound)
> > +                    return null;
> > +
> > +                Ensure.ZeroResult(res1);
> > +
> > +                GitMergeResultHandle ret;
> > +
> > +                int res2 = NativeMethods.git_merge(out ret, repo, ref their_heads, (UIntPtr)1, ref opts);
> > +
> > +                if (res2 == (int)GitErrorCode.NotFound)
>
> Maybe @ethomson <https://github.com/ethomson> can correct me but I think
> I was incorrect in putting the check there, his example method above does
> not do a similar check and this is now reflected in the new version of the
> method. I'll go over the git_merge method in libgit2 to see if it can
> return GIT_ENOTFOUND however (if no one knows off the top of their heads).
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/libgit2/libgit2sharp/pull/579/files#r8162091>
> .
>