]> git.proxmox.com Git - cargo.git/blobdiff - vendor/git2/src/blame.rs
New upstream version 0.52.0
[cargo.git] / vendor / git2 / src / blame.rs
index 5c582458df5bc8a475702957220ae602d4bd5cfe..7db275229cc4978d3c5fee1e6a863dcadb430fa7 100644 (file)
@@ -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 {
@@ -216,6 +228,18 @@ impl BlameOptions {
         }
         self
     }
+
+    /// The first line in the file to blame.
+    pub fn min_line(&mut self, lineno: usize) -> &mut BlameOptions {
+        self.raw.min_line = lineno;
+        self
+    }
+
+    /// The last line in the file to blame.
+    pub fn max_line(&mut self, lineno: usize) -> &mut BlameOptions {
+        self.raw.max_line = lineno;
+        self
+    }
 }
 
 impl<'repo> Binding for Blame<'repo> {
@@ -295,7 +319,7 @@ mod tests {
         let (_td, repo) = crate::test::repo_init();
         let mut index = repo.index().unwrap();
 
-        let root = repo.path().parent().unwrap();
+        let root = repo.workdir().unwrap();
         fs::create_dir(&root.join("foo")).unwrap();
         File::create(&root.join("foo/bar")).unwrap();
         index.add_path(Path::new("foo/bar")).unwrap();