Expose line-by-line diff information #4

gjtorikian opened this Issue Apr 21, 2013 · 4 comments


None yet
4 participants

gjtorikian commented Apr 21, 2013

To be able to generate something like:

   var CssDiff = new fbDiff(true);
   CssDiff.tokenize = function(value) {
-    return removeEmpty(value.split(/([{}:;,]|\s+)/g));
+    return removeEmpty(value.split(/([{}:;,]|\s+)/));

   var LineDiff = new fbDiff();
   LineDiff.tokenize = function(value) {
-    var values = value.split(/\n/g),
-        ret = [];
-    for (var i = 0; i < values.length-1; i++) {
-      ret.push(values[i] + "\n");
-    }
-    if (values.length) {
-      ret.push(values[values.length-1]);
-    }
-    return ret;
+    return value.split(/^/m);

The change will likely be made in GetLineDiffs, and maybe using the DiffDataCallback. I couldn't figure the libgit2 part out, honestly.


gjtorikian commented Apr 24, 2013

Talked to Russell a bit about this at lunch yesterday. The key here is to emulate the sequence done by the printing over here: https://github.com/libgit2/libgit2/blob/development/src/diff_output.c#L1254

I forgot the details but because of the blob_to_file diff here, not all of the simple diff capabilities are available. This needs to also be done on the DataCallback level.

+1. I would love this!

Actually this is possible. Using the data returned by getLineDiffs and getHeadBlolb, you can compare the current file contents with the HEAD version and build the diff.
What I couldn't find is getIndexBlob, since when a file is staged, its contents could be different from the unstaged version of the same file.

ewaves commented Sep 18, 2015

Is this still a possible future feature?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment