Commit 89d4ea002ce8eba46b2a851392339309844af851
Fix handling git capabilities
Charles Lehner committed on 10/8/2016, 2:18:59 AMParent: 4435fc8900324c433d7c0e31c8a5bda3a5ee53e0
Files changed
index.js | changed |
lib/pkt-line.js | changed |
index.js | ||
---|---|---|
@@ -60,12 +60,14 @@ | ||
60 | 60 … | /* multi_ack thin-pack side-band side-band-64k ofs-delta shallow no-progress |
61 | 61 … | * include-tag multi_ack_detailed |
62 | 62 … | * agent=git/2.7.0 */ |
63 | 63 … | var sendRefs = receivePackHeader([ |
64 | - 'thin-pack', | |
65 | - ], repo.refs(), repo.symrefs(), false) | |
64 … | + ], repo.refs(), repo.symrefs()) | |
66 | 65 … | |
67 | - var lines = pktLine.decode(read, options) | |
66 … | + var lines = pktLine.decode(read, { | |
67 … | + onCaps: onCaps, | |
68 … | + verbosity: options.verbosity | |
69 … | + }) | |
68 | 70 … | var readWantHave = lines.haves() |
69 | 71 … | var acked |
70 | 72 … | var commonHash |
71 | 73 … | var sendPack |
@@ -74,8 +76,11 @@ | ||
74 | 76 … | var aborted |
75 | 77 … | var hasWants |
76 | 78 … | var gotHaves |
77 | 79 … | |
80 … | + function onCaps(caps) { | |
81 … | + } | |
82 … | + | |
78 | 83 … | function readWant(abort, cb) { |
79 | 84 … | if (abort) return |
80 | 85 … | // read upload request (wants list) from client |
81 | 86 … | readWantHave(null, function next(end, want) { |
@@ -100,8 +105,9 @@ | ||
100 | 105 … | // Read upload haves (haves list). |
101 | 106 … | // On first obj-id that we have, ACK |
102 | 107 … | // If we have none, NAK. |
103 | 108 … | // TODO: implement multi_ack_detailed |
109 … | + // FIXME! | |
104 | 110 … | if (abort) return |
105 | 111 … | if (gotHaves) return cb(true) |
106 | 112 … | readWantHave(null, function next(end, have) { |
107 | 113 … | if (end === true) { |
@@ -321,9 +327,9 @@ | ||
321 | 327 … | */ |
322 | 328 … | |
323 | 329 … | // Get a line for each ref that we have. The first line also has capabilities. |
324 | 330 … | // Wrap with pktLine.encode. |
325 | -function receivePackHeader(capabilities, refSource, symrefs, usePlaceholder) { | |
331 … | +function receivePackHeader(capabilities, refSource, symrefs) { | |
326 | 332 … | var first = true |
327 | 333 … | var symrefed = {} |
328 | 334 … | var symrefsObj = {} |
329 | 335 … | |
@@ -359,9 +365,9 @@ | ||
359 | 365 … | pull.flatten(), |
360 | 366 … | pull.map(function (ref) { |
361 | 367 … | var name = ref.name |
362 | 368 … | var value = ref.hash |
363 | - if (first && usePlaceholder) { | |
369 … | + if (first) { | |
364 | 370 … | first = false |
365 | 371 … | /* |
366 | 372 … | if (end) { |
367 | 373 … | // use placeholder data if there are no refs |
@@ -381,9 +387,9 @@ | ||
381 | 387 … | function receivePack(read, repo, options) { |
382 | 388 … | var sendRefs = receivePackHeader([ |
383 | 389 … | 'delete-refs', |
384 | 390 … | 'no-thin', |
385 | - ], repo.refs(), null, true) | |
391 … | + ], repo.refs(), null) | |
386 | 392 … | var done = multicb({pluck: 1}) |
387 | 393 … | |
388 | 394 … | return pktLine.encode( |
389 | 395 … | cat([ |
lib/pkt-line.js | ||
---|---|---|
@@ -74,10 +74,14 @@ | ||
74 | 74 … | if (!line.length) return cb(true) |
75 | 75 … | var args = util.split3(line.toString('ascii')) |
76 | 76 … | var args2 = util.split2(args[2], '\0') |
77 | 77 … | var caps = args2[1] |
78 | - if (caps && options.verbosity >= 2) | |
79 | - console.error('update capabilities:', caps) | |
78 … | + if (caps) { | |
79 … | + if (options.verbosity >= 2) | |
80 … | + console.error('update capabilities:', caps) | |
81 … | + if (options.onCaps) | |
82 … | + options.onCaps(caps.split(' ')) | |
83 … | + } | |
80 | 84 … | cb(null, { |
81 | 85 … | old: rev(args[0]), |
82 | 86 … | new: rev(args[1]), |
83 | 87 … | name: args2[0] |
@@ -94,10 +98,14 @@ | ||
94 | 98 … | if (line === 'done') return abortCb(cb, true, onEnd) |
95 | 99 … | if (line.length === 0) return cb(null, {type: 'flush-pkt'}) |
96 | 100 … | var args = util.split3(line) |
97 | 101 … | var caps = args[2] |
98 | - if (caps && options.verbosity >= 2) | |
99 | - console.error('want capabilities:', caps) | |
102 … | + if (caps) { | |
103 … | + if (options.verbosity >= 2) | |
104 … | + console.error('want capabilities:', caps) | |
105 … | + if (options.onCaps) | |
106 … | + options.onCaps(caps) | |
107 … | + } | |
100 | 108 … | cb(null, { |
101 | 109 … | type: args[0], |
102 | 110 … | hash: args[1], |
103 | 111 … | }) |
Built with git-ssb-web