git fast-import commit order

550 Views Asked by At

I'm writing a fast-export/fast-import suite for Plastic SCM/Git and I'm finding some issues.

As I read from the documentation:

This design allows a frontend program to process an unlimited number of branches simultaneously, generating commits in the order they are available from the source data

But, implementing the "exporter" I see that you can't reference a commit that hasn't been created yet. For instance, suppose you introduce first the commit destination of the merge than the source, then you simply reference the source there, but it simply doesn't work.

So, as far as I understand the sentence "generating commits in the order they are available from the source" is simply wrong and git fast-import really need the commits to be supplied in order and references can only exist to objects introduced BEFORE.

Is it correct?

Thanks.

1

There are 1 best solutions below

0
On

Yes, git-fast-import needs to see the commits for each branch in order from oldest to newest. The statement you quoted from the documentation is somewhat ambiguous, because "the order they are available from the source data" must in fact be increasing time order per branch.

I think that statement means that you don't have to present all the commits across all branches in strictly chronological order. Rather, just like working with Git normally, each commit must be created after all its ancestors have been created.

This approach still leaves a bit of flexibility in how commits can be imported. I wrote an importer (for an old proprietary source control system) that processed the entirety of each branch separately (from oldest to newest, of course). Git matched up the common ancestors between different branches and made a nice sensible hierarchy tree because the SHA1 hashes of common ancestors in each branch were the same.