diff tools cannot handle moving code blocks
diff tools cannot handle moving code blocks


- 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)
bleistift2 @feddit.de I’m surprised that after almost 20 years of versioning C code, git still manages to assign the closing brace of a function wrongly.
84 0 Replysim642 @lemm.ee
Because text is text and all
}
are the same.8 0 Reply
killeronthecorner @lemmy.world
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.
34 0 ReplyOmidMnz @lemmy.world You mean like Difftastic?
51 0 Replykilleronthecorner @lemmy.world
Hell yeah, being lazy paid off. Thanks.
24 0 Reply
ryathal @sh.itjust.works There is, but your dif tool would have to be language aware and likely be slower to show difs.
11 0 Replykibiz0r @midwest.social There have been some attempts at semantic diffs, but it’s very uhh… difficult to gain traction with such a thing.
6 0 Replysim642 @lemm.ee
Diffing algorithms on trees might not be as efficient, especially if they have to find arbitrary node moves.
5 0 Replykilleronthecorner @lemmy.world
I wouldn't expect it to be, but I think modern processors can handle the load!
2 0 Reply
saigot @lemmy.ca Me adding one if statement around around a code block. Ah shit I guess I own the whole function now.
20 0 ReplyRednax @lemmy.world At least a good diff tool will ignore whitespace diffs.
8 0 Reply
Kbin_space_program @kbin.social laughs in IntelliJ
19 1 Replyalokir @lemmy.world 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.
13 0 Reply
Blackbird @infosec.pub Beyond Compare is awesome and handles this and many other things quite well.
11 0 Replydragnucs @lemmy.ml Most diff tools have an option to ignore leading or trailing whitespace changes.
11 2 ReplyFeathercrown @lemmy.world 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
17 0 Replypomodoro_longbreak @sh.itjust.works
I think OP meant moving a code block up or down in a file, not left or right
15 0 ReplyPeriodicallyPedantic @lemmy.ca OP Yes, thank you. I probably should have been more clear
3 0 Reply
nicoweio @lemmy.world 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.
9 1 ReplyPeriodicallyPedantic @lemmy.ca OP 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
5 0 Replynicoweio @lemmy.world Good question. Maybe GitLens can help with that, if not the official GitHub extensions.
1 0 Reply
tastysnacks @programming.dev If you're going to rearrange code, have that as a separate check in from changing code.
8 0 Replydream_weasel @sh.itjust.works Maybe specify a different diff algorithm? Histogram for example?
7 0 Replycsm10495 @sh.itjust.works
Give me some love for adding an indent level either showing nothing changed or you rewrote everything too.
4 0 ReplyMJBrune @beehaw.org Perforce diff works better than this. Even my basic Git/Gitlab diffs don't do this.
4 0 Replymormegil @programming.dev
Try difftastic! https://github.com/Wilfred/difftastic
4 0 Replydill @lemmy.one
That logo tho. oh noooooo
3 0 Replyflux @lemmy.ml 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.
1 0 Reply
sim642 @lemm.ee
How do you expect it to be shown though?
2 0 ReplyPeriodicallyPedantic @lemmy.ca OP For example, on side by side views, you can draw a box around it on both sides, and draw a line connecting the two
10 0 ReplyScrollone @feddit.it I think Sublime Merge does this with the conflict resolution tool
3 0 Reply