]> git.proxmox.com Git - cargo.git/commit
Auto merge of #10829 - ehuss:corrupted-checkout, r=weihanglo
authorbors <bors@rust-lang.org>
Wed, 6 Jul 2022 22:26:17 +0000 (22:26 +0000)
committerbors <bors@rust-lang.org>
Wed, 6 Jul 2022 22:26:17 +0000 (22:26 +0000)
commit9c4bae65b743df07d10a58836a5ee09103050d02
tree2ed4045d25be3bb9ca013e0d8647f54230d2f8c7
parentca190acce06982d1405e6e16936c890787eddb7d
parentc46e57b0cf7489f8d6a41a42f4eebcc08201e195
Auto merge of #10829 - ehuss:corrupted-checkout, r=weihanglo

Fix corrupted git checkout recovery.

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