Live data from Hacker News

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

tekin.co.uk

31–40 of 53 posts

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

#31
post #11

Is there a good utility for diff-ing JSON content? I am calling jq to sort keys first and then let the default textual diff highlight the changes, but that's neither convenient nor complete.

Graphtage is a command line utility and underlying library for semantically comparing and merging tree-like structures such as JSON, JSON5, XML, HTML, YAML, and TOML files.

https://blog.trailofbits.com/2020/08/28/graphtage/

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

#32
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…

P4merge is my go-to tool for diffs and merges.

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

#33
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).

Insane that I never tried looking for different diff tools, thanks for the recommendation!

I'd say 95% of the new tools I try come from HN recommendations, I hope we don't start seeing interlopers trying to game it.

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

#34
post #24

Earlier quoted context omitted.

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

I use Sublime Merge pretty much every day, and it's nothing short of fantastic.

It's properly fast, the diff/stage/commit/etc UX is excellent. I particularly enjoy how straightforward it makes it to hand-pick lines from multiple files really quickly. The interface abstracts over enough of the Git ux/api to make it get out of your way, but in a way that doesn't make what it's doing a mystery or too out of your control - hovering over a button will often yield the equivalent git cli commands for example.

Personal preference here, but it's also not an electron app, so it's very resource light.

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

#35
post #22

Earlier quoted context omitted.

> 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/

https://github.com/KDE/kdiff3

In theory there's newer builds of kdiff3 but I've not had any luck running the Windows versions & I don't think there's been significant improvements to the manual alignment code which still require a lot of battling to get the right outcome.

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

#36
No need for:

  git config --global core.attributesfile ~/.gitattributes
Git looks for your personal attributes file by default in ~/.config/git/attributes (well, $XDG_CONFIG_HOME/git/attributes to be precise), so if you put it there you don't have to set the config option.

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

#37
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).

Worth pointing out that this is not mutually exclusive with the article. You can use both, the article (when combined with this pager) will affect what appears inside the chunk header.

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

#38

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…

Wouldn’t the optimal solution be both?

Though, being able to refactor code, and assert that it is logically and functionally equivalent as the previous checkin would be super useful, even if there’s some gaps (sting value or comparison changes could not be asserted, for example)

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

#39
I’ve been using git since a year or two after it was released and I’ve never paid any attention to that part of the diff. I could see it that preventing some editing of the wrong method but that is something testing should reveal.

I’m curious if others see some value in it, either before or with changes from this post?

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

#40
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/

Kinda disappointed that the old Qt4 KDiff3 setup for Windows is 11 MB, but the KDE Qt5 KDiff3 setup is 51 MB.
Post reply on HN