rugged 1.1.1 → 1.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (407) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -0
  3. data/README.md +1 -1
  4. data/ext/rugged/extconf.rb +2 -2
  5. data/ext/rugged/rugged.c +7 -4
  6. data/ext/rugged/rugged_config.c +7 -2
  7. data/ext/rugged/rugged_object.c +1 -1
  8. data/ext/rugged/rugged_remote.c +17 -0
  9. data/ext/rugged/rugged_repo.c +3 -3
  10. data/lib/rugged/repository.rb +2 -2
  11. data/lib/rugged/version.rb +1 -1
  12. data/vendor/libgit2/CMakeLists.txt +103 -271
  13. data/vendor/libgit2/COPYING +149 -24
  14. data/vendor/libgit2/cmake/AddCFlagIfSupported.cmake +21 -21
  15. data/vendor/libgit2/cmake/DefaultCFlags.cmake +154 -0
  16. data/vendor/libgit2/cmake/EnableWarnings.cmake +13 -13
  17. data/vendor/libgit2/cmake/FindCoreFoundation.cmake +13 -13
  18. data/vendor/libgit2/cmake/FindGSSAPI.cmake +171 -287
  19. data/vendor/libgit2/cmake/FindGSSFramework.cmake +13 -13
  20. data/vendor/libgit2/cmake/{FindHTTP_Parser.cmake → FindHTTPParser.cmake} +17 -17
  21. data/vendor/libgit2/cmake/FindIconv.cmake +27 -27
  22. data/vendor/libgit2/cmake/FindLibSSH2.cmake +13 -0
  23. data/vendor/libgit2/cmake/FindPCRE.cmake +13 -13
  24. data/vendor/libgit2/cmake/FindPCRE2.cmake +12 -12
  25. data/vendor/libgit2/cmake/FindPkgLibraries.cmake +19 -19
  26. data/vendor/libgit2/cmake/FindSecurity.cmake +14 -14
  27. data/vendor/libgit2/cmake/FindStatNsec.cmake +12 -18
  28. data/vendor/libgit2/cmake/Findfutimens.cmake +14 -0
  29. data/vendor/libgit2/cmake/FindmbedTLS.cmake +63 -70
  30. data/vendor/libgit2/cmake/IdeSplitSources.cmake +18 -18
  31. data/vendor/libgit2/cmake/PkgBuildConfig.cmake +60 -60
  32. data/vendor/libgit2/cmake/SanitizeBool.cmake +20 -20
  33. data/vendor/libgit2/cmake/SelectGSSAPI.cmake +37 -37
  34. data/vendor/libgit2/cmake/SelectHTTPParser.cmake +19 -0
  35. data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +100 -96
  36. data/vendor/libgit2/cmake/SelectHashes.cmake +39 -48
  37. data/vendor/libgit2/cmake/SelectRegex.cmake +51 -0
  38. data/vendor/libgit2/cmake/SelectSSH.cmake +41 -0
  39. data/vendor/libgit2/cmake/SelectWinHTTP.cmake +17 -0
  40. data/vendor/libgit2/cmake/SelectZlib.cmake +34 -0
  41. data/vendor/libgit2/deps/chromium-zlib/CMakeLists.txt +101 -0
  42. data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +32 -20
  43. data/vendor/libgit2/deps/ntlmclient/crypt.h +14 -9
  44. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +20 -20
  45. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +3 -3
  46. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +37 -36
  47. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +4 -3
  48. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +178 -51
  49. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +74 -5
  50. data/vendor/libgit2/deps/ntlmclient/ntlm.c +154 -122
  51. data/vendor/libgit2/deps/ntlmclient/ntlm.h +17 -13
  52. data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +17 -4
  53. data/vendor/libgit2/deps/ntlmclient/unicode.h +10 -4
  54. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +16 -27
  55. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.h +20 -0
  56. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +28 -52
  57. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.h +22 -0
  58. data/vendor/libgit2/deps/pcre/CMakeLists.txt +88 -88
  59. data/vendor/libgit2/deps/winhttp/CMakeLists.txt +14 -16
  60. data/vendor/libgit2/include/git2/apply.h +16 -2
  61. data/vendor/libgit2/include/git2/attr.h +106 -2
  62. data/vendor/libgit2/include/git2/blame.h +97 -43
  63. data/vendor/libgit2/include/git2/blob.h +33 -2
  64. data/vendor/libgit2/include/git2/branch.h +27 -0
  65. data/vendor/libgit2/include/git2/buffer.h +18 -78
  66. data/vendor/libgit2/include/git2/cert.h +43 -6
  67. data/vendor/libgit2/include/git2/checkout.h +32 -13
  68. data/vendor/libgit2/include/git2/clone.h +4 -4
  69. data/vendor/libgit2/include/git2/commit.h +37 -19
  70. data/vendor/libgit2/include/git2/common.h +46 -5
  71. data/vendor/libgit2/include/git2/config.h +19 -3
  72. data/vendor/libgit2/include/git2/credential.h +2 -1
  73. data/vendor/libgit2/include/git2/credential_helpers.h +1 -0
  74. data/vendor/libgit2/include/git2/deprecated.h +326 -6
  75. data/vendor/libgit2/include/git2/describe.h +7 -2
  76. data/vendor/libgit2/include/git2/diff.h +50 -121
  77. data/vendor/libgit2/include/git2/email.h +127 -0
  78. data/vendor/libgit2/include/git2/errors.h +7 -6
  79. data/vendor/libgit2/include/git2/filter.h +69 -18
  80. data/vendor/libgit2/include/git2/graph.h +21 -2
  81. data/vendor/libgit2/include/git2/ignore.h +1 -1
  82. data/vendor/libgit2/include/git2/index.h +13 -7
  83. data/vendor/libgit2/include/git2/indexer.h +19 -0
  84. data/vendor/libgit2/include/git2/merge.h +23 -3
  85. data/vendor/libgit2/include/git2/message.h +2 -0
  86. data/vendor/libgit2/include/git2/notes.h +2 -2
  87. data/vendor/libgit2/include/git2/object.h +23 -0
  88. data/vendor/libgit2/include/git2/odb.h +65 -6
  89. data/vendor/libgit2/include/git2/odb_backend.h +1 -1
  90. data/vendor/libgit2/include/git2/oidarray.h +5 -8
  91. data/vendor/libgit2/include/git2/pack.h +24 -8
  92. data/vendor/libgit2/include/git2/patch.h +16 -0
  93. data/vendor/libgit2/include/git2/pathspec.h +1 -1
  94. data/vendor/libgit2/include/git2/proxy.h +1 -1
  95. data/vendor/libgit2/include/git2/rebase.h +34 -2
  96. data/vendor/libgit2/include/git2/refdb.h +3 -0
  97. data/vendor/libgit2/include/git2/reflog.h +1 -1
  98. data/vendor/libgit2/include/git2/refs.h +8 -4
  99. data/vendor/libgit2/include/git2/remote.h +246 -46
  100. data/vendor/libgit2/include/git2/repository.h +25 -18
  101. data/vendor/libgit2/include/git2/reset.h +2 -2
  102. data/vendor/libgit2/include/git2/revparse.h +5 -5
  103. data/vendor/libgit2/include/git2/revwalk.h +4 -1
  104. data/vendor/libgit2/include/git2/signature.h +1 -1
  105. data/vendor/libgit2/include/git2/stash.h +4 -4
  106. data/vendor/libgit2/include/git2/status.h +124 -62
  107. data/vendor/libgit2/include/git2/stdint.h +3 -3
  108. data/vendor/libgit2/include/git2/submodule.h +16 -2
  109. data/vendor/libgit2/include/git2/sys/commit_graph.h +174 -0
  110. data/vendor/libgit2/include/git2/sys/email.h +45 -0
  111. data/vendor/libgit2/include/git2/sys/filter.h +49 -28
  112. data/vendor/libgit2/include/git2/sys/midx.h +74 -0
  113. data/vendor/libgit2/include/git2/sys/odb_backend.h +9 -5
  114. data/vendor/libgit2/include/git2/sys/remote.h +31 -0
  115. data/vendor/libgit2/include/git2/sys/stream.h +1 -1
  116. data/vendor/libgit2/include/git2/sys/transport.h +26 -34
  117. data/vendor/libgit2/include/git2/tag.h +13 -0
  118. data/vendor/libgit2/include/git2/tree.h +4 -17
  119. data/vendor/libgit2/include/git2/types.h +16 -7
  120. data/vendor/libgit2/include/git2/version.h +4 -4
  121. data/vendor/libgit2/include/git2/worktree.h +13 -2
  122. data/vendor/libgit2/include/git2.h +1 -0
  123. data/vendor/libgit2/src/CMakeLists.txt +192 -290
  124. data/vendor/libgit2/src/alloc.c +21 -8
  125. data/vendor/libgit2/src/allocators/failalloc.c +92 -0
  126. data/vendor/libgit2/src/allocators/failalloc.h +23 -0
  127. data/vendor/libgit2/src/allocators/stdalloc.c +41 -10
  128. data/vendor/libgit2/src/allocators/win32_leakcheck.c +118 -0
  129. data/vendor/libgit2/src/allocators/{win32_crtdbg.h → win32_leakcheck.h} +3 -3
  130. data/vendor/libgit2/src/annotated_commit.c +21 -9
  131. data/vendor/libgit2/src/annotated_commit.h +1 -1
  132. data/vendor/libgit2/src/apply.c +34 -25
  133. data/vendor/libgit2/src/apply.h +2 -2
  134. data/vendor/libgit2/src/array.h +11 -11
  135. data/vendor/libgit2/src/attr.c +204 -82
  136. data/vendor/libgit2/src/attr_file.c +105 -52
  137. data/vendor/libgit2/src/attr_file.h +36 -15
  138. data/vendor/libgit2/src/attrcache.c +55 -45
  139. data/vendor/libgit2/src/attrcache.h +4 -5
  140. data/vendor/libgit2/src/blame.c +15 -9
  141. data/vendor/libgit2/src/blame_git.c +2 -2
  142. data/vendor/libgit2/src/blob.c +76 -52
  143. data/vendor/libgit2/src/blob.h +1 -1
  144. data/vendor/libgit2/src/branch.c +203 -110
  145. data/vendor/libgit2/src/branch.h +15 -3
  146. data/vendor/libgit2/src/buf.c +126 -0
  147. data/vendor/libgit2/src/buf.h +50 -0
  148. data/vendor/libgit2/src/cache.c +2 -2
  149. data/vendor/libgit2/src/cache.h +7 -7
  150. data/vendor/libgit2/src/cc-compat.h +11 -9
  151. data/vendor/libgit2/src/checkout.c +118 -91
  152. data/vendor/libgit2/src/cherrypick.c +16 -12
  153. data/vendor/libgit2/src/clone.c +97 -103
  154. data/vendor/libgit2/src/commit.c +167 -84
  155. data/vendor/libgit2/src/commit.h +24 -1
  156. data/vendor/libgit2/src/commit_graph.c +1224 -0
  157. data/vendor/libgit2/src/commit_graph.h +169 -0
  158. data/vendor/libgit2/src/commit_list.c +48 -3
  159. data/vendor/libgit2/src/commit_list.h +2 -0
  160. data/vendor/libgit2/src/common.h +35 -5
  161. data/vendor/libgit2/src/config.c +119 -64
  162. data/vendor/libgit2/src/config.h +15 -2
  163. data/vendor/libgit2/src/config_cache.c +5 -3
  164. data/vendor/libgit2/src/config_file.c +120 -100
  165. data/vendor/libgit2/src/config_mem.c +9 -9
  166. data/vendor/libgit2/src/config_parse.c +29 -27
  167. data/vendor/libgit2/src/crlf.c +36 -23
  168. data/vendor/libgit2/src/date.c +13 -19
  169. data/vendor/libgit2/src/date.h +33 -0
  170. data/vendor/libgit2/src/delta.c +1 -1
  171. data/vendor/libgit2/src/describe.c +32 -21
  172. data/vendor/libgit2/src/diff.c +71 -183
  173. data/vendor/libgit2/src/diff.h +2 -4
  174. data/vendor/libgit2/src/diff_driver.c +53 -51
  175. data/vendor/libgit2/src/diff_driver.h +3 -3
  176. data/vendor/libgit2/src/diff_file.c +31 -26
  177. data/vendor/libgit2/src/diff_generate.c +76 -23
  178. data/vendor/libgit2/src/diff_generate.h +5 -3
  179. data/vendor/libgit2/src/diff_print.c +120 -95
  180. data/vendor/libgit2/src/diff_stats.c +47 -34
  181. data/vendor/libgit2/src/{message.h → diff_stats.h} +7 -6
  182. data/vendor/libgit2/src/diff_tform.c +18 -16
  183. data/vendor/libgit2/src/diff_xdiff.c +7 -10
  184. data/vendor/libgit2/src/diff_xdiff.h +1 -1
  185. data/vendor/libgit2/src/email.c +315 -0
  186. data/vendor/libgit2/src/email.h +25 -0
  187. data/vendor/libgit2/src/errors.c +37 -32
  188. data/vendor/libgit2/src/features.h.in +11 -2
  189. data/vendor/libgit2/src/fetch.c +77 -26
  190. data/vendor/libgit2/src/fetch.h +1 -1
  191. data/vendor/libgit2/src/fetchhead.c +27 -23
  192. data/vendor/libgit2/src/filebuf.c +36 -34
  193. data/vendor/libgit2/src/filebuf.h +1 -1
  194. data/vendor/libgit2/src/filter.c +278 -132
  195. data/vendor/libgit2/src/filter.h +46 -6
  196. data/vendor/libgit2/src/fs_path.c +2071 -0
  197. data/vendor/libgit2/src/fs_path.h +772 -0
  198. data/vendor/libgit2/src/futils.c +96 -90
  199. data/vendor/libgit2/src/futils.h +27 -15
  200. data/vendor/libgit2/src/graph.c +64 -9
  201. data/vendor/libgit2/src/hash/sha1/collisiondetect.c +5 -5
  202. data/vendor/libgit2/src/hash/sha1/common_crypto.c +5 -5
  203. data/vendor/libgit2/src/hash/sha1/generic.c +2 -2
  204. data/vendor/libgit2/src/hash/sha1/generic.h +1 -1
  205. data/vendor/libgit2/src/hash/sha1/mbedtls.c +13 -13
  206. data/vendor/libgit2/src/hash/sha1/openssl.c +5 -5
  207. data/vendor/libgit2/src/hash/sha1/sha1dc/sha1.c +9 -11
  208. data/vendor/libgit2/src/hash/sha1/win32.c +21 -17
  209. data/vendor/libgit2/src/hash/sha1.h +3 -1
  210. data/vendor/libgit2/src/hash.c +71 -36
  211. data/vendor/libgit2/src/hash.h +13 -13
  212. data/vendor/libgit2/src/hashsig.c +23 -10
  213. data/vendor/libgit2/src/ident.c +30 -20
  214. data/vendor/libgit2/src/ignore.c +63 -46
  215. data/vendor/libgit2/src/ignore.h +2 -2
  216. data/vendor/libgit2/src/index.c +184 -149
  217. data/vendor/libgit2/src/index.h +7 -4
  218. data/vendor/libgit2/src/indexer.c +143 -89
  219. data/vendor/libgit2/src/integer.h +64 -2
  220. data/vendor/libgit2/src/iterator.c +93 -73
  221. data/vendor/libgit2/src/iterator.h +6 -6
  222. data/vendor/libgit2/src/khash.h +3 -12
  223. data/vendor/libgit2/src/{settings.c → libgit2.c} +165 -56
  224. data/vendor/libgit2/src/libgit2.h +15 -0
  225. data/vendor/libgit2/src/mailmap.c +60 -45
  226. data/vendor/libgit2/src/map.h +3 -3
  227. data/vendor/libgit2/src/merge.c +104 -61
  228. data/vendor/libgit2/src/merge.h +3 -15
  229. data/vendor/libgit2/src/merge_driver.c +21 -15
  230. data/vendor/libgit2/src/merge_file.c +24 -6
  231. data/vendor/libgit2/src/message.c +21 -8
  232. data/vendor/libgit2/src/midx.c +501 -18
  233. data/vendor/libgit2/src/midx.h +29 -2
  234. data/vendor/libgit2/src/mwindow.c +103 -59
  235. data/vendor/libgit2/src/mwindow.h +3 -3
  236. data/vendor/libgit2/src/net.c +405 -71
  237. data/vendor/libgit2/src/net.h +26 -5
  238. data/vendor/libgit2/src/netops.c +7 -5
  239. data/vendor/libgit2/src/netops.h +3 -3
  240. data/vendor/libgit2/src/notes.c +40 -49
  241. data/vendor/libgit2/src/object.c +68 -20
  242. data/vendor/libgit2/src/object.h +1 -1
  243. data/vendor/libgit2/src/odb.c +320 -80
  244. data/vendor/libgit2/src/odb.h +17 -3
  245. data/vendor/libgit2/src/odb_loose.c +96 -86
  246. data/vendor/libgit2/src/odb_mempack.c +19 -6
  247. data/vendor/libgit2/src/odb_pack.c +402 -125
  248. data/vendor/libgit2/src/oid.c +16 -8
  249. data/vendor/libgit2/src/oid.h +15 -0
  250. data/vendor/libgit2/src/oidarray.c +10 -1
  251. data/vendor/libgit2/src/pack-objects.c +90 -69
  252. data/vendor/libgit2/src/pack-objects.h +11 -6
  253. data/vendor/libgit2/src/pack.c +337 -127
  254. data/vendor/libgit2/src/pack.h +25 -7
  255. data/vendor/libgit2/src/patch.c +17 -10
  256. data/vendor/libgit2/src/patch.h +1 -0
  257. data/vendor/libgit2/src/patch_generate.c +29 -13
  258. data/vendor/libgit2/src/patch_generate.h +5 -5
  259. data/vendor/libgit2/src/patch_parse.c +26 -25
  260. data/vendor/libgit2/src/path.c +86 -1768
  261. data/vendor/libgit2/src/path.h +39 -635
  262. data/vendor/libgit2/src/pathspec.c +12 -12
  263. data/vendor/libgit2/src/pathspec.h +2 -2
  264. data/vendor/libgit2/src/pool.c +13 -7
  265. data/vendor/libgit2/src/posix.c +14 -6
  266. data/vendor/libgit2/src/posix.h +1 -0
  267. data/vendor/libgit2/src/pqueue.h +1 -1
  268. data/vendor/libgit2/src/proxy.c +4 -1
  269. data/vendor/libgit2/src/proxy.h +1 -1
  270. data/vendor/libgit2/src/push.c +30 -35
  271. data/vendor/libgit2/src/push.h +4 -16
  272. data/vendor/libgit2/src/rand.c +226 -0
  273. data/vendor/libgit2/src/rand.h +37 -0
  274. data/vendor/libgit2/src/reader.c +18 -14
  275. data/vendor/libgit2/src/reader.h +2 -2
  276. data/vendor/libgit2/src/rebase.c +177 -132
  277. data/vendor/libgit2/src/refdb.c +30 -13
  278. data/vendor/libgit2/src/refdb_fs.c +548 -222
  279. data/vendor/libgit2/src/reflog.c +19 -14
  280. data/vendor/libgit2/src/refs.c +107 -72
  281. data/vendor/libgit2/src/refs.h +2 -2
  282. data/vendor/libgit2/src/refspec.c +53 -38
  283. data/vendor/libgit2/src/refspec.h +5 -2
  284. data/vendor/libgit2/src/regexp.c +1 -1
  285. data/vendor/libgit2/src/remote.c +960 -486
  286. data/vendor/libgit2/src/remote.h +16 -10
  287. data/vendor/libgit2/src/repository.c +702 -422
  288. data/vendor/libgit2/src/repository.h +26 -8
  289. data/vendor/libgit2/src/reset.c +16 -12
  290. data/vendor/libgit2/src/revert.c +16 -12
  291. data/vendor/libgit2/src/revparse.c +66 -48
  292. data/vendor/libgit2/src/revwalk.c +39 -22
  293. data/vendor/libgit2/src/runtime.c +162 -0
  294. data/vendor/libgit2/src/runtime.h +62 -0
  295. data/vendor/libgit2/src/settings.h +11 -0
  296. data/vendor/libgit2/src/signature.c +18 -11
  297. data/vendor/libgit2/src/signature.h +1 -1
  298. data/vendor/libgit2/src/sortedcache.c +1 -1
  299. data/vendor/libgit2/src/sortedcache.h +10 -8
  300. data/vendor/libgit2/src/stash.c +39 -38
  301. data/vendor/libgit2/src/status.c +11 -5
  302. data/vendor/libgit2/src/{buffer.c → str.c} +459 -136
  303. data/vendor/libgit2/src/str.h +357 -0
  304. data/vendor/libgit2/src/strarray.c +2 -1
  305. data/vendor/libgit2/src/streams/mbedtls.c +22 -23
  306. data/vendor/libgit2/src/streams/mbedtls.h +1 -1
  307. data/vendor/libgit2/src/streams/openssl.c +101 -201
  308. data/vendor/libgit2/src/streams/openssl.h +9 -1
  309. data/vendor/libgit2/src/streams/openssl_dynamic.c +309 -0
  310. data/vendor/libgit2/src/streams/openssl_dynamic.h +348 -0
  311. data/vendor/libgit2/src/streams/openssl_legacy.c +203 -0
  312. data/vendor/libgit2/src/streams/openssl_legacy.h +63 -0
  313. data/vendor/libgit2/src/streams/registry.c +5 -6
  314. data/vendor/libgit2/src/streams/socket.c +6 -2
  315. data/vendor/libgit2/src/streams/stransport.c +6 -3
  316. data/vendor/libgit2/src/streams/tls.c +5 -3
  317. data/vendor/libgit2/src/submodule.c +290 -212
  318. data/vendor/libgit2/src/submodule.h +10 -10
  319. data/vendor/libgit2/src/sysdir.c +70 -56
  320. data/vendor/libgit2/src/sysdir.h +15 -10
  321. data/vendor/libgit2/src/tag.c +72 -34
  322. data/vendor/libgit2/src/thread.c +140 -0
  323. data/vendor/libgit2/src/thread.h +479 -0
  324. data/vendor/libgit2/src/threadstate.c +84 -0
  325. data/vendor/libgit2/src/threadstate.h +24 -0
  326. data/vendor/libgit2/src/trace.c +3 -16
  327. data/vendor/libgit2/src/trace.h +17 -30
  328. data/vendor/libgit2/src/trailer.c +2 -2
  329. data/vendor/libgit2/src/transaction.c +20 -9
  330. data/vendor/libgit2/src/transport.c +13 -13
  331. data/vendor/libgit2/src/transports/auth.c +8 -10
  332. data/vendor/libgit2/src/transports/auth.h +2 -3
  333. data/vendor/libgit2/src/transports/auth_negotiate.c +23 -17
  334. data/vendor/libgit2/src/transports/auth_ntlm.c +20 -16
  335. data/vendor/libgit2/src/transports/auth_ntlm.h +0 -1
  336. data/vendor/libgit2/src/transports/credential.c +15 -7
  337. data/vendor/libgit2/src/transports/git.c +10 -14
  338. data/vendor/libgit2/src/transports/http.c +56 -34
  339. data/vendor/libgit2/src/transports/http.h +3 -3
  340. data/vendor/libgit2/src/transports/httpclient.c +106 -79
  341. data/vendor/libgit2/src/transports/httpclient.h +1 -1
  342. data/vendor/libgit2/src/transports/local.c +127 -119
  343. data/vendor/libgit2/src/transports/smart.c +61 -144
  344. data/vendor/libgit2/src/transports/smart.h +26 -32
  345. data/vendor/libgit2/src/transports/smart_pkt.c +33 -33
  346. data/vendor/libgit2/src/transports/smart_protocol.c +68 -44
  347. data/vendor/libgit2/src/transports/ssh.c +100 -131
  348. data/vendor/libgit2/src/transports/winhttp.c +86 -82
  349. data/vendor/libgit2/src/tree-cache.c +5 -5
  350. data/vendor/libgit2/src/tree-cache.h +2 -2
  351. data/vendor/libgit2/src/tree.c +150 -116
  352. data/vendor/libgit2/src/tree.h +1 -0
  353. data/vendor/libgit2/src/tsort.c +0 -2
  354. data/vendor/libgit2/src/unix/map.c +3 -3
  355. data/vendor/libgit2/src/unix/posix.h +1 -4
  356. data/vendor/libgit2/src/unix/pthread.h +2 -1
  357. data/vendor/libgit2/src/unix/realpath.c +0 -2
  358. data/vendor/libgit2/src/utf8.c +150 -0
  359. data/vendor/libgit2/src/utf8.h +52 -0
  360. data/vendor/libgit2/src/util.c +68 -144
  361. data/vendor/libgit2/src/util.h +36 -68
  362. data/vendor/libgit2/src/vector.c +23 -19
  363. data/vendor/libgit2/src/vector.h +5 -3
  364. data/vendor/libgit2/src/win32/findfile.c +172 -114
  365. data/vendor/libgit2/src/win32/findfile.h +7 -4
  366. data/vendor/libgit2/src/win32/map.c +1 -1
  367. data/vendor/libgit2/src/win32/msvc-compat.h +9 -1
  368. data/vendor/libgit2/src/win32/path_w32.c +162 -33
  369. data/vendor/libgit2/src/win32/path_w32.h +2 -1
  370. data/vendor/libgit2/src/win32/posix.h +6 -7
  371. data/vendor/libgit2/src/win32/posix_w32.c +26 -33
  372. data/vendor/libgit2/src/win32/precompiled.h +0 -1
  373. data/vendor/libgit2/src/win32/reparse.h +4 -4
  374. data/vendor/libgit2/src/win32/thread.c +24 -15
  375. data/vendor/libgit2/src/win32/thread.h +1 -1
  376. data/vendor/libgit2/src/win32/w32_buffer.c +5 -6
  377. data/vendor/libgit2/src/win32/w32_buffer.h +2 -3
  378. data/vendor/libgit2/src/win32/w32_common.h +18 -9
  379. data/vendor/libgit2/src/win32/{w32_crtdbg_stacktrace.c → w32_leakcheck.c} +269 -33
  380. data/vendor/libgit2/src/win32/w32_leakcheck.h +222 -0
  381. data/vendor/libgit2/src/win32/w32_util.h +6 -6
  382. data/vendor/libgit2/src/worktree.c +138 -105
  383. data/vendor/libgit2/src/worktree.h +1 -1
  384. data/vendor/libgit2/src/xdiff/git-xdiff.h +53 -0
  385. data/vendor/libgit2/src/xdiff/xdiff.h +15 -15
  386. data/vendor/libgit2/src/xdiff/xdiffi.c +134 -108
  387. data/vendor/libgit2/src/xdiff/xemit.c +23 -7
  388. data/vendor/libgit2/src/xdiff/xhistogram.c +87 -78
  389. data/vendor/libgit2/src/xdiff/xinclude.h +1 -12
  390. data/vendor/libgit2/src/xdiff/xmerge.c +104 -117
  391. data/vendor/libgit2/src/xdiff/xpatience.c +6 -17
  392. data/vendor/libgit2/src/xdiff/xprepare.c +15 -20
  393. data/vendor/libgit2/src/xdiff/xutils.c +18 -7
  394. data/vendor/libgit2/src/zstream.c +6 -6
  395. data/vendor/libgit2/src/zstream.h +4 -4
  396. metadata +60 -24
  397. data/vendor/libgit2/src/allocators/win32_crtdbg.c +0 -118
  398. data/vendor/libgit2/src/buf_text.c +0 -316
  399. data/vendor/libgit2/src/buf_text.h +0 -122
  400. data/vendor/libgit2/src/buffer.h +0 -222
  401. data/vendor/libgit2/src/global.c +0 -363
  402. data/vendor/libgit2/src/global.h +0 -41
  403. data/vendor/libgit2/src/thread-utils.c +0 -58
  404. data/vendor/libgit2/src/thread-utils.h +0 -369
  405. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +0 -127
  406. data/vendor/libgit2/src/win32/w32_stack.c +0 -188
  407. data/vendor/libgit2/src/win32/w32_stack.h +0 -140
@@ -18,6 +18,7 @@
18
18
  #include "sortedcache.h"
19
19
  #include "signature.h"
20
20
  #include "wildmatch.h"
21
+ #include "path.h"
21
22
 
22
23
  #include <git2/tag.h>
23
24
  #include <git2/object.h>
@@ -34,7 +35,7 @@ enum {
34
35
  PACKREF_HAS_PEEL = 1,
35
36
  PACKREF_WAS_LOOSE = 2,
36
37
  PACKREF_CANNOT_PEEL = 4,
37
- PACKREF_SHADOWED = 8,
38
+ PACKREF_SHADOWED = 8
38
39
  };
39
40
 
40
41
  enum {
@@ -64,9 +65,43 @@ typedef struct refdb_fs_backend {
64
65
  git_iterator_flag_t iterator_flags;
65
66
  uint32_t direach_flags;
66
67
  int fsync;
68
+ git_map packed_refs_map;
69
+ git_mutex prlock; /* protect packed_refs_map */
70
+ git_futils_filestamp packed_refs_stamp;
71
+ bool sorted;
67
72
  } refdb_fs_backend;
68
73
 
69
74
  static int refdb_reflog_fs__delete(git_refdb_backend *_backend, const char *name);
75
+ static char *packed_set_peeling_mode(char *data, size_t data_sz, refdb_fs_backend *backend);
76
+
77
+ GIT_INLINE(int) loose_path(
78
+ git_str *out,
79
+ const char *base,
80
+ const char *refname)
81
+ {
82
+ if (git_str_joinpath(out, base, refname) < 0)
83
+ return -1;
84
+
85
+ return git_fs_path_validate_str_length_with_suffix(out,
86
+ CONST_STRLEN(".lock"));
87
+ }
88
+
89
+ GIT_INLINE(int) reflog_path(
90
+ git_str *out,
91
+ git_repository *repo,
92
+ const char *refname)
93
+ {
94
+ const char *base;
95
+ int error;
96
+
97
+ base = (strcmp(refname, GIT_HEAD_FILE) == 0) ? repo->gitdir :
98
+ repo->commondir;
99
+
100
+ if ((error = git_str_joinpath(out, base, GIT_REFLOG_DIR)) < 0)
101
+ return error;
102
+
103
+ return loose_path(out, out->ptr, refname);
104
+ }
70
105
 
71
106
  static int packref_cmp(const void *a_, const void *b_)
72
107
  {
@@ -77,7 +112,7 @@ static int packref_cmp(const void *a_, const void *b_)
77
112
  static int packed_reload(refdb_fs_backend *backend)
78
113
  {
79
114
  int error;
80
- git_buf packedrefs = GIT_BUF_INIT;
115
+ git_str packedrefs = GIT_STR_INIT;
81
116
  char *scan, *eof, *eol;
82
117
 
83
118
  if (!backend->gitpath)
@@ -93,7 +128,7 @@ static int packed_reload(refdb_fs_backend *backend)
93
128
  */
94
129
  if (error <= 0) {
95
130
  if (error == GIT_ENOTFOUND) {
96
- git_sortedcache_clear(backend->refcache, true);
131
+ GIT_UNUSED(git_sortedcache_clear(backend->refcache, true));
97
132
  git_error_clear();
98
133
  error = 0;
99
134
  }
@@ -102,33 +137,14 @@ static int packed_reload(refdb_fs_backend *backend)
102
137
 
103
138
  /* At this point, refresh the packed refs from the loaded buffer. */
104
139
 
105
- git_sortedcache_clear(backend->refcache, false);
140
+ GIT_UNUSED(git_sortedcache_clear(backend->refcache, false));
106
141
 
107
- scan = (char *)packedrefs.ptr;
142
+ scan = packedrefs.ptr;
108
143
  eof = scan + packedrefs.size;
109
144
 
110
- backend->peeling_mode = PEELING_NONE;
111
-
112
- if (*scan == '#') {
113
- static const char *traits_header = "# pack-refs with: ";
114
-
115
- if (git__prefixcmp(scan, traits_header) == 0) {
116
- scan += strlen(traits_header);
117
- eol = strchr(scan, '\n');
118
-
119
- if (!eol)
120
- goto parse_failed;
121
- *eol = '\0';
122
-
123
- if (strstr(scan, " fully-peeled ") != NULL) {
124
- backend->peeling_mode = PEELING_FULL;
125
- } else if (strstr(scan, " peeled ") != NULL) {
126
- backend->peeling_mode = PEELING_STANDARD;
127
- }
128
-
129
- scan = eol + 1;
130
- }
131
- }
145
+ scan = packed_set_peeling_mode(scan, packedrefs.size, backend);
146
+ if (!scan)
147
+ goto parse_failed;
132
148
 
133
149
  while (scan < eof && *scan == '#') {
134
150
  if (!(eol = strchr(scan, '\n')))
@@ -183,26 +199,26 @@ static int packed_reload(refdb_fs_backend *backend)
183
199
  }
184
200
 
185
201
  git_sortedcache_wunlock(backend->refcache);
186
- git_buf_dispose(&packedrefs);
202
+ git_str_dispose(&packedrefs);
187
203
 
188
204
  return 0;
189
205
 
190
206
  parse_failed:
191
207
  git_error_set(GIT_ERROR_REFERENCE, "corrupted packed references file");
192
208
 
193
- git_sortedcache_clear(backend->refcache, false);
209
+ GIT_UNUSED(git_sortedcache_clear(backend->refcache, false));
194
210
  git_sortedcache_wunlock(backend->refcache);
195
- git_buf_dispose(&packedrefs);
211
+ git_str_dispose(&packedrefs);
196
212
 
197
213
  return -1;
198
214
  }
199
215
 
200
216
  static int loose_parse_oid(
201
- git_oid *oid, const char *filename, git_buf *file_content)
217
+ git_oid *oid, const char *filename, git_str *file_content)
202
218
  {
203
- const char *str = git_buf_cstr(file_content);
219
+ const char *str = git_str_cstr(file_content);
204
220
 
205
- if (git_buf_len(file_content) < GIT_OID_HEXSZ)
221
+ if (git_str_len(file_content) < GIT_OID_HEXSZ)
206
222
  goto corrupted;
207
223
 
208
224
  /* we need to get 40 OID characters from the file */
@@ -219,14 +235,13 @@ corrupted:
219
235
  return -1;
220
236
  }
221
237
 
222
- static int loose_readbuffer(git_buf *buf, const char *base, const char *path)
238
+ static int loose_readbuffer(git_str *buf, const char *base, const char *path)
223
239
  {
224
240
  int error;
225
241
 
226
- /* build full path to file */
227
- if ((error = git_buf_joinpath(buf, base, path)) < 0 ||
228
- (error = git_futils_readbuffer(buf, buf->ptr)) < 0)
229
- git_buf_dispose(buf);
242
+ if ((error = loose_path(buf, base, path)) < 0 ||
243
+ (error = git_futils_readbuffer(buf, buf->ptr)) < 0)
244
+ git_str_dispose(buf);
230
245
 
231
246
  return error;
232
247
  }
@@ -234,7 +249,7 @@ static int loose_readbuffer(git_buf *buf, const char *base, const char *path)
234
249
  static int loose_lookup_to_packfile(refdb_fs_backend *backend, const char *name)
235
250
  {
236
251
  int error = 0;
237
- git_buf ref_file = GIT_BUF_INIT;
252
+ git_str ref_file = GIT_STR_INIT;
238
253
  struct packref *ref = NULL;
239
254
  git_oid oid;
240
255
 
@@ -247,7 +262,7 @@ static int loose_lookup_to_packfile(refdb_fs_backend *backend, const char *name)
247
262
  }
248
263
 
249
264
  /* skip symbolic refs */
250
- if (!git__prefixcmp(git_buf_cstr(&ref_file), GIT_SYMREF))
265
+ if (!git__prefixcmp(git_str_cstr(&ref_file), GIT_SYMREF))
251
266
  goto done;
252
267
 
253
268
  /* parse OID from file */
@@ -267,11 +282,11 @@ static int loose_lookup_to_packfile(refdb_fs_backend *backend, const char *name)
267
282
  git_sortedcache_wunlock(backend->refcache);
268
283
 
269
284
  done:
270
- git_buf_dispose(&ref_file);
285
+ git_str_dispose(&ref_file);
271
286
  return error;
272
287
  }
273
288
 
274
- static int _dirent_loose_load(void *payload, git_buf *full_path)
289
+ static int _dirent_loose_load(void *payload, git_str *full_path)
275
290
  {
276
291
  refdb_fs_backend *backend = payload;
277
292
  const char *file_path;
@@ -279,8 +294,8 @@ static int _dirent_loose_load(void *payload, git_buf *full_path)
279
294
  if (git__suffixcmp(full_path->ptr, ".lock") == 0)
280
295
  return 0;
281
296
 
282
- if (git_path_isdir(full_path->ptr)) {
283
- int error = git_path_direach(
297
+ if (git_fs_path_isdir(full_path->ptr)) {
298
+ int error = git_fs_path_direach(
284
299
  full_path, backend->direach_flags, _dirent_loose_load, backend);
285
300
  /* Race with the filesystem, ignore it */
286
301
  if (error == GIT_ENOTFOUND) {
@@ -305,9 +320,9 @@ static int _dirent_loose_load(void *payload, git_buf *full_path)
305
320
  static int packed_loadloose(refdb_fs_backend *backend)
306
321
  {
307
322
  int error;
308
- git_buf refs_path = GIT_BUF_INIT;
323
+ git_str refs_path = GIT_STR_INIT;
309
324
 
310
- if (git_buf_joinpath(&refs_path, backend->gitpath, GIT_REFS_DIR) < 0)
325
+ if (git_str_joinpath(&refs_path, backend->gitpath, GIT_REFS_DIR) < 0)
311
326
  return -1;
312
327
 
313
328
  /*
@@ -315,10 +330,10 @@ static int packed_loadloose(refdb_fs_backend *backend)
315
330
  * This will overwrite any old packed entries with their
316
331
  * updated loose versions
317
332
  */
318
- error = git_path_direach(
333
+ error = git_fs_path_direach(
319
334
  &refs_path, backend->direach_flags, _dirent_loose_load, backend);
320
335
 
321
- git_buf_dispose(&refs_path);
336
+ git_str_dispose(&refs_path);
322
337
 
323
338
  return error;
324
339
  }
@@ -329,17 +344,17 @@ static int refdb_fs_backend__exists(
329
344
  const char *ref_name)
330
345
  {
331
346
  refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
332
- git_buf ref_path = GIT_BUF_INIT;
347
+ git_str ref_path = GIT_STR_INIT;
333
348
  int error;
334
349
 
335
- assert(backend);
350
+ GIT_ASSERT_ARG(backend);
336
351
 
337
352
  *exists = 0;
338
353
 
339
- if ((error = git_buf_joinpath(&ref_path, backend->gitpath, ref_name)) < 0)
354
+ if ((error = loose_path(&ref_path, backend->gitpath, ref_name)) < 0)
340
355
  goto out;
341
356
 
342
- if (git_path_isfile(ref_path.ptr)) {
357
+ if (git_fs_path_isfile(ref_path.ptr)) {
343
358
  *exists = 1;
344
359
  goto out;
345
360
  }
@@ -353,18 +368,18 @@ static int refdb_fs_backend__exists(
353
368
  }
354
369
 
355
370
  out:
356
- git_buf_dispose(&ref_path);
371
+ git_str_dispose(&ref_path);
357
372
  return error;
358
373
  }
359
374
 
360
- static const char *loose_parse_symbolic(git_buf *file_content)
375
+ static const char *loose_parse_symbolic(git_str *file_content)
361
376
  {
362
377
  const unsigned int header_len = (unsigned int)strlen(GIT_SYMREF);
363
378
  const char *refname_start;
364
379
 
365
380
  refname_start = (const char *)file_content->ptr;
366
381
 
367
- if (git_buf_len(file_content) < header_len + 1) {
382
+ if (git_str_len(file_content) < header_len + 1) {
368
383
  git_error_set(GIT_ERROR_REFERENCE, "corrupted loose reference file");
369
384
  return NULL;
370
385
  }
@@ -396,7 +411,7 @@ static int loose_lookup(
396
411
  refdb_fs_backend *backend,
397
412
  const char *ref_name)
398
413
  {
399
- git_buf ref_file = GIT_BUF_INIT;
414
+ git_str ref_file = GIT_STR_INIT;
400
415
  int error = 0;
401
416
  const char *ref_dir;
402
417
 
@@ -410,10 +425,10 @@ static int loose_lookup(
410
425
 
411
426
  if ((error = loose_readbuffer(&ref_file, ref_dir, ref_name)) < 0)
412
427
  /* cannot read loose ref file - gah */;
413
- else if (git__prefixcmp(git_buf_cstr(&ref_file), GIT_SYMREF) == 0) {
428
+ else if (git__prefixcmp(git_str_cstr(&ref_file), GIT_SYMREF) == 0) {
414
429
  const char *target;
415
430
 
416
- git_buf_rtrim(&ref_file);
431
+ git_str_rtrim(&ref_file);
417
432
 
418
433
  if (!(target = loose_parse_symbolic(&ref_file)))
419
434
  error = -1;
@@ -427,7 +442,7 @@ static int loose_lookup(
427
442
  *out = git_reference__alloc(ref_name, &oid, NULL);
428
443
  }
429
444
 
430
- git_buf_dispose(&ref_file);
445
+ git_str_dispose(&ref_file);
431
446
  return error;
432
447
  }
433
448
 
@@ -437,10 +452,198 @@ static int ref_error_notfound(const char *name)
437
452
  return GIT_ENOTFOUND;
438
453
  }
439
454
 
440
- static int packed_lookup(
441
- git_reference **out,
442
- refdb_fs_backend *backend,
443
- const char *ref_name)
455
+ static char *packed_set_peeling_mode(
456
+ char *data,
457
+ size_t data_sz,
458
+ refdb_fs_backend *backend)
459
+ {
460
+ static const char *traits_header = "# pack-refs with:";
461
+ char *eol;
462
+ backend->peeling_mode = PEELING_NONE;
463
+
464
+ if (git__prefixncmp(data, data_sz, traits_header) == 0) {
465
+ size_t hdr_sz = strlen(traits_header);
466
+ const char *sorted = " sorted ";
467
+ const char *peeled = " peeled ";
468
+ const char *fully_peeled = " fully-peeled ";
469
+ data += hdr_sz;
470
+ data_sz -= hdr_sz;
471
+
472
+ eol = memchr(data, '\n', data_sz);
473
+
474
+ if (!eol)
475
+ return NULL;
476
+
477
+ if (git__memmem(data, eol - data, fully_peeled, strlen(fully_peeled)))
478
+ backend->peeling_mode = PEELING_FULL;
479
+ else if (git__memmem(data, eol - data, peeled, strlen(peeled)))
480
+ backend->peeling_mode = PEELING_STANDARD;
481
+
482
+ backend->sorted = NULL != git__memmem(data, eol - data, sorted, strlen(sorted));
483
+
484
+ return eol + 1;
485
+ }
486
+ return data;
487
+ }
488
+
489
+ static void packed_map_free(refdb_fs_backend *backend)
490
+ {
491
+ if (backend->packed_refs_map.data) {
492
+ #ifdef GIT_WIN32
493
+ git__free(backend->packed_refs_map.data);
494
+ #else
495
+ git_futils_mmap_free(&backend->packed_refs_map);
496
+ #endif
497
+ backend->packed_refs_map.data = NULL;
498
+ backend->packed_refs_map.len = 0;
499
+ git_futils_filestamp_set(&backend->packed_refs_stamp, NULL);
500
+ }
501
+ }
502
+
503
+ static int packed_map_check(refdb_fs_backend *backend)
504
+ {
505
+ int error = 0;
506
+ git_file fd = -1;
507
+ struct stat st;
508
+
509
+ if ((error = git_mutex_lock(&backend->prlock)) < 0)
510
+ return error;
511
+
512
+ if (backend->packed_refs_map.data &&
513
+ !git_futils_filestamp_check(
514
+ &backend->packed_refs_stamp, backend->refcache->path)) {
515
+ git_mutex_unlock(&backend->prlock);
516
+ return error;
517
+ }
518
+ packed_map_free(backend);
519
+
520
+ fd = git_futils_open_ro(backend->refcache->path);
521
+ if (fd < 0) {
522
+ git_mutex_unlock(&backend->prlock);
523
+ if (fd == GIT_ENOTFOUND) {
524
+ git_error_clear();
525
+ return 0;
526
+ }
527
+ return fd;
528
+ }
529
+
530
+ if (p_fstat(fd, &st) < 0) {
531
+ p_close(fd);
532
+ git_mutex_unlock(&backend->prlock);
533
+ git_error_set(GIT_ERROR_OS, "unable to stat packed-refs '%s'", backend->refcache->path);
534
+ return -1;
535
+ }
536
+
537
+ if (st.st_size == 0) {
538
+ p_close(fd);
539
+ git_mutex_unlock(&backend->prlock);
540
+ return 0;
541
+ }
542
+
543
+ git_futils_filestamp_set_from_stat(&backend->packed_refs_stamp, &st);
544
+
545
+ #ifdef GIT_WIN32
546
+ /* on windows, we copy the entire file into memory rather than using
547
+ * mmap() because using mmap() on windows also locks the file and this
548
+ * map is long-lived. */
549
+ backend->packed_refs_map.len = (size_t)st.st_size;
550
+ backend->packed_refs_map.data =
551
+ git__malloc(backend->packed_refs_map.len);
552
+ GIT_ERROR_CHECK_ALLOC(backend->packed_refs_map.data);
553
+ {
554
+ ssize_t bytesread =
555
+ p_read(fd, backend->packed_refs_map.data,
556
+ backend->packed_refs_map.len);
557
+ error = (bytesread == (ssize_t)backend->packed_refs_map.len) ? 0 : -1;
558
+ }
559
+ #else
560
+ error = git_futils_mmap_ro(&backend->packed_refs_map, fd, 0, (size_t)st.st_size);
561
+ #endif
562
+ p_close(fd);
563
+ if (error < 0) {
564
+ git_mutex_unlock(&backend->prlock);
565
+ return error;
566
+ }
567
+
568
+ packed_set_peeling_mode(
569
+ backend->packed_refs_map.data, backend->packed_refs_map.len,
570
+ backend);
571
+
572
+ git_mutex_unlock(&backend->prlock);
573
+ return error;
574
+ }
575
+
576
+ /*
577
+ * Find beginning of packed-ref record pointed to by p.
578
+ * buf - a lower-bound pointer to some memory buffer
579
+ * p - an upper-bound pointer to the same memory buffer
580
+ */
581
+ static const char *start_of_record(const char *buf, const char *p)
582
+ {
583
+ const char *nl = p;
584
+ while (true) {
585
+ nl = git__memrchr(buf, '\n', nl - buf);
586
+ if (!nl)
587
+ return buf;
588
+
589
+ if (nl[1] == '^' && nl > buf)
590
+ --nl;
591
+ else
592
+ break;
593
+ };
594
+ return nl + 1;
595
+ }
596
+
597
+ /*
598
+ * Find end of packed-ref record pointed to by p.
599
+ * end - an upper-bound pointer to some memory buffer
600
+ * p - a lower-bound pointer to the same memory buffer
601
+ */
602
+ static const char *end_of_record(const char *p, const char *end)
603
+ {
604
+ while (1) {
605
+ size_t sz = end - p;
606
+ p = memchr(p, '\n', sz);
607
+ if (!p)
608
+ return end;
609
+ ++p;
610
+ if (p < end && p[0] == '^')
611
+ ++p;
612
+ else
613
+ break;
614
+ }
615
+ return p;
616
+ }
617
+
618
+ static int
619
+ cmp_record_to_refname(const char *rec, size_t data_end, const char *ref_name)
620
+ {
621
+ const size_t ref_len = strlen(ref_name);
622
+ int cmp_val;
623
+ const char *end;
624
+
625
+ rec += GIT_OID_HEXSZ + 1; /* <oid> + space */
626
+ if (data_end < GIT_OID_HEXSZ + 3) {
627
+ /* an incomplete (corrupt) record is treated as less than ref_name */
628
+ return -1;
629
+ }
630
+ data_end -= GIT_OID_HEXSZ + 1;
631
+
632
+ end = memchr(rec, '\n', data_end);
633
+ if (end)
634
+ data_end = end - rec;
635
+
636
+ cmp_val = memcmp(rec, ref_name, min(ref_len, data_end));
637
+
638
+ if (cmp_val == 0 && data_end != ref_len)
639
+ return (data_end > ref_len) ? 1 : -1;
640
+ return cmp_val;
641
+ }
642
+
643
+ static int packed_unsorted_lookup(
644
+ git_reference **out,
645
+ refdb_fs_backend *backend,
646
+ const char *ref_name)
444
647
  {
445
648
  int error = 0;
446
649
  struct packref *entry;
@@ -465,6 +668,85 @@ static int packed_lookup(
465
668
  return error;
466
669
  }
467
670
 
671
+ static int packed_lookup(
672
+ git_reference **out,
673
+ refdb_fs_backend *backend,
674
+ const char *ref_name)
675
+ {
676
+ int error = 0;
677
+ const char *left, *right, *data_end;
678
+
679
+ if ((error = packed_map_check(backend)) < 0)
680
+ return error;
681
+
682
+ if (!backend->sorted)
683
+ return packed_unsorted_lookup(out, backend, ref_name);
684
+
685
+ left = backend->packed_refs_map.data;
686
+ right = data_end = (const char *) backend->packed_refs_map.data +
687
+ backend->packed_refs_map.len;
688
+
689
+ while (left < right && *left == '#') {
690
+ if (!(left = memchr(left, '\n', data_end - left)))
691
+ goto parse_failed;
692
+ left++;
693
+ }
694
+
695
+ while (left < right) {
696
+ const char *mid, *rec;
697
+ int compare;
698
+
699
+ mid = left + (right - left) / 2;
700
+ rec = start_of_record(left, mid);
701
+ compare = cmp_record_to_refname(rec, data_end - rec, ref_name);
702
+
703
+ if (compare < 0) {
704
+ left = end_of_record(mid, right);
705
+ } else if (compare > 0) {
706
+ right = rec;
707
+ } else {
708
+ const char *eol;
709
+ git_oid oid, peel, *peel_ptr = NULL;
710
+
711
+ if (data_end - rec < GIT_OID_HEXSZ ||
712
+ git_oid_fromstr(&oid, rec) < 0) {
713
+ goto parse_failed;
714
+ }
715
+ rec += GIT_OID_HEXSZ + 1;
716
+ if (!(eol = memchr(rec, '\n', data_end - rec))) {
717
+ goto parse_failed;
718
+ }
719
+
720
+ /* look for optional "^<OID>\n" */
721
+
722
+ if (eol + 1 < data_end) {
723
+ rec = eol + 1;
724
+
725
+ if (*rec == '^') {
726
+ rec++;
727
+ if (data_end - rec < GIT_OID_HEXSZ ||
728
+ git_oid_fromstr(&peel, rec) < 0) {
729
+ goto parse_failed;
730
+ }
731
+ peel_ptr = &peel;
732
+ }
733
+ }
734
+
735
+ *out = git_reference__alloc(ref_name, &oid, peel_ptr);
736
+ if (!*out) {
737
+ return -1;
738
+ }
739
+
740
+ return 0;
741
+ }
742
+ }
743
+ return GIT_ENOTFOUND;
744
+
745
+ parse_failed:
746
+ git_error_set(GIT_ERROR_REFERENCE, "corrupted packed references file");
747
+ return -1;
748
+ }
749
+
468
750
  static int refdb_fs_backend__lookup(
469
751
  git_reference **out,
470
752
  git_refdb_backend *_backend,
@@ -473,7 +755,7 @@ static int refdb_fs_backend__lookup(
473
755
  refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
474
756
  int error;
475
757
 
476
- assert(backend);
758
+ GIT_ASSERT_ARG(backend);
477
759
 
478
760
  if (!(error = loose_lookup(out, backend, ref_name)))
479
761
  return 0;
@@ -484,7 +766,6 @@ static int refdb_fs_backend__lookup(
484
766
  git_error_clear();
485
767
  error = packed_lookup(out, backend, ref_name);
486
768
  }
487
-
488
769
  return error;
489
770
  }
490
771
 
@@ -514,7 +795,7 @@ static void refdb_fs_backend__iterator_free(git_reference_iterator *_iter)
514
795
  static int iter_load_loose_paths(refdb_fs_backend *backend, refdb_fs_iter *iter)
515
796
  {
516
797
  int error = 0;
517
- git_buf path = GIT_BUF_INIT;
798
+ git_str path = GIT_STR_INIT;
518
799
  git_iterator *fsit = NULL;
519
800
  git_iterator_options fsit_opts = GIT_ITERATOR_OPTIONS_INIT;
520
801
  const git_index_entry *entry = NULL;
@@ -550,26 +831,26 @@ static int iter_load_loose_paths(refdb_fs_backend *backend, refdb_fs_iter *iter)
550
831
  }
551
832
  }
552
833
 
553
- if ((error = git_buf_printf(&path, "%s/", backend->commonpath)) < 0 ||
554
- (error = git_buf_put(&path, ref_prefix, ref_prefix_len)) < 0) {
555
- git_buf_dispose(&path);
834
+ if ((error = git_str_puts(&path, backend->commonpath)) < 0 ||
835
+ (error = git_str_put(&path, ref_prefix, ref_prefix_len)) < 0) {
836
+ git_str_dispose(&path);
556
837
  return error;
557
838
  }
558
839
 
559
840
  if ((error = git_iterator_for_filesystem(&fsit, path.ptr, &fsit_opts)) < 0) {
560
- git_buf_dispose(&path);
841
+ git_str_dispose(&path);
561
842
  return (iter->glob && error == GIT_ENOTFOUND)? 0 : error;
562
843
  }
563
844
 
564
- error = git_buf_sets(&path, ref_prefix);
845
+ error = git_str_sets(&path, ref_prefix);
565
846
 
566
847
  while (!error && !git_iterator_advance(&entry, fsit)) {
567
848
  const char *ref_name;
568
849
  char *ref_dup;
569
850
 
570
- git_buf_truncate(&path, ref_prefix_len);
571
- git_buf_puts(&path, entry->path);
572
- ref_name = git_buf_cstr(&path);
851
+ git_str_truncate(&path, ref_prefix_len);
852
+ git_str_puts(&path, entry->path);
853
+ ref_name = git_str_cstr(&path);
573
854
 
574
855
  if (git__suffixcmp(ref_name, ".lock") == 0 ||
575
856
  (iter->glob && wildmatch(iter->glob, ref_name, 0) != 0))
@@ -583,7 +864,7 @@ static int iter_load_loose_paths(refdb_fs_backend *backend, refdb_fs_iter *iter)
583
864
  }
584
865
 
585
866
  git_iterator_free(fsit);
586
- git_buf_dispose(&path);
867
+ git_str_dispose(&path);
587
868
 
588
869
  return error;
589
870
  }
@@ -679,7 +960,7 @@ static int refdb_fs_backend__iterator(
679
960
  refdb_fs_iter *iter = NULL;
680
961
  int error;
681
962
 
682
- assert(backend);
963
+ GIT_ASSERT_ARG(backend);
683
964
 
684
965
  iter = git__calloc(1, sizeof(refdb_fs_iter));
685
966
  GIT_ERROR_CHECK_ALLOC(iter);
@@ -736,7 +1017,7 @@ static bool ref_is_available(
736
1017
  static int reference_path_available(
737
1018
  refdb_fs_backend *backend,
738
1019
  const char *new_ref,
739
- const char* old_ref,
1020
+ const char *old_ref,
740
1021
  int force)
741
1022
  {
742
1023
  size_t i;
@@ -782,12 +1063,14 @@ static int reference_path_available(
782
1063
  static int loose_lock(git_filebuf *file, refdb_fs_backend *backend, const char *name)
783
1064
  {
784
1065
  int error, filebuf_flags;
785
- git_buf ref_path = GIT_BUF_INIT;
1066
+ git_str ref_path = GIT_STR_INIT;
786
1067
  const char *basedir;
787
1068
 
788
- assert(file && backend && name);
1069
+ GIT_ASSERT_ARG(file);
1070
+ GIT_ASSERT_ARG(backend);
1071
+ GIT_ASSERT_ARG(name);
789
1072
 
790
- if (!git_path_isvalid(backend->repo, name, 0, GIT_PATH_REJECT_FILESYSTEM_DEFAULTS)) {
1073
+ if (!git_path_is_valid(backend->repo, name, 0, GIT_FS_PATH_REJECT_FILESYSTEM_DEFAULTS)) {
791
1074
  git_error_set(GIT_ERROR_INVALID, "invalid reference name '%s'", name);
792
1075
  return GIT_EINVALIDSPEC;
793
1076
  }
@@ -803,8 +1086,8 @@ static int loose_lock(git_filebuf *file, refdb_fs_backend *backend, const char *
803
1086
  if ((error = git_futils_rmdir_r(name, basedir, GIT_RMDIR_SKIP_NONEMPTY)) < 0)
804
1087
  return error;
805
1088
 
806
- if (git_buf_joinpath(&ref_path, basedir, name) < 0)
807
- return -1;
1089
+ if ((error = loose_path(&ref_path, basedir, name)) < 0)
1090
+ return error;
808
1091
 
809
1092
  filebuf_flags = GIT_FILEBUF_CREATE_LEADING_DIRS;
810
1093
  if (backend->fsync)
@@ -815,13 +1098,14 @@ static int loose_lock(git_filebuf *file, refdb_fs_backend *backend, const char *
815
1098
  if (error == GIT_EDIRECTORY)
816
1099
  git_error_set(GIT_ERROR_REFERENCE, "cannot lock ref '%s', there are refs beneath that folder", name);
817
1100
 
818
- git_buf_dispose(&ref_path);
1101
+ git_str_dispose(&ref_path);
819
1102
  return error;
820
1103
  }
821
1104
 
822
1105
  static int loose_commit(git_filebuf *file, const git_reference *ref)
823
1106
  {
824
- assert(file && ref);
1107
+ GIT_ASSERT_ARG(file);
1108
+ GIT_ASSERT_ARG(ref);
825
1109
 
826
1110
  if (ref->type == GIT_REFERENCE_DIRECT) {
827
1111
  char oid[GIT_OID_HEXSZ + 1];
@@ -831,7 +1115,7 @@ static int loose_commit(git_filebuf *file, const git_reference *ref)
831
1115
  } else if (ref->type == GIT_REFERENCE_SYMBOLIC) {
832
1116
  git_filebuf_printf(file, GIT_SYMREF "%s\n", ref->target.symbolic);
833
1117
  } else {
834
- assert(0); /* don't let this happen */
1118
+ GIT_ASSERT(0);
835
1119
  }
836
1120
 
837
1121
  return git_filebuf_commit(file);
@@ -982,7 +1266,7 @@ static int packed_remove_loose(refdb_fs_backend *backend)
982
1266
  {
983
1267
  size_t i;
984
1268
  git_filebuf lock = GIT_FILEBUF_INIT;
985
- git_buf ref_content = GIT_BUF_INIT;
1269
+ git_str ref_content = GIT_STR_INIT;
986
1270
  int error = 0;
987
1271
 
988
1272
  /* backend->refcache is already locked when this is called */
@@ -1003,7 +1287,7 @@ static int packed_remove_loose(refdb_fs_backend *backend)
1003
1287
  continue;
1004
1288
 
1005
1289
  if (error < 0) {
1006
- git_buf_dispose(&ref_content);
1290
+ git_str_dispose(&ref_content);
1007
1291
  git_error_set(GIT_ERROR_REFERENCE, "failed to lock loose reference '%s'", ref->name);
1008
1292
  return error;
1009
1293
  }
@@ -1034,7 +1318,7 @@ static int packed_remove_loose(refdb_fs_backend *backend)
1034
1318
  p_unlink(lock.path_original);
1035
1319
  }
1036
1320
 
1037
- git_buf_dispose(&ref_content);
1321
+ git_str_dispose(&ref_content);
1038
1322
  git_filebuf_cleanup(&lock);
1039
1323
  return 0;
1040
1324
  }
@@ -1049,6 +1333,15 @@ static int packed_write(refdb_fs_backend *backend)
1049
1333
  int error, open_flags = 0;
1050
1334
  size_t i;
1051
1335
 
1336
+ /* take lock and close up packed-refs mmap if open */
1337
+ if ((error = git_mutex_lock(&backend->prlock)) < 0) {
1338
+ return error;
1339
+ }
1340
+
1341
+ packed_map_free(backend);
1342
+
1343
+ git_mutex_unlock(&backend->prlock);
1344
+
1052
1345
  /* lock the cache to updates while we do this */
1053
1346
  if ((error = git_sortedcache_wlock(refcache)) < 0)
1054
1347
  return error;
@@ -1068,7 +1361,7 @@ static int packed_write(refdb_fs_backend *backend)
1068
1361
 
1069
1362
  for (i = 0; i < git_sortedcache_entrycount(refcache); ++i) {
1070
1363
  struct packref *ref = git_sortedcache_entry(refcache, i);
1071
- assert(ref);
1364
+ GIT_ASSERT(ref);
1072
1365
 
1073
1366
  if ((error = packed_find_peel(backend, ref)) < 0)
1074
1367
  goto fail;
@@ -1142,8 +1435,11 @@ static int cmp_old_ref(int *cmp, git_refdb_backend *backend, const char *name,
1142
1435
  if (!old_id && !old_target)
1143
1436
  return 0;
1144
1437
 
1145
- if ((error = refdb_fs_backend__lookup(&old_ref, backend, name)) < 0)
1438
+ if ((error = refdb_fs_backend__lookup(&old_ref, backend, name)) < 0) {
1439
+ if (error == GIT_ENOTFOUND && old_id && git_oid_is_zero(old_id))
1440
+ return 0;
1146
1441
  goto out;
1442
+ }
1147
1443
 
1148
1444
  /* If the types don't match, there's no way the values do */
1149
1445
  if (old_id && old_ref->type != GIT_REFERENCE_DIRECT) {
@@ -1221,7 +1517,7 @@ static int refdb_fs_backend__write(
1221
1517
  git_filebuf file = GIT_FILEBUF_INIT;
1222
1518
  int error = 0;
1223
1519
 
1224
- assert(backend);
1520
+ GIT_ASSERT_ARG(backend);
1225
1521
 
1226
1522
  if ((error = reference_path_available(backend, ref->name, NULL, force)) < 0)
1227
1523
  return error;
@@ -1294,41 +1590,56 @@ on_error:
1294
1590
  return error;
1295
1591
  }
1296
1592
 
1297
- static void refdb_fs_backend__prune_refs(
1593
+ static int refdb_fs_backend__prune_refs(
1298
1594
  refdb_fs_backend *backend,
1299
1595
  const char *ref_name,
1300
1596
  const char *prefix)
1301
1597
  {
1302
- git_buf relative_path = GIT_BUF_INIT;
1303
- git_buf base_path = GIT_BUF_INIT;
1598
+ git_str relative_path = GIT_STR_INIT;
1599
+ git_str base_path = GIT_STR_INIT;
1304
1600
  size_t commonlen;
1601
+ int error;
1305
1602
 
1306
- assert(backend && ref_name);
1603
+ GIT_ASSERT_ARG(backend);
1604
+ GIT_ASSERT_ARG(ref_name);
1307
1605
 
1308
- if (git_buf_sets(&relative_path, ref_name) < 0)
1606
+ if ((error = git_str_sets(&relative_path, ref_name)) < 0)
1309
1607
  goto cleanup;
1310
1608
 
1311
- git_path_squash_slashes(&relative_path);
1312
- if ((commonlen = git_path_common_dirlen("refs/heads/", git_buf_cstr(&relative_path))) == strlen("refs/heads/") ||
1313
- (commonlen = git_path_common_dirlen("refs/tags/", git_buf_cstr(&relative_path))) == strlen("refs/tags/") ||
1314
- (commonlen = git_path_common_dirlen("refs/remotes/", git_buf_cstr(&relative_path))) == strlen("refs/remotes/")) {
1609
+ git_fs_path_squash_slashes(&relative_path);
1610
+ if ((commonlen = git_fs_path_common_dirlen("refs/heads/", git_str_cstr(&relative_path))) == strlen("refs/heads/") ||
1611
+ (commonlen = git_fs_path_common_dirlen("refs/tags/", git_str_cstr(&relative_path))) == strlen("refs/tags/") ||
1612
+ (commonlen = git_fs_path_common_dirlen("refs/remotes/", git_str_cstr(&relative_path))) == strlen("refs/remotes/")) {
1315
1613
 
1316
- git_buf_truncate(&relative_path, commonlen);
1614
+ git_str_truncate(&relative_path, commonlen);
1317
1615
 
1318
- if (prefix) {
1319
- if (git_buf_join3(&base_path, '/', backend->commonpath, prefix, git_buf_cstr(&relative_path)) < 0)
1320
- goto cleanup;
1321
- } else {
1322
- if (git_buf_joinpath(&base_path, backend->commonpath, git_buf_cstr(&relative_path)) < 0)
1323
- goto cleanup;
1324
- }
1616
+ if (prefix)
1617
+ error = git_str_join3(&base_path, '/',
1618
+ backend->commonpath, prefix,
1619
+ git_str_cstr(&relative_path));
1620
+ else
1621
+ error = git_str_joinpath(&base_path,
1622
+ backend->commonpath,
1623
+ git_str_cstr(&relative_path));
1624
+
1625
+ if (!error)
1626
+ error = git_path_validate_str_length(NULL, &base_path);
1627
+
1628
+ if (error < 0)
1629
+ goto cleanup;
1325
1630
 
1326
- git_futils_rmdir_r(ref_name + commonlen, git_buf_cstr(&base_path), GIT_RMDIR_EMPTY_PARENTS | GIT_RMDIR_SKIP_ROOT);
1631
+ error = git_futils_rmdir_r(ref_name + commonlen,
1632
+ git_str_cstr(&base_path),
1633
+ GIT_RMDIR_EMPTY_PARENTS | GIT_RMDIR_SKIP_ROOT);
1634
+
1635
+ if (error == GIT_ENOTFOUND)
1636
+ error = 0;
1327
1637
  }
1328
1638
 
1329
1639
  cleanup:
1330
- git_buf_dispose(&relative_path);
1331
- git_buf_dispose(&base_path);
1640
+ git_str_dispose(&relative_path);
1641
+ git_str_dispose(&base_path);
1642
+ return error;
1332
1643
  }
1333
1644
 
1334
1645
  static int refdb_fs_backend__delete(
@@ -1340,7 +1651,8 @@ static int refdb_fs_backend__delete(
1340
1651
  git_filebuf file = GIT_FILEBUF_INIT;
1341
1652
  int error = 0;
1342
1653
 
1343
- assert(backend && ref_name);
1654
+ GIT_ASSERT_ARG(backend);
1655
+ GIT_ASSERT_ARG(ref_name);
1344
1656
 
1345
1657
  if ((error = loose_lock(&file, backend, ref_name)) < 0)
1346
1658
  return error;
@@ -1355,19 +1667,19 @@ static int refdb_fs_backend__delete(
1355
1667
 
1356
1668
  static int loose_delete(refdb_fs_backend *backend, const char *ref_name)
1357
1669
  {
1358
- git_buf loose_path = GIT_BUF_INIT;
1670
+ git_str path = GIT_STR_INIT;
1359
1671
  int error = 0;
1360
1672
 
1361
- if (git_buf_joinpath(&loose_path, backend->commonpath, ref_name) < 0)
1362
- return -1;
1673
+ if ((error = loose_path(&path, backend->commonpath, ref_name)) < 0)
1674
+ return error;
1363
1675
 
1364
- error = p_unlink(loose_path.ptr);
1676
+ error = p_unlink(path.ptr);
1365
1677
  if (error < 0 && errno == ENOENT)
1366
1678
  error = GIT_ENOTFOUND;
1367
1679
  else if (error != 0)
1368
1680
  error = -1;
1369
1681
 
1370
- git_buf_dispose(&loose_path);
1682
+ git_str_dispose(&path);
1371
1683
 
1372
1684
  return error;
1373
1685
  }
@@ -1426,7 +1738,7 @@ static int refdb_fs_backend__delete_tail(
1426
1738
  cleanup:
1427
1739
  git_filebuf_cleanup(file);
1428
1740
  if (error == 0)
1429
- refdb_fs_backend__prune_refs(backend, ref_name, "");
1741
+ error = refdb_fs_backend__prune_refs(backend, ref_name, "");
1430
1742
  return error;
1431
1743
  }
1432
1744
 
@@ -1446,7 +1758,7 @@ static int refdb_fs_backend__rename(
1446
1758
  git_filebuf file = GIT_FILEBUF_INIT;
1447
1759
  int error;
1448
1760
 
1449
- assert(backend);
1761
+ GIT_ASSERT_ARG(backend);
1450
1762
 
1451
1763
  if ((error = reference_path_available(
1452
1764
  backend, new_name, old_name, force)) < 0 ||
@@ -1499,7 +1811,7 @@ static int refdb_fs_backend__compress(git_refdb_backend *_backend)
1499
1811
  int error;
1500
1812
  refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1501
1813
 
1502
- assert(backend);
1814
+ GIT_ASSERT_ARG(backend);
1503
1815
 
1504
1816
  if ((error = packed_reload(backend)) < 0 || /* load the existing packfile */
1505
1817
  (error = packed_loadloose(backend)) < 0 || /* add all the loose refs */
@@ -1513,9 +1825,16 @@ static void refdb_fs_backend__free(git_refdb_backend *_backend)
1513
1825
  {
1514
1826
  refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1515
1827
 
1516
- assert(backend);
1828
+ if (!backend)
1829
+ return;
1517
1830
 
1518
1831
  git_sortedcache_free(backend->refcache);
1832
+
1833
+ git_mutex_lock(&backend->prlock);
1834
+ packed_map_free(backend);
1835
+ git_mutex_unlock(&backend->prlock);
1836
+ git_mutex_free(&backend->prlock);
1837
+
1519
1838
  git__free(backend->gitpath);
1520
1839
  git__free(backend->commonpath);
1521
1840
  git__free(backend);
@@ -1523,17 +1842,17 @@ static void refdb_fs_backend__free(git_refdb_backend *_backend)
1523
1842
 
1524
1843
  static char *setup_namespace(git_repository *repo, const char *in)
1525
1844
  {
1526
- git_buf path = GIT_BUF_INIT;
1845
+ git_str path = GIT_STR_INIT;
1527
1846
  char *parts, *start, *end, *out = NULL;
1528
1847
 
1529
1848
  if (!in)
1530
1849
  goto done;
1531
1850
 
1532
- git_buf_puts(&path, in);
1851
+ git_str_puts(&path, in);
1533
1852
 
1534
1853
  /* if the repo is not namespaced, nothing else to do */
1535
1854
  if (repo->namespace == NULL) {
1536
- out = git_buf_detach(&path);
1855
+ out = git_str_detach(&path);
1537
1856
  goto done;
1538
1857
  }
1539
1858
 
@@ -1548,22 +1867,23 @@ static char *setup_namespace(git_repository *repo, const char *in)
1548
1867
  * refs under refs/namespaces/foo/refs/namespaces/bar/
1549
1868
  */
1550
1869
  while ((start = git__strsep(&end, "/")) != NULL)
1551
- git_buf_printf(&path, "refs/namespaces/%s/", start);
1870
+ git_str_printf(&path, "refs/namespaces/%s/", start);
1552
1871
 
1553
- git_buf_printf(&path, "refs/namespaces/%s/refs", end);
1872
+ git_str_printf(&path, "refs/namespaces/%s/refs", end);
1554
1873
  git__free(parts);
1555
1874
 
1556
1875
  /* Make sure that the folder with the namespace exists */
1557
- if (git_futils_mkdir_relative(git_buf_cstr(&path), in, 0777,
1876
+ if (git_futils_mkdir_relative(git_str_cstr(&path), in, 0777,
1558
1877
  GIT_MKDIR_PATH, NULL) < 0)
1559
1878
  goto done;
1560
1879
 
1561
- /* Return root of the namespaced gitpath, i.e. without the trailing '/refs' */
1562
- git_buf_rtruncate_at_char(&path, '/');
1563
- out = git_buf_detach(&path);
1880
+ /* Return root of the namespaced gitpath, i.e. without the trailing 'refs' */
1881
+ git_str_rtruncate_at_char(&path, '/');
1882
+ git_str_putc(&path, '/');
1883
+ out = git_str_detach(&path);
1564
1884
 
1565
1885
  done:
1566
- git_buf_dispose(&path);
1886
+ git_str_dispose(&path);
1567
1887
  return out;
1568
1888
  }
1569
1889
 
@@ -1660,30 +1980,23 @@ static int create_new_reflog_file(const char *filepath)
1660
1980
  return p_close(fd);
1661
1981
  }
1662
1982
 
1663
- GIT_INLINE(int) retrieve_reflog_path(git_buf *path, git_repository *repo, const char *name)
1664
- {
1665
- if (strcmp(name, GIT_HEAD_FILE) == 0)
1666
- return git_buf_join3(path, '/', repo->gitdir, GIT_REFLOG_DIR, name);
1667
- return git_buf_join3(path, '/', repo->commondir, GIT_REFLOG_DIR, name);
1668
- }
1669
-
1670
1983
  static int refdb_reflog_fs__ensure_log(git_refdb_backend *_backend, const char *name)
1671
1984
  {
1672
1985
  refdb_fs_backend *backend;
1673
1986
  git_repository *repo;
1674
- git_buf path = GIT_BUF_INIT;
1987
+ git_str path = GIT_STR_INIT;
1675
1988
  int error;
1676
1989
 
1677
- assert(_backend && name);
1990
+ GIT_ASSERT_ARG(_backend && name);
1678
1991
 
1679
1992
  backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1680
1993
  repo = backend->repo;
1681
1994
 
1682
- if ((error = retrieve_reflog_path(&path, repo, name)) < 0)
1995
+ if ((error = reflog_path(&path, repo, name)) < 0)
1683
1996
  return error;
1684
1997
 
1685
- error = create_new_reflog_file(git_buf_cstr(&path));
1686
- git_buf_dispose(&path);
1998
+ error = create_new_reflog_file(git_str_cstr(&path));
1999
+ git_str_dispose(&path);
1687
2000
 
1688
2001
  return error;
1689
2002
  }
@@ -1691,15 +2004,15 @@ static int refdb_reflog_fs__ensure_log(git_refdb_backend *_backend, const char *
1691
2004
  static int has_reflog(git_repository *repo, const char *name)
1692
2005
  {
1693
2006
  int ret = 0;
1694
- git_buf path = GIT_BUF_INIT;
2007
+ git_str path = GIT_STR_INIT;
1695
2008
 
1696
- if (retrieve_reflog_path(&path, repo, name) < 0)
2009
+ if (reflog_path(&path, repo, name) < 0)
1697
2010
  goto cleanup;
1698
2011
 
1699
- ret = git_path_isfile(git_buf_cstr(&path));
2012
+ ret = git_fs_path_isfile(git_str_cstr(&path));
1700
2013
 
1701
2014
  cleanup:
1702
- git_buf_dispose(&path);
2015
+ git_str_dispose(&path);
1703
2016
  return ret;
1704
2017
  }
1705
2018
 
@@ -1707,7 +2020,8 @@ static int refdb_reflog_fs__has_log(git_refdb_backend *_backend, const char *nam
1707
2020
  {
1708
2021
  refdb_fs_backend *backend;
1709
2022
 
1710
- assert(_backend && name);
2023
+ GIT_ASSERT_ARG(_backend);
2024
+ GIT_ASSERT_ARG(name);
1711
2025
 
1712
2026
  backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1713
2027
 
@@ -1717,13 +2031,15 @@ static int refdb_reflog_fs__has_log(git_refdb_backend *_backend, const char *nam
1717
2031
  static int refdb_reflog_fs__read(git_reflog **out, git_refdb_backend *_backend, const char *name)
1718
2032
  {
1719
2033
  int error = -1;
1720
- git_buf log_path = GIT_BUF_INIT;
1721
- git_buf log_file = GIT_BUF_INIT;
2034
+ git_str log_path = GIT_STR_INIT;
2035
+ git_str log_file = GIT_STR_INIT;
1722
2036
  git_reflog *log = NULL;
1723
2037
  git_repository *repo;
1724
2038
  refdb_fs_backend *backend;
1725
2039
 
1726
- assert(out && _backend && name);
2040
+ GIT_ASSERT_ARG(out);
2041
+ GIT_ASSERT_ARG(_backend);
2042
+ GIT_ASSERT_ARG(name);
1727
2043
 
1728
2044
  backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1729
2045
  repo = backend->repo;
@@ -1731,19 +2047,19 @@ static int refdb_reflog_fs__read(git_reflog **out, git_refdb_backend *_backend,
1731
2047
  if (reflog_alloc(&log, name) < 0)
1732
2048
  return -1;
1733
2049
 
1734
- if (retrieve_reflog_path(&log_path, repo, name) < 0)
2050
+ if (reflog_path(&log_path, repo, name) < 0)
1735
2051
  goto cleanup;
1736
2052
 
1737
- error = git_futils_readbuffer(&log_file, git_buf_cstr(&log_path));
2053
+ error = git_futils_readbuffer(&log_file, git_str_cstr(&log_path));
1738
2054
  if (error < 0 && error != GIT_ENOTFOUND)
1739
2055
  goto cleanup;
1740
2056
 
1741
2057
  if ((error == GIT_ENOTFOUND) &&
1742
- ((error = create_new_reflog_file(git_buf_cstr(&log_path))) < 0))
2058
+ ((error = create_new_reflog_file(git_str_cstr(&log_path))) < 0))
1743
2059
  goto cleanup;
1744
2060
 
1745
2061
  if ((error = reflog_parse(log,
1746
- git_buf_cstr(&log_file), git_buf_len(&log_file))) < 0)
2062
+ git_str_cstr(&log_file), git_str_len(&log_file))) < 0)
1747
2063
  goto cleanup;
1748
2064
 
1749
2065
  *out = log;
@@ -1753,14 +2069,14 @@ cleanup:
1753
2069
  git_reflog_free(log);
1754
2070
 
1755
2071
  success:
1756
- git_buf_dispose(&log_file);
1757
- git_buf_dispose(&log_path);
2072
+ git_str_dispose(&log_file);
2073
+ git_str_dispose(&log_path);
1758
2074
 
1759
2075
  return error;
1760
2076
  }
1761
2077
 
1762
2078
  static int serialize_reflog_entry(
1763
- git_buf *buf,
2079
+ git_str *buf,
1764
2080
  const git_oid *oid_old,
1765
2081
  const git_oid *oid_new,
1766
2082
  const git_signature *committer,
@@ -1772,61 +2088,61 @@ static int serialize_reflog_entry(
1772
2088
  git_oid_tostr(raw_old, GIT_OID_HEXSZ+1, oid_old);
1773
2089
  git_oid_tostr(raw_new, GIT_OID_HEXSZ+1, oid_new);
1774
2090
 
1775
- git_buf_clear(buf);
2091
+ git_str_clear(buf);
1776
2092
 
1777
- git_buf_puts(buf, raw_old);
1778
- git_buf_putc(buf, ' ');
1779
- git_buf_puts(buf, raw_new);
2093
+ git_str_puts(buf, raw_old);
2094
+ git_str_putc(buf, ' ');
2095
+ git_str_puts(buf, raw_new);
1780
2096
 
1781
2097
  git_signature__writebuf(buf, " ", committer);
1782
2098
 
1783
2099
  /* drop trailing LF */
1784
- git_buf_rtrim(buf);
2100
+ git_str_rtrim(buf);
1785
2101
 
1786
2102
  if (msg) {
1787
2103
  size_t i;
1788
2104
 
1789
- git_buf_putc(buf, '\t');
1790
- git_buf_puts(buf, msg);
2105
+ git_str_putc(buf, '\t');
2106
+ git_str_puts(buf, msg);
1791
2107
 
1792
2108
  for (i = 0; i < buf->size - 2; i++)
1793
2109
  if (buf->ptr[i] == '\n')
1794
2110
  buf->ptr[i] = ' ';
1795
- git_buf_rtrim(buf);
2111
+ git_str_rtrim(buf);
1796
2112
  }
1797
2113
 
1798
- git_buf_putc(buf, '\n');
2114
+ git_str_putc(buf, '\n');
1799
2115
 
1800
- return git_buf_oom(buf);
2116
+ return git_str_oom(buf);
1801
2117
  }
1802
2118
 
1803
2119
  static int lock_reflog(git_filebuf *file, refdb_fs_backend *backend, const char *refname)
1804
2120
  {
1805
2121
  git_repository *repo;
1806
- git_buf log_path = GIT_BUF_INIT;
2122
+ git_str log_path = GIT_STR_INIT;
1807
2123
  int error;
1808
2124
 
1809
2125
  repo = backend->repo;
1810
2126
 
1811
- if (!git_path_isvalid(backend->repo, refname, 0, GIT_PATH_REJECT_FILESYSTEM_DEFAULTS)) {
2127
+ if (!git_path_is_valid(backend->repo, refname, 0, GIT_FS_PATH_REJECT_FILESYSTEM_DEFAULTS)) {
1812
2128
  git_error_set(GIT_ERROR_INVALID, "invalid reference name '%s'", refname);
1813
2129
  return GIT_EINVALIDSPEC;
1814
2130
  }
1815
2131
 
1816
- if (retrieve_reflog_path(&log_path, repo, refname) < 0)
2132
+ if (reflog_path(&log_path, repo, refname) < 0)
1817
2133
  return -1;
1818
2134
 
1819
- if (!git_path_isfile(git_buf_cstr(&log_path))) {
2135
+ if (!git_fs_path_isfile(git_str_cstr(&log_path))) {
1820
2136
  git_error_set(GIT_ERROR_INVALID,
1821
2137
  "log file for reference '%s' doesn't exist", refname);
1822
2138
  error = -1;
1823
2139
  goto cleanup;
1824
2140
  }
1825
2141
 
1826
- error = git_filebuf_open(file, git_buf_cstr(&log_path), 0, GIT_REFLOG_FILE_MODE);
2142
+ error = git_filebuf_open(file, git_str_cstr(&log_path), 0, GIT_REFLOG_FILE_MODE);
1827
2143
 
1828
2144
  cleanup:
1829
- git_buf_dispose(&log_path);
2145
+ git_str_dispose(&log_path);
1830
2146
 
1831
2147
  return error;
1832
2148
  }
@@ -1837,10 +2153,11 @@ static int refdb_reflog_fs__write(git_refdb_backend *_backend, git_reflog *reflo
1837
2153
  unsigned int i;
1838
2154
  git_reflog_entry *entry;
1839
2155
  refdb_fs_backend *backend;
1840
- git_buf log = GIT_BUF_INIT;
2156
+ git_str log = GIT_STR_INIT;
1841
2157
  git_filebuf fbuf = GIT_FILEBUF_INIT;
1842
2158
 
1843
- assert(_backend && reflog);
2159
+ GIT_ASSERT_ARG(_backend);
2160
+ GIT_ASSERT_ARG(reflog);
1844
2161
 
1845
2162
  backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1846
2163
 
@@ -1862,7 +2179,7 @@ cleanup:
1862
2179
  git_filebuf_cleanup(&fbuf);
1863
2180
 
1864
2181
  success:
1865
- git_buf_dispose(&log);
2182
+ git_str_dispose(&log);
1866
2183
 
1867
2184
  return error;
1868
2185
  }
@@ -1872,7 +2189,7 @@ static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, co
1872
2189
  {
1873
2190
  int error, is_symbolic, open_flags;
1874
2191
  git_oid old_id = {{0}}, new_id = {{0}};
1875
- git_buf buf = GIT_BUF_INIT, path = GIT_BUF_INIT;
2192
+ git_str buf = GIT_STR_INIT, path = GIT_STR_INIT;
1876
2193
  git_repository *repo = backend->repo;
1877
2194
 
1878
2195
  is_symbolic = ref->type == GIT_REFERENCE_SYMBOLIC;
@@ -1913,10 +2230,10 @@ static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, co
1913
2230
  if ((error = serialize_reflog_entry(&buf, &old_id, &new_id, who, message)) < 0)
1914
2231
  goto cleanup;
1915
2232
 
1916
- if ((error = retrieve_reflog_path(&path, repo, ref->name)) < 0)
2233
+ if ((error = reflog_path(&path, repo, ref->name)) < 0)
1917
2234
  goto cleanup;
1918
2235
 
1919
- if (((error = git_futils_mkpath2file(git_buf_cstr(&path), 0777)) < 0) &&
2236
+ if (((error = git_futils_mkpath2file(git_str_cstr(&path), 0777)) < 0) &&
1920
2237
  (error != GIT_EEXISTS)) {
1921
2238
  goto cleanup;
1922
2239
  }
@@ -1924,11 +2241,11 @@ static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, co
1924
2241
  /* If the new branch matches part of the namespace of a previously deleted branch,
1925
2242
  * there maybe an obsolete/unused directory (or directory hierarchy) in the way.
1926
2243
  */
1927
- if (git_path_isdir(git_buf_cstr(&path))) {
1928
- if ((error = git_futils_rmdir_r(git_buf_cstr(&path), NULL, GIT_RMDIR_SKIP_NONEMPTY)) < 0) {
2244
+ if (git_fs_path_isdir(git_str_cstr(&path))) {
2245
+ if ((error = git_futils_rmdir_r(git_str_cstr(&path), NULL, GIT_RMDIR_SKIP_NONEMPTY)) < 0) {
1929
2246
  if (error == GIT_ENOTFOUND)
1930
2247
  error = 0;
1931
- } else if (git_path_isdir(git_buf_cstr(&path))) {
2248
+ } else if (git_fs_path_isdir(git_str_cstr(&path))) {
1932
2249
  git_error_set(GIT_ERROR_REFERENCE, "cannot create reflog at '%s', there are reflogs beneath that folder",
1933
2250
  ref->name);
1934
2251
  error = GIT_EDIRECTORY;
@@ -1943,11 +2260,11 @@ static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, co
1943
2260
  if (backend->fsync)
1944
2261
  open_flags |= O_FSYNC;
1945
2262
 
1946
- error = git_futils_writebuffer(&buf, git_buf_cstr(&path), open_flags, GIT_REFLOG_FILE_MODE);
2263
+ error = git_futils_writebuffer(&buf, git_str_cstr(&path), open_flags, GIT_REFLOG_FILE_MODE);
1947
2264
 
1948
2265
  cleanup:
1949
- git_buf_dispose(&buf);
1950
- git_buf_dispose(&path);
2266
+ git_str_dispose(&buf);
2267
+ git_str_dispose(&path);
1951
2268
 
1952
2269
  return error;
1953
2270
  }
@@ -1955,14 +2272,16 @@ cleanup:
1955
2272
  static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_name, const char *new_name)
1956
2273
  {
1957
2274
  int error = 0, fd;
1958
- git_buf old_path = GIT_BUF_INIT;
1959
- git_buf new_path = GIT_BUF_INIT;
1960
- git_buf temp_path = GIT_BUF_INIT;
1961
- git_buf normalized = GIT_BUF_INIT;
2275
+ git_str old_path = GIT_STR_INIT;
2276
+ git_str new_path = GIT_STR_INIT;
2277
+ git_str temp_path = GIT_STR_INIT;
2278
+ git_str normalized = GIT_STR_INIT;
1962
2279
  git_repository *repo;
1963
2280
  refdb_fs_backend *backend;
1964
2281
 
1965
- assert(_backend && old_name && new_name);
2282
+ GIT_ASSERT_ARG(_backend);
2283
+ GIT_ASSERT_ARG(old_name);
2284
+ GIT_ASSERT_ARG(new_name);
1966
2285
 
1967
2286
  backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1968
2287
  repo = backend->repo;
@@ -1971,16 +2290,16 @@ static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_
1971
2290
  &normalized, new_name, GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL)) < 0)
1972
2291
  return error;
1973
2292
 
1974
- if (git_buf_joinpath(&temp_path, repo->gitdir, GIT_REFLOG_DIR) < 0)
2293
+ if (git_str_joinpath(&temp_path, repo->gitdir, GIT_REFLOG_DIR) < 0)
1975
2294
  return -1;
1976
2295
 
1977
- if (git_buf_joinpath(&old_path, git_buf_cstr(&temp_path), old_name) < 0)
1978
- return -1;
2296
+ if ((error = loose_path(&old_path, git_str_cstr(&temp_path), old_name)) < 0)
2297
+ return error;
1979
2298
 
1980
- if (git_buf_joinpath(&new_path, git_buf_cstr(&temp_path), git_buf_cstr(&normalized)) < 0)
1981
- return -1;
2299
+ if ((error = loose_path(&new_path, git_str_cstr(&temp_path), git_str_cstr(&normalized))) < 0)
2300
+ return error;
1982
2301
 
1983
- if (!git_path_exists(git_buf_cstr(&old_path))) {
2302
+ if (!git_fs_path_exists(git_str_cstr(&old_path))) {
1984
2303
  error = GIT_ENOTFOUND;
1985
2304
  goto cleanup;
1986
2305
  }
@@ -1992,43 +2311,43 @@ static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_
1992
2311
  * - a/b -> a/b/c
1993
2312
  * - a/b/c/d -> a/b/c
1994
2313
  */
1995
- if (git_buf_joinpath(&temp_path, git_buf_cstr(&temp_path), "temp_reflog") < 0)
1996
- return -1;
2314
+ if ((error = loose_path(&temp_path, git_str_cstr(&temp_path), "temp_reflog")) < 0)
2315
+ return error;
1997
2316
 
1998
- if ((fd = git_futils_mktmp(&temp_path, git_buf_cstr(&temp_path), GIT_REFLOG_FILE_MODE)) < 0) {
2317
+ if ((fd = git_futils_mktmp(&temp_path, git_str_cstr(&temp_path), GIT_REFLOG_FILE_MODE)) < 0) {
1999
2318
  error = -1;
2000
2319
  goto cleanup;
2001
2320
  }
2002
2321
 
2003
2322
  p_close(fd);
2004
2323
 
2005
- if (p_rename(git_buf_cstr(&old_path), git_buf_cstr(&temp_path)) < 0) {
2324
+ if (p_rename(git_str_cstr(&old_path), git_str_cstr(&temp_path)) < 0) {
2006
2325
  git_error_set(GIT_ERROR_OS, "failed to rename reflog for %s", new_name);
2007
2326
  error = -1;
2008
2327
  goto cleanup;
2009
2328
  }
2010
2329
 
2011
- if (git_path_isdir(git_buf_cstr(&new_path)) &&
2012
- (git_futils_rmdir_r(git_buf_cstr(&new_path), NULL, GIT_RMDIR_SKIP_NONEMPTY) < 0)) {
2330
+ if (git_fs_path_isdir(git_str_cstr(&new_path)) &&
2331
+ (git_futils_rmdir_r(git_str_cstr(&new_path), NULL, GIT_RMDIR_SKIP_NONEMPTY) < 0)) {
2013
2332
  error = -1;
2014
2333
  goto cleanup;
2015
2334
  }
2016
2335
 
2017
- if (git_futils_mkpath2file(git_buf_cstr(&new_path), GIT_REFLOG_DIR_MODE) < 0) {
2336
+ if (git_futils_mkpath2file(git_str_cstr(&new_path), GIT_REFLOG_DIR_MODE) < 0) {
2018
2337
  error = -1;
2019
2338
  goto cleanup;
2020
2339
  }
2021
2340
 
2022
- if (p_rename(git_buf_cstr(&temp_path), git_buf_cstr(&new_path)) < 0) {
2341
+ if (p_rename(git_str_cstr(&temp_path), git_str_cstr(&new_path)) < 0) {
2023
2342
  git_error_set(GIT_ERROR_OS, "failed to rename reflog for %s", new_name);
2024
2343
  error = -1;
2025
2344
  }
2026
2345
 
2027
2346
  cleanup:
2028
- git_buf_dispose(&temp_path);
2029
- git_buf_dispose(&old_path);
2030
- git_buf_dispose(&new_path);
2031
- git_buf_dispose(&normalized);
2347
+ git_str_dispose(&temp_path);
2348
+ git_str_dispose(&old_path);
2349
+ git_str_dispose(&new_path);
2350
+ git_str_dispose(&normalized);
2032
2351
 
2033
2352
  return error;
2034
2353
  }
@@ -2036,24 +2355,25 @@ cleanup:
2036
2355
  static int refdb_reflog_fs__delete(git_refdb_backend *_backend, const char *name)
2037
2356
  {
2038
2357
  refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
2039
- git_buf path = GIT_BUF_INIT;
2358
+ git_str path = GIT_STR_INIT;
2040
2359
  int error;
2041
2360
 
2042
- assert(_backend && name);
2361
+ GIT_ASSERT_ARG(_backend);
2362
+ GIT_ASSERT_ARG(name);
2043
2363
 
2044
- if ((error = retrieve_reflog_path(&path, backend->repo, name)) < 0)
2364
+ if ((error = reflog_path(&path, backend->repo, name)) < 0)
2045
2365
  goto out;
2046
2366
 
2047
- if (!git_path_exists(path.ptr))
2367
+ if (!git_fs_path_exists(path.ptr))
2048
2368
  goto out;
2049
2369
 
2050
2370
  if ((error = p_unlink(path.ptr)) < 0)
2051
2371
  goto out;
2052
2372
 
2053
- refdb_fs_backend__prune_refs(backend, name, GIT_REFLOG_DIR);
2373
+ error = refdb_fs_backend__prune_refs(backend, name, GIT_REFLOG_DIR);
2054
2374
 
2055
2375
  out:
2056
- git_buf_dispose(&path);
2376
+ git_str_dispose(&path);
2057
2377
 
2058
2378
  return error;
2059
2379
  }
@@ -2063,11 +2383,16 @@ int git_refdb_backend_fs(
2063
2383
  git_repository *repository)
2064
2384
  {
2065
2385
  int t = 0;
2066
- git_buf gitpath = GIT_BUF_INIT;
2386
+ git_str gitpath = GIT_STR_INIT;
2067
2387
  refdb_fs_backend *backend;
2068
2388
 
2069
2389
  backend = git__calloc(1, sizeof(refdb_fs_backend));
2070
2390
  GIT_ERROR_CHECK_ALLOC(backend);
2391
+ if (git_mutex_init(&backend->prlock) < 0) {
2392
+ git__free(backend);
2393
+ return -1;
2394
+ }
2395
+
2071
2396
 
2072
2397
  if (git_refdb_init_backend(&backend->parent, GIT_REFDB_BACKEND_VERSION) < 0)
2073
2398
  goto fail;
@@ -2088,21 +2413,21 @@ int git_refdb_backend_fs(
2088
2413
  goto fail;
2089
2414
  }
2090
2415
 
2091
- if (git_buf_joinpath(&gitpath, backend->commonpath, GIT_PACKEDREFS_FILE) < 0 ||
2416
+ if (git_str_joinpath(&gitpath, backend->commonpath, GIT_PACKEDREFS_FILE) < 0 ||
2092
2417
  git_sortedcache_new(
2093
2418
  &backend->refcache, offsetof(struct packref, name),
2094
- NULL, NULL, packref_cmp, git_buf_cstr(&gitpath)) < 0)
2419
+ NULL, NULL, packref_cmp, git_str_cstr(&gitpath)) < 0)
2095
2420
  goto fail;
2096
2421
 
2097
- git_buf_dispose(&gitpath);
2422
+ git_str_dispose(&gitpath);
2098
2423
 
2099
2424
  if (!git_repository__configmap_lookup(&t, backend->repo, GIT_CONFIGMAP_IGNORECASE) && t) {
2100
2425
  backend->iterator_flags |= GIT_ITERATOR_IGNORE_CASE;
2101
- backend->direach_flags |= GIT_PATH_DIR_IGNORE_CASE;
2426
+ backend->direach_flags |= GIT_FS_PATH_DIR_IGNORE_CASE;
2102
2427
  }
2103
2428
  if (!git_repository__configmap_lookup(&t, backend->repo, GIT_CONFIGMAP_PRECOMPOSE) && t) {
2104
2429
  backend->iterator_flags |= GIT_ITERATOR_PRECOMPOSE_UNICODE;
2105
- backend->direach_flags |= GIT_PATH_DIR_PRECOMPOSE_UNICODE;
2430
+ backend->direach_flags |= GIT_FS_PATH_DIR_PRECOMPOSE_UNICODE;
2106
2431
  }
2107
2432
  if ((!git_repository__configmap_lookup(&t, backend->repo, GIT_CONFIGMAP_FSYNCOBJECTFILES) && t) ||
2108
2433
  git_repository__fsync_gitdir)
@@ -2130,7 +2455,8 @@ int git_refdb_backend_fs(
2130
2455
  return 0;
2131
2456
 
2132
2457
  fail:
2133
- git_buf_dispose(&gitpath);
2458
+ git_mutex_free(&backend->prlock);
2459
+ git_str_dispose(&gitpath);
2134
2460
  git__free(backend->gitpath);
2135
2461
  git__free(backend->commonpath);
2136
2462
  git__free(backend);