dandavison / magit-delta

Use delta (https://github.com/dandavison/delta) when viewing diffs in Magit
MIT License
288 stars 10 forks source link

Does not work with line-numbers #18

Closed shadyalfred closed 3 years ago

shadyalfred commented 3 years ago

image

I'm not sure what this is, probably old commits' diffs or something. It shows up as soon as I open magit, and it's not even foldable nor collapsible.

dandavison commented 3 years ago

Hi @ShadyAlfred, the problem here is that line-numbers cannot be used1 with magit-delta. So the question is, how does one activate line-numbers for normal Delta usage (including git add -p) but disable it for magit-delta? The best solution for that currently is to add "--no-gitconfig" to magit-delta-delta-args, for example like this:

(add-to-list 'magit-delta-delta-args "--no-gitconfig")

Of course, the disadvantage there is that magit-delta won't use any of the colours configured in your gitconfig. There might be other ways of doing this in the future: it's an active issue in Delta (https://github.com/dandavison/delta/issues/307).

1 As you can imagine, it's essential for the output that magit receives from Delta to be in the standard git patch format, without any line numbers or decorations etc, because magit is expecting to receive output from git, and magit uses that output to form its own patches to send to git apply. So the only "unusual" thing that Delta is allowed to add to the patch are ANSI colour codes (which are converted to emacs colours and removed from the patch by the xterm-color elisp library).

shadyalfred commented 3 years ago

Thanks, that fixed it. I found it indeed in my .gitconfig file, I had copied it from the snippet that was provided in the git delta repo.