Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] Problems with bitmaps and cloning and DFS back end

On Tue, Jun 18, 2013 at 12:13 PM, Alex Blewitt <alex.blewitt@xxxxxxxxx> wrote:
> What I'd like to do is sanity check the files by re-creating a local JGit
> repository and writing the pack files out locally, but I seem to remember
> that the pack file format for JGit differs from Git in that the leading byte
> counter may not be set correctly.

The JGit local filesystem format is identical with the Git format.

The JGit DFS format differs when a pack is received over the network,
e.g. by push or fetch. In the DFS system we can't go back and fix up
the object count in the 8th-11th bytes of the pack header when a thin
pack is completed to be non-thin by appending base objects to the tail
of the file. To make C Git work with this pack the header would have
to be adjusted. This will cause the trailing SHA-1 footer to be wrong,
making tools like verify-pack and fsck complain. If you fix the
trailer (optional) you also have to fix the copy of the trailer in the
corresponding .idx file.

Keep in mind this format difference only happens with packs from the
wire. A pack written to the DFS by the DfsGarbageCollector or
DfsPackCompactor is a valid Git format file and can be accessed by any
version of Git that groks the V2 index format. Which is pretty much
everything these days, it was introduced around 1.5.1 timeframe (April
2007, 6 years ago!).

> Is there an easy way to transform a pack
> file into a valid Git one, by reading from the index file how many objects
> it contains and writing that to a JGit pack file? How do I calculate what
> the name of the pack file should be on the file system so that I can point
> JGit and Git to it?

The pack name just has to be a SHA-1. Git doesn't actually care what
the SHA-1 is of. If you want to be pedantic, the name is the SHA-1 of
the binary sorted SHA-1s in the file. sha1 of some bytes from
/dev/urandom is fine so long as that name is unique in the repository
at the time you go to copy the files into it. If its an empty
directory `perl -le 'printf "pack-1%s.pack", "0"x39'` is also a
suitable name. :-)

Back to the top