)]}'
{
  "commit": "a674b3095807a3679f154c5a4a6df738aeffdfdf",
  "tree": "cd36bfa06c14e7c7a8bd1bd2367f7cf66d4178d7",
  "parents": [
    "74798f5aa5d5c9720e7ff8895fee08e19db05cc7"
  ],
  "author": {
    "name": "Darkhan Kubigenov",
    "email": "darkhanu@gmail.com",
    "time": "Sat Jan 21 23:12:39 2023 +0000"
  },
  "committer": {
    "name": "Darkhan Kubigenov",
    "email": "darkhanu@gmail.com",
    "time": "Mon Jan 23 23:37:06 2023 +0000"
  },
  "message": "Fix line diff by using runes without separators\n\n[The suggested approach](https://github.com/google/diff-match-patch/wiki/Line-or-Word-Diffs#line-mode\n) for doing line level diffing is the following set of steps:\n\n1. `ti1, ti2, linesIdx \u003d DiffLinesToChars(t1, t2)`\n2. `diffs \u003d DiffMain(ti1, ti2)`\n3. `DiffCharsToLines(diff, linesIdx)`\n\nThe original implementation in `google/diff-match-patch` uses\nunicode codepoints for storing indices in `ti1` and `ti2` joined by an empty string.\nCurrent implementation in this repo stores them as integers joined by a\ncomma. While this implementation makes `ti1` and `ti2` more readable, it\nintroduces bugs when trying to rely on it when doing line level diffing\nwith `DiffMain`. The root cause of the issue is that an integer line\nindex might span more than one character/rune, and `DiffMain` can assume\nthat two different lines having the same index prefix match partially. For\nexample, indices 123 and 129 will have partial match `12`. In that\nexample, the diff will show lines 3 and 9 which is not correct. A simple\nfailing test case demonstrating this issue is available at\n`TestDiffPartialLineIndex`.\n\nIn this PR I am adjusting the algorithm to use the same approach as in\n[diff-match-patch](https://github.com/google/diff-match-patch/blob/62f2e689f498f9c92dbc588c58750addec9b1654/javascript/diff_match_patch_uncompressed.js#L508-L510\n) by storing each line index as a rune.\nWhile a rune in Golang is a type alias to uint32, not every uint32\ncan be a valid rune. During string to rune slice conversion invalid runes will\nbe replaced with `utf.RuneError`.\n\nThe integer to rune generation logic is based on the table in https://en.wikipedia.org/wiki/UTF-8#Encoding\n\nThe first 127 lines will work the fastest as they are represented as a\nsingle bytes. Higher numbers are represented as 2-4 bytes.\n\nIn addition to that, the range `U+D800 - U+DFFF` contains\n[invalid codepoints](https://en.wikipedia.org/wiki/UTF-8#Invalid_sequences_and_error_handling).\nand all codepoints higher or equal to `0xD800` are incremented by\n`0xDFFF - 0xD800`.\n\nThe maximum representable integer using this approach is 1\u0027112\u0027060.\nThis improves on Javascript implementation which currently\n[bails out](https://github.com/google/diff-match-patch/blob/62f2e689f498f9c92dbc588c58750addec9b1654/javascript/diff_match_patch_uncompressed.js#L503-L505\n) when files have more than 65535 lines.\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "4f7b42488aad85ed87053e12542cd458a185cdf8",
      "old_mode": 33188,
      "old_path": "diffmatchpatch/diff.go",
      "new_id": "915d5090ddea6b810c2462c06db9dba59ef9bc20",
      "new_mode": 33188,
      "new_path": "diffmatchpatch/diff.go"
    },
    {
      "type": "modify",
      "old_id": "95a7c8d551567b4051233ea78c1f01ae3747d3b5",
      "old_mode": 33188,
      "old_path": "diffmatchpatch/diff_test.go",
      "new_id": "4532b794ede529b907cb23ea55279ca38775349a",
      "new_mode": 33188,
      "new_path": "diffmatchpatch/diff_test.go"
    },
    {
      "type": "modify",
      "old_id": "44c43595478161985cfad44e476862b41be6b355",
      "old_mode": 33188,
      "old_path": "diffmatchpatch/stringutil.go",
      "new_id": "eb727bb5948d05ce5611167ac2420b4bee10299f",
      "new_mode": 33188,
      "new_path": "diffmatchpatch/stringutil.go"
    },
    {
      "type": "modify",
      "old_id": "ab2bc103fbdb5c8ef3ace69b2d3257fff204c6d8",
      "old_mode": 33188,
      "old_path": "diffmatchpatch/stringutil_test.go",
      "new_id": "73ab6ca754975e8ce5f9a47e6284f36c5990c190",
      "new_mode": 33188,
      "new_path": "diffmatchpatch/stringutil_test.go"
    },
    {
      "type": "modify",
      "old_id": "c73103350089435b3ee16f208a2f51f23ccfadc2",
      "old_mode": 33188,
      "old_path": "go.mod",
      "new_id": "c7886ce66cbbde304dcc25fc21218876f1b68c30",
      "new_mode": 33188,
      "new_path": "go.mod"
    }
  ]
}
