Live data from Hacker News

Better Git diff output for Ruby, Python, Elixir, Go

tekin.co.uk

21–30 of 53 posts

Re: Better Git diff output for Ruby, Python, Elixir, Go

#21
A bigger problem is tree structures, it is particularly egregious for HTML and JSON where the output tend to be a complete mess of red and green. I think a good solution would be for git to call out to the respective language servers (the VS Language Server Protocol) and render changes based on AST and syntax specific diffs.

Re: Better Git diff output for Ruby, Python, Elixir, Go

#22
post #14

From the title I was hoping that it was going to do syntax-aware alignment of diffs, but alas no. I've been using kdiff3 even though it hasn't been updated in a very long time because it has one killer feature: manual diff alignment. I can select a token in both (or all three) files and then force the diff to align at that point. It makes merges a whole lot easier. Sometimes, a single realign is all that's needed for…

> Did I miss something? Sure https://download.kde.org/stable/kdiff3/

Aww, you got my hopes up but that looks like KDE-only fork of the original, which lives here: http://kdiff3.sourceforge.net/

Re: Better Git diff output for Ruby, Python, Elixir, Go

#23

I tried to figure out why the extensions aren't configured by default. I found a 2011 patch/proposal to make it the default, which appears to have stranded: https://lore.kernel.org/git/20110825204047.GA9948@sigill.int... With some discussion by the patch's author of possible downsides ( https://lore.kernel.org/git/20110826025913.GC17625@sigill.in... ): > I think it could be a problem in the future if the builtin user…

I rarely see files with incorrect file extensions outside of collisions and user error?

I don’t see any downside apart from extensionless files like shell scripts with the executable flag set, shebang, and no file extension which could also be solved.

Edit: and if comprehensive correctness was truly desired, file magic could make a better guess, but that would be overkill imo.

Re: Better Git diff output for Ruby, Python, Elixir, Go

#24
post #8

I use delta as a diff tool: https://github.com/dandavison/delta It also offers contextual information as well as side-by-side diffs. For syntax highlighting, it uses the same as bat (the cat clone).

This looks like a great command line alternative to git diff or diff, but I have to admit that I greatly prefer meld when I need a quick diff against non version controlled files, or sublime merge when using revision controlled files.

Re: Better Git diff output for Ruby, Python, Elixir, Go

#26

Diffs are still pretty bad at preserving context, especially the “greedy” diff algorithm that assumes that files are identical for as long as possible instead of preserving as much context around the change as possible (if the diff is equally large. This has the familiar effect where you add a method under an existing method and they both have the same documentation header prefix line such as / , then the diff will m…

Agreed that AST diff is better, but there's also just better diff algorithms like the lesser-known Tichy diff: https://www.researchgate.net/publication/220439403_The_Strin... that I learned from http://bryanpendleton.blogspot.com/2010/04/more-study-of-dif... ; it seems to preserve more context and is better suited for big code refactors.

Re: Better Git diff output for Ruby, Python, Elixir, Go

#27
post #24
post #8

I use delta as a diff tool: https://github.com/dandavison/delta It also offers contextual information as well as side-by-side diffs. For syntax highlighting, it uses the same as bat (the cat clone).

This looks like a great command line alternative to git diff or diff, but I have to admit that I greatly prefer meld when I need a quick diff against non version controlled files, or sublime merge when using revision controlled files.

still using Sublime Merge? I never used it, wondering if you still like it

Re: Better Git diff output for Ruby, Python, Elixir, Go

#29

I tried to figure out why the extensions aren't configured by default. I found a 2011 patch/proposal to make it the default, which appears to have stranded: https://lore.kernel.org/git/20110825204047.GA9948@sigill.int... With some discussion by the patch's author of possible downsides ( https://lore.kernel.org/git/20110826025913.GC17625@sigill.in... ): > I think it could be a problem in the future if the builtin user…

The idea of everyone configuring this individually instead of just being the default behavior in git reminds me a lot of this comment:

https://news.ycombinator.com/item?id=24136477

Re: Better Git diff output for Ruby, Python, Elixir, Go

#30
post #14

From the title I was hoping that it was going to do syntax-aware alignment of diffs, but alas no. I've been using kdiff3 even though it hasn't been updated in a very long time because it has one killer feature: manual diff alignment. I can select a token in both (or all three) files and then force the diff to align at that point. It makes merges a whole lot easier. Sometimes, a single realign is all that's needed for…

meld has manual alignment
Post reply on HN