3 ms·
Sadly, you're right, but while AST-based diff (vs text-as-code based) has yet to become mainstream, code formatting standards date back to the second ever progr
by fragmede 10y ago
Sadly, you're right, but while AST-based diff (vs text-as-code based) has yet to become mainstream, code formatting standards date back to the second ever programmer, and some of those are for good reason.
To use a trivial example, Python allows trailing commas for list items, eg: [1,2,]. With diffing in mind,
list_o_things = [
thing1,
thing2,
]
then, the diff to add "thing3," is a single line , rather than two in order to add a comma to the preceeding line.
The solution, then, is the code should be "properly" formatted at all times, to avoid running into a situation that goes formatting -> logical change -> formatting leading to the problem you describe.
There are similar hacks, where git's diff implementation supports ignoring white space, and doing word-based (vs line-based) diffing, but what we're really after is AST-based diffing tool(s).
- majewsky 10y ago> The solution, then, is the code should be "properly" formatted at all times This is why I love gofmt(1).