1#![forbid(unsafe_code)]
2#![deny(elided_lifetimes_in_paths)]
3
4pub mod prelude {
5 pub use crate::ext::prelude::*;
6}
7
8mod ext;
9
10pub use git2::Error as GitError;
11
12pub use crate::prelude::*;
13
14use git2::{Commit, DiffDelta, DiffFormat, DiffHunk, DiffLine, Repository};
15
16use crate::ext::WalkOutput;
17
18#[inline]
19pub fn commits(repo: &Repository) -> Result<Commits<'_>, GitError> {
20 repo.commits()
21}
22
23#[inline]
24pub fn count_commits(repo: &Repository) -> Result<usize, GitError> {
25 repo.count_commits()
26}
27
28#[inline]
29pub fn walk_commits<T, F>(repo: &Repository, f: F) -> Result<(), GitError>
30where
31 F: FnMut(Commit<'_>) -> T,
32 T: WalkOutput,
33{
34 repo.walk_commits(f)
35}
36
37#[inline]
38pub fn walk_changes<T, F>(
39 repo: &Repository,
40 commit: &Commit<'_>,
41 format: DiffFormat,
42 f: F,
43) -> Result<(), GitError>
44where
45 F: FnMut(DiffDelta<'_>, Option<DiffHunk<'_>>, DiffLine<'_>) -> T,
46 T: WalkOutput,
47{
48 commit.walk_changes(&repo, format, f)
49}