~/selfhut

selfhut/src/git/diffs.rs -rw-r--r-- 591 B
392c317a — Arthur Melton format 2 years ago
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
pub fn diffs<'a>(commit: git2::Commit<'a>, repo: &'a git2::Repository) -> Option<git2::Diff<'a>> {
    match commit.tree() {
        Ok(tree) => match commit.parent(0) {
            Ok(parent) => match parent.tree() {
                Ok(parent_tree) => {
                    match repo.diff_tree_to_tree(Some(&tree), Some(&parent_tree), None) {
                        Ok(diff) => Some(diff),
                        Err(_) => None,
                    }
                }
                Err(_) => None,
            },
            Err(_) => None,
        },
        Err(_) => None,
    }
}