summary refs log tree commit diff
path: root/src/diff_thread/mod.rs
blob: 9416509f1aa661f5df537c2162952694d178a8e8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// SPDX-License-Identifier: EUPL-1.2
// SPDX-FileCopyrightText: 2021 Alyssa Ross <hi@alyssa.is>

//! libgit2's diffing API gives us a callback whenever a file diff is ready, but
//! that's not very convenient for Rust code, because it can't be used as an
//! iterator.  So we run the diff in a thread, and send the diff information we need
//! to the main thread over a channel.  When the main thread is processing diff
//! information too slowly, we block the diff thread until the main thread catches
//! up.

mod server;
mod client;

pub use client::DiffThread;

use std::path::PathBuf;

use git2::{Repository, Diff, Delta};

pub trait MakeDiff: Send + 'static {
    fn make_diff(self, _: &Repository) -> Result<Diff, git2::Error>;
}

/// `new_path` isn't included because it's not currently used in git-girf.
pub struct FileDiff {
    pub status: Delta,
    pub old_path: Option<PathBuf>,
}