)]}'
{
  "commit": "05fd01656ee295e4a8d3c1efff0ca3a6f48c1f4c",
  "tree": "f5cc10ca58ac98b090c091b73d5e77b78bbcf732",
  "parents": [
    "ddc0e9e84abf88701c32c1947fe536050a0b1043"
  ],
  "author": {
    "name": "Marco Miller",
    "email": "marco.miller@ericsson.com",
    "time": "Wed Apr 20 17:42:34 2016 -0400"
  },
  "committer": {
    "name": "Matthias Sohn",
    "email": "matthias.sohn@sap.com",
    "time": "Thu May 05 00:49:44 2016 +0200"
  },
  "message": "Scan loose ref before packed in case gc about to remove the loose\n\nBefore this change, jgit used to read packed-refs before scanning\nloose refs. That was not a problem if gc didn\u0027t run concurrently. When\ngc did run concurrently with such refs reading, that order sometimes\nbroke the latter. This lead to reading an older version of a ref\u0027s\ntip, which meant \"losing\" the real tip or commit. The specific\nread-Vs-gc concurrency scenario which broke reading that way follows:\n\n1. let ref R be in packed-refs and R\u0027 be in loose\n2. jgit starts reading packed-refs\n3. gc also starts its business around that very time\n4. jgit still has the time to read R from packed-refs\n5. as gc is not done yet updating packed-refs with R\u0027\n6. jgit then starts scanning loose refs (or is about to)\n7. gc quickly ends up being done moving loose R\u0027 to packed-refs\n8. so gc (quickly) removes loose refs\n9. -while jgit is scanning loose refs, now gone\n10. so jgit assumes no loose to consider \u003d\u003e packed-refs winning\n11. so jgit wrongfully returns R (from 4.) as the tip, instead of R\u0027.\n\nThis fix switches the order so loose refs are scanned (secured) before\ntaking the time to read packed-refs. This way, knowledge of the\nlikelier tip is guaranteed for ref reading to return the true tip\n- despite concurrent gc. If there is no loose ref to scan, jgit reads\npacked-refs and lands on R\u0027 (or S), which it then returns, as\nexpected. The gerrit issue [1] should be solved by this fix.\n\n[1] https://code.google.com/p/gerrit/issues/detail?id\u003d2302\n\nChange-Id: Ibd120120a361a3a6ed565f3836afc1db706fbcdd\nSigned-off-by: Marco Miller \u003cmarco.miller@ericsson.com\u003e\nSigned-off-by: Matthias Sohn \u003cmatthias.sohn@sap.com\u003e",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "6f3166a680f584f95d37093f01214975731e6edb",
      "old_mode": 33188,
      "old_path": "org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java",
      "new_id": "4bb2982b481810b7ee09b768afe3cf8a52069d9f",
      "new_mode": 33188,
      "new_path": "org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java"
    }
  ]
}
