Subject: git-fast-export bug, commits emmitted in incorrect order causing parent data to be lost from commits turning essentially linear repo into "islands"

From: Yves Orton <[email-masked]>
Date: Thu, 12 Jun 2008 12:21:40 +0200

Hi,

Ive been working with git-fast-export a bit recently and Ive hit a bug
that is causing some trouble. 

Essentially it seems that one of our repos git-fast-export fails to emit
the proper 'from' information for several commits in the repo. These
commits are emitted first without parent data even though their parents
ARE emitted later.

The code responsible for skipping the parent info is in

builtin-fast-export.c around line 402:

        for (i = 0, p = commit->parents; p; p = p->next) {
                int mark = get_object_mark(&p->item->object);
                if (!mark)
                        continue;
                if (i == 0)
                        printf("from :%d\n", mark);
                else
                        printf("merge :%d\n", mark);
                i++;
        }

If i modify this loop to warn when skipping a parent I get a warning for
each of the "broken" commits. Apparently because they are emitted before
their parents the parents have no "mark" assigned to them (via
decoration) and thus are skipped in this emit process. This would make
sense for emitting a limited number of patches, but makes no sense when
the --all option is used. Ive tried to investigate further but i got
lost in a twisty maze of routines in revision.c, which apparently is
responsible for building a list of items to emit in the correct order. 

However i think it is notable that both gitk and git log seem quite able
to deal with things properly, thus i find it a bit strange that
fast-export would get it wrong.

Unfortunately I have no idea how to create a minimal repo that
illustrates this problem. 

Im currently on git version 1.5.6.rc2.29.g3ba9 (latest version from last
night), however this problem shows itself on 1.5.4.3 as well, as well as
an earlier version whose exact number i no longer know. 

Other evidence that might be useful

	git log --pretty=format:"%H:%P" 

shows that every commit but one (the root) has parents. And gitk renders
the original repo fine. The repo can be cloned and etc, without trouble.
The problem seems to be strictly related to fast-export.

Im not on list so please cc me on any replies. 

Thanks a lot!
Yves