You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem
When using the git-fetch-with-cli configuration option, Cargo will fail to update the a repository if it has been force-pushed:
$ cargo update
Updating git repository `file:///Users/sfackler/bar`
error: failed to load source for a dependency on `bar`
Caused by:
Unable to update file:///Users/sfackler/bar
Caused by:
failed to fetch into /Users/sfackler/.cargo/git/db/bar-399b59269c932c61
Caused by:
process didn't exit successfully: `git fetch --tags --quiet --update-head-ok 'file:///Users/sfackler/bar' 'refs/heads/*:refs/heads/*'` (exit code: 1)
Here I used a local git repository for simplicity, but a remote one behaves the same way.
Cargo appears to throw away git's output, unfortunately. Weirdly enough, manually running the failing command in the fetch directory succeeds but cargo update continues to fail afterwards. Deleting the fetch directory does make things work though.
Steps
Make a crate with a git dependency.
Run cargo generate-lockfile.
Force-push to the dependency's git repository.
Run cargo update.
Notes
cargo 1.33.0 (f099fe94b 2019-02-12)
git version 2.21.0
Darwin sfackler51-mac 17.7.0 Darwin Kernel Version 17.7.0: Thu Dec 20 21:47:19 PST 2018; root:xnu-4570.71.22~1/RELEASE_X86_64 x86_64
The text was updated successfully, but these errors were encountered:
sfackler
changed the title
git-fetch-with-cli fails to update when the repository is force-pushed
Cargo fails to update force-pushed git repositories when git-fetch-with-cli is enabled
Mar 29, 2019
Support force-pushed repos with git-fetch-with-cli.
If a git repo had a force push, then the `git-fetch-with-cli` feature would fail to fetch an update. This adds the `--force` flag to force the fetch. There's a bit of a lengthy discussion in the [git docs](https://git-scm.com/docs/git-fetch#Documentation/git-fetch.txt-ltrefspecgt) about why this is needed when a refspec is supplied.
I also changed it to remove the `--quiet` flag and to capture the output, which is only displayed on error. I'm not sure what the reasoning for the `--quiet` flag was, but I don't see any harm since the output was previously unused. This can maybe help people debug problems, however in this situation
all you would see is ` ! [rejected] master -> master (non-fast-forward)` which isn't terribly informative.
Fixes#6795.
Problem
When using the git-fetch-with-cli configuration option, Cargo will fail to update the a repository if it has been force-pushed:
Here I used a local git repository for simplicity, but a remote one behaves the same way.
Cargo appears to throw away git's output, unfortunately. Weirdly enough, manually running the failing command in the fetch directory succeeds but cargo update continues to fail afterwards. Deleting the fetch directory does make things work though.
Steps
cargo generate-lockfile
.cargo update
.Notes
The text was updated successfully, but these errors were encountered: