fix(git): git gc with safe.bareRepository=explicit - #17370
Conversation
|
r? @epage rustbot has assigned @epage. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
Always feel sketchy testing for indirect results because it makes the test brittle and kicks that can down the road to someone who feels responsible for making them still work. |
I am also fine without any test as it is pretty straightforward. How do you want to proceed? |
Git v3 will enforce `safe.bareRepository=explicit`, while older versions don't. See <https://git-scm.com/docs/BreakingChanges/2.55.0#_git_3_0> This ensures `git gc` work with `safe.bareRepository=explicit` by setting an explicit `GIT_DIR` environment variable. This is not a requirement of making CLI fetch the default, but better to have before Git CLI v3 is out.
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
Yeah, would be nice to have a tests generally but unsure if it is worth it here. |
|
TIL |
Update cargo submodule 6 commits in 8a0d8afba810304bcf9a10bac430be80dd470233..514c56dd7321eecbfdcf9b6479519cf4edfab906 2026-08-15 01:32:53 +0000 to 2026-08-19 00:31:04 +0000 - fix(git): `git gc` with `safe.bareRepository=explicit` (rust-lang/cargo#17370) - test: make snapshots agnostic to `-Zembed-metadata=no` (rust-lang/cargo#17374) - fix(clean): Improving description for clean options (rust-lang/cargo#17365) - Re-stabilize build-dir layout v2 (rust-lang/cargo#17354) - Enable `-Zembed-metadata=no` by default on nightly Cargo (rust-lang/cargo#17267) - fix(frontmatter): Don't panic on a short closing fence before a non-ASCII char (rust-lang/cargo#17274)
Update cargo submodule 6 commits in 8a0d8afba810304bcf9a10bac430be80dd470233..514c56dd7321eecbfdcf9b6479519cf4edfab906 2026-08-15 01:32:53 +0000 to 2026-08-19 00:31:04 +0000 - fix(git): `git gc` with `safe.bareRepository=explicit` (rust-lang/cargo#17370) - test: make snapshots agnostic to `-Zembed-metadata=no` (rust-lang/cargo#17374) - fix(clean): Improving description for clean options (rust-lang/cargo#17365) - Re-stabilize build-dir layout v2 (rust-lang/cargo#17354) - Enable `-Zembed-metadata=no` by default on nightly Cargo (rust-lang/cargo#17267) - fix(frontmatter): Don't panic on a short closing fence before a non-ASCII char (rust-lang/cargo#17274)
Update cargo submodule 6 commits in 8a0d8afba810304bcf9a10bac430be80dd470233..514c56dd7321eecbfdcf9b6479519cf4edfab906 2026-08-15 01:32:53 +0000 to 2026-08-19 00:31:04 +0000 - fix(git): `git gc` with `safe.bareRepository=explicit` (rust-lang/cargo#17370) - test: make snapshots agnostic to `-Zembed-metadata=no` (rust-lang/cargo#17374) - fix(clean): Improving description for clean options (rust-lang/cargo#17365) - Re-stabilize build-dir layout v2 (rust-lang/cargo#17354) - Enable `-Zembed-metadata=no` by default on nightly Cargo (rust-lang/cargo#17267) - fix(frontmatter): Don't panic on a short closing fence before a non-ASCII char (rust-lang/cargo#17274)
What does this PR try to resolve?
Git v3 will enforce
safe.bareRepository=explicit,while older versions don't.
See https://git-scm.com/docs/BreakingChanges/2.55.0#_git_3_0
This ensures
git gcwork withsafe.bareRepository=explicitby setting an explicit
GIT_DIRenvironment variable.This is not a requirement of making CLI fetch the default,
but better to have before Git CLI v3 is out.
CC #17329
How to test and review this PR?
You can basically repro this manually today with Git 2.38.0 and later (which
safe.bareRepositoryfirst appears).safe.bareRepository=explicitcargo fetchwith confignet.git-fetch-with-cli=true$CARGO_HOME/git/db/<git-dir>/cargo updateto force a git fetchI am not sure if there is a better way to test it than a marker file though.
🤖 LLM disclosure: I told Codex to check if Cargo's
git fetchusage is not compatibility with Git CLI v3, and surprisingly it told megit gcis not good. I didn't expect this.