dandavison / delta

A syntax-highlighting pager for git, diff, grep, and blame output
https://dandavison.github.io/delta/
MIT License
21.43k stars 361 forks source link

šŸ› blame parser fails with `-b` / `blankBoundary` #1530

Open adamchainz opened 10 months ago

adamchainz commented 10 months ago

Similar to #1171. It seems the blame parser also isnā€™t ready for lines with no commit information at the start, from the -b option / blankBoundary configuration option.

Hereā€™s an example from the Django repository, providing --since so that thereā€™s a boundary. First, the following is correctly parsed with delta:

$ git --no-pager blame -L 1,1 --since yesterday django/utils/html.py
^facc153af7 (sarahboyce 2023-04-06 19:40:14 +0200 1) """HTML utilities suitable for global use."""

ā€¦which looks like:

$ git blame -L 1,1 --since yesterday django/utils/html.py
4 months ago    sarahboyce      ^facc153af7ā”‚  1 ā”‚ """HTML utilities suitable for global use."""

Second, adding -b changes Git to not output any commit information for those beyond the boundary (previously indicated by the ^):

$ git --no-pager blame -L 1,1 --since yesterday -b django/utils/html.py
            (sarahboyce 2023-04-06 19:40:14 +0200 1) """HTML utilities suitable for global use."""

ā€¦which delta fails to highlight:

$ git blame -L 1,1 --since yesterday -b django/utils/html.py
            (sarahboyce 2023-04-06 19:40:14 +0200 1) """HTML utilities suitable for global use."""

(This is a shame because the oh-my-zsh aliases set -b by default: https://github.com/ohmyzsh/ohmyzsh/blob/03a0d5bbaedc732436b5c67b166cde954817cc2f/plugins/git/git.plugin.zsh#L118 . Though I just made a PR to remove that: https://github.com/ohmyzsh/ohmyzsh/pull/11864 .)

Thanks for filing a Delta bug report!