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

Add basic parser for Git pack files #101

Merged
merged 3 commits into from
Jan 7, 2025
Merged

Conversation

oliver
Copy link
Contributor

@oliver oliver commented Jan 6, 2025

This adds a parser for Git pack files (the files under .git/objects/pack/pack-*.pack). The format is documented at https://git-scm.com/docs/gitformat-pack .

This parser is not complete and it probably has several bugs; but it worked for my use case, so I wanted to make it publicly available.

The commit message for the test file documents how the file was created.

oliver added 3 commits January 6, 2025 21:10
The parser is not complete and it probably has several bugs,
but it works in general.
This file was created by running:

    mkdir testrepo
    cd testrepo
    git init
    git config --local author.name "Test User"
    git config --local author.email "testuser@testhost"
    git config --local committer.name "Test User"
    git config --local committer.email "testuser@testhost"
    gunzip -c ~/hachoir/tests/files/test.txt.gz > test.txt
    git add test.txt
    TZ= faketime '2025-01-06 10:00:00' git commit -m "add test.txt"
    cp ~/hachoir/tests/files/vim.lnk .
    echo "This is another line" >> test.txt
    git add .
    TZ= faketime '2025-01-06 10:01:00' git commit -m "add another line, and add binary file"
    git gc
    cp .git/objects/pack/pack-31c691f659cbc7841ca55a26a342fdaf0b89c533.pack ~/hachoir/tests/files/

(using Git 2.34.1)
@vstinner vstinner merged commit b73c805 into vstinner:main Jan 7, 2025
2 checks passed
@vstinner
Copy link
Owner

vstinner commented Jan 7, 2025

Merged, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants