)]}'
{
  "commit": "dcd1742e56ebb944c4ff62346da4548e1e3be675",
  "tree": "044e8388b6e047cba5b907e0d082dad07797028c",
  "parents": [
    "3efb988098858bf6b974b1e673a190f9d2965d1d"
  ],
  "author": {
    "name": "Jeff King",
    "email": "peff@peff.net",
    "time": "Thu Sep 24 19:12:45 2015 -0400"
  },
  "committer": {
    "name": "Junio C Hamano",
    "email": "gitster@pobox.com",
    "time": "Mon Sep 28 14:57:23 2015 -0700"
  },
  "message": "xdiff: reject files larger than ~1GB\n\nThe xdiff code is not prepared to handle extremely large\nfiles. It uses \"int\" in many places, which can overflow if\nwe have a very large number of lines or even bytes in our\ninput files. This can cause us to produce incorrect diffs,\nwith no indication that the output is wrong. Or worse, we\nmay even underallocate a buffer whose size is the result of\nan overflowing addition.\n\nWe\u0027re much better off to tell the user that we cannot diff\nor merge such a large file. This patch covers both cases,\nbut in slightly different ways:\n\n  1. For merging, we notice the large file and cleanly fall\n     back to a binary merge (which is effectively \"we cannot\n     merge this\").\n\n  2. For diffing, we make the binary/text distinction much\n     earlier, and in many different places. For this case,\n     we\u0027ll use the xdi_diff as our choke point, and reject\n     any diff there before it hits the xdiff code.\n\n     This means in most cases we\u0027ll die() immediately after.\n     That\u0027s not ideal, but in practice we shouldn\u0027t\n     generally hit this code path unless the user is trying\n     to do something tricky. We already consider files\n     larger than core.bigfilethreshold to be binary, so this\n     code would only kick in when that is circumvented\n     (either by bumping that value, or by using a\n     .gitattribute to mark a file as diffable).\n\n     In other words, we can avoid being \"nice\" here, because\n     there is already nice code that tries to do the right\n     thing. We are adding the suspenders to the nice code\u0027s\n     belt, so notice when it has been worked around (both to\n     protect the user from malicious inputs, and because it\n     is better to die() than generate bogus output).\n\nThe maximum size was chosen after experimenting with feeding\nlarge files to the xdiff code. It\u0027s just under a gigabyte,\nwhich leaves room for two obvious cases:\n\n  - a diff3 merge conflict result on files of maximum size X\n    could be 3*X plus the size of the markers, which would\n    still be only about 3G, which fits in a 32-bit int.\n\n  - some of the diff code allocates arrays of one int per\n    record. Even if each file consists only of blank lines,\n    then a file smaller than 1G will have fewer than 1G\n    records, and therefore the int array will fit in 4G.\n\nSince the limit is arbitrary anyway, I chose to go under a\ngigabyte, to leave a safety margin (e.g., we would not want\nto overflow by allocating \"(records + 1) * sizeof(int)\" or\nsimilar.\n\nSigned-off-by: Jeff King \u003cpeff@peff.net\u003e\nSigned-off-by: Junio C Hamano \u003cgitster@pobox.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "8ea03e536a56655ff48f4fa8a3050c0225d52f38",
      "old_mode": 33188,
      "old_path": "ll-merge.c",
      "new_id": "4e789f533043c78916b4281ac8113f1e75d342b4",
      "new_mode": 33188,
      "new_path": "ll-merge.c"
    },
    {
      "type": "modify",
      "old_id": "ecfa05f616f4b72d65bcb129c1ee2141cf3d1c47",
      "old_mode": 33188,
      "old_path": "xdiff-interface.c",
      "new_id": "cb67c1c42b35e412dccf9a13ad18dde727ab8ce6",
      "new_mode": 33188,
      "new_path": "xdiff-interface.c"
    },
    {
      "type": "modify",
      "old_id": "eff7762ee1a1bb0ea648c60a07389e22e9a1ac07",
      "old_mode": 33188,
      "old_path": "xdiff-interface.h",
      "new_id": "fbb5a1c3949b6ef6ba0dfb758723a48f3b402190",
      "new_mode": 33188,
      "new_path": "xdiff-interface.h"
    }
  ]
}
