★ wanayoo — archive 1999 https://github.com/libgit2/libgit2sharp/issues/1479Nouvelle recherche | Portail wanayoo
Skip to content
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

Possible In-memory repository regression? #1479

Open
Zoxive opened this issue Jul 27, 2017 · 4 comments
Open

Possible In-memory repository regression? #1479

Zoxive opened this issue Jul 27, 2017 · 4 comments

Comments

@Zoxive
Copy link

@Zoxive Zoxive commented Jul 27, 2017

So I'm trying to get my branch updated with master https://github.com/Zoxive/libgit2sharp/tree/zoxive/refdb/ which revives the pluggable RefDb backend (#1226)

I've gotten through all the compile issues rebasing it up to the latest with dotnet core, and the codegen stuff. (Took a while to figure out that I had to change all the NativeMethod funcs to use the new custom marshaler)

Anyways all compiles and stuff now.. but testing my changes im running into an error that appears to be coming straight from libgit2.

LibGit2SharpException: path cannot exist in repository

It happens when i have an in memory repository and an OdbBackend.

Heres a sample unit test that shows the problem.
Zoxive@7957581

I did see that libgit2 had a regression (libgit2/libgit2#4263) @ethomson fixed.
I'm guessing its related?

@ethomson
Copy link
Member

@ethomson ethomson commented Jul 30, 2017

Thanks for tackling some more in-memory work. Exciting!

I think that this is fallout from the fact that we never really decided how to support building a wholly in-memory repository and add backends to it. I don't remember all the details offhand, so I'll have to debug into this - but this is something that libgit2 itself supports (and tests) so I think the problem is that we're trying to use something before we've fully configured it.

@Zoxive
Copy link
Author

@Zoxive Zoxive commented Aug 2, 2017 •

So i looked into this some today.

Appears for a in-memory repository that _odb is null (https://github.com/libgit2/libgit2/blob/master/src/repository.c#L1073) and thus when the lazy ObjectDatabase is constructed in the Repository constructor (for the ObjectDatabase property) it explodes in the above test.
Seems like a bit of a chicken/egg scenario. So there may have to be some changes around Repository and ObjectDatabase that is needed.

The easiest way for me to get it working is a breaking change, property not desired. (I just hacked this together while debugging the issue to figure out what it was)

I altered the RepositoryOptions to accept a defaultOdb so inside the constructor it can set the defaultOdb that will then be picked up by the ObjectDatabase constructor Proxy.git_repository_odb call.

@Zoxive
Copy link
Author

@Zoxive Zoxive commented Aug 4, 2017 •

Scratch those code changes/thoughts above. I think I have it figured out. ObjectDatabase needs to call git_odb_new then git_repository_set_odb when its bare inmemory. (Should be no breaking changes) I'll have a PR for that in a few minutes.

@sterlind
Copy link

@sterlind sterlind commented Nov 13, 2019 •

@Zoxive FYI I've rewritten your PR to target the current libgit2 API #1739 . @ethomson I tried to hew closely to how refdb backends in libgit2 are plugged in, but I'm new to this repo so I could use guidance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.