git ssb

0+

cel / pull-git-remote-helper



Commit cf3e042658b75b328309f0f7f47d952ea5d5fa72

Use pull-hash for hashing git objects

Charles Lehner committed on 3/6/2016, 11:10:30 PM
Parent: d277eb374a1ee2ccb35f0d56565c6887c626dfdd

Files changed

package.jsonchanged
test/remote/git-remote-empty.jschanged
package.jsonView
@@ -28,8 +28,9 @@
2828 "pull-buffered": "^0.3.0",
2929 "pull-cache": "^0.0.0",
3030 "pull-cat": "^1.1.8",
3131 "pull-git-pack": "^0.0.0",
32+ "pull-hash": "^0.0.0",
3233 "pull-stream": "^3.1.0",
3334 "stream-to-pull-stream": "^1.6.6"
3435 },
3536 "devDependencies": {
test/remote/git-remote-empty.jsView
@@ -1,9 +1,10 @@
11 #!/usr/bin/env node
22
33 var toPull = require('stream-to-pull-stream')
44 var pull = require('pull-stream')
5-var createGitObjectHash = require('pull-git-pack/lib/util').createGitObjectHash
5+var createGitHash = require('pull-hash/ext/git')
6+var multicb = require('multicb')
67
78 process.on('uncaughtException', function (err) {
89 if (err.stack)
910 err = {stack: err.stack, message: err.message}
@@ -29,24 +30,25 @@
2930 )
3031 readObjects(null, function next(end, object) {
3132 if (end === true) return
3233 if (end) throw end
33- var hasher = createGitObjectHash(object.type, object.length)
34+ var done = multicb({ pluck: 1, spread: true })
3435 pull(
3536 object.read,
36- hasher,
37- pull.collect(function (err, bufs) {
38- if (err) throw err
39- var buf = Buffer.concat(bufs, object.length)
40- process.send({object: {
41- type: object.type,
42- data: buf.toString('ascii'),
43- length: object.length,
44- hash: hasher.digest('hex')
45- }})
46- readObjects(null, next)
47- })
37+ createGitObjectHash(object, done()),
38+ pull.collect(done())
4839 )
40+ done(function (err, id, bufs) {
41+ if (err) throw err
42+ var buf = Buffer.concat(bufs, object.length)
43+ process.send({object: {
44+ type: object.type,
45+ data: buf.toString('ascii'),
46+ length: object.length,
47+ hash: id
48+ }})
49+ readObjects(null, next)
50+ })
4951 })
5052 }
5153 }),
5254 toPull(process.stdout, function (err) {

Built with git-ssb-web