git ssb

0+

cel / pull-git-remote-helper



Commit 9bfd8551bbfc41059d347102b284dc7e828d99d4

Use verbosity option in pack

Charles Lehner committed on 2/19/2016, 3:17:59 PM
Parent: 724e669bfdbabf69fc74f6bf68b894c9bd32eacb

Files changed

README.mdchanged
index.jschanged
lib/pack.jschanged
README.mdView
@@ -60,9 +60,8 @@
6060 ## TODO
6161
6262 - Handle shallow and unshallow fetch
6363 - Show progress during operations
64-- Handle verbosity option throughout operations
6564
6665 ## License
6766
6867 Fair License
index.jsView
@@ -132,9 +132,9 @@
132132 if (!sendPack)
133133 getObjects(repo, commonHash, wants, shallows,
134134 function (err, numObjects, readObjects) {
135135 if (err) return cb(err)
136- sendPack = pack.encode(numObjects, readObjects)
136+ sendPack = pack.encode(options, numObjects, readObjects)
137137 havesDone(abort, cb)
138138 }
139139 )
140140 else
@@ -296,9 +296,9 @@
296296 pull.collect(function (err, updates) {
297297 if (err) return cb(err)
298298 repo.update(pull.values(updates), pull(
299299 lines.passthrough,
300- pack.decode(repo, done())
300+ pack.decode(options, repo, done())
301301 ), done())
302302 done(function (err) {
303303 cb(err || true)
304304 })
lib/pack.jsView
@@ -94,11 +94,11 @@
9494 })
9595 }
9696 }
9797
98-function decodePack(repo, onEnd, read) {
98+function decodePack(opts, repo, onEnd, read) {
9999 if (read === undefined)
100- return decodePack.bind(this, repo, onEnd)
100+ return decodePack.bind(this, opts, repo, onEnd)
101101
102102 var ended
103103 var numObjects = -1
104104 var checksum = createHash('sha1')
@@ -108,11 +108,8 @@
108108 var readWord = checksum(b.chunks(4))
109109 var readHash = checksum(b.chunks(20))
110110 var readChecksum = b.chunks(20)
111111 var expectChecksum = true
112- var opts = {
113- verbosity: 2
114- }
115112
116113 function readHeader(cb) {
117114 readWord(null, function (end, header) {
118115 if (ended = end) return cb(end)
@@ -137,9 +134,9 @@
137134 function readNumObjects(cb) {
138135 readWord(null, function (end, word) {
139136 if (ended = end) return cb(end)
140137 numObjects = word.readUInt32BE()
141- if (opts.verbosity >= 1)
138+ if (opts.verbosity >= 2)
142139 console.error(numObjects + ' objects')
143140 readObject(null, cb)
144141 })
145142 }
@@ -204,14 +201,19 @@
204201 readVarInt(readInflatedByte, function (err, expectedSourceLength) {
205202 if (err) return cb(err)
206203 readVarInt(readInflatedByte, function (err, expectedTargetLength) {
207204 if (err) return cb(err)
205+ if (opts.verbosity >= 3)
206+ console.error('getting object', sourceHash)
208207 repo.getObject(sourceHash, function (err, sourceObject) {
208+ if (opts.verbosity >= 3)
209+ console.error('got object', sourceHash, sourceObject, err)
209210 if (err) return cb(err)
210211 if (sourceObject.length != expectedSourceLength)
211212 cb(new Error('Incorrect source object size in ref delta'))
212213 else
213- patchObject(b, length, sourceObject, expectedTargetLength, cb)
214+ patchObject(opts, b, length, sourceObject,
215+ expectedTargetLength, cb)
214216 })
215217 })
216218 })
217219 })
@@ -227,9 +229,9 @@
227229 if (!value.equals(expected)) {
228230 onEnd(new Error('Checksum mismatch: ' +
229231 expected.hexSlice() + ' != ' + value.hexSlice()))
230232 } else {
231- if (opts.verbosity >= 2)
233+ if (opts.verbosity >= 3)
232234 console.error('checksum ok', expected.hexSlice())
233235 onEnd(null)
234236 }
235237 })
@@ -259,14 +261,15 @@
259261 cb(null, value)
260262 })
261263 }
262264
263-function patchObject(deltaB, deltaLength, srcObject, targetLength, cb) {
265+function patchObject(opts, deltaB, deltaLength, srcObject, targetLength, cb) {
264266 var readByte = deltaB.chunks(1)
265267 var srcBuf
266268 var ended
267269
268- // console.error('patching', srcObject.type, targetLength)
270+ if (opts.verbosity >= 2)
271+ console.error('patching', srcObject.type, targetLength)
269272 pull(
270273 srcObject.read,
271274 pull.collect(function (err, bufs) {
272275 srcBuf = Buffer.concat(bufs, srcObject.length)
@@ -364,9 +367,9 @@
364367 */
365368 cb(null, new Buffer(vals))
366369 }
367370
368-function encodePack(numObjects, readObject) {
371+function encodePack(opts, numObjects, readObject) {
369372 if (readObject === undefined)
370373 return encodePack.bind(this, numObjects)
371374
372375 var header = new Buffer(12)

Built with git-ssb-web