-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Repository Format v1 is coming #3253
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
Conversation
src/repository.c
Outdated
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.
❤️
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.
We return our usual 0 or -1 to indicate success. Though GIT_REPO_VERSION is 0 here, we should still have a return 0; here.
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.
Ops, this is a leftover from a previous iteration where the version was returned as return value instead of out-arg.
|
This works great as long as the repository doesn't actually specify any extensions. If someone has This is still rather future-looking, but the issue is bound to become larger as extensions come up. Not that this should stop this from getting merged, but this is bound to have API implications. |
We can add a getter on the repository to get the available extensions. Can you confirm that libgit2 does not delete objects in any way? |
We don't even have a method for that in the odb interface :) |
|
Hah, makes sense. Gonna add handling for the |
Extensions aren't really "available", they're things you must support in order to operate on the repository, which is why I'm worried about how to expose it. If there's an extension that relates to how a user of libgit2 must behave but where libgit2 doesn't have anything in particular to do, there wouldn't be any reason for libgit2 to refuse opening the repository, but a caller which is not aware of extensions would continue regardless, because they don't know that they must check them. What I'm worried about is enabling a user of libgit2 to open the repository even though they shouldn't. I would like to make the caller agree to supporting the particular extensions while opening the repository, instead of relying on them looking at it afterwards, which a programmer in a hurry/under pressure isn't going to do while they're whipping up the prototype, and then that prototype gets to production and breaks some v1-repo. But this is probably better left for an issue to discuss the dangers/possibilities of this rather than this PR. |
|
Something that would be relevant is an entry in the changelog (remember those rules you put? ;) |
@carlosmn Pffff... That's a very cheap shot. 😜 |
|
@carlosmn Yeah, I share your concern about an application not respecting The conservative API to expose it is that the application says to libgit2 beforehand "these are the extensions I'm willing to comply with". And then libgit2 barfs if the application hasn't agreed to it (just like old pre-preciousObjects versions of git would barf on the same repo). But there's a flip side, too. For something like a new ref storage format, we'd expect libgit2 to handle that completely and transparently from the application's perspective. Sure, an app could try skipping libgit2 and writing directly into So I think it really comes down to a per-extension interpretation: is this something libgit2 can control, or is it something where we reasonably expect the app to go around our back? For Sorry to ramble, but I think we do need to know whether to claim |
src/repository.c
Outdated
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.
The git-core spelling is extensions with an s. This needs fixed here, above in extension_each_cb, and in the tests.
I'm open to making it extension (I waffled between the two while writing the original), but we should make sure that git-core makes the same change. ;)
|
When we implement the tdb/lmdb/berkley/whatever refs backend which git-core is getting, we will handle it for the user. But that only really works if the user doesn't switch the backend to their own. This is presumably an unlikely scenario since such a user wouldn't have bothered with the newer refs backend. But more likely would be a user who has their own odb backend. We can vouch for libgit2 not deleting objects, but if we've vouched for the user and they swap odb backends, they might just delete objects so in this case we would want the user to specify preciousObjects even though most of the time, there would be no need. Maybe having the user pass a list would be good enough most of the time, but for users which replace backends, we'd want to have them agree to the extensions which libgit2 would normally take care of and it's probably not practicable to have libgit2 know which extensions belong to which backend, as new ones might crop up which we don't know about. |
Hmm, yeah, I didn't think people would do stuff that wild. But I guess they do. |
|
OK, brought the PR up to speed and added support for |
Note that no behavior changes are implemented because libgit2 has no support for removing objects from the ODB (or any similar destructive operations).
|
I've also added changelog entries to please our new benevolent dictators. lulz |
|
I'm less worried about custom ODB backends and whether they have some notion of deleting objects because we don't actually have an API that would drive them to do so. My concern is just app code in general. Maybe some user of libgit2 has built their own If they were to upgrade to this new version then they would (unwittingly) be violating the This particular extension has the implication of pretty serious damage if misunderstood, so I want to be very clear to end-users about it. Let me ask some questions: Should we forcefully break the Should we offer an API to query configured extensions so that if somebody had built One thing I do think that we should do, though, is be more forceful in our
|
|
Sorry I'm coming late to the party - those questions were more for myself to better understand this issue and for people who didn't weigh in (above). I think that everybody who's commented thus far has made their opinions clear and it seems like we're all on the same page. Anyway, I think this is the right start and we can deal with future extensions on a case-by-case basis. |
This looks free and immediately useful. Why not do it? |
It looks like the extensions are bools now? So But if this is something that would be useful immediately then let's just put it in. |
They could be anything, really (e.g. |
|
Yeah, the extensions can be any config value. They may even take progressive examination to know whether you support them or not. For example, the parsing process for a ref backend will probably be something like:
We can't build the code for (2) until the extension is defined; all we can do generically is step 1. Note that as a side effect, setting |
I know if at least one build system that does this... so you're not far off the mark here. |
|
It seems we might need to take a step back on preciousObjects. @vmg if you don't have this extension in repos you work with, maybe we can remove that bit of the PR and leave it as just loading version 1 without any extensions. |
|
How so? What has changed re: preciousObjects? |
|
I think he means the discussion above. I can certainly live with libgit2 not claiming I think the most sensible API may be to just provide a callback function to the library, and libgit2 will call it for each |
|
It's not so much that it's changed, but it does look like even preciousObjects, the one extension that exists, is more about the application's behaviour than libgit2 by itself. I was also thinking about callbacks, but I don't think we should limit them to extensions libgit2 doesn't understand. Even for preciousObjects both libgit2 and the application need to be aware of it. |
|
It's OK to show all extensions to the application, but I don't think you necessarily want to respect the application callback's response in all cases; only when you do not trust that libgit2 can handle the extension by itself. So for |
|
Right, for something like |
|
This PR has been idle for over a year; I'm going to close this. I think that the issues that were raised were / are important and that we will look to this in the future for inspiration, but I don't think that we want to merge this as-is. Thanks again! |
The following patch by @peff is making its way upstream: http://thread.gmane.org/gmane.comp.version-control.git/272447/focus=272450
It allows Git to start accepting repository version v1, which is the same as v0 except it now reads optional extensions from the config file and fails to load the repository if an extension is not known (because it could affect the behaviour of git in unexpected ways). @peff does a much better job at explaining this on his commit message. Please check it out.
This PR brings libgit2 in-par with the upstream changes.
cc @peff @ethomson @carlosmn