fix(config): Ensure `--config net.git-fetch-with-cli=true` is respected
### What does this PR try to resolve?
#13479 changed the global context initialization order so that command line stuff is processed after we read some config.
This had a side effect of breaking `--config net.git-fetch-with-cli=true`.
I reverted the change to restore support for `--config`.
Fixes#13991
### How should we test and review this PR?
### Additional information
This reverts commit f525e1f383.
This removes color control from warnings for unstable features.
For some reason this removed color support from `cargo -Zhelp` in the
tests but I can't reproduce it locally.
The most important thing was getting the config fix in.
There are two follow ups
- Can we have the config working *and* color?
- Why did this fail for this field and not the others we already had
tests for?
I ran out my immediate time box for looking into these.
This reverts commit f525e1f383fc0d0a7adbdfb1bac6d6228ae79b33.
This removes color control from warnings for unstable features.
For some reason this removed color support from `cargo -Zhelp` in the
tests but I can't reproduce it locally.
The most important thing was getting the config fix in.
There are two follow ups
- Can we have the config working *and* color?
- Why did this fail for this field and not the others we already had
tests for?
I ran out my immediate time box for looking into these.
Fixes#13991
Fix libcurl proxy documentation link
### What does this PR try to resolve?
Fixes a broken link to the libcurl proxy documentation by updating it with new location.
fix(toml): Ensure targets are in a deterministic order
### What does this PR try to resolve?
With #13713, we enumerate all targets in `Cargo.toml` on `cargo publish` and `cargo vendor`.
However, the order of the targets is non-determistic. This can be annoying for comparing the published `Cargo.toml` across releases but even worse is the churn it causes for `cargo vendor`.
So we sort all the targets during publish.
This keeps costs minimal with the following risks
- If the non-determinism shows up in a way that affects developers during development
- If there is a reason the user wants to control target order for explicit targets
Fixes#13988
### How should we test and review this PR?
As for writing of tests, I'm unsure why none of our existing tests failed which makes it unclear to me what would be needed to write a test for this.
### Additional information
With #13713, we enumerate all targets in `Cargo.toml` on `cargo publish`
and `cargo vendor`.
However, the order of the targets is non-determistic.
This can be annoying for comparing the published `Cargo.toml` across releases but even
worse is the churn it causes for `cargo vendor`.
So we sort all the targets during publish.
This keeps costs minimal with the following risks
- If the non-determinism shows up in a way that affects developers
during development
- If there is a reason the user wants to control target order for
explicit targets
Fixes#13988
feat: stabilize `cargo update --precise <yanked>`
### What does this PR try to resolve?
Stabilize `cargo update --precise <yanked>`.
The cargo team has discussed the stabilization in the meeting today.
The interface of this is quite small and not as controversial as `--precise <pre-release>`,
since there is no version requirement operators involved.
We'd like to move forward and stabilize this part.
Note that `--precise <yanked>` allows using yanked version only for the specified package,
We leave the cascading allowing yanked versions (e.g. <https://github.com/rust-lang/cargo/issues/4225#issuecomment-1930353693>) as a future extension.
### How should we test and review this PR?
Check if any adjustment needed for warnings and CLI help text.
### Additional information
cc <https://github.com/rust-lang/cargo/issues/4225>.
Update openssl-src to 111.28.2+1.1.1w
### What does this PR try to resolve?
This PR is to fix the build of `loongarch64-unknown-linux-musl` target.
Update `openssl-src` from `111.28.1+1.1.1w` to `111.28.2+1.1.1w`.
### How should we test and review this PR?
Nothing special.
### Additional information
openssl-src diffs: cb7b3c8862...8c19f63843
Include `lints.rust.unexpected_cfgs.check-cfg` in the fingerprint
### What does this PR try to resolve?
When changing the `--check-cfg` args in the `lints.rust.unexpected_cfgs.check-cfg` lint config, the build should be restarted as the arguments we pass to the compiler change, and they can change the diagnostics output by generating new or removing some `unexpected_cfgs` warning(s).
### How should we test and review this PR?
Look at the before and after test (separate commit).
### Additional information
Similar to https://github.com/rust-lang/cargo/pull/13012 which did that for the declared features.
Contrary to that PR, I didn't add a new `DirtyReason` variant, since even the `[lints]` table didn't get one.
r? `@epage`
feat(test): Auto-redact elapsed time
By making this a redaction,
it automatically gets applied when generating the snapshot,
removing these extra steps
(that you likely only discover after the fact and have to debug)
chore: Update to snapbox 0.6
### What does this PR try to resolve?
This unblocks regex redactions which will help with `Finished in 3.45s` messages as well as maybe switching away from `compare.rs` generally.
### How should we test and review this PR?
### Additional information
Improve error description when deserializing partial field struct
### What does this PR try to resolve?
Fixes#13688
### How should we test and review this PR?
one commit add test, one commit fixed and update the test.
### Additional information
Add more high level traces
This accounts for more time when running rustc (which turns out to be a significant amount of time).
I'm less sure about the start/wait calls but I'm seeing very different results from different builds of `cargo` and some have some large amounts of unaccounted time that I want to dig into (and callgrind and and samply haven't helped).
This accounts for more time when running rustc (which turns out to be a
significant amount of time).
I'm less sure about the start/wait calls but I'm seeing very different
results from different builds of `cargo` and some have some large
amounts of unaccounted time that I want to dig into (and callgrind and
and samply haven't helped).
Use `i32` rather than `usize` as "default integer" in library template
`usize` was renamed from `uint` in order to convey that it's not the "default integer type". Guide new users to use `i32` instead of `usize`.
`usize` was renamed from `uint` in order to convey that it's not the
"default integer type". Guide new users to use integers with specific
bit width instead of `usize`.
fetch specific commits even if the github fast path fails
### What does this PR try to resolve?
This PR fixes#13555, which describes a regression from 1.64.0 to 1.65.0 where the inability to fetch commit information from api.github.com (the "GitHub fast path") silently changes Cargo's behavior.
Cargo can fetch a specific Git commit from a remote without having to fetch all refs. Prior to #10807, this functionality required a repository hosted on github.com and providing the full commit hash (usually available from the Cargo.lock); after that change, any revision (including abbreviated revisions) that could be resolved by GitHub's API could be fetched directly. However, this logic requires the "GitHub fast path", which was not intended to be robust, to successfully return the resolved commit hash; if a client is currently rate-limited by api.github.com (very common in CI and shared cloud / corporate environments) this fails and Cargo falls back to fetching all refs.
Usually this is not noticeable. However, GitHub allows fetching commits that are related to the repository but not actually part of any of its refs, including commits pushed to a fork. This results in the same command working fine in some environments where api.github.com is accessible, and not working in other environments that are rate-limited, which is very confusing and difficult to debug.
This change adds another branch to cover the regression case: if we are going through the GitHub fast path with a full commit hash, return early indicating that we need to fetch it. (Previously: ~~when the GitHub fast path was unsuccessful, the user is not using the unstable shallow clone options, and we have a full commit hash and expect to be able to fetch it directly because we know it's a github.com repository.~~)
### How should we test and review this PR?
I have been testing this PR by temporarily adding a `0.0.0.0 api.github.com` entry to my `/etc/hosts`, which causes the GitHub fast path to always fail, then running:
```
target/release/cargo install --git https://github.com/haha-business/unstable-test-repo.git --rev c9040898c9183ddbb9402dcbf749ed06d6ea90ad
```
This refers to [a particular commit on a fork of the repo](c9040898c9) which won't be found by the fallback path or current Cargo.
**Note** that you will need to delete `~/.cargo/git/checkouts/unstable-test-repo-*` and `~/.cargo/git/db/unstable-test-repo-*` after a successful run with this change in order to reproduce the broken behavior of the current release.
I am having trouble getting the test suite to run at all on my system so I haven't experimented with writing a specific test for this case, but I probably should.
### Additional information
This uses the same logic as the unstable shallow clone support to detect if the revision is a full commit hash. This is not compatible with SHA-256 commit hashes; `git2::Oid` specifically expects a 40-character hexadecimal string. Given that the change introducing this bug was meant to future-proof SHA-256 support (despite only doing so for GitHub repositories), it might be good to make the logic more explicit within Cargo and allow either 40- or 64-character hex strings.
I wanted to keep this change focused on the regression fix, but in testing, pretty much every Git repository I could think of (including non-forges, like git.kernel.org and some repositories I host on my own infrastructure with cgit) supports fetching directly from a commit, so it would be ideal to eventually relax the GitHub requirement for this functionality. However, it would need some sort of fallback logic because I suspect the HTTP [dumb protocol](https://git-scm.com/book/en/v2/Git-Internals-Transfer-Protocols) doesn't support commit references, and I haven't researched when this functionality was added to the smart protocol.