cargo
cargo copied to clipboard
Why does cargo need to download git dependencies completely?
Problem
Why does cargo need to download git dependencies completely?
(base) [root@x86 ~]# cargo check
Updating git repository `https://code.com/base/cbb-rs.git`
remote: Enumerating objects: 935, done.
remote: Counting objects: 100% (40/40), done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 935 (delta 35), reused 30 (delta 30), pack-reused 895 (from 1)
Receiving objects: 100% (935/935), 239.33 KiB | 633.00 KiB/s, done.
Resolving deltas: 100% (346/346), done.
From https://code.com/base/cbb-rs
* [new branch] 1.x -> origin/1.x
* [new branch] 2.x -> origin/2.x
* [new branch] master -> origin/master
* [new ref] -> origin/HEAD
* [new tag] 1.0.0 -> 1.0.0
* [new tag] 1.0.1 -> 1.0.1
* [new tag] 1.0.10 -> 1.0.10
* [new tag] 1.0.2 -> 1.0.2
* [new tag] 1.0.3 -> 1.0.3
* [new tag] 1.0.6 -> 1.0.6
* [new tag] 1.0.8 -> 1.0.8
* [new tag] 1.0.9 -> 1.0.9
* [new tag] 2.0.0 -> 2.0.0
* [new tag] 2.0.1 -> 2.0.1
* [new tag] 2.0.2 -> 2.0.2
* [new tag] 2.0.3 -> 2.0.3
* [new tag] 2.0.4 -> 2.0.4
* [new tag] 2.0.5 -> 2.0.5
* [new tag] 2.0.6 -> 2.0.6
* [new tag] 2.0.7 -> 2.0.7
* [new tag] 2.0.8 -> 2.0.8
* [new tag] 2.0.9 -> 2.0.9
* [new tag] 2.1.0 -> 2.1.0
Proposed Solution
Set depth=1 when git is used for download.
Notes
No response
We are tracking shallow clones in #13285.
What seems odd though is I didn't think we downloaded all tags and branches for a git dependency. Do you have reproduction steps?
What seems odd though is I didn't think we downloaded all tags and branches for a git dependency. Do you have reproduction steps?
This is the CARGO_NET_GIT_FETCH_WITH_CLI=true case. I guess Cargo should pass --no-tags to git CLI for the default case.
Besides, the -Zgit shallow clone feature doesn't really extend to support CARGO_NET_GIT_FETCH_WITH_CLI=true, and I don't remember anyone has even talked about that.
We used CARGO_NET_GIT_FETCH_WITH_CLI=true,
https://github.com/rust-lang/cargo/blob/89eb406e4751b80dada86c9c149a507ddd09e6ba/src/cargo/sources/git/utils.rs#L1187-L1198