Avoid cloning into an existing path

[?]
Jan 4, 2021, 9:03 PM
LYTVEPH3W5UHF7MAYFWBT6NVNC42HEVKJGGMFDKUDZDNDOI33YJQC

Dependencies

  • [2] TPEH2XNB 1.0.0-alpha.28, with Tokio 1.0
  • [3] Q45QHPO4 Feedback on network stuff
  • [4] L4JXJHWX pijul/*: reorganize imports and remove extern crate
  • [5] I52XSRUH Massive cleanup, and simplification
  • [6] UFCZKKLX Upgrading to the latest Sanakirja/Rand
  • [7] BT2ZHPY4 Version bumps
  • [8] SXEYMYF7 Fixing the bad changes in history (unfortunately, by rebooting).
  • [9] L4LAD4XM Fixing clone on WSL (Windows Subsystem for Linux)
  • [10] GHO6DWPI Refactoring iterators
  • [11] CCLLB7OI Upgrading to Sanakirja 0.15 + version bump
  • [*] 2K7JLB4Z No pager on Windows
  • [*] XWETQ4DE Upgrading versions
  • [*] SAGSYAPX Various version bumps

Change contents

  • edit in pijul/src/commands/clone.rs at line 1
    [3.182891][3.2297:2317]()
    use std::io::Write;
  • edit in pijul/src/commands/clone.rs at line 8
    [3.2958][3.183001:183024](),[3.183001][3.183001:183024]()
    use tempfile::TempDir;
  • replacement in pijul/src/commands/clone.rs at line 58
    [3.184550][3.184550:184784]()
    let parent = std::fs::canonicalize(path.parent().unwrap())?;
    let temp = TempDir::new_in(&parent)?;
    debug!("temp = {:?}", temp.path());
    let mut repo = Repository::init(Some(temp.path().to_path_buf()))?;
    [3.184550]
    [3.184784]
    let path_ = path.clone();
    ctrlc::set_handler(move || {
    std::fs::remove_dir_all(&path_).unwrap_or(());
    })
    .unwrap_or(());
    let repo_path = RepoPath(path);
    let mut repo = Repository::init(Some(repo_path.0.clone()))?;
  • replacement in pijul/src/commands/clone.rs at line 112
    [3.30][3.2591:2732](),[3.2732][3.62:211](),[3.211][3.2772:2839](),[3.2772][3.2772:2839]()
    let temp = temp.into_path();
    if let Err(e) = std::fs::rename(&temp, &path) {
    let mut stderr = std::io::stderr();
    writeln!(
    stderr,
    "Error while renaming {:?} to {:?}: {}",
    temp, path, e
    )?;
    std::fs::remove_dir_all(temp).unwrap_or(());
    }
    [3.30]
    [3.185940]
    std::mem::forget(repo_path);
  • edit in pijul/src/commands/clone.rs at line 116
    [3.185963]
    struct RepoPath(PathBuf);
    impl Drop for RepoPath {
    fn drop(&mut self) {
    std::fs::remove_dir_all(&self.0).unwrap_or(());
    }
    }
  • edit in pijul/Cargo.toml at line 76
    [3.198110][3.198110:198127]()
    tempfile = "3.1"
  • edit in pijul/Cargo.toml at line 80
    [2.1704]
    [13.309]
    ctrlc = "3.1"
  • edit in Cargo.lock at line 310
    [14.611]
    [14.611]
    "winapi 0.3.9",
    ]
    [[package]]
    name = "ctrlc"
    version = "3.1.7"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "b57a92e9749e10f25a171adcebfafe72991d45e7ec2dcb853e8f83d9dafaeb08"
    dependencies = [
    "nix",
  • edit in Cargo.lock at line 1209
    [2.2863]
    [2.2863]
    ]
    [[package]]
    name = "nix"
    version = "0.18.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "83450fe6a6142ddd95fb064b746083fc4ef1705fe81f64a64e1d4b39f54a1055"
    dependencies = [
    "bitflags",
    "cc",
    "cfg-if 0.1.10",
    "libc",
  • edit in Cargo.lock at line 1388
    [15.5811]
    [3.1064186]
    "ctrlc",
  • edit in Cargo.lock at line 1412
    [3.1064451][3.1064451:1064464]()
    "tempfile",