Skip to content

Commit 6caa3e8

Browse files
committed
Fixes remaining blocking issues
- Updated gitignore for Windows. - Renamed repo => repository. - Fixed DiffList => Diff conversion and tests.
1 parent cb83ac2 commit 6caa3e8

File tree

14 files changed

+412
-35
lines changed

14 files changed

+412
-35
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
/build/
44
/test/repos/
55

6+
/vendor/Release
7+
/vendor/*.vcxproj
8+
/vendor/*.filters
9+
/vendor/*.sln
10+
611
/src/*
712
!/src/functions/copy.cc
813
!/src/wrapper.cc

binding.gyp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@
2828
"src/common.cc",
2929
"src/config.cc",
3030
"src/cred_helpers.cc",
31+
"src/delta.cc",
3132
"src/diff.cc",
33+
"src/diff_file.cc",
34+
"src/diff_line.cc",
3235
"src/diff_options.cc",
3336
"src/errors.cc",
3437
"src/filter.cc",

generate/descriptor.json

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,54 @@
166166
"cred_helpers": {
167167
},
168168

169+
"delta": {
170+
"isStruct": true,
171+
"cType": "git_diff_delta",
172+
173+
"dependencies": [
174+
"../include/diff.h",
175+
"../include/diff_file.h",
176+
"../include/types.h"
177+
],
178+
179+
"fields": [
180+
{
181+
"name": "status",
182+
"cType": "git_delta_t"
183+
},
184+
{
185+
"name": "flags",
186+
"cType": "uint32_t"
187+
},
188+
{
189+
"name": "similarity",
190+
"cType": "uint16_t"
191+
},
192+
{
193+
"name": "nfiles",
194+
"cType": "uint16_t"
195+
},
196+
{
197+
"name": "old_file",
198+
"cType": "git_diff_file"
199+
},
200+
{
201+
"name": "new_file",
202+
"cType": "git_diff_file"
203+
}
204+
]
205+
},
206+
169207
"diff": {
208+
"dependencies": [
209+
"../include/diff.h",
210+
"../include/delta.h",
211+
"../include/repository.h",
212+
"../include/tree.h",
213+
"../include/index.h",
214+
"../include/diff_options.h"
215+
],
216+
170217
"functions": {
171218
"git_diff_tree_to_tree": {
172219
"isAsync": true,
@@ -181,10 +228,100 @@
181228
"return": {
182229
"isErrorCode": true
183230
}
231+
},
232+
233+
"git_diff_num_deltas": {
234+
"ignore": false,
235+
"args": [{ "isSelf": true }]
236+
},
237+
238+
"git_diff_get_delta": {
239+
"ignore": false,
240+
"args": [{ "shouldAlloc": true, "isSelf": true }],
241+
"return": {
242+
"cType": "const git_diff_delta **",
243+
"copy": "git_diff_delta_dup"
244+
}
184245
}
185246
}
186247
},
187248

249+
"diff_file": {
250+
"isStruct": true,
251+
"cType": "git_diff_file",
252+
253+
"dependencies": [
254+
"../include/diff.h",
255+
"../include/oid.h",
256+
"../include/types.h"
257+
],
258+
259+
"fields": [
260+
{
261+
"name": "oid",
262+
"cType": "git_oid"
263+
},
264+
{
265+
"name": "path",
266+
"cType": "const char *"
267+
},
268+
{
269+
"name": "size",
270+
"cType": "git_off_t"
271+
},
272+
{
273+
"name": "flags",
274+
"cType": "uint32_t"
275+
},
276+
{
277+
"name": "mode",
278+
"cType": "uint16_t"
279+
}
280+
]
281+
},
282+
283+
"diff_line": {
284+
"isStruct": true,
285+
"cType": "git_diff_line",
286+
287+
"dependencies": [
288+
"../include/diff.h",
289+
"../include/oid.h",
290+
"../include/types.h"
291+
],
292+
293+
"fields": [
294+
{
295+
"name": "origin",
296+
"cType": "int"
297+
},
298+
{
299+
"name": "old_lineno",
300+
"cType": "int"
301+
},
302+
{
303+
"name": "new_lineno",
304+
"cType": "int"
305+
},
306+
{
307+
"name": "num_lines",
308+
"cType": "int"
309+
},
310+
{
311+
"name": "content_len",
312+
"cType": "size_t"
313+
},
314+
{
315+
"name": "content_offset",
316+
"cType": "git_off_t"
317+
},
318+
{
319+
"name": "content",
320+
"cType": "const char *"
321+
}
322+
]
323+
},
324+
188325
"diff_options": {
189326
"isStruct": true,
190327
"cType": "git_diff_options",
@@ -305,6 +442,52 @@
305442
},
306443

307444
"patch": {
445+
"isStruct": true,
446+
"forwardDeclare": true,
447+
"dependencies": [
448+
"../include/delta.h",
449+
"../include/diff_file.h",
450+
"../include/diff_line.h"
451+
],
452+
"functions": {
453+
"git_patch_get_delta": {
454+
"ignore": false,
455+
"args": [
456+
{ "isReturn": false, "isSelf": true }
457+
],
458+
"return": {
459+
"copy": "git_diff_delta_dup"
460+
}
461+
},
462+
463+
"git_patch_from_diff": {
464+
"ignore": false,
465+
"isAsync": false,
466+
"isConstructorMethod": true
467+
},
468+
469+
"git_patch_num_hunks": {
470+
"ignore": false,
471+
"args": [
472+
{ "isReturn": false, "isSelf": true }
473+
]
474+
},
475+
476+
"git_patch_num_lines_in_hunk": {
477+
"ignore": false,
478+
"args": [
479+
{ "isReturn": false, "isSelf": true }
480+
]
481+
},
482+
483+
"git_patch_get_line_in_hunk": {
484+
"ignore": false,
485+
"args": [
486+
{ "isReturn": true },
487+
{ "isSelf": true }
488+
]
489+
}
490+
}
308491
},
309492

310493
"pathspec": {
@@ -474,6 +657,7 @@
474657
},
475658

476659
"time": {
660+
"isStruct": true,
477661
"cType": "git_time",
478662
"freeFunctionName": "free",
479663

generate/setup.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ typeMap.__proto__ = {
2828
"git_branch_iterator *": { cpp: "BranchIterator", js: "Iterator" },
2929
"git_branch_iterator **": { cpp: "BranchIterator", js: "Iterator" },
3030
"git_branch_t *": { cpp: "GitBranch", js: "Branch" },
31-
"const git_commit *[]": { cpp: "Array", js: "Array" }
31+
"const git_commit *[]": { cpp: "Array", js: "Array" },
32+
"git_diff_file": { cpp: "GitDiffFile", js: "DiffFile" }
3233
};
3334

3435
var files = [];

generate/types.json

Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -480,12 +480,12 @@
480480
"cpp": "GitPatch"
481481
},
482482
"git_diff_patch_delta": {
483-
"js": "delta",
484-
"cpp": "Delta"
483+
"js": "Delta",
484+
"cpp": "GitDelta"
485485
},
486486
"const git_diff_delta *": {
487-
"js": "GitDelta",
488-
"cpp": "Delta"
487+
"js": "Delta",
488+
"cpp": "GitDelta"
489489
},
490490
"git_diff_patch_num_hunks": {
491491
"js": "size",
@@ -8983,5 +8983,65 @@
89838983
"const git_diff_options **": {
89848984
"cpp": "GitDiffOptions",
89858985
"js": "DiffOptions"
8986+
},
8987+
"git_delta": {
8988+
"cpp": "GitDelta",
8989+
"js": "Delta"
8990+
},
8991+
"git_delta **": {
8992+
"cpp": "GitDelta",
8993+
"js": "Delta"
8994+
},
8995+
"git_delta *": {
8996+
"cpp": "GitDelta",
8997+
"js": "Delta"
8998+
},
8999+
"const git_delta **": {
9000+
"cpp": "GitDelta",
9001+
"js": "Delta"
9002+
},
9003+
"const git_delta *": {
9004+
"cpp": "GitDelta",
9005+
"js": "Delta"
9006+
},
9007+
"git_diff_file": {
9008+
"cpp": "GitDiffFile",
9009+
"js": "DiffFile"
9010+
},
9011+
"git_diff_file **": {
9012+
"cpp": "GitDiffFile",
9013+
"js": "DiffFile"
9014+
},
9015+
"git_diff_file *": {
9016+
"cpp": "GitDiffFile",
9017+
"js": "DiffFile"
9018+
},
9019+
"const git_diff_file **": {
9020+
"cpp": "GitDiffFile",
9021+
"js": "DiffFile"
9022+
},
9023+
"const git_diff_file *": {
9024+
"cpp": "GitDiffFile",
9025+
"js": "DiffFile"
9026+
},
9027+
"git_diff_line": {
9028+
"cpp": "GitDiffLine",
9029+
"js": "DiffLine"
9030+
},
9031+
"git_diff_line **": {
9032+
"cpp": "GitDiffLine",
9033+
"js": "DiffLine"
9034+
},
9035+
"git_diff_line *": {
9036+
"cpp": "GitDiffLine",
9037+
"js": "DiffLine"
9038+
},
9039+
"const git_diff_line **": {
9040+
"cpp": "GitDiffLine",
9041+
"js": "DiffLine"
9042+
},
9043+
"const git_diff_line *": {
9044+
"cpp": "GitDiffLine",
9045+
"js": "DiffLine"
89869046
}
89879047
}

lib/commit.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,27 +147,27 @@ Commit.prototype.parents = function() {
147147
* and its parent(s).
148148
*
149149
* @param {Function} callback
150-
* @return {[DiffList]} an array of difflists
150+
* @return {[Diff]} an array of diffs
151151
*/
152152
Commit.prototype.getDiff = function(callback) {
153153
var self = this;
154154
self.getParents(function commitParents(error, parents) {
155155
if (error) return callback(error);
156156

157-
var parentDiffLists = [];
157+
var parentDiffs = [];
158158
parents.forEach(function commitEachParent(parent) {
159159
parent.getTree(function(error, parentTree) {
160160
if (error) return callback(error);
161161

162162
self.getTree(function(error, thisTree) {
163163
if (error) return callback(error);
164164

165-
parentTree.diff(thisTree, function walkDiffList(error, diffList) {
165+
parentTree.diff(thisTree, function walkDiff(error, diff) {
166166
if (error) return callback(error);
167167

168-
parentDiffLists.push(diffList);
169-
if (parentDiffLists.length === parents.length) {
170-
callback(null, parentDiffLists);
168+
parentDiffs.push(diff);
169+
if (parentDiffs.length === parents.length) {
170+
callback(null, parentDiffs);
171171
}
172172
});
173173
});

lib/convenient_hunk.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ ConvenientHunk.prototype.header = function() {
1717
* @return {Number}
1818
*/
1919
ConvenientHunk.prototype.size = function() {
20-
return this.raw.hunk(this.i).lines;
20+
return this.raw.numLinesInHunk(this.i);
2121
};
2222

2323
/**
@@ -26,8 +26,9 @@ ConvenientHunk.prototype.size = function() {
2626
*/
2727
ConvenientHunk.prototype.lines = function() {
2828
var result = [];
29-
for (var i = 0; i < this.size(); i++)
30-
result.push(this.raw.line(this.i, i));
29+
for (var i = 0; i < this.size(); i++) {
30+
result.push(this.raw.getLineInHunk(this.i, i));
31+
}
3132
return result;
3233
};
3334

0 commit comments

Comments
 (0)