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

Tracking Issue for -Zgitoxide #11813

Open
6 of 15 tasks
Byron opened this issue Mar 9, 2023 · 16 comments
Open
6 of 15 tasks

Tracking Issue for -Zgitoxide #11813

Byron opened this issue Mar 9, 2023 · 16 comments
Labels
C-tracking-issue Category: A tracking issue for something unstable. S-waiting-on-feedback Status: An implemented feature is waiting on community feedback for bugs or design concerns. Z-gitoxide Nightly: gitoxide integration

Comments

@Byron
Copy link
Member

Byron commented Mar 9, 2023

Summary

RFC: None
Documentation: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#gitoxide
Issues: Z-gitoxide Nightly: gitoxide integration
Original issue:

With the ‘gitoxide’ unstable feature, all of the specified git operations will be performed by the gitoxide crate instead of git2. This allows git2 to be replaced in full.

Steps

Unstable feature sub-categories:

Further tasks

  • short-hash handling can be done by gix_hash::Prefix.
  • optimize dependencies to only include those that cargo actually uses.
  • When specifying a dependency with rev but nothing found, cargo with shallow fetch should fetch full history as a fallback.

Unresolved Issues

  • work with https://rsproxy.cn (the proxy seems to work different making naive negotiations fail due to multi-round negotiation)
  • all features as listed in this gitoxide tracking issue to be able to replace git2 in full
  • support for the file:// protocol without relying on the git binary
  • support of the ssh:// protocol without relying on the ssh binary
  • double-check and validate that authentication works similarly to git2 or if unfeasible, assure users have a migration path. How to deal with this correctly is still to be determined.
  • transitive dependency tempfile is pinned to ~3.3.0 temporarily (see [email protected])
  • A-git Area: anything dealing with git might contain more potential blockers
    • take a look at all of these and either fix them, resolve them, or store them in gitoxide itself

Future Extensions

Some features not in libgit2 are good candidates for future extensions

About tracking issues

Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.

Implementation history

@Byron Byron added the C-tracking-issue Category: A tracking issue for something unstable. label Mar 9, 2023
@weihanglo weihanglo added the Z-gitoxide Nightly: gitoxide integration label Mar 9, 2023
@epage

This comment was marked as resolved.

@weihanglo

This comment was marked as resolved.

@ehuss

This comment was marked as resolved.

@Byron

This comment was marked as resolved.

@epage

This comment was marked as resolved.

@Byron

This comment was marked as resolved.

@epage

This comment was marked as resolved.

@Byron

This comment was marked as resolved.

@epage

This comment was marked as resolved.

@Byron

This comment was marked as resolved.

@epage

This comment was marked as resolved.

@Nemo157
Copy link
Member

Nemo157 commented Nov 18, 2023

Is it possible to enable this through environment variables somehow? I wasn't able to figure out any syntax that didn't run into this error:

> CARGO_UNSTABLE_GITOXIDE=true cargo build
error: missing field `fetch`

(it may also be useful for this usecase to support an explicit CARGO_UNSTABLE_GITOXIDE=all feature alias that acts like -Zgitoxide)

@Byron
Copy link
Member Author

Byron commented Nov 18, 2023

I think I did that with the following, on stable:

export CARGO_REGISTRIES_CRATES_IO_PROTOCOL=git
export __CARGO_USE_GITOXIDE_INSTEAD_OF_GIT2=1 # nobody should be using this on stable, but it's there if truly needed.

CARGO_UNSTABLE_GITOXIDE=fetch cargo build should work, and so should CARGO_UNSTABLE_GITOXIDE=fetch,shallow cargo build for shallow clones. Please note that I wasn't aware of these environment variables before reading this, so I just assume whatever -Z gitoxide=<value> supports can be used as CARGO_UNSTABLE_GITOXIDE=<value>.

@Nemo157
Copy link
Member

Nemo157 commented Nov 18, 2023

CARGO_UNSTABLE_GITOXIDE=fetch cargo build should work

It doesn't, it gives the same error message. The CARGO_UNSTABLE_* environment variables correspond to the [unstable] table in .cargo/config.toml not the -Z flag.

By actually trying to set it in .cargo/config.toml it gave some more useful error messages, and I managed to get it working with

[unstable.gitoxide]
fetch = true
shallow_index = true
shallow_deps = true
checkout = true
internal_use_git2 = false

and

> CARGO_UNSTABLE_GITOXIDE_FETCH=true CARGO_UNSTABLE_GITOXIDE_SHALLOW_INDEX=true CARGO_UNSTABLE_GITOXIDE_SHALLOW_DEPS=true CARGO_UNSTABLE_GITOXIDE_CHECKOUT=true CARGO_UNSTABLE_GITOXIDE_INTERNAL_USE_GIT2=false cargo build

I do think it would be good to override the toml parser for this variable too so that you don't have to specify every single field.

@ibraheemdev
Copy link
Member

How is shallow cloning dependencies different than specifying the refspec (e.g. +HEAD:refs/remotes/origin/HEAD) that cargo already does? I think it only really helps if when fetching a specific branch or tag?

@Nemo157
Copy link
Member

Nemo157 commented May 30, 2024

A refspec reduces the heads that you're requesting, so you don't get other unneeded branches being pulled down. But you still request the entire history from that head back to initial commit(s) of the repo. A shallow clone allows you to limit how much of the history you request, presumably for cargo's usecase it only needs to pull down the current commit of the requested head and can ignore the history entirely (though technically this is visible to build.rs scripts running from git dependencies).

bors added a commit that referenced this issue Jun 3, 2024
Allows the default git/gitoxide configuration to be obtained from the ENV and config

### What does this PR try to resolve?
The default git/gitoxide feautures config can be obtained througt `-Zgit` and `-Zgitoxide`.
However, it cannot be obtained from environment variables or configurations.
It's not very ergonomic.

### How should we test and review this PR?
The previous commit explained the staus quo, the next commit addressed the problem.

### Additional information
Inspired by #11813 (comment)
See also #13285 (comment)

### Change of usage

1. Mirror Zgit/Zgitoxide when they parsed as string

Specify the feature you like
```
CARGO_UNSABLE_GIT='shallow-deps' cargo fetch
cargo fetch --config "unstable.git='shallow-deps'"
cargo fetch -Zgit="shallow-deps"
```

2. Specify partial fields when parsed as table

```
CARGO_UNSTABLE_GITOXIDE_FETCH=true cargo fetch

```

The rest fields will use Rust default value. That said, checkout and internal_use_git2 will be false.

Besides, you can pass true to the whole feature to specify the pre-defined features.

```
CARGO_UNSTABLE_GITOXIDE=true cargo fetch

```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-tracking-issue Category: A tracking issue for something unstable. S-waiting-on-feedback Status: An implemented feature is waiting on community feedback for bugs or design concerns. Z-gitoxide Nightly: gitoxide integration
Projects
Status: In Progress
Development

No branches or pull requests

6 participants