Live data from Hacker News

Diff Algorithms

flo.znkr.io

61–64 of 64 posts

Re: Diff Algorithms

#61

Earlier quoted context omitted.

> Git Diff with Vimdiff https://technotales.wordpress.com/2009/05/17/git-diff-with-v...

I'll have to come up with a way to make it so that I can optionally use that, I don't always want it, and I've already got a differ that I sometimes regret having plumbed in there. I need to see if there's an easy way to switch them out.

depends why/when your want to use different differs. the ‘GIT_EXTERNAL_DIFF’ environment variable can be used, but if there's a specific diff for a specific path, then gitattributes is your friend.

Re: Diff Algorithms

#62

while work on pure algorithms is invaluable i always feel work on knowledge augmented algorithms has lots of untapped potential. two examples: recording key events like move and delete on a more fine grained timescale or directly from editors and then storing those as mutable metadata in commits that is only allowed to be used for diff generation. as its provable if diffs are technically correct these do not weaken t…

Do you have examples of any of these ideas being implemented? In general I agree, there’s so much opportunity for these “knowledge augmented” algorithms

nothing im aware of except some of the semantic diff tools that can use knowledge about language. i would love to see this.

Re: Diff Algorithms

#63
post #29

Earlier quoted context omitted.

Another thing I’ve encountered with tree/structured diffs is a concept of identity. diff([{id:1,name:foo}],[{id:2,name:foo}] should show object w/ id:1 removed and id:2 added, not id changed from 1 to 2. Tough because then your diffing algo needs to be aware of the object structure (imo using convention and saying “no objects can contain this key” is pretty tough when you accept any user generated data).

tho i would say that a diff has to define the set of operations allowed to be done to the thing being diff'ed. E.g., in the example scenario of the diff in json objects, if a possible operation is a change in a property value (such as the "id" field), then the diff correctly deduced the smallest change possible is indeed a change in the field. However, if you can define the set of operation to only be a change in an…

I think his point was that different fields should be treated differently. I.e. if you have two objects with the same ID but different descriptions then you can assume that it's the same object but with a changed description; but if you have two objects with different IDs but the same description then you should assume that the new object is completely different and the identical description is coincidental.

I don't agree that these are always the correct interpretations though. IDs could be reused (especially in a DVCS) or mistaken IDs could be corrected. This ambiguity is a fundamental limitation of the entire concept of diffing, that is reconstructing a set of operations to go from one state to another - you simply don't have the information to deduce the correct logical steps in all cases.

Re: Diff Algorithms

#64

My favorite differ in more than trivial cases is "vimdiff". Just hit a case where I wished I had "git vimdiff".

> Git Diff with Vimdiff https://technotales.wordpress.com/2009/05/17/git-diff-with-v...

I finally spent some time digging around in "delta" and found a few configs so that I can do "git diff-side-by-side" to get a side by side view of a diff and some other enhancements. Delta is very, very cool!
Post reply on HN