FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Support custom git extensions by ethomson · Pull Request #6031 · libgit2/libgit2 · GitHub

Support custom git extensions - #6031

Merged
ethomson merged 2 commits into
mainfrom
ethomson/extensions
Sep 14, 2021
Merged

ethomson merged 2 commits into
mainfrom
ethomson/extensions

Conversation

ethomson commented Sep 4, 2021

Copy link
Copy Markdown
Member

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 commented Sep 4, 2021

Copy link
Copy Markdown
Member Author

/cc @jairbubbles

ethomson force-pushed the ethomson/extensions branch from 2cbae75 to 21dd15b Compare September 4, 2021 16:26
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.

Copy link
Copy Markdown
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

Copy link
Copy Markdown
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.

Copy link
Copy Markdown
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.

Comment thread src/libgit2.c
git_odb__loose_priority = va_arg(ap, int);
break;

case GIT_OPT_SET_EXTENSIONS:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

(code indent looks incorrect)

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

Copy link
Copy Markdown
Contributor

🥳

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Member Author

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

Copy link
Copy Markdown
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

2 participants


Back | FazBrowse Home | New Git URL