logoalt Hacker News

gfodyyesterday at 10:35 AM3 repliesview on HN

I've had this idea too, and think about it everytime I'm on a PR with lots of whitespace/non-functional noise how nice it would be if source code wern't just text and I could be looking at a cleaner higher level diff instead.. I think you have to go higher than AST though, it should at least be language-aware


Replies

gritzkoyesterday at 10:40 AM

(Author) In my current codebase, I preserve the whitespace nodes. Whitespace changes would not affect the other nodes though. My first attempt to recover whitespace algorithmically not exactly failed, but more like I was unable to verify it is OK enough. We clang-format or go fmt the entire thing anyway, and whitespace changes are mostly noise, but I did not find 100% sure approach yet.

show 1 reply
zelphirkaltyesterday at 11:19 AM

Some languages are unfortunately whitespace sensitive, so a generic VCS cannot discard whitespace at all. But maybe the diffing tools themselves could be made language aware and hide not meaningful changes.

show 1 reply
procaryoteyesterday at 11:28 AM

You can build a mergetool (https://git-scm.com/docs/git-mergetool)