Do not compute the entire diff if all we want is --json --untracked

pmeunier
Jul 21, 2021, 2:21 PM
V6J6DTJCGVYSL5W7NVSRP5ROIUWTMZW2MBYO7UBZFCUEJQO3ADWQC

Dependencies

  • [2] EUZFFJSO Updating Pijul with the latest changes in Libpijul
  • [3] HSEYMLO2 Adding an untracked change iterator
  • [4] 2K7JLB4Z No pager on Windows
  • [5] VIHXB7SG commands: set up pager for diff, change, and credit
  • [6] ZRUPLBBT Colours in diff and change: separating concerns and dependencies
  • [7] 5BB266P6 Optional colours in the global config file
  • [8] SXEYMYF7 Fixing the bad changes in history (unfortunately, by rebooting).
  • [*] YDKNUL6B Add `diff --short` that lists changes without showing them

Change contents

  • edit in pijul/src/commands/diff.rs at line 42
    [4.174275]
    [2.16050]
    if self.untracked && self.json {
    let txn = txn.read();
    serde_json::to_writer_pretty(
    &mut std::io::stdout(),
    &untracked(&repo, &*txn)?.collect::<Vec<_>>(),
    )?;
    writeln!(stdout)?;
    return Ok(());
    }
  • replacement in pijul/src/commands/diff.rs at line 133
    [4.175800][3.203:1884]()
    if self.untracked {
    serde_json::to_writer_pretty(
    &mut std::io::stdout(),
    &untracked(&repo, &*txn)?.collect::<Vec<_>>(),
    )?;
    writeln!(stdout)?;
    } else {
    let mut changes = BTreeMap::new();
    for ch in change.changes.iter() {
    changes
    .entry(ch.path())
    .or_insert_with(Vec::new)
    .push(Status {
    operation: match ch {
    Hunk::FileMove { .. } => "file move",
    Hunk::FileDel { .. } => "file del",
    Hunk::FileUndel { .. } => "file undel",
    Hunk::SolveNameConflict { .. } => "solve name conflict",
    Hunk::UnsolveNameConflict { .. } => "unsolve name conflict",
    Hunk::FileAdd { .. } => "file add",
    Hunk::Edit { .. } => "edit",
    Hunk::Replacement { .. } => "replacement",
    Hunk::SolveOrderConflict { .. } => "solve order conflict",
    Hunk::UnsolveOrderConflict { .. } => "unsolve order conflict",
    Hunk::ResurrectZombies { .. } => "resurrect zombies",
    },
    line: ch.line(),
    });
    }
    serde_json::to_writer_pretty(&mut std::io::stdout(), &changes)?;
    writeln!(stdout)?;
    [4.175800]
    [4.176894]
    let mut changes = BTreeMap::new();
    for ch in change.changes.iter() {
    changes
    .entry(ch.path())
    .or_insert_with(Vec::new)
    .push(Status {
    operation: match ch {
    Hunk::FileMove { .. } => "file move",
    Hunk::FileDel { .. } => "file del",
    Hunk::FileUndel { .. } => "file undel",
    Hunk::SolveNameConflict { .. } => "solve name conflict",
    Hunk::UnsolveNameConflict { .. } => "unsolve name conflict",
    Hunk::FileAdd { .. } => "file add",
    Hunk::Edit { .. } => "edit",
    Hunk::Replacement { .. } => "replacement",
    Hunk::SolveOrderConflict { .. } => "solve order conflict",
    Hunk::UnsolveOrderConflict { .. } => "unsolve order conflict",
    Hunk::ResurrectZombies { .. } => "resurrect zombies",
    },
    line: ch.line(),
    });
  • edit in pijul/src/commands/diff.rs at line 155
    [4.176908]
    [10.50]
    serde_json::to_writer_pretty(&mut std::io::stdout(), &changes)?;
    writeln!(stdout)?;