git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Fake linear history in a deterministic manner.

From
Linus Torvalds <torvalds@osdl.org>
Date
Feb 13, 2006, 16:34 UTC
Message-ID
<Pine.LNX.4.64.0602130819490.3691@g5.osdl.org>
In-Reply-To
<46a038f90602122158n51fc94a8h2ff2631c16cd28b5@mail.gmail.com>
On Mon, 13 Feb 2006, Martin Langhoff wrote:
> 
> In any case, I'm undecided whether to use --topo-order or
> --merge-order. Does it really matter?
Use topo-order.

merge-order is much more expensive to calculate, and doesn't even exist if NO_OPENSSL is set.

Anyway, while linearization in general is impossible, I'd suggest a few heuristics:

 - you obviously must remember the head of the previous linearization. Any 
   tree choices you made in the past are not something you can change any 
   more for cvs export.
   This may sound obvious, but the fact is, especially if you do the cvs 
   export frequently, and the main maintainer updates the tree in a timely 
   manner, it will limit your choices a LOT. In fact, most of the time 
   you'll have no choice at all: you will have an unambiguous "TRUNK" that 
   is defined by the fact that there is only one linear path from the 
   previous export-head to the current HEAD.

In short, most of the time you won't have any issues in a stable system. You'll see a true "fork in the road" choice only when the maintainer hasn't pushed his tree to the thing you export in a while, long enough that no CVS exporting has taken place over a whole parallel cycle. It's probably rare.

So the main issue of "which child to choose" becomes one of the initial export, and then just occasionally thereafter. And in that case, there's really just one obvious algorithm:

 - simply enumerate the possible paths (not that hard - it's just 
   enumerating a tree once you've generated the graph in memory with child 
   and parent pointers), and just selecting the one with the "longest 
   weighted path".

I say "weighted path", because you might want to consider different commits to have different weights. For example, you might want to consider merge commits to be less interesting (so weight them as 0.5 commits) in order to get as many "real" commits as possible. And you might consider commits made by a certain person to be "more TRUNKish", and give them a weight of 2, so that you'll be more likely to follow the "maintainer view" over any other linearized history.

No other algorithm seems very sane. 
		Linus
Previous: Martin LanghoffNext: Eric Wong
Message 4 of 7 in “Fake linear history in a deterministic manner.”
  1. Martin LanghoffFeb 13, 2006
  2. Junio C HamanoFeb 13, 2006
  3. Martin LanghoffFeb 13, 2006
  4. Linus TorvaldsFeb 13, 2006
  5. Eric WongFeb 16, 2006
  6. Martin LanghoffFeb 16, 2006
  7. Junio C HamanoFeb 16, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.