Skip to content

Expose libgit2 reference database backend for managed code refdb impls. #401

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 1 commit into from

Conversation

nulltoken
Copy link
Member

Follow up of #392

@nulltoken
Copy link
Member Author

Doh. Travis doesn't like me. 😿

@nulltoken
Copy link
Member Author

Ooooops.

Output on my box:

------ Test started: Assembly: LibGit2Sharp.Tests.dll ------

Output from LibGit2Sharp.Tests.RefdbBackendFixture.CannotOverwriteExistingInRefdbBackend:
  in Write: referencePtr = 108535680
  in Write: referenceHandle = 108535680

1 passed, 0 failed, 0 skipped, took 49,68 seconds (xUnit.net 1.9.0 build 1566).

Output on Travis:

/home/travis/build/libgit2/libgit2sharp/CI-build.msbuild: error : LibGit2Sharp.Tests.RefdbBackendFixture.CannotOverwriteExistingInRefdbBackend: System.NullReferenceException : Object reference not set to an instance of an object
/home/travis/build/libgit2/libgit2sharp/CI-build.msbuild: error :   at LibGit2Sharp.Core.Utf8Marshaler.FromNative (IntPtr pNativeData) [0x00000] in <filename unknown>:0 
  at LibGit2Sharp.Core.Utf8Marshaler.MarshalNativeToManaged (IntPtr pNativeData) [0x00000] in <filename unknown>:0 
  at (wrapper managed-to-native) LibGit2Sharp.Core.Nativethods:git_reference_name (LibGit2Sharp.Core.Handles.NotOwnedReferenceSafeHandle)
  at LibGit2Sharp.Core.Proxy.git_reference_name (LibGit2Sharp.Core.Handles.NotOwnedReferenceSafeHandle reference) [0x00000] in <filename unknown>:0 
  at LibGit2Sharp.RefdbBackend+BackendEntryPoints.Write (IntPtr backend, IntPtr referencePtr) [0x00000] in <filename unknown>:0 
  at (wrapper native-to-managed) LibGit2Sharp.RefdbBackend/BackendEntryPoints:Write (intptr,intptr)
  at (wrapper managed-to-native) LibGit2Sharp.Core.Nativethods:git_reference_create (LibGit2Sharp.Core.Handles.ReferenceSafeHandle&,LibGit2Sharp.Core.Handles.RepositorySafeHandle,string,LibGit2Sharp.Core.GitOid&,bool)
  at LibGit2Sharp.Core.Proxy.git_reference_create (LibGit2Sharp.Core.Handles.RepositorySafeHandle repo, System.String name, LibGit2Sharp.ObjectId targetId, Boolean allowOverwrite) [0x00000] in <filename unknown>:0 
  at LibGit2Sharp.ReferenceCollection.Add (System.String name, LibGit2Sharp.ObjectId targetId, Boolean allowOverwrite, System.String logMessage) [0x00000] in <filename unknown>:0 
  at LibGit2Sharp.Tests.RefdbBackendFixture.CannotOverwriteExistingInRefdbBackend () [0x00000] in <filename unknown>:0 
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 
            Captured output:
              in Write: referencePtr = 140101970351904
              in Write: referenceHandle = 0

@nulltoken
Copy link
Member Author

Doh. Travis doesn't like me.

Ok. Travis and I are BFF again 😉

@ethomson: Ready for your review, Sir!

@paumayr
Copy link

paumayr commented Jun 9, 2014

I'm really looking forward to having this RefDB backend in libgit2sharp, but I have a little objection: The libgit2 version of the backend explicitly passes the old_oid / old_target in the write mechanism. This is crucial to ensure that the write only occurs if the previous value is unchanged (optimistic concurrency). Without these parameters I find it difficult to support generic key/value backends (s3, azure storage, etc) for refdb.

Researching a bit further, since this has been idle for a year, I guess the libgit2 interface may have changed in the meanwhile.

Can we update this to reflect the change?

@nulltoken
Copy link
Member Author

I guess the libgit2 interface may have changed in the meanwhile.

@paumayr Indeed, it's evolved a bit. 😉 I'll try and see if I can bring this back up to date in the near future. However, if you feel like giving it a try, please do! We'll be happy to help.

@paumayr
Copy link

paumayr commented Jun 9, 2014

I'll give it a try!

@nulltoken
Copy link
Member Author

I'll give it a try!

Cool! You may be willing to give a look at the current filesystem based implementation for inspiration.

@alcheByte
Copy link

Is this going to get merged?

@nulltoken
Copy link
Member Author

Is this going to get merged?

@alcheByte Not in its current state. See the discussion above 😉

@alcheByte
Copy link

@nulltoken sorry, I misread the 'All is well' notification at the end of the thread ;)

I created a fork and resolved the merge conflicts, although I may have botched the handling of the NotOwned/ReferenceSafeHandle. I'm getting a AccessViolationException on the call to NativeMethods.git_repository_free(repo). If I remove the using clause for the Repository instance the exception goes away.

I'm a little confused though. Is the plugged in refdb backend supposed to replace the file system backend or be in addition to it? The .git folder is being created...

@nulltoken
Copy link
Member Author

I created a fork and resolved the merge conflict

@alcheByte Neat!

Although I may have botched the handling of the NotOwned/ReferenceSafeHandle. I'm getting a AccessViolationException on the call to NativeMethods.git_repository_free(repo). If I remove the using clause for the Repository instance the exception goes away.

Could you please create a Pull Request from your fork, it will be easier for us to help you? Just a quick note: I would strongly advise you to create a dedicated branch, rather than working directly on vNext. Then create the Pull Request from this newly created branch.

@alcheByte
Copy link

Done, let me know if I botched it, I'm a git/GitHub noob :)

So is the plugged in refdb supposed to be in lieu of the fs backend?
I wasn't expecting the .git folder to be created when the refdb has been set...

@nulltoken
Copy link
Member Author

@alcheByte I've taken a quick look. I think the issue you're encountering is related to the fact that the GitRefDbBackend doesn't match the libgit2 interface.

@nulltoken
Copy link
Member Author

Hmmm. Let's move this over to #797

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.

5 participants