Live data from Hacker News

Ask HN: Do you ever truly use your revision history?

news.ycombinator.com

61–70 of 287 posts

Re: Ask HN: Do you ever truly use your revision history?

#61
Yes, regularly. Some archaic code has a surprising longevity. Personally at least once per month I end up with a case where I wonder why some code was implemented or for what purpose. Context that is rarely documented in the source code, but is often exposed at least implicitly through commits, commit messages, date or authors.

I strongly advice against abandoning revision history just because it is easier to just start fresh from a single git commit of the current state of the code. Especially so for code that has been in use more than a couple of years, where the developers may have forgotten the purpose or who did what.

Surely you can convert the svn repository to git with history intact? We did that when we migrated from cvs to mercurial. If it is too complicated to do directly from svn to git, maybe it is easier to convert via mercurial, i.e first from svn to hg, then from hg to git?

https://www.mercurial-scm.org/wiki/ConvertExtension

Re: Ask HN: Do you ever truly use your revision history?

#62
> So I ask: at your company and in your experience, do you get value from source-control-arachaeology? And if so, what does that look like in your case?

I work with different code bases, some have 20+ years of history (migrated from RCS to CVS to git).

There's no week where I don't go back to look at some kind of history, usually to find out why or when something was done. Often the issue keys / ticket numbers referenced in the commit messages help me when the commit message itself is too opaque to understand.

I also like to get a sense of how often a file changes. This gives me a sense of whether the code is likely to be fragile and/or touches often-changing requirements.

There is a diminishing return for very old commits, partly because our team was much smaller back then, and communicated less in writing, partly because too much of the context has changed. But two years doesn't qualify as "very old" here, in our case the diminishing returns start more at 5 to 8 years.

That said, if I were working with SVN again, I'd likely look at the history much less, because it's that much slower and more painful.

Re: Ask HN: Do you ever truly use your revision history?

#63
I think you do get value from it. You won't know it till you eventually do have to go digging in commit history, though I don't find myself doing this regularly. I have found it useful when attempting to understand why code was changed or written the way it was some years previous before. I have also used it to understand when/where a bug was introduced. A tool I like for exploring git history is DeepGit.

Re: Ask HN: Do you ever truly use your revision history?

#66
post #47
post #12

An underrated feature is “blame” in the IDE. IntelliJ or Eclipse both support showing the last commit a line was changed in in the “gutter” of the code editor. Makes it easier to figure out how old a line of code is and (if the commit messages are any good) why it was introduced or changed.

>why it was introduced or changed. "Fixed formatting"

That one’s easy enough. Show diff, run annotate again in the left hand side.

Which is also why I always separate my formatting and structural changes into two sequential commits. Last interesting change is easy to read, and the previous one is the work of a few extra seconds.

Re: Ask HN: Do you ever truly use your revision history?

#67
post #45
post #41

Who wrote this piece of junk code? ... git blame ... oh ...

But seriously. I have seen many places just move the files from their old vcs and into git. It is wrong to say you loose the history; you just have to go into old system to access it. Also sometimes; you change from a monorepo approach to a repository pr. project approach and you want to tidy up in dead projects and irrelevant history while you do that.

Git importation tools are perfectly well equipped to preserve the code deltas in individual commits. Some metadata might get dropped, but you can and should have your commit history.

Re: Ask HN: Do you ever truly use your revision history?

#68
I often use the VCS feature of PHPStorm where I can select a piece of code and then immediately get a nice list of all the commits that changed that code. I can then double click on that code and get a list of other files that were modified. For example, I can then figure out why a certain piece of code does what it does, and why it was added.

Re: Ask HN: Do you ever truly use your revision history?

#69
Yes! I performed a major refactor that lasted about 6 months. With the commit history (that linked to tickets with discussions and even mockups), I could understand the process of people who had left the company two or three years ago. It allowed me to tell obscure business logic from leftover code and bugs. I could trace each line of code to its requirement.

I also used it to pinpoint the cause of a bug after updating a docker image, knowing that the bug was introduced in a certain file between certain dates.

Now I try to strictly enforce detailed tickets and ticket numbers in commit messages.

Re: Ask HN: Do you ever truly use your revision history?

#70
post #19

Frequently. Just this evening I was looking in the HN repository for the last version of the code that pg wrote, to remind myself how he used to do something. One of my favorite tricks is to make a file out of all the changes in the history: git log -p > bigass and then grep through the file (edit: which I like to do in Emacs—hence the file) to see every appearance of some construct. There's a lot of knowledge in the…

This is good. I'm stealing it. It's using git as sort of a super-brain, helping you remember stuff you wouldn't otherwise. It's how I use gmail. Instead of shooting for inbox zero, I just leave anything in there that I might want to remember later and delete the rest. Then, many times years later, I can search through looking for important correspondence. Both of these stories are good examples of how simple but flex…

I use gmail the same way. I do feel that the search functionality could be improved though which I find ironic.
Post reply on HN