Request for code review: cvs-fast-export
<p>Sometimes reading code is really difficult, even when it&#8217;s good code.  I have a challenge for all you hackers out there&#8230;</p>
<p><span id="more-6228"></span></p>
<p>cvs-fast-export translates CVS repositories into a git-fast-export stream.  It does a remarkably good job, considering that (a) the problem is hard and grotty, with weird edge cases, and (b) the codebase is small and written in C, which is not the optimal language for this sort of thing.</p>
<p>It does a remarkably good job because Keith Packard wrote most of it, and Keith is a brilliant systems hacker (he codesigned X and wrote large parts of it).  I wrote most of the parts Keith didn&#8217;t, and while I like to think my contribution is solid it doesn&#8217;t approach his in algorithmic density.</p>
<p>Algorithmic density has a downside. There are significant parts of Keith&#8217;s code I don&#8217;t understand.  Sadly, Keith no longer understands them either.  This is a problem, because there are a bunch of individually small issues which (I think) add up to: the core code needs work.  Right now, neither I nor anyone else has the knowledge required to do that work.</p>
<p>I&#8217;ve just spent most of a week trying to acquire and document that knowledge.  The result is a file called &#8220;hacking.asc&#8221; in the cvs-fast-export repository.  It documents what I&#8217;ve been able to figure out about the code. It also lists unanswered questions.  But it is incomplete.</p>
<p>It won&#8217;t be complete until someone can read it and know how to intelligently modify the heart of the program &#8211; a function called rev_list_merge() that does the hard part of merging cliques of CVS per-file commits into a changeset DAG.</p>
<p>The good news is that I&#8217;ve managed to figure out and document almost everything else.  A week ago, the code for analyzing CVS masters into in-core data objects was trackless jungle. Now, pretty much any reasonably competent C systems programmer could read hacking.txt and the comments and grasp what&#8217;s going on.</p>
<p>More remains to be done, though, and I&#8217;ve hit a wall.  The problem needs a fresh perspective, ideally more than one. Accordingly, I&#8217;m requesting help.  If you want a real challenge in comprehending C code written by a master programmer &#8211; a work of genius, seriously &#8211; dive in. </p>
<p>https://gitorious.org/cvs-fast-export/</p>
<p>There&#8217;s the repository link.  Get the code; it&#8217;s not huge, only 10KLOC, but it&#8217;s fiendishly clever.  Read it.  See what you can figure out that isn&#8217;t already documented.  Discuss it with me.  I guarantee you&#8217;ll find it an impressive learning experience &#8211; I have, and I&#8217;ve been writing C for 30 years.</p>
<p>This challenge is recommended for intermediate to advanced C systems programmers, especially those with an interest in the technicalia of version-control systems.</p>
