summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS1
-rw-r--r--git/repo/base.py11
-rw-r--r--test/test_repo.py7
3 files changed, 16 insertions, 3 deletions
diff --git a/AUTHORS b/AUTHORS
index 97e14789..8f3f2ccf 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -49,4 +49,5 @@ Contributors are:
-Julien Mauroy <pro.julien.mauroy _at_ gmail.com>
-Patrick Gerard
-Luke Twist <itsluketwist@gmail.com>
+-Joseph Hale <me _at_ jhale.dev>
Portions derived from other open source works and are clearly marked.
diff --git a/git/repo/base.py b/git/repo/base.py
index a1be5ff9..c49c6118 100644
--- a/git/repo/base.py
+++ b/git/repo/base.py
@@ -950,7 +950,12 @@ class Repo(object):
)
def blame(
- self, rev: Union[str, HEAD], file: str, incremental: bool = False, **kwargs: Any
+ self,
+ rev: Union[str, HEAD],
+ file: str,
+ incremental: bool = False,
+ rev_opts: Optional[List[str]] = None,
+ **kwargs: Any
) -> List[List[Commit | List[str | bytes] | None]] | Iterator[BlameEntry] | None:
"""The blame information for the given file at the given revision.
@@ -962,8 +967,8 @@ class Repo(object):
of appearance."""
if incremental:
return self.blame_incremental(rev, file, **kwargs)
-
- data: bytes = self.git.blame(rev, "--", file, p=True, stdout_as_string=False, **kwargs)
+ rev_opts = rev_opts or []
+ data: bytes = self.git.blame(rev, *rev_opts, "--", file, p=True, stdout_as_string=False, **kwargs)
commits: Dict[str, Commit] = {}
blames: List[List[Commit | List[str | bytes] | None]] = []
diff --git a/test/test_repo.py b/test/test_repo.py
index 75b590fe..703dbb43 100644
--- a/test/test_repo.py
+++ b/test/test_repo.py
@@ -553,6 +553,13 @@ class TestRepo(TestBase):
self.assertEqual(len(res), 1)
self.assertEqual(len(res[0][1]), 83, "Unexpected amount of parsed blame lines")
+ @mock.patch.object(Git, "_call_process")
+ def test_blame_accepts_rev_opts(self, git):
+ res = self.rorepo.blame("HEAD", "README.md", rev_opts=["-M", "-C", "-C"])
+ expected_args = ['blame', 'HEAD', '-M', '-C', '-C', '--', 'README.md']
+ boilerplate_kwargs = {"p" : True, "stdout_as_string": False}
+ git.assert_called_once_with(*expected_args, **boilerplate_kwargs)
+
@skipIf(
HIDE_WINDOWS_KNOWN_ERRORS and Git.is_cygwin(),
"""FIXME: File "C:\\projects\\gitpython\\git\\cmd.py", line 671, in execute