mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00

We've received a lot of intermittent bug reports historically about corrupt git repositories. These inevitably happens as Cargo is ctrl-c'd or for whatever other reason, and to provide a better user experience Cargo strives to automatically handle these situations by blowing away the old checkout for a new update. This commit adds a new test which attempts to pathologically corrupt a git database and checkout in an attempt to expose bugs in Cargo. Sure enough there were some more locations that we needed to handle gracefully for corrupt git checkouts. Notable inclusions were: * The `fetch` operation in libgit2 would fail due to corrupt references. This starts by adding an explicit whitelist for classes of errors coming out of `fetch` to auto-retry by blowing away the repository. We need to be super careful here as network errors commonly come out of this function and we don't want to too aggressively re-clone. * After a `fetch` succeeded a repository could fail to actual resolve a git reference to the actual revision we want. This indicated that we indeed needed to blow everything away and re-clone entirely again. * When creating a checkout from a database the `reset` operation might fail due to a corrupt local database of the checkout itself. If this happens we needed to just blow it away and try again. There's likely more lurking situations where we need to re-clone but I figure we can discover those over time.
88 lines
1.3 KiB
Rust
88 lines
1.3 KiB
Rust
extern crate bufstream;
|
|
extern crate cargo;
|
|
extern crate filetime;
|
|
extern crate flate2;
|
|
extern crate git2;
|
|
extern crate glob;
|
|
extern crate hex;
|
|
extern crate libc;
|
|
#[macro_use]
|
|
extern crate serde_derive;
|
|
#[macro_use]
|
|
extern crate serde_json;
|
|
extern crate tar;
|
|
extern crate tempdir;
|
|
extern crate toml;
|
|
extern crate url;
|
|
#[cfg(windows)]
|
|
extern crate winapi;
|
|
|
|
#[macro_use]
|
|
mod cargotest;
|
|
mod hamcrest;
|
|
|
|
mod alt_registry;
|
|
mod bad_config;
|
|
mod bad_manifest_path;
|
|
mod bench;
|
|
mod build_auth;
|
|
mod build_lib;
|
|
mod build;
|
|
mod build_script_env;
|
|
mod build_script;
|
|
mod cargo_alias_config;
|
|
mod cargo_features;
|
|
mod cargo_command;
|
|
mod cfg;
|
|
mod check;
|
|
mod clean;
|
|
mod concurrent;
|
|
mod config;
|
|
mod corrupt_git;
|
|
mod cross_compile;
|
|
mod cross_publish;
|
|
mod death;
|
|
mod dep_info;
|
|
mod directory;
|
|
mod doc;
|
|
mod features;
|
|
mod fetch;
|
|
mod freshness;
|
|
mod generate_lockfile;
|
|
mod git;
|
|
mod init;
|
|
mod install;
|
|
mod jobserver;
|
|
mod local_registry;
|
|
mod lockfile_compat;
|
|
mod login;
|
|
mod metadata;
|
|
mod net_config;
|
|
mod new;
|
|
mod overrides;
|
|
mod package;
|
|
mod patch;
|
|
mod path;
|
|
mod plugins;
|
|
mod proc_macro;
|
|
mod profiles;
|
|
mod publish;
|
|
mod read_manifest;
|
|
mod registry;
|
|
mod rename_deps;
|
|
mod required_features;
|
|
mod resolve;
|
|
mod run;
|
|
mod rustc;
|
|
mod rustdocflags;
|
|
mod rustdoc;
|
|
mod rustflags;
|
|
mod search;
|
|
mod small_fd_limits;
|
|
mod test;
|
|
mod tool_paths;
|
|
mod verify_project;
|
|
mod version;
|
|
mod warn_on_failure;
|
|
mod workspaces;
|