Skip to content

fix(git): git gc with safe.bareRepository=explicit - #17370

Merged
epage merged 1 commit into
rust-lang:masterfrom
weihanglo:bare-repo
Aug 19, 2026
Merged

fix(git): git gc with safe.bareRepository=explicit#17370
epage merged 1 commit into
rust-lang:masterfrom
weihanglo:bare-repo

Conversation

@weihanglo

@weihanglo weihanglo commented Aug 16, 2026

Copy link
Copy Markdown
Member

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 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.
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.bareRepository first appears).

  1. Set safe.bareRepository=explicit
  2. cargo fetch with config net.git-fetch-with-cli=true
  3. Put a marker file inside $CARGO_HOME/git/db/<git-dir>/
  4. cargo update to force a git fetch
  5. Observe the marker is gone, because Cargo reinitialized the entire db.

I 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 fetch usage is not compatibility with Git CLI v3, and surprisingly it told me git gc is not good. I didn't expect this.

@rustbot rustbot added A-git Area: anything dealing with git S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 16, 2026
@rustbot

rustbot commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator

r? @epage

rustbot has assigned @epage.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @epage, @weihanglo
  • @epage, @weihanglo expanded to epage, weihanglo

@epage

epage commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

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.

@weihanglo

weihanglo commented Aug 18, 2026

Copy link
Copy Markdown
Member Author

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?

@weihanglo weihanglo closed this Aug 18, 2026
@weihanglo
weihanglo deleted the bare-repo branch August 18, 2026 23:54
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 18, 2026
@weihanglo
weihanglo restored the bare-repo branch August 18, 2026 23:54
@weihanglo weihanglo reopened this Aug 18, 2026
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 18, 2026
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.
@rustbot

rustbot commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

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.

@epage
epage enabled auto-merge August 18, 2026 23:58
@epage

epage commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Yeah, would be nice to have a tests generally but unsure if it is worth it here.

@weihanglo

Copy link
Copy Markdown
Member Author

TIL jj push after jj bookmark delete deletes remote bookmarks. I should have read the manual first

@epage
epage added this pull request to the merge queue Aug 19, 2026
Merged via the queue into rust-lang:master with commit 514c56d Aug 19, 2026
29 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 19, 2026

@zzz6519003 zzz6519003 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might add test as well? XD

sorry for duplication

@weihanglo
weihanglo deleted the bare-repo branch August 19, 2026 01:30
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request Aug 19, 2026
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)
@rustbot rustbot added this to the 1.100.0 milestone Aug 19, 2026
RalfJung pushed a commit to RalfJung/miri that referenced this pull request Aug 19, 2026
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)
pull Bot pushed a commit to asukaminato0721/rust-analyzer that referenced this pull request Aug 20, 2026
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)
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants