While exporting a project from Unfuddle in order to import its issues to Jira, I took a look at the other files beyond backup.xml
and the media/
directory. Turns out that when Unfuddle provides you with a project backup, it includes the repositories in an undocumented (on their site, at least) format, under the dmp
file extension. Let's find out how to actually use these.
A quick check shows them NOT to be produced by git archive or git bundle:
Looking into the file showed them to be some sort of stream-oriented TLV format. A bit of search showed it was actually a format used for the little-known commands git fast-export
and git fast-import
. A the documentation on those pages says: This program is usually not what the end user wants to run directly.
Turns out that in the case of Unfuddle backups, this is exactly what we want. It just takes a few steps to go from these dumps to usable repositories. Although the git fast-import
doc mentions that the fast-import backend itself can import into an empty repository (one that has already been initialized by git init), in practice, when working on a just-created repository, it appears that the commits are read into the repository, but the branches never appears, so we have to do a bit more setup.
Actual numbers will vary, obviously. At this point the repo contains the history from the original, but it may still have a problem if, as was my case, it dit not contain a master
branch. The usual gitk
will show nothing, and even git log
will show nothing either. Is that a problem ?
As shown by git fsck
, the data is indeed there, it's just a limitation of many porcelain tools which don't work as expected if there is neither a default branch nor an explicit one being checked out. The fix is to just tell them which branch to use for default using the more or less arcane git symbolic-ref command, after finding which ones exist:
In this case, the exported repo only had a single 4.x
branch, which was not set as the default branch (this is an Unfuddle Stack limitation: it does not support default branches not being called master
. After using git symbolic-ref
, the index is properly setup, but the checkout still contains no file, hence the final git reset --hard
to have the repository be clean on the chosen branch.
A shortcut for this would have been a simple git checkout 4.x
, which provides an active checkout branch for porcelain tools, but it does not set the repository default branch. Using git symbolic-ref
is therefore safer.