Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I like it! Doing it this way will mess up the blame for non-unique lines like

    else if {
but I don't think that matters because you are unlikely to care where such lines come from. (You could fix this anyway by doing unique lines first, then using the blame of those to make better choices for the non-unique lines.)

See also the more complicated variant at the end of this post from the git mailing list:

http://marc.info/?l=git&m=116070384211583&w=2



Blame is always messed up anyway, because there is no right answer. You may as well choose what is quick to compute and looks okay.

Version control systems are not storing what actually changed between files, they are storing the smallest set of differences between them.

IE Given two versions of the same file, and the history graph A->B they store how to reproduce the bits of B from the bits of A.

This is completely unrelated to how B actually got that way. So in turn, they use textual diff algorithms to approximate how B was formed from A.

Even moving back into the text world, there is still no right answer. It only tells you one of the possible ways that A was transformed into B. It would be perfectly valid for the text diff algorithm to say "every line in A was removed, every line in B was added". This in turn would give you a blame that pointed to that rev for everything.

Most textual diff algorithms "try" to do something sensible, but blame is essentially trying to turn applesauce back into apples.

Even git's more "advanced" blame can be completely messed up by the internal text diff doing dumb things.

All that said, one of the reasons you may like it is because it's basically what everyone actually does.


I wonder if, someday, it might be practical to integrate the "micro history" of a change into the overall version control system's understanding of the "macro history". I'm thinking of something like an intelligently-condensed version of the kind of change-replay you see by rolling forward or back through an editor's undo buffer. A system like git would still work the same way, but with this new extra blob of detailed metadata associated with the specific commit.

Fractal Designs Painter (now Corel Painter), back in the day, used to have a feature where the entire creation and edit history of a "painting" could be captured and replayed in full detail, right down to the level of the brush angle and pressure used by the artist with every stroke. This was useful for creating art at low resolution, then re-creating the piece automatically (and much more slowly) at high resolution. Corel's version may still have this feature; I haven't used it in years. But if it was practical ten years ago in manipulating multi-hundred-megabyte files, certainly it would be possible now, for what are usually plain text files.

Instead of just doing a diff or git bisect, imagine being able to load up the commit of a file with one of those ambiguous changes, grab a slider (or your favorite keyboard equivalents), and scrub back and forth through a condensed replay of someone else's actual changes exactly as they were keyed.

I'm not sure this would always be a good thing (a form of surveillance?), but it would certainly be useful when the original author of the code is unavailable.


Version control systems are not storing what actually changed between files, they are storing the smallest set of differences between them.

Many version control systems work that way, but there are other possible strategies. For example, Darcs' patch theory is very much based on recording what actually changed in each revision (and consequently achieves better results in some awkward cases than a purely text-based VCS).


No, actually, Darcs is not, it only looks like it is. Again, unless it's recording key strokes and line changes you actually made in the editor, it's still just approximating what happened with a text diff algorithm that doesn't know what you actually did, and is figuring it out after the fact.

Besides not having the goal of figuring out what changed, they often are heuristic and give up (IE they stop trying to align the original files, and just say "removed here, added there").


No, actually, Darcs is not, it only looks like it is.

I think that's a little unfair. Darcs does store what actually changed between the files, at least at the points they were committed, in a qualitatively different way to the flattening effect of cumulative commits in a system like say Git.

Of course, you can defeat even that approach if your edits from one commit to the next are ambiguous, for example if you have two verbatim copies of something next to each other where you had only one before, and this will subsequently lead to ambiguity if you try to merge a change from someone else to the original copy since the merge has no way to determine whether the first or second duplicate (or both) should be modified.

It sounds like you want something that is directly tied into your editor, so it is aware of changes between commits, or perhaps something that has semantic understanding so that instead of recording half a dozen text edits, it records "variable foo was renamed to bar". Tools that worked on that level would be fantastic to work with, but until you've swapped a text file representation of code for some sort of database-backed semantic model and your edits/refactorings can all be expressed in terms of that model, I don't see how any VCS could possibly achieve it.


It's really not qualitatively different, it's just faster for the operations it provides. It does, however, take great pains to try to display to the user the "right thing". It also does in fact, not lose information once given it. But that actually is not qualitatively different than you could make git or svn or anything else, it's just a more careful implementation.

As for the rest, i don't want anything. I just don't pretend that textual displays of blame/diff/etc are actually showing me a correct history, instead of one possible history of textual changes. If it says bob wrote/changed some code, i don't assume that's really correct (unless of course, the changelog says "wrote code" :P), I ask bob.

I will point out that historically, there were version control systems that were integrated like you describe, even for C++ (IBM Visualage C++). But people are happy with what things like git/svn/etc provide, and that's fine by me.

Remember that I worked on a system whose sole goal was to provide a qualitatively better experience than CVS, so I don't have very high standards :P.


All that said, one of the reasons you may like it is because it's basically what everyone actually does.

Please correct me if I'm misunderstanding, but Bram is proposing to do blame without using the diffs, a nice simplification and not something I'm aware of other version control systems doing.


The commits themselves will still, presumably, be generated by diffing. After that, sure, it should be fairly easy to compute exactly what commit contributed each character of a file, and when.


No. The simplest example I can think of is:

  Revision 1: x

  Revision 2: xx
Which x was added in revision 2?

In real life, you get things like replacements of a statement by an if-else block with statements similar to, but not identical to, the original statement in each branch. Are there still parts of the original statement there? If so, in which branch(es)?

Also, suppose I add code in version 6, you remove it in version 14 and someone else resurrects it in version 23. What commit contributed that code? How can you know whether that someone else resurrected the code, rather than write a new copy?

Finally, what is 'contribute'? Does a commit that 'only' moves lines around in online help contribute to a file? What does it contribute? How do you show that contribution in a diff? What if the move also necessitated some minor changes like adding punctuation?


No, you can't do blame without the diffs. Bram is proposing not attempting to figure out the actual lineage of a line, but instead, when there are multiple possible answers, pick one.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: