ChimeraCoder / gitgo

A Go implementation of Git functions
Other
346 stars 25 forks source link

Question regarding Git PACK/IDX Files #11

Closed mkaesemann closed 3 years ago

mkaesemann commented 6 years ago

I have found an article you wrote about git pack and idx files (Unpacking Git Packfiles) and while it explains the format and its handling quite well, I did failed to understand where the idx file actually comes from. I tried to have a look at the gitgo source, but could only identify coding that reads the idx file from the file system. I may be missing something (since I don't actually know go), but I have a rather similar problem, where I can receive a pack file through a 0056want <sha1> side-band-64k no-progress multi_ack#000Ddeepen 1#00000009done# command (where is the sha of the branch I want, but I just can't find any documentation on how to receive the idx file or where it comes from. Could you give me a hint where you got your information about pack/idx files and their transfer (not the format; that is documented, but all documentation assumes that the file is already there, which it isn't when trying to write a git version in a new language). Any help would be appreciated. Thanks.

ChimeraCoder commented 6 years ago

I assume you're beginning with an existing git repository that was created using git itself. In that case, the IDX file would be located in the .git/objects/pack directory - every packfile pack-ae231xxxxxxx.pack file will have a corresponding pack-ae231xxxxxxx.idx file associated with it.

The index file itself is constructed by git as part of the packing process by which the packfile itself is generated.

sanjayts commented 3 years ago

In case someone else stumbles on this thread like I did, the answer to the question "who creates pack index files" is "git". This happens after you have received the pack file from the Git server after a git clone by internally running the git index-pack command.