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

Support custom git extensions #6031

Merged
merged 2 commits into from
Sep 14, 2021
Merged

Support custom git extensions #6031

merged 2 commits into from
Sep 14, 2021

Conversation

ethomson
Copy link
Member

@ethomson ethomson commented Sep 4, 2021

Allow users to specify additional repository extensions that they want to support. For example, callers can specify that they support preciousObjects and then may open repositories that support extensions.preciousObjects.

Similarly, callers may opt out of supporting extensions that the library itself supports.

@ethomson
Copy link
Member Author

ethomson commented Sep 4, 2021

/cc @jairbubbles

Allow users to specify additional repository extensions that they want
to support.  For example, callers can specify that they support
`preciousObjects` and then may open repositories that support
`extensions.preciousObjects`.

Similarly, callers may opt out of supporting extensions that the library
itself supports.
@jairbubbles
Copy link
Contributor

Thx @ethomson, I created a draft PR to test it in libgit2sharp: libgit2/libgit2sharp#1908

I can confirm it works as expected as I was able to open repositories with "partialclone" extension! 🤘🏼

While writing the tests I was not sure about the behavior when setting the extensions two times in a row:

 GlobalSettings.SetExtensions(new[] { "!noop" });
 Assert.Empty(GlobalSettings.GetExtensions());

 GlobalSettings.SetExtensions(new[] { "partialclone", "newext" });
 Assert.Equal(new[] { "noop", "partialclone", "newext" }, GlobalSettings.GetExtensions()); // 👈🏼 I expected "noop" to remain disabled

@ethomson
Copy link
Member Author

Right - sorry, I expect you to call it one time with what you support. (Subsequent calls will reset the supported extensions.)

I think that this is not super important in practice since most people will only call it once at startup and forget about it. But it made testing easier in the library.

If you have strong opinions that I did this wrong then I'm definitely open to reconsidering.

@jairbubbles
Copy link
Contributor

If you have strong opinions that I did this wrong then I'm definitely open to reconsidering.

@ethomson Not at all, I just mentioned it in case this behavior was not expected.

@@ -367,6 +368,28 @@ int git_libgit2_opts(int key, ...)
git_odb__loose_priority = va_arg(ap, int);
break;

case GIT_OPT_SET_EXTENSIONS:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(code indent looks incorrect)

@ethomson ethomson merged commit 4f24a93 into main Sep 14, 2021
@ethomson ethomson deleted the ethomson/extensions branch September 14, 2021 11:47
@jairbubbles
Copy link
Contributor

🥳

@jairbubbles
Copy link
Contributor

@ethomson Do you plan to release a version that includes this in a near future?

@ethomson
Copy link
Member Author

@jairbubbles Yes. I would like to do a v1.3.0 this weekend.

@jairbubbles
Copy link
Contributor

Sounds like a nice plan. I'll wait for 1.3.0 and update it in libGit2Sharp.

jairbubbles added a commit to jairbubbles/libgit2sharp that referenced this pull request Sep 29, 2021
- C# wrapper for libgit2/libgit2#6031

(I'm not sure at all for the P/Invoke code)
jairbubbles added a commit to jairbubbles/libgit2sharp that referenced this pull request Sep 29, 2021
- C# wrapper for libgit2/libgit2#6031

(I'm not sure at all for the P/Invoke code)
knutwalker added a commit to knutwalker/git2-rs that referenced this pull request Jan 21, 2022
This would allow one to use git worktrees together with sparse-checkout.

Reference: libgit2/libgit2#6031
alexcrichton pushed a commit to rust-lang/git2-rs that referenced this pull request Jan 24, 2022
* Add support for custom git extensions

This would allow one to use git worktrees together with sparse-checkout.

Reference: libgit2/libgit2#6031

* Mark extension methods unsafe

* Replace custom spin-lock in tests with serial-test crate

* Rewrite tests as integration tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants