uv icon indicating copy to clipboard operation
uv copied to clipboard

Use `libgit2` first then fallback to the `git` command on failure

Open zanieb opened this issue 2 years ago • 1 comments

Some necessary context in https://github.com/astral-sh/uv/pull/1781.

This should be faster in the happy path but robust to less common authentication schemes. Cargo uses an environment variable to toggle instead of this "fallback" approach. I'm hesitant to require that from our users.

The downside of this is that we will always retry with the git command even if the failure is not related to authentication. This could result in confusing logs and is, of course, slower. In practice, I think the error messages from the git command are better as they give you something reproducible to test with and have more context, the libgit2 errors are very opaque.

I've also added a rough way to reuse the discovered correct strategy for fetching (https://github.com/astral-sh/uv/pull/1786/commits/df4382f4d1b415d3c86cd119876734b2596cb311) we could extend this to avoid unnecessary calls to libgit2 in the future.

We can definitely say this is overkill and just drop fetching with libgit2 entirely in favor of the git CLI. We could also only use the git command if we detect authentication via some heuristic?

zanieb avatar Feb 20 '24 22:02 zanieb

Currently a big problem here is that libgit2 will retry several times before we try git.

zanieb avatar Feb 21 '24 01:02 zanieb

To be explored another day..

zanieb avatar Mar 04 '24 21:03 zanieb