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

Cargo fails to update force-pushed git repositories when git-fetch-with-cli is enabled #6795

Closed
sfackler opened this issue Mar 29, 2019 · 0 comments · Fixed by #6800
Closed
Labels
C-bug Category: bug

Comments

@sfackler
Copy link
Member

sfackler commented Mar 29, 2019

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

  1. Make a crate with a git dependency.
  2. Run cargo generate-lockfile.
  3. Force-push to the dependency's git repository.
  4. 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
@sfackler sfackler added the C-bug Category: bug label Mar 29, 2019
@sfackler 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
bors added a commit that referenced this issue Apr 1, 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.
@bors bors closed this as completed in #6800 Apr 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant