Permalink
Browse files

[lib] pack pack/unpack under lib/pack/

  • Loading branch information...
1 parent e01f505 commit a1474742576ea1c20aaa82912f9ef662947c3d60 @tmpvar tmpvar committed Nov 6, 2012
Showing with 23 additions and 18 deletions.
  1. 0 {lib → legacy}/pack.js
  2. +2 −0 lib/pack/index.js
  3. +3 −0 lib/pack/pack.js
  4. +4 −4 lib/{ → pack}/unpack.js
  5. +2 −2 test/tests/objects.js
  6. +12 −12 test/tests/unpack.js
File renamed without changes.
View
@@ -0,0 +1,2 @@
+module.exports.unpack = require('./unpack');
+module.exports.pack = require('./pack');
View
@@ -0,0 +1,3 @@
+module.exports = function() {
+
+};
@@ -3,10 +3,10 @@
// see: http://www.kernel.org/pub/software/scm/git/docs/technical/pack-format.txt
var Buffer = require('buffer').Buffer,
- getType = require('../common/pack').getType,
- rawInflate = require('../common/rawinflate'),
- git = new (require('../git'))(),
- objects = require('./objects');
+ getType = require('../../common/pack').getType,
+ rawInflate = require('../../common/rawinflate'),
+ git = new (require('../../git'))(),
+ objects = require('../objects');
// TODO: I really want to use this, but there is no way to get the
// number of bytes it consumed
View
@@ -1,6 +1,6 @@
var objects = require('../../lib/objects'),
repo = require('../fixtures/repo'),
- unpack = require('../../lib/unpack'),
+ pack = require('../../lib/pack'),
git = new (require('../../git'))(),
commitParts = [
'tree 039486ad38f1b796b5cb39b2548481016af44d8e',
@@ -65,7 +65,7 @@ module.exports = {
repo.getPackFile(function(err, packFile) {
t.ok(!err);
- unpack(packFile.buffer, function(err, obj) {
+ pack.unpack(packFile.buffer, function(err, obj) {
t.end();
}, function make(type, data) {
if (type === objects.TREE) {
View
@@ -5,13 +5,13 @@ var repo = require('../fixtures/repo');
var Buffer = require('buffer').Buffer;
var objects = require('../../lib/objects')
-var unpack = require('../../lib/unpack');
+var pack = require('../../lib/pack');
var noop = function() { return null };
module.exports = {
"unpack: not a buffer" : function(t) {
t.plan(2);
- unpack('not a buffer', function(err) {
+ pack.unpack('not a buffer', function(err) {
t.ok(err);
t.ok(err.message.indexOf('expects a buffer') > 0);
t.end();
@@ -20,7 +20,7 @@ module.exports = {
"unpack: invalid signature" : function(t) {
t.plan(2);
- unpack(new Buffer(['']), function(err) {
+ pack.unpack(new Buffer(['']), function(err) {
t.ok(err);
t.ok(err.message.indexOf('signature') > 0);
t.end();
@@ -29,7 +29,7 @@ module.exports = {
"unpack: valid signature" : function(t) {
t.plan(1);
- unpack(new Buffer('PACK'), function(err) {
+ pack.unpack(new Buffer('PACK'), function(err) {
t.ok(!err || err.message.indexOf('signature') < 0);
t.end();
}, noop);
@@ -43,7 +43,7 @@ module.exports = {
buffer.fill(0);
buffer.write('PACK');
- unpack(buffer, function(err) {
+ pack.unpack(buffer, function(err) {
t.ok(err.message.indexOf('version') > 0);
t.end();
}, noop);
@@ -57,7 +57,7 @@ module.exports = {
buffer.write('PACK');
buffer.writeUInt8(6, 7);
- unpack(new Buffer('PACK'), function(err) {
+ pack.unpack(new Buffer('PACK'), function(err) {
t.ok(err.message.indexOf('version') > 0);
t.end();
}, noop);
@@ -71,7 +71,7 @@ module.exports = {
buffer.write('PACK');
buffer.writeUInt8(2, 7);
- unpack(buffer, function(err, obj) {
+ pack.unpack(buffer, function(err, obj) {
t.ok(!err || err.message.indexOf('version') < 0);
t.end();
}, noop);
@@ -85,7 +85,7 @@ module.exports = {
buffer.write('PACK');
buffer.writeUInt8(2, 7);
- unpack(buffer, function(err) {
+ pack.unpack(buffer, function(err) {
t.ok(err.message.indexOf('object count') > 0);
t.end();
}, noop);
@@ -100,7 +100,7 @@ module.exports = {
buffer.writeUInt8(2, 7);
buffer.writeUInt32BE(150, 8);
- unpack(buffer, function(err, obj) {
+ pack.unpack(buffer, function(err, obj) {
t.ok(!err || err.message.indexOf('object count') < 0);
t.equals(obj.count, 150);
t.end();
@@ -110,7 +110,7 @@ module.exports = {
"unpack: valid object count (real file)" : function(t) {
t.plan(2);
repo.getPackFile(function(err, packFile) {
- unpack(packFile.buffer, function(err, obj) {
+ pack.unpack(packFile.buffer, function(err, obj) {
// from previous observation, the packfile had 3 objects in it
// ensure sanity before we assume that we actually parsed the packfile
@@ -142,7 +142,7 @@ module.exports = {
"unpack: valid object entries (real file)" : function(t) {
repo.getPackFile(function(err, packFile) {
- unpack(packFile.buffer, function(err, obj) {
+ pack.unpack(packFile.buffer, function(err, obj) {
t.plan(2+obj.objects.length);
// ensure sanity before we assume that we actually parsed the packfile correctly.
t.ok(packFile.totalObjects > 0, 'the packfie has more than 0 objects');
@@ -162,7 +162,7 @@ module.exports = {
repo.getPackFile(function(err, packFile) {
// subtract 3 which includes summary, status, newline
t.plan((packFile.verifyString.split('\n').length - 3)*3);
- unpack(
+ pack.unpack(
packFile.buffer,
function(err, obj) {},
function make(type, data) {

0 comments on commit a147474

Please sign in to comment.