Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git/odb/pack: implement v1 object searching #2421

Merged
merged 3 commits into from
Jul 24, 2017
Merged

Conversation

ttaylorr
Copy link
Contributor

This pull request implements object searching for v1 index files, and is the second in the series started by #2420.

The main goal of this pull request is to implement a function that the IndexVersion.Search() function can call into, as:

func (i *IndexVersion) Search(idx *Index, name []byte, at uint64) (*IndexEntry, int, error) {
        switch i {
        case V1:
                return v1IndexSearch(idx, name, at)
        }

        panic(...)
}

This implements the search functionality (i.e., find an object, or return a comparison value of where to search next) for V1 pack files.

I estimate that it's unlikely LFS will parse many v1 packfiles during regular usage. Git stopped writing v1 packfiles near git/git@c553ca2, which was first released in the v1.5.2 series, which was released earlier than our minimum supported version of Git.

That being said, I think it's important for LFS to be able to parse all packfiles, since we won't have git-cat-file(1) to fallback on if we can't parse an earlier packfile version.

V1 packfiles have the following structure:

  1. 256 4-byte network order unsigned integers, comprising the L1 fanout table.
  2. One 24 byte entry per object, composed of a 4-byte network byte ordered unsigned integer (the object offset) and 20 bytes for the object name.

The v1Search function understands the above structure and does the appropriate search/comparison operation.


/cc @git-lfs/core @peff
/cc #2415

@ttaylorr ttaylorr changed the base branch from git-odb-pack-idx to master July 24, 2017 17:02
@ttaylorr ttaylorr merged commit 22db5de into master Jul 24, 2017
@ttaylorr ttaylorr deleted the git-odb-pack-idx-v1 branch July 24, 2017 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants