)]}'
{
  "commit": "fa83a33b22283e465aafdacc53ad0fddea55bdf4",
  "tree": "ddc6297ab6a35dd61625a4dd7b77a0c7eab5f641",
  "parents": [
    "ec2764ee8fb9a37cc92e0a1bce3b49ae2de0ffbc"
  ],
  "author": {
    "name": "Johan Herland",
    "email": "johan@herland.net",
    "time": "Sun Apr 21 23:52:01 2013 +0200"
  },
  "committer": {
    "name": "Junio C Hamano",
    "email": "gitster@pobox.com",
    "time": "Sun Apr 21 15:14:41 2013 -0700"
  },
  "message": "checkout: Use remote refspecs when DWIMming tracking branches\n\nThe DWIM mode of checkout allows you to run \"git checkout foo\" when there\nis no existing local ref or path called \"foo\", and there is exactly _one_\nremote with a remote-tracking branch called \"foo\". Git will automatically\ncreate a new local branch called \"foo\" using the remote-tracking \"foo\" as\nits starting point and configured upstream.\n\nFor example, consider the following unconventional (but perfectly valid)\nremote setup:\n\n\t[remote \"origin\"]\n\t\tfetch \u003d refs/heads/*:refs/remotes/origin/*\n\t[remote \"frotz\"]\n\t\tfetch \u003d refs/heads/*:refs/remotes/frotz/nitfol/*\n\nCase 1: Assume both \"origin\" and \"frotz\" have remote-tracking branches called\n\"foo\", at \"refs/remotes/origin/foo\" and \"refs/remotes/frotz/nitfol/foo\"\nrespectively. In this case \"git checkout foo\" should fail, because there is\nmore than one remote with a \"foo\" branch.\n\nCase 2: Assume only \"frotz\" have a remote-tracking branch called \"foo\". In\nthis case \"git checkout foo\" should succeed, and create a local branch \"foo\"\nfrom \"refs/remotes/frotz/nitfol/foo\", using remote branch \"foo\" from \"frotz\"\nas its upstream.\n\nThe current code hardcodes the assumption that all remote-tracking branches\nmust match the \"refs/remotes/$remote/*\" pattern (which is true for remotes\nwith \"conventional\" refspecs, but not true for the \"frotz\" remote above).\nWhen running \"git checkout foo\", the current code looks for exactly one ref\nmatching \"refs/remotes/*/foo\", hence in the above example, it fails to find\n\"refs/remotes/frotz/nitfol/foo\", which causes it to fail both case #1 and #2.\n\nThe better way to handle the above example is to actually study the fetch\nrefspecs to deduce the candidate remote-tracking branches for \"foo\"; i.e.\nassume \"foo\" is a remote branch being fetched, and then map \"refs/heads/foo\"\nthrough the refspecs in order to get the corresponding remote-tracking\nbranches \"refs/remotes/origin/foo\" and \"refs/remotes/frotz/nitfol/foo\".\nFinally we check which of these happens to exist in the local repo, and\nif there is exactly one, we have an unambiguous match for \"git checkout foo\",\nand may proceed.\n\nThis fixes most of the failing tests introduced in the previous patch.\n\nSigned-off-by: Johan Herland \u003cjohan@herland.net\u003e\nSigned-off-by: Junio C Hamano \u003cgitster@pobox.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "8edcdcae9d0082928073a85c77bdc30593ad5361",
      "old_mode": 33188,
      "old_path": "Documentation/git-checkout.txt",
      "new_id": "bf0c99c5397653374200871c2d121273a02fd09d",
      "new_mode": 33188,
      "new_path": "Documentation/git-checkout.txt"
    },
    {
      "type": "modify",
      "old_id": "eb51872347d9b7d3e81c37d9ddb4272a99f2b75f",
      "old_mode": 33188,
      "old_path": "builtin/checkout.c",
      "new_id": "bcb18c8d206774efde9453a64775ebd9379ea342",
      "new_mode": 33188,
      "new_path": "builtin/checkout.c"
    },
    {
      "type": "modify",
      "old_id": "b1e34443e279c11e7aa1bff3a3a4ebb46209b934",
      "old_mode": 33261,
      "old_path": "t/t2024-checkout-dwim.sh",
      "new_id": "31e3d47b801cfcae073542244db2a64a63309685",
      "new_mode": 33261,
      "new_path": "t/t2024-checkout-dwim.sh"
    }
  ]
}
