)]}'
{
  "commit": "df53c80822735ddd30638ba77be3face438d5ad8",
  "tree": "22889a0e787a22769cdc456780220cb23a412dd7",
  "parents": [
    "34933d0eff5d4c91fae6ad6f71a6e6a69a496ced"
  ],
  "author": {
    "name": "Thomas Gummerer",
    "email": "t.gummerer@gmail.com",
    "time": "Wed Nov 13 15:01:36 2019 +0000"
  },
  "committer": {
    "name": "Junio C Hamano",
    "email": "gitster@pobox.com",
    "time": "Thu Nov 14 11:08:25 2019 +0900"
  },
  "message": "stash: make sure we have a valid index before writing it\n\nIn \u0027do_apply_stash()\u0027 we refresh the index in the end.  Since\n34933d0eff (\"stash: make sure to write refreshed cache\", 2019-09-11),\nwe also write that refreshed index when --quiet is given to \u0027git stash\napply\u0027.\n\nHowever if \u0027--index\u0027 is not given to \u0027git stash apply\u0027, we also\ndiscard the index in the else clause just before.  We need to do so\nbecause we use an external \u0027git update-index --add --stdin\u0027, which\nleads to an out of date in-core index.\n\nLater we call \u0027refresh_and_write_cache\u0027, which now leads to writing\nthe discarded index, which means we essentially write an empty index\nfile.  This is obviously not correct, or the behaviour the user\nwanted.  We should not modify the users index without being asked to\ndo so.\n\nMake sure to re-read the index after discarding the current in-core\nindex, to avoid dealing with outdated information.  Instead we could\nalso drop the \u0027discard_cache()\u0027 + \u0027read_cache()\u0027, however that would\nmake it easy to fall into the same trap as 34933d0eff did, so it\u0027s\nbetter to avoid that.\n\nWe can also drop the \u0027refresh_and_write_cache\u0027 completely in the quiet\ncase.  Previously in legacy stash we relied on \u0027git status\u0027 to refresh\nthe index after calling \u0027git read-tree\u0027 when \u0027--index\u0027 was passed to\n\u0027git apply\u0027.  However the \u0027reset_tree()\u0027 call that replaced \u0027git\nread-tree\u0027 always passes options that are equivalent to \u0027-m\u0027, making\nthe refresh of the index unnecessary.\n\nReported-by: Grzegorz Rajchman \u003crayman17@gmail.com\u003e\nSigned-off-by: Thomas Gummerer \u003ct.gummerer@gmail.com\u003e\nSigned-off-by: Junio C Hamano \u003cgitster@pobox.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "ab30d1e9203b42dec154b4b171f74ba7fec1b6b7",
      "old_mode": 33188,
      "old_path": "builtin/stash.c",
      "new_id": "372fbdb7ac059cb858ae959266bd1ce0603b0752",
      "new_mode": 33188,
      "new_path": "builtin/stash.c"
    },
    {
      "type": "modify",
      "old_id": "392954d6dd9243faa03a9092f21ba9959acdc371",
      "old_mode": 33261,
      "old_path": "t/t3903-stash.sh",
      "new_id": "9de1c3616ab3bed69cf3d7012b8866ce57a34965",
      "new_mode": 33261,
      "new_path": "t/t3903-stash.sh"
    }
  ]
}
