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 -Zgit #13285

Open
3 tasks
weihanglo opened this issue Jan 11, 2024 · 6 comments
Open
3 tasks

Tracking Issue for -Zgit #13285

weihanglo opened this issue Jan 11, 2024 · 6 comments
Labels
A-git Area: anything dealing with git C-tracking-issue Category: A tracking issue for something unstable.

Comments

@weihanglo
Copy link
Member

weihanglo commented Jan 11, 2024

Summary

Original issue: #1171. See also #11813
Implementation: #13252
Documentation: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#git

-Zgit is a collection of new Git features in Cargo. Currently we have experiments on

  • Shallow clones for git dependencies
  • Shallow clones for registry indexes

Unresolved Issues

Future Extensions

See "Future Extensions" in #11813. Most of them depend on upstream features in libgit2.

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.

@weihanglo weihanglo added A-git Area: anything dealing with git C-tracking-issue Category: A tracking issue for something unstable. labels Jan 11, 2024
@NoelJacob
Copy link

NoelJacob commented Mar 24, 2024

My ~/.cargo/config.toml looks like this:

git.shallow-index = true
git.shallow-deps = true
gitoxide.fetch = true
gitoxide.checkout = true

But on running cargo help I get :

>  cargo help
error: missing field `internal_use_git2`

>  cargo help
warning: unused config key `unstable.git.shallow-index` in `/home/noel/.cargo/config.toml`
warning: unused config key `unstable.git.shallow-deps` in `/home/noel/.cargo/config.toml`
error: missing field `shallow_index`

Keep repeating cargo <command> and the error seems to repeat between the two. Passing -Zgit -Zgitoxide seems to not give error.

Also modifying it to:

[unstable.git]
shallow_index = true
shallow_deps = true

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

does not give any error but I don't know if its working or not.

@weihanglo
Copy link
Member Author

Under ~/.cargo/git, check if the git clone contains a -shallow suffix.

~/.cargo/git $ tree -L 2
./
├── checkouts/
│  └── empty-library-0161899a0cd3bb43-shallow/
└── db/
   └── empty-library-0161899a0cd3bb43-shallow/

As of this writing, you need this in your .cargo/config.toml:

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

It is not ergonomic, but while it is still unstable, I am not too concerned. If people want to fix it, go for it! See #11813 (comment) as well.

@linyihai
Copy link
Contributor

linyihai commented Apr 1, 2024

(Maybe a bit off topic) what is the relationship between -Zgit and -Zgitoxide? I see both features being developed at the same time, will they be stable in the future?

@weihanglo
Copy link
Member Author

-Zgitoxide was first developed. The shallow clone support in libgit2 came out after and then we decided to split into -Zgit and -Zgitoxide. The former controls Git related unstable features in general, and with the latter some of those operations will be performed by gitoxide.

@soloturn
Copy link

soloturn commented Apr 27, 2024

for build environments partial clones in the sense of

--filter=tree:0

make most sense. shallow clones i the sense of -depth=1 may have undesired side effects. see e.g. here for details: https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/

@weihanglo what you think about ditching "shallow" in general as dead end and replace with "partial"? @cesfahani did a promising start: Byron/gitoxide#1046 .

@weihanglo
Copy link
Member Author

Sparse checkout and partial clone have been discussed in #11165.

It is possible that Cargo ditch or adopt anything for -Zgit since it is still an experimental unstable feature. See Byron's comment #11165 (comment) for some integration challenges. I can see that download blobs on demand would be helpful for fetching registry index. I am not sure about git dependencies. People might want a "fetch-first-then-offline-build" environment, and we need to model a lazy mechanism for it in Cargo, which is also a bit challenging.

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
A-git Area: anything dealing with git C-tracking-issue Category: A tracking issue for something unstable.
Projects
Status: Unstable, baking
Development

No branches or pull requests

4 participants