-
-
Notifications
You must be signed in to change notification settings - Fork 398
Introduce Refdb type #982
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
Introduce Refdb type #982
Conversation
7c93e2b
to
4ff6185
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your work! It's quite a lot.
Looking at the API level. I see there're a number of ways to get a backend: refdb = repo.refdb # wraps git_repository_refdb
refdb = Refdb(repo) # wraps git_refdb_new
refdb = Refdb.open(repo) # wraps git_refdb_open For consistency and to be explicit please change |
4169c01
to
a4cbb58
Compare
Done. |
Related libgit2 bug: This prevents us from being able to create a RefdbFsBackend and use it to create a Refdb from scratch. Other than that, the functionality of this patch is complete. I'll add tests in a day or two. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only a couple of comments for the 1st commit. Thanks!
Addressed comments on odb fixes. Still need to write tests and verify that everything works. I ran into some issues in a shallow test the other day. |
Note: Windows CI is failing due to lack of fnmatch support, which I used to implement globbing. Options:
|
✓ Tests Code-wise, this should be ready for review. The question of what to do about fnmatch on Windows remains, and I need to write up some docs and rebase everything. |
Oh, note that this requires the following libgit2 change before it'll work: libgit2/libgit2#5456 |
Regarding |
I'll just vendor it in the meanwhile (on Monday). |
✓ fnmatch -> wildmatch ✓ Questions answered from libgit2 about the semantics of refdb_backend.write Still needs docs but otherwise I think this is good to go. |
The test failures are because of libgit2/libgit2#5456 ? |
fdf0244
to
2406bf4
Compare
Got all of the CI pointing at libgit2 master and the tests are passing. |
I have rigged up the documentation as well. |
Cool, now we have to wait for a libgit2 release with libgit2/libgit2#5456 |
Prevents freeing an uninitialized pointer later on.
Custom refdb backends will need to be able to construct References, and this change adds the necessary constructors. However, the resulting Reference objects are fragile, and should not be used for much else. This is noted in the docstring.
Currently this allows you to manipulate refdbs in a vacuum. A later commit will introduce RefdbBackend, then allow you to create a Repository given a refdb backend and an odb backend. The refdb is more or less a write-only interface from libgit2, so it's not really possible to verify that the functions added here have affected libgit2's state in the desired way. For this reason, tests are not included for this type.
This creates a git_repository with no odb and no refdb.
This is imported from libgit2
I pushed a little bit of clean up in the course of implementing this: https://git.sr.ht/~sircmpwn/git.sr.ht/commit/a3fe57b6844709eac64fdca60370e5c227979fd3 It works 😁 |
src/refdb_backend.c
Outdated
@@ -198,7 +198,6 @@ pygit2_refdb_backend_lookup(git_reference **out, | |||
|
|||
*out = result->reference; | |||
out: | |||
Py_DECREF(result); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this? Doesn't lookup(..)
return a new reference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently not. This was causing double frees.
Thanks! |
Thank you! |
TODO:
docs/backends.rst
Future work: