4 ms·
Feels like there ought to be a cute scoring algorithm to determine which to use. It is a pretty important UX to get right IMO. I reckon it'd be nice to include
by kohtatsu 6y ago
Feels like there ought to be a cute scoring algorithm to determine which to use. It is a pretty important UX to get right IMO.
I reckon it'd be nice to include which to use in the commit too.
- swinglock 6y agoIt'd be even nicer if git could figure it out. From those two examples only, looks like fewer hunks are better, but so are smaller hunks, at least when the number of hunks are equal.
- GolDDranks 6y agoI hazard a guess that there doesn't exist a simple heuristic (such as "number of chunks") that always does the right thing. I think that to achieve better diffs, the diff tool should have some understanding over the structural properties of the language – but that would, of course, mean that the diff tool should be different for each language. (Or more like, there should be a parsing frontend that parses a "labeled tree" structure, and then a generic diffing algorithm over those kinds of trees.)
- yencabulator 6y agogit's diff already has language-specific configurability, for example xfuncname sets a "function declaration" or similar header (e.g. markdown heading, org-mode section) that is shown in a diff. Similarly, one could imagine a language-specific regexp that gives "anchor points" such as declaration start, where one would prefer that a single diff hunk doesn't mutate things across that anchor, if it doesn't have to.