Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fe1934c

Browse filesBrowse files
authored
Merge pull request #1846 from Gaubbe/main
`repo.blame` and `repo.blame_incremental` now accept `None` as the `rev` parameter.
2 parents 1e044ea + 27d8a14 commit fe1934c
Copy full SHA for fe1934c

File tree

1 file changed

+8
-4
lines changed
Filter options

1 file changed

+8
-4
lines changed

‎git/repo/base.py

Copy file name to clipboardExpand all lines: git/repo/base.py
+8-4Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -957,13 +957,15 @@ def active_branch(self) -> Head:
957957
# reveal_type(self.head.reference) # => Reference
958958
return self.head.reference
959959

960-
def blame_incremental(self, rev: str | HEAD, file: str, **kwargs: Any) -> Iterator["BlameEntry"]:
960+
def blame_incremental(self, rev: str | HEAD | None, file: str, **kwargs: Any) -> Iterator["BlameEntry"]:
961961
"""Iterator for blame information for the given file at the given revision.
962962
963963
Unlike :meth:`blame`, this does not return the actual file's contents, only a
964964
stream of :class:`BlameEntry` tuples.
965965
966-
:param rev: Revision specifier, see git-rev-parse for viable options.
966+
:param rev: Revision specifier. If `None`, the blame will include all the latest
967+
uncommitted changes. Otherwise, anything succesfully parsed by git-rev-parse
968+
is a valid option.
967969
968970
:return: Lazy iterator of :class:`BlameEntry` tuples, where the commit indicates
969971
the commit to blame for the line, and range indicates a span of line numbers
@@ -1045,15 +1047,17 @@ def blame_incremental(self, rev: str | HEAD, file: str, **kwargs: Any) -> Iterat
10451047

10461048
def blame(
10471049
self,
1048-
rev: Union[str, HEAD],
1050+
rev: Union[str, HEAD, None],
10491051
file: str,
10501052
incremental: bool = False,
10511053
rev_opts: Optional[List[str]] = None,
10521054
**kwargs: Any,
10531055
) -> List[List[Commit | List[str | bytes] | None]] | Iterator[BlameEntry] | None:
10541056
"""The blame information for the given file at the given revision.
10551057
1056-
:param rev: Revision specifier, see git-rev-parse for viable options.
1058+
:param rev: Revision specifier. If `None`, the blame will include all the latest
1059+
uncommitted changes. Otherwise, anything succesfully parsed by git-rev-parse
1060+
is a valid option.
10571061
10581062
:return:
10591063
list: [git.Commit, list: [<line>]]

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.