From 993a71c4fb903766e1e702c9343a925426dceaa1 Mon Sep 17 00:00:00 2001 From: Hiroki Noda Date: Tue, 10 Nov 2020 21:59:24 +0900 Subject: [PATCH] Add new blame options --- libgit2-sys/lib.rs | 2 ++ src/blame.rs | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/libgit2-sys/lib.rs b/libgit2-sys/lib.rs index 5bf894d07e..807287558d 100644 --- a/libgit2-sys/lib.rs +++ b/libgit2-sys/lib.rs @@ -714,6 +714,8 @@ pub const GIT_BLAME_TRACK_COPIES_SAME_COMMIT_MOVES: u32 = 1 << 1; pub const GIT_BLAME_TRACK_COPIES_SAME_COMMIT_COPIES: u32 = 1 << 2; pub const GIT_BLAME_TRACK_COPIES_ANY_COMMIT_COPIES: u32 = 1 << 3; pub const GIT_BLAME_FIRST_PARENT: u32 = 1 << 4; +pub const GIT_BLAME_USE_MAILMAP: u32 = 1 << 5; +pub const GIT_BLAME_IGNORE_WHITESPACE: u32 = 1 << 6; #[repr(C)] #[derive(Copy, Clone)] diff --git a/src/blame.rs b/src/blame.rs index 5c582458df..1d7364b6b3 100644 --- a/src/blame.rs +++ b/src/blame.rs @@ -201,6 +201,18 @@ impl BlameOptions { self.flag(raw::GIT_BLAME_FIRST_PARENT, opt) } + /// Use mailmap file to map author and committer names and email addresses + /// to canonical real names and email addresses. The mailmap will be read + /// from the working directory, or HEAD in a bare repository. + pub fn use_mailmap(&mut self, opt: bool) -> &mut BlameOptions { + self.flag(raw::GIT_BLAME_USE_MAILMAP, opt) + } + + /// Ignore whitespace differences. + pub fn ignore_whitespace(&mut self, opt: bool) -> &mut BlameOptions { + self.flag(raw::GIT_BLAME_IGNORE_WHITESPACE, opt) + } + /// Setter for the id of the newest commit to consider. pub fn newest_commit(&mut self, id: Oid) -> &mut BlameOptions { unsafe {