Skip to content
git packfile library for looking up and decoding git objects
Find file
Latest commit dd0678e @chrisdickinson 0.0.4
Failed to load latest commit information.
.travis.yml add travis.yml, readme badges, testling ci stuff
inflate-shim.js initial code commit
inflate.js initial code commit


read object data out of git packfiles, applying ofs/ref deltas and zlib decompression.

Build Status browser support

var packfile = require('git-packfile')
  , idxparse = require('git-packidx-parser')

  .on('data', next)

function next(packIndex) {
  var pack = packfile(
      , lookup
      , readStream

  lookup(<some git hash as a buffer>, function(err, object) {
    // obj === {type: git type number, data: buffer}

  function readStream(start, end) {
    return fs.createReadStream('path/to/packfile', {
      start: start
    , end: end

  function lookup(oid, ready) {
    var location = packIndex.find(oid),, ready)


packfile(size, lookupRef, createReadStream) -> Packfile instance

create a packfile instance. all arguments are required.

lookupRef should be a function that takes a buffer instance and a callback, and calls that callback with the results of searching for that hash against all available object databases.

createReadStream is a function that takes a byte start and end, and should return a readable stream object.

Packfile#read(offset, nextOffset, ready)

Read from offset until nextOffset (given by the pack index), and calls ready with the result.

Returned objects look like so:

{ type: <integer git object type>
, data: <Buffer> }

The data is decompressed and has all deltas already applied to it.



Something went wrong with that request. Please try again.