When importing initial Git commits, use walk rather than iter to walk the tree

pmeunier
May 5, 2022, 9:50 AM
XFYALEYNPVBGT6ET2LT2QKBM4C5MFTIQKABOU3VQJLAYEWMJM22QC

Dependencies

  • [2] AAXP2534 Tags: completing the subcommand
  • [3] CVAT6LN3 Fixing git import, and adding more useful feedback (with `RUST_LOG="pijul=info"`)
  • [4] VU4KVXHW Git import was importing parents and hidden files (including .git), in some cases
  • [5] SXEYMYF7 Fixing the bad changes in history (unfortunately, by rebooting).
  • [6] 2RXOCWUW Making libpijul deterministic (and getting rid of `rand`)

Change contents

  • replacement in pijul/src/commands/git.rs at line 604
    [3.139][3.139:178](),[3.178][2.1615:1661](),[2.1661][3.178:318](),[3.178][3.178:318](),[3.318][3.157148:157180](),[3.157148][3.157148:157180]()
    for t in new_tree.iter() {
    debug!("t = {:?}", t.name());
    if let Some(n) = t.name() {
    let n = Path::new(n).to_path_buf();
    prefixes.insert(n);
    }
    }
    [3.139]
    [3.157180]
    use git2::{TreeWalkMode, TreeWalkResult};
    new_tree
    .walk(TreeWalkMode::PreOrder, |x, t| {
    debug!("t = {:?} {:?}", x, t.name());
    if let Some(n) = t.name() {
    let mut m = Path::new(x).to_path_buf();
    m.push(n);
    prefixes.insert(m);
    }
    TreeWalkResult::Ok
    })
    .unwrap();