Commit 3743a50e99ae0400aabf3a4a34e510181b274aea
Fix thin packfile before uploading it
This fixes previous buggy behavior where the generated pack index file does not correspond to the uploaded pack file. When git-index-pack fixes a thin pack, it outputs the fixed pack. So we have to use that instead of the original (possibly thin) pack. This means that some objects will be included in the pack that were deltified when they were pushed from the client; however git-index-pack will not index a thin pack before fixing it, so we have to deal with this at least until we have a packfile indexer that indexes a thin pack.Charles Lehner committed on 3/19/2016, 7:50:34 PM
Parent: a22a279107c69519d6303fae61c7e77f1d11672f
Files changed
index.js | changed |
lib/index-pack.js | changed |
index.js | ||
---|---|---|
@@ -373,14 +373,13 @@ | ||
373 | 373 | var progress = progressObjects(options) |
374 | 374 | |
375 | 375 | if (repo.uploadPack) { |
376 | 376 | var idxCb = done() |
377 | - var packfile = cache(lines.passthrough) | |
378 | - indexPack(packfile(), function (err, idx) { | |
377 | + indexPack(lines.passthrough, function (err, idx, packfileFixed) { | |
379 | 378 | if (err) return idxCb(err) |
380 | 379 | repo.uploadPack(pull.values(updates), pull.once({ |
381 | 380 | pack: pull( |
382 | - packfile(), | |
381 | + packfileFixed, | |
383 | 382 | // for some reason i was getting zero length buffers which |
384 | 383 | // were causing muxrpc to fail, so remove them here. |
385 | 384 | pull.filter(function (buf) { |
386 | 385 | return buf.length |
lib/index-pack.js | ||
---|---|---|
@@ -16,12 +16,20 @@ | ||
16 | 16 | }) |
17 | 17 | pull(packFile, toPull.sink(child.stdin)) |
18 | 18 | child.on('close', function (err) { |
19 | 19 | if (err) return cb(new Error('git index-pack returned ' + err)) |
20 | - fs.unlink(packFilename, function (err) { | |
21 | - if (err) return cb(err) | |
22 | - cb(null, toPull(fs.createReadStream(indexFilename), function (err) { | |
23 | - if (err) return console.error(err) | |
24 | - })) | |
25 | - }) | |
20 | + cb(null, | |
21 | + toPull(fs.createReadStream(indexFilename), function (err) { | |
22 | + fs.unlink(indexFilename, function (err) { | |
23 | + if (err) return console.error(err) | |
24 | + }) | |
25 | + }), | |
26 | + // the output packfile here is the original packfile transformed to make | |
27 | + // it not thin. | |
28 | + toPull(fs.createReadStream(packFilename), function (err) { | |
29 | + fs.unlink(packFilename, function (err) { | |
30 | + if (err) return console.error(err) | |
31 | + }) | |
32 | + }) | |
33 | + ) | |
26 | 34 | }) |
27 | 35 | } |
Built with git-ssb-web