git ssb

0+

cel / pull-git-remote-helper



Commit 89d4ea002ce8eba46b2a851392339309844af851

Fix handling git capabilities

Charles Lehner committed on 10/8/2016, 2:18:59 AM
Parent: 4435fc8900324c433d7c0e31c8a5bda3a5ee53e0

Files changed

index.jschanged
lib/pkt-line.jschanged
index.jsView
@@ -60,12 +60,14 @@
6060 /* multi_ack thin-pack side-band side-band-64k ofs-delta shallow no-progress
6161 * include-tag multi_ack_detailed
6262 * agent=git/2.7.0 */
6363 var sendRefs = receivePackHeader([
64- 'thin-pack',
65- ], repo.refs(), repo.symrefs(), false)
64 + ], repo.refs(), repo.symrefs())
6665
67- var lines = pktLine.decode(read, options)
66 + var lines = pktLine.decode(read, {
67 + onCaps: onCaps,
68 + verbosity: options.verbosity
69 + })
6870 var readWantHave = lines.haves()
6971 var acked
7072 var commonHash
7173 var sendPack
@@ -74,8 +76,11 @@
7476 var aborted
7577 var hasWants
7678 var gotHaves
7779
80 + function onCaps(caps) {
81 + }
82 +
7883 function readWant(abort, cb) {
7984 if (abort) return
8085 // read upload request (wants list) from client
8186 readWantHave(null, function next(end, want) {
@@ -100,8 +105,9 @@
100105 // Read upload haves (haves list).
101106 // On first obj-id that we have, ACK
102107 // If we have none, NAK.
103108 // TODO: implement multi_ack_detailed
109 + // FIXME!
104110 if (abort) return
105111 if (gotHaves) return cb(true)
106112 readWantHave(null, function next(end, have) {
107113 if (end === true) {
@@ -321,9 +327,9 @@
321327 */
322328
323329 // Get a line for each ref that we have. The first line also has capabilities.
324330 // Wrap with pktLine.encode.
325-function receivePackHeader(capabilities, refSource, symrefs, usePlaceholder) {
331 +function receivePackHeader(capabilities, refSource, symrefs) {
326332 var first = true
327333 var symrefed = {}
328334 var symrefsObj = {}
329335
@@ -359,9 +365,9 @@
359365 pull.flatten(),
360366 pull.map(function (ref) {
361367 var name = ref.name
362368 var value = ref.hash
363- if (first && usePlaceholder) {
369 + if (first) {
364370 first = false
365371 /*
366372 if (end) {
367373 // use placeholder data if there are no refs
@@ -381,9 +387,9 @@
381387 function receivePack(read, repo, options) {
382388 var sendRefs = receivePackHeader([
383389 'delete-refs',
384390 'no-thin',
385- ], repo.refs(), null, true)
391 + ], repo.refs(), null)
386392 var done = multicb({pluck: 1})
387393
388394 return pktLine.encode(
389395 cat([
lib/pkt-line.jsView
@@ -74,10 +74,14 @@
7474 if (!line.length) return cb(true)
7575 var args = util.split3(line.toString('ascii'))
7676 var args2 = util.split2(args[2], '\0')
7777 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 + }
8084 cb(null, {
8185 old: rev(args[0]),
8286 new: rev(args[1]),
8387 name: args2[0]
@@ -94,10 +98,14 @@
9498 if (line === 'done') return abortCb(cb, true, onEnd)
9599 if (line.length === 0) return cb(null, {type: 'flush-pkt'})
96100 var args = util.split3(line)
97101 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 + }
100108 cb(null, {
101109 type: args[0],
102110 hash: args[1],
103111 })

Built with git-ssb-web