• Adding a line: ✅
  • Removing a line: ✅
  • Modifying a line: ✅
  • Moving a codeblock: ❌ i see you’ve rewritten everything, let me just highlight it all.

RIP reviewers on my PR.

(Meme created by my coworker)

Beyond Compare is awesome and handles this and many other things quite well.

@nicoweio@lemmy.world
link
fedilink
8
edit-2
1Y

VSCode has had that feature for some months now. Maybe it’s still hidden behind an off-by-default setting, but it’s there and I use it.

I’ll have to take a look to see if I can use it to view (enterprise) GitHub PRs, because that’d be a huge help

Good question. Maybe GitLens can help with that, if not the official GitHub extensions.

Me adding one if statement around around a code block. Ah shit I guess I own the whole function now.

At least a good diff tool will ignore whitespace diffs.

@MJBrune@beehaw.org
link
fedilink
English
41Y

Perforce diff works better than this. Even my basic Git/Gitlab diffs don’t do this.

How do you expect it to be shown though?

For example, on side by side views, you can draw a box around it on both sides, and draw a line connecting the two

I think Sublime Merge does this with the conflict resolution tool

I’m convinced there must be a way of using ASTs to do more intelligent diffing of a given programming language, but I’m far too lazy to find out for myself.

There is, but your dif tool would have to be language aware and likely be slower to show difs.

OmidMnz
link
fedilink
501Y

You mean like Difftastic?

Hell yeah, being lazy paid off. Thanks.

OmidMnz
link
fedilink
71Y

You’re welcome. And have fun trying to break it!

@kibiz0r@midwest.social
link
fedilink
English
61Y

There have been some attempts at semantic diffs, but it’s very uhh… difficult to gain traction with such a thing.

Diffing algorithms on trees might not be as efficient, especially if they have to find arbitrary node moves.

I wouldn’t expect it to be, but I think modern processors can handle the load!

It’s not necessarily about the load, it’s about the algorithmic complexity. Going from lists (lines in a file, characters in a line) to trees introduces a potentially exponential increase in complexity due to the number of ways the same list of elements can be organized into a tree.

Also, you’re underestimating the amount of processing. It’s not about pure CPU computations but RAM access or even I/O. Even existing non-semantic diff implementations are unexpectedly inadequate in terms of performance. You clearly haven’t tried diffing multi-GB log files.

@killeronthecorner@lemmy.world
link
fedilink
English
1
edit-2
1Y

Log files wouldn’t fall under the banner of compiled languages or ASTs, so I’m not sure how that example applies.

And I’m aware that it can lead to O(n²) complexity but, as others have provided, there are already tools that do this, so it is within the capabilities of modern processors

Yes there will be cases where the size of the search space will make it prohibitive to run in reasonable times but this is - by merit of the existing tools and the fact that they seem to work quite well - an edge case.

Log files themselves don’t, but I’m just comparing it with simpler files with simpler structure with simpler algorithms with better complexity.

@bleistift2@feddit.de
link
fedilink
English
831Y

I’m surprised that after almost 20 years of versioning C code, git still manages to assign the closing brace of a function wrongly.

Because text is text and all } are the same.

Most diff tools have an option to ignore leading or trailing whitespace changes.

I think OP meant moving a code block up or down in a file, not left or right

Yes, thank you. I probably should have been more clear

Me omw to shift the entire codebase to the right by one tab and claim authorship over every line in the project with a completely untraceable commit

That’s awesome. I wonder how it’d handle moving plus a small change.

Too bad GitHub doesn’t support it yet afaict. But at least it’s not all diff tools.

laughs in IntelliJ

that’s not even a joke, I’m using intellij community as a merge and diff tool exclusively. it doesn’t support the language I want but even without it it’s better then anything else.

Give me some love for adding an indent level either showing nothing changed or you rewrote everything too.

@flux@lemmy.ml
link
fedilink
English
11Y

It doesn’t actually detect moved code, though, like git diff can? I gave it a shot and also there’s a couple issues open about it, e.g. https://github.com/Wilfred/difftastic/issues/520 .

Other than that, difftastic is quite nice.

That logo tho. oh noooooo

dream_weasel
link
fedilink
71Y

Maybe specify a different diff algorithm? Histogram for example?

If you’re going to rearrange code, have that as a separate check in from changing code.

Create a post

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.
  • 1 user online
  • 120 users / day
  • 257 users / week
  • 744 users / month
  • 3.72K users / 6 months
  • 1 subscriber
  • 1.48K Posts
  • 32.6K Comments
  • Modlog