git ssb

0+

cel / pull-git-remote-helper



Commit 9f6b7a97b920fe19a6c5b5cde35a13230b4e1b9a

Handle more capabilities

Charles Lehner committed on 10/11/2016, 2:09:13 AM
Parent: 946fb8a79ab4d51e97cb324addd262ca482fa7d1

Files changed

index.jschanged
lib/pkt-line.jschanged
index.jsView
@@ -58,8 +58,11 @@
5858 }
5959 }
6060
6161 // upload-pack: fetch to client
62 +// references:
63 +// git/documentation/technical/pack-protocol.txt
64 +// git/documentation/technical/protocol-capabilities.txt
6265 function uploadPack(read, repo, options) {
6366 /* multi_ack thin-pack side-band side-band-64k ofs-delta shallow no-progress
6467 * include-tag multi_ack_detailed
6568 * agent=git/2.7.0 */
@@ -81,8 +84,11 @@
8184 var hasWants
8285 var gotHaves
8386
8487 function onCaps(caps) {
88 + if (options.verbosity >= 2) {
89 + console.error('client capabilities:', caps)
90 + }
8591 }
8692
8793 function readWant(abort, cb) {
8894 if (abort) return
@@ -391,21 +397,31 @@
391397 function receivePack(read, repo, options) {
392398 var sendRefs = receivePackHeader([
393399 agentCap,
394400 'delete-refs',
401 + 'quiet',
395402 'no-thin',
396403 ], repo.refs(), null)
397404 var done = multicb({pluck: 1})
398405
406 + function onCaps(caps) {
407 + if (options.verbosity >= 2) {
408 + console.error('client capabilities:', caps)
409 + }
410 + }
411 +
399412 return pktLine.encode(
400413 cat([
401414 // send our refs
402415 sendRefs,
403416 pull.once(''),
404417 function (abort, cb) {
405418 if (abort) return
406419 // receive their refs
407- var lines = pktLine.decode(read, options)
420 + var lines = pktLine.decode(read, {
421 + onCaps: onCaps,
422 + verbosity: options.verbosity
423 + })
408424 pull(
409425 lines.updates,
410426 pull.collect(function (err, updates) {
411427 if (err) return cb(err)
lib/pkt-line.jsView
@@ -73,12 +73,15 @@
7373 var args = util.split3(line.toString('ascii'))
7474 var args2 = util.split2(args[2], '\0')
7575 var caps = args2[1]
7676 if (caps) {
77- if (options.verbosity >= 2)
78- console.error('update capabilities:', caps)
79- if (options.onCaps)
80- options.onCaps(caps.split(' '))
77 + if (options.onCaps) {
78 + var capsSet = {}
79 + caps.split(' ').forEach(function (cap) {
80 + capsSet[cap] = true
81 + })
82 + options.onCaps(capsSet)
83 + }
8184 }
8285 cb(null, {
8386 old: rev(args[0]),
8487 new: rev(args[1]),
@@ -95,10 +98,8 @@
9598 if (line.length === 0) return cb(null, {type: 'flush-pkt'})
9699 var args = util.split3(line)
97100 var caps = args[2]
98101 if (caps) {
99- if (options.verbosity >= 2)
100- console.error('want capabilities:', caps)
101102 if (options.onCaps)
102103 options.onCaps(caps)
103104 }
104105 cb(null, {

Built with git-ssb-web