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

Fix corrupted git checkout recovery. #10829

Merged
merged 1 commit into from
Jul 6, 2022
Merged

Conversation

ehuss
Copy link
Contributor

@ehuss ehuss commented Jul 6, 2022

This fixes an issue where cargo would not recover from a corrupted git checkout correctly when using net.git-fetch-with-cli.

Git dependencies have two clones, the "db" and the "checkout". The "db" is shared amongst multiple checkout revisions from the same repository. The "checkout" is each individual revision. There was some code in copy_to which creates the "checkout" that tries to recover from an error. The "checkout" can be invalid if cargo was interrupted while cloning it, or if there is fs corruption. However, that code was failing when using the git CLI. For reasons I did not dig into, the "db" does not have a HEAD ref, so that special-case fetch was failing with a couldn't find remote ref HEAD error from git.

This changes it so that if the "checkout" is invalid, it just gets blown away and a new clone is created (instead of calling git fetch from the "db").

I believe there is some long history for this copy_to code where it made more sense in the past. Previously, the "checkout" directories used the GitReference string as-is. So, for example, a branch would checkout into a directory with that branch name. At some point, it was changed so that each checkout uses a short hash of the actual revision. Rebuilding the checkout made sense when it was possible for that checkout revision to change (like if new commits were pushed to a branch). That recovery is no longer necessary since a checkout is only ever one revision.

Fixes #10826

@rust-highfive
Copy link

@ehuss: no appropriate reviewer found, use r? to override

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 6, 2022
@Eh2406
Copy link
Contributor

Eh2406 commented Jul 6, 2022

Looks good to me.

Copy link
Member

@weihanglo weihanglo left a comment

Choose a reason for hiding this comment

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

Make sense!

@weihanglo
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Jul 6, 2022

📌 Commit c46e57b has been approved by weihanglo

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 6, 2022
@bors
Copy link
Contributor

bors commented Jul 6, 2022

⌛ Testing commit c46e57b with merge 9c4bae6...

@bors
Copy link
Contributor

bors commented Jul 6, 2022

☀️ Test successful - checks-actions
Approved by: weihanglo
Pushing 9c4bae6 to master...

@bors bors merged commit 9c4bae6 into rust-lang:master Jul 6, 2022
weihanglo added a commit to weihanglo/rust that referenced this pull request Jul 10, 2022
…79e13a071ad4b17435bd6bfa4c

2022-07-03 13:41:11 +0000 to 2022-07-09 14:48:50 +0000

- Mention `[patch]` config in "Overriding Dependencies" (rust-lang/cargo#10836)
- Update terminal-width flag. (rust-lang/cargo#10833)
- Refactor check_yanked to avoid some duplication (rust-lang/cargo#10835)
- Fix publishing to crates.io with -Z sparse-registry (rust-lang/cargo#10831)
- Make `is_yanked` return `Poll<>` (rust-lang/cargo#10830)
- Fix corrupted git checkout recovery. (rust-lang/cargo#10829)
- add a cache for discovered workspace roots (rust-lang/cargo#10776)
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 10, 2022
Update cargo

7 commits in c0bbd42ce5e83fe2a93e817c3f9b955492d3130a..b1dd22e668af5279e13a071ad4b17435bd6bfa4c
2022-07-03 13:41:11 +0000 to 2022-07-09 14:48:50 +0000

- Mention `[patch]` config in "Overriding Dependencies" (rust-lang/cargo#10836)
- Update terminal-width flag. (rust-lang/cargo#10833)
- Refactor check_yanked to avoid some duplication (rust-lang/cargo#10835)
- Fix publishing to crates.io with -Z sparse-registry (rust-lang/cargo#10831)
- Make `is_yanked` return `Poll<>` (rust-lang/cargo#10830)
- Fix corrupted git checkout recovery. (rust-lang/cargo#10829)
- add a cache for discovered workspace roots (rust-lang/cargo#10776)
@ehuss ehuss added this to the 1.64.0 milestone Jul 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cargo build reports fatal: couldn't find remote ref HEAD
5 participants