fast-export: Correctly generate initial commits with no parents
authorShawn O. Pearce <spearce@spearce.org>
Fri, 13 Jun 2008 04:38:55 +0000 (00:38 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 13 Jun 2008 05:42:20 +0000 (22:42 -0700)
commitd8933f013a66cc1deadf83a9c24eccb6fee78a35
treecebb26344b16228e7d3a563afb62997e7148353a
parent7b7b4516def229846ae20a43818be7e0b30d4261
fast-export: Correctly generate initial commits with no parents

If we are exporting a commit which has no parents we may be doing
it to a branch that already exists, causing fast-import to assume
the branch's current revision should be the sole parent of the
new commit.  This can cause `git fast-export | git fast-import`
to produce an incorrect graph for:

   A-------M----o------o  refs/heads/master
          /
       B-+

In this graph A and B are initial commits (no parents) but if A was
output first to refs/heads/master and then B is output fast-import
would assume the graph was this instead:

   A-------M----o------o  refs/heads/master
    \     /
     +-B-+

Which would cause B, M, and all later commits to have a different
SHA-1, and obviously be quite a different graph.

Sending a reset command prior to B informs fast-import to clear
the implied parent of A, allowing B to remain an initial commit.

Reported-by: Ben Lynn <benlynn@gmail.com>
Deemed-obviously-correct-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-fast-export.c