FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

An initial wrapper for git_diff_blob_to_buffer · nodegit/nodegit@b294842 · GitHub

Repository navigation

Commit b294842

Browse files
committed
An initial wrapper for git_diff_blob_to_buffer
1 parent b641689 commit b294842

3 files changed

Lines changed: 35 additions & 1 deletion

File tree

‎generate/input/descriptor.json‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,10 @@
524524
],
525525
"functions": {
526526
"git_diff_blob_to_buffer": {
527-
"ignore": true
527+
"return": {
528+
"isErrorCode": true
529+
},
530+
"isAsync": true
528531
},
529532
"git_diff_blobs": {
530533
"ignore": true

‎lib/diff.js‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,10 @@ Diff.prototype.findSimilar = function(opts) {
6262
opts = normalizeOptions(opts, NodeGit.DiffFindOptions);
6363
return findSimilar.call(this, opts);
6464
};
65+
66+
var blobToBuffer = Diff.prototype.blobToBuffer;
67+
Diff.prototype.blobToBuffer = function(old_blob, old_as_path, buffer, buffer_length, buffer_as_path, opts, file_cb, hunk_cb, line_cb) {
68+
console.log("********************************");
69+
opts = normalizeOptions(opts, NodeGit.DiffOptions);
70+
return blobToBuffer.call(this, old_blob, old_as_path, buffer, buffer_length, buffer_as_path, opts, file_cb, hunk_cb, line_cb);
71+
};

‎test/tests/diff.js‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,30 @@ describe("Diff", function() {
145145
});
146146
});
147147

148+
it("can diff the contents of a file to the index", function(done) {
149+
this.repository.getBranchCommit("master")
150+
.then(function(commit) {
151+
var difffile = "LICENSE";
152+
return commit.getEntry(difffile);
153+
})
154+
.then(function(entry) {
155+
var _entry = entry;
156+
return _entry.getBlob();
157+
})
158+
.then(function(blob) {
159+
var buffer = "New Text";
160+
console.log(buffer, buffer.length);
161+
Diff.blobToBuffer(blob, null, buffer, buffer.length, null, null, null, function() {
162+
console.log('delta');
163+
done();
164+
}, null, null);
165+
}, function(error) {
166+
console.log('Error', error);
167+
throw new Error(error);
168+
})
169+
170+
});
171+
148172
it("can diff with a null tree", function() {
149173
var repo = this.repository;
150174
var tree = this.masterCommitTree;

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL