| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -524,7 +524,10 @@ | |||
| 524 | 524 | ], | |
| 525 | 525 | "functions": { | |
| 526 | 526 | "git_diff_blob_to_buffer": { | |
| 527 | - "ignore": true | ||
| 527 | + "return": { | ||
| 528 | + "isErrorCode": true | ||
| 529 | + }, | ||
| 530 | + "isAsync": true | ||
| 528 | 531 | }, | |
| 529 | 532 | "git_diff_blobs": { | |
| 530 | 533 | "ignore": true | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -62,3 +62,10 @@ Diff.prototype.findSimilar = function(opts) { | |||
| 62 | 62 | opts = normalizeOptions(opts, NodeGit.DiffFindOptions); | |
| 63 | 63 | return findSimilar.call(this, opts); | |
| 64 | 64 | }; | |
| 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 | + }; | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -145,6 +145,30 @@ describe("Diff", function() { | |||
| 145 | 145 | }); | |
| 146 | 146 | }); | |
| 147 | 147 | ||
| 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 | + | ||
| 148 | 172 | it("can diff with a null tree", function() { | |
| 149 | 173 | var repo = this.repository; | |
| 150 | 174 | var tree = this.masterCommitTree; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments