rugged 0.27.7 → 0.27.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (409) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rugged/version.rb +1 -1
  3. data/vendor/libgit2/AUTHORS +1 -0
  4. data/vendor/libgit2/CMakeLists.txt +99 -51
  5. data/vendor/libgit2/COPYING +28 -0
  6. data/vendor/libgit2/cmake/Modules/AddCFlagIfSupported.cmake +15 -1
  7. data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.c.in +29 -0
  8. data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.cmake +96 -0
  9. data/vendor/libgit2/cmake/Modules/EnableWarnings.cmake +9 -8
  10. data/vendor/libgit2/cmake/Modules/FindCoreFoundation.cmake +2 -2
  11. data/vendor/libgit2/cmake/Modules/FindGSSAPI.cmake +1 -1
  12. data/vendor/libgit2/cmake/Modules/FindGSSFramework.cmake +28 -0
  13. data/vendor/libgit2/cmake/Modules/FindIconv.cmake +11 -6
  14. data/vendor/libgit2/cmake/Modules/FindPCRE.cmake +38 -0
  15. data/vendor/libgit2/cmake/Modules/FindPCRE2.cmake +37 -0
  16. data/vendor/libgit2/cmake/Modules/FindSecurity.cmake +2 -2
  17. data/vendor/libgit2/cmake/Modules/FindStatNsec.cmake +6 -0
  18. data/vendor/libgit2/cmake/Modules/PkgBuildConfig.cmake +110 -0
  19. data/vendor/libgit2/cmake/Modules/SelectGSSAPI.cmake +53 -0
  20. data/vendor/libgit2/cmake/Modules/SelectHTTPSBackend.cmake +124 -0
  21. data/vendor/libgit2/cmake/Modules/SelectHashes.cmake +66 -0
  22. data/vendor/libgit2/deps/http-parser/http_parser.c +11 -6
  23. data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +21 -0
  24. data/vendor/libgit2/deps/ntlmclient/compat.h +33 -0
  25. data/vendor/libgit2/deps/ntlmclient/crypt.h +64 -0
  26. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +120 -0
  27. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +18 -0
  28. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +145 -0
  29. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +18 -0
  30. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +130 -0
  31. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +21 -0
  32. data/vendor/libgit2/deps/ntlmclient/ntlm.c +1420 -0
  33. data/vendor/libgit2/deps/ntlmclient/ntlm.h +174 -0
  34. data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +320 -0
  35. data/vendor/libgit2/deps/ntlmclient/unicode.h +36 -0
  36. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +445 -0
  37. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +201 -0
  38. data/vendor/libgit2/deps/ntlmclient/utf8.h +1257 -0
  39. data/vendor/libgit2/deps/ntlmclient/util.c +21 -0
  40. data/vendor/libgit2/deps/ntlmclient/util.h +14 -0
  41. data/vendor/libgit2/deps/pcre/CMakeLists.txt +140 -0
  42. data/vendor/libgit2/deps/pcre/COPYING +5 -0
  43. data/vendor/libgit2/deps/pcre/cmake/COPYING-CMAKE-SCRIPTS +22 -0
  44. data/vendor/libgit2/deps/pcre/cmake/FindEditline.cmake +17 -0
  45. data/vendor/libgit2/deps/pcre/cmake/FindPackageHandleStandardArgs.cmake +58 -0
  46. data/vendor/libgit2/deps/pcre/cmake/FindReadline.cmake +29 -0
  47. data/vendor/libgit2/deps/pcre/config.h.in +57 -0
  48. data/vendor/libgit2/deps/pcre/pcre.h +641 -0
  49. data/vendor/libgit2/deps/pcre/pcre_byte_order.c +319 -0
  50. data/vendor/libgit2/deps/pcre/pcre_chartables.c +198 -0
  51. data/vendor/libgit2/deps/pcre/pcre_compile.c +9800 -0
  52. data/vendor/libgit2/deps/pcre/pcre_config.c +190 -0
  53. data/vendor/libgit2/deps/pcre/pcre_dfa_exec.c +3676 -0
  54. data/vendor/libgit2/deps/pcre/pcre_exec.c +7173 -0
  55. data/vendor/libgit2/deps/pcre/pcre_fullinfo.c +245 -0
  56. data/vendor/libgit2/deps/pcre/pcre_get.c +669 -0
  57. data/vendor/libgit2/deps/pcre/pcre_globals.c +86 -0
  58. data/vendor/libgit2/deps/pcre/pcre_internal.h +2787 -0
  59. data/vendor/libgit2/deps/pcre/pcre_jit_compile.c +11913 -0
  60. data/vendor/libgit2/deps/pcre/pcre_maketables.c +156 -0
  61. data/vendor/libgit2/deps/pcre/pcre_newline.c +210 -0
  62. data/vendor/libgit2/deps/pcre/pcre_ord2utf8.c +94 -0
  63. data/vendor/libgit2/deps/pcre/pcre_printint.c +834 -0
  64. data/vendor/libgit2/deps/pcre/pcre_refcount.c +92 -0
  65. data/vendor/libgit2/deps/pcre/pcre_string_utils.c +211 -0
  66. data/vendor/libgit2/deps/pcre/pcre_study.c +1686 -0
  67. data/vendor/libgit2/deps/pcre/pcre_tables.c +727 -0
  68. data/vendor/libgit2/deps/pcre/pcre_ucd.c +3644 -0
  69. data/vendor/libgit2/deps/pcre/pcre_valid_utf8.c +301 -0
  70. data/vendor/libgit2/deps/pcre/pcre_version.c +98 -0
  71. data/vendor/libgit2/deps/pcre/pcre_xclass.c +268 -0
  72. data/vendor/libgit2/deps/pcre/pcreposix.c +421 -0
  73. data/vendor/libgit2/deps/pcre/pcreposix.h +117 -0
  74. data/vendor/libgit2/deps/pcre/ucp.h +224 -0
  75. data/vendor/libgit2/deps/winhttp/COPYING.GPL +993 -0
  76. data/vendor/libgit2/deps/winhttp/COPYING.LGPL +502 -0
  77. data/vendor/libgit2/deps/zlib/CMakeLists.txt +1 -0
  78. data/vendor/libgit2/deps/zlib/COPYING +27 -0
  79. data/vendor/libgit2/deps/zlib/adler32.c +0 -7
  80. data/vendor/libgit2/deps/zlib/crc32.c +0 -7
  81. data/vendor/libgit2/include/git2/annotated_commit.h +9 -0
  82. data/vendor/libgit2/include/git2/apply.h +149 -0
  83. data/vendor/libgit2/include/git2/attr.h +20 -13
  84. data/vendor/libgit2/include/git2/blame.h +4 -4
  85. data/vendor/libgit2/include/git2/blob.h +44 -12
  86. data/vendor/libgit2/include/git2/buffer.h +20 -26
  87. data/vendor/libgit2/include/git2/cert.h +135 -0
  88. data/vendor/libgit2/include/git2/checkout.h +53 -21
  89. data/vendor/libgit2/include/git2/cherrypick.h +3 -3
  90. data/vendor/libgit2/include/git2/clone.h +5 -5
  91. data/vendor/libgit2/include/git2/commit.h +25 -3
  92. data/vendor/libgit2/include/git2/common.h +35 -10
  93. data/vendor/libgit2/include/git2/config.h +29 -19
  94. data/vendor/libgit2/include/git2/cred.h +308 -0
  95. data/vendor/libgit2/include/git2/deprecated.h +493 -0
  96. data/vendor/libgit2/include/git2/describe.h +4 -4
  97. data/vendor/libgit2/include/git2/diff.h +177 -135
  98. data/vendor/libgit2/include/git2/errors.h +53 -46
  99. data/vendor/libgit2/include/git2/filter.h +8 -0
  100. data/vendor/libgit2/include/git2/index.h +74 -52
  101. data/vendor/libgit2/include/git2/indexer.h +76 -6
  102. data/vendor/libgit2/include/git2/merge.h +25 -10
  103. data/vendor/libgit2/include/git2/net.h +0 -5
  104. data/vendor/libgit2/include/git2/notes.h +1 -1
  105. data/vendor/libgit2/include/git2/object.h +17 -29
  106. data/vendor/libgit2/include/git2/odb.h +12 -11
  107. data/vendor/libgit2/include/git2/odb_backend.h +10 -9
  108. data/vendor/libgit2/include/git2/oid.h +2 -2
  109. data/vendor/libgit2/include/git2/pack.h +14 -3
  110. data/vendor/libgit2/include/git2/proxy.h +5 -3
  111. data/vendor/libgit2/include/git2/rebase.h +46 -2
  112. data/vendor/libgit2/include/git2/refs.h +34 -16
  113. data/vendor/libgit2/include/git2/remote.h +111 -14
  114. data/vendor/libgit2/include/git2/repository.h +69 -34
  115. data/vendor/libgit2/include/git2/revert.h +1 -1
  116. data/vendor/libgit2/include/git2/revwalk.h +7 -7
  117. data/vendor/libgit2/include/git2/signature.h +2 -2
  118. data/vendor/libgit2/include/git2/stash.h +5 -5
  119. data/vendor/libgit2/include/git2/status.h +26 -17
  120. data/vendor/libgit2/include/git2/submodule.h +23 -6
  121. data/vendor/libgit2/include/git2/sys/alloc.h +18 -18
  122. data/vendor/libgit2/include/git2/sys/commit.h +1 -1
  123. data/vendor/libgit2/include/git2/sys/config.h +13 -13
  124. data/vendor/libgit2/include/git2/sys/cred.h +90 -0
  125. data/vendor/libgit2/include/git2/sys/filter.h +6 -6
  126. data/vendor/libgit2/include/git2/sys/merge.h +3 -3
  127. data/vendor/libgit2/include/git2/sys/odb_backend.h +66 -22
  128. data/vendor/libgit2/include/git2/sys/path.h +14 -5
  129. data/vendor/libgit2/include/git2/sys/refdb_backend.h +76 -40
  130. data/vendor/libgit2/include/git2/sys/repository.h +5 -1
  131. data/vendor/libgit2/include/git2/sys/stream.h +92 -12
  132. data/vendor/libgit2/include/git2/sys/transport.h +129 -83
  133. data/vendor/libgit2/include/git2/tag.h +13 -4
  134. data/vendor/libgit2/include/git2/trace.h +2 -2
  135. data/vendor/libgit2/include/git2/transport.h +11 -311
  136. data/vendor/libgit2/include/git2/tree.h +4 -4
  137. data/vendor/libgit2/include/git2/types.h +25 -106
  138. data/vendor/libgit2/include/git2/version.h +3 -3
  139. data/vendor/libgit2/include/git2/worktree.h +5 -5
  140. data/vendor/libgit2/include/git2.h +4 -0
  141. data/vendor/libgit2/src/CMakeLists.txt +104 -235
  142. data/vendor/libgit2/src/alloc.c +14 -18
  143. data/vendor/libgit2/src/{stdalloc.c → allocators/stdalloc.c} +7 -8
  144. data/vendor/libgit2/src/{stdalloc.h → allocators/stdalloc.h} +4 -4
  145. data/vendor/libgit2/src/allocators/win32_crtdbg.c +118 -0
  146. data/vendor/libgit2/src/{transports/cred.h → allocators/win32_crtdbg.h} +5 -4
  147. data/vendor/libgit2/src/annotated_commit.c +18 -11
  148. data/vendor/libgit2/src/apply.c +535 -28
  149. data/vendor/libgit2/src/apply.h +3 -1
  150. data/vendor/libgit2/src/array.h +2 -2
  151. data/vendor/libgit2/src/attr.c +77 -71
  152. data/vendor/libgit2/src/attr_file.c +203 -117
  153. data/vendor/libgit2/src/attr_file.h +9 -9
  154. data/vendor/libgit2/src/attrcache.c +49 -51
  155. data/vendor/libgit2/src/attrcache.h +2 -1
  156. data/vendor/libgit2/src/blame.c +38 -18
  157. data/vendor/libgit2/src/blame.h +1 -1
  158. data/vendor/libgit2/src/blame_git.c +29 -15
  159. data/vendor/libgit2/src/blob.c +123 -37
  160. data/vendor/libgit2/src/blob.h +19 -2
  161. data/vendor/libgit2/src/branch.c +47 -23
  162. data/vendor/libgit2/src/buf_text.c +7 -6
  163. data/vendor/libgit2/src/buffer.c +60 -53
  164. data/vendor/libgit2/src/cache.c +38 -45
  165. data/vendor/libgit2/src/cache.h +3 -3
  166. data/vendor/libgit2/src/cc-compat.h +20 -3
  167. data/vendor/libgit2/src/checkout.c +77 -67
  168. data/vendor/libgit2/src/cherrypick.c +12 -6
  169. data/vendor/libgit2/src/clone.c +36 -14
  170. data/vendor/libgit2/src/clone.h +4 -0
  171. data/vendor/libgit2/src/commit.c +103 -48
  172. data/vendor/libgit2/src/commit.h +7 -0
  173. data/vendor/libgit2/src/commit_list.c +36 -78
  174. data/vendor/libgit2/src/commit_list.h +2 -2
  175. data/vendor/libgit2/src/common.h +24 -90
  176. data/vendor/libgit2/src/config.c +203 -176
  177. data/vendor/libgit2/src/config.h +8 -20
  178. data/vendor/libgit2/src/config_backend.h +96 -0
  179. data/vendor/libgit2/src/config_cache.c +41 -35
  180. data/vendor/libgit2/src/config_entries.c +229 -0
  181. data/vendor/libgit2/src/config_entries.h +24 -0
  182. data/vendor/libgit2/src/config_file.c +422 -680
  183. data/vendor/libgit2/src/config_mem.c +220 -0
  184. data/vendor/libgit2/src/config_parse.c +96 -68
  185. data/vendor/libgit2/src/config_parse.h +15 -14
  186. data/vendor/libgit2/src/config_snapshot.c +206 -0
  187. data/vendor/libgit2/src/crlf.c +219 -196
  188. data/vendor/libgit2/src/delta.c +25 -18
  189. data/vendor/libgit2/src/describe.c +42 -41
  190. data/vendor/libgit2/src/diff.c +52 -67
  191. data/vendor/libgit2/src/diff.h +2 -1
  192. data/vendor/libgit2/src/diff_driver.c +44 -46
  193. data/vendor/libgit2/src/diff_file.c +16 -14
  194. data/vendor/libgit2/src/diff_file.h +1 -1
  195. data/vendor/libgit2/src/diff_generate.c +158 -103
  196. data/vendor/libgit2/src/diff_generate.h +3 -3
  197. data/vendor/libgit2/src/diff_parse.c +4 -4
  198. data/vendor/libgit2/src/diff_print.c +34 -22
  199. data/vendor/libgit2/src/diff_stats.c +22 -7
  200. data/vendor/libgit2/src/diff_tform.c +18 -16
  201. data/vendor/libgit2/src/diff_xdiff.c +3 -3
  202. data/vendor/libgit2/src/errors.c +51 -39
  203. data/vendor/libgit2/src/errors.h +81 -0
  204. data/vendor/libgit2/src/features.h.in +9 -3
  205. data/vendor/libgit2/src/fetch.c +8 -3
  206. data/vendor/libgit2/src/fetchhead.c +12 -12
  207. data/vendor/libgit2/src/filebuf.c +28 -32
  208. data/vendor/libgit2/src/filebuf.h +2 -2
  209. data/vendor/libgit2/src/filter.c +47 -33
  210. data/vendor/libgit2/src/filter.h +0 -10
  211. data/vendor/libgit2/src/{fileops.c → futils.c} +70 -63
  212. data/vendor/libgit2/src/{fileops.h → futils.h} +6 -6
  213. data/vendor/libgit2/src/global.c +35 -55
  214. data/vendor/libgit2/src/global.h +0 -2
  215. data/vendor/libgit2/src/hash/sha1/collisiondetect.c +48 -0
  216. data/vendor/libgit2/src/hash/sha1/collisiondetect.h +19 -0
  217. data/vendor/libgit2/src/hash/{hash_common_crypto.h → sha1/common_crypto.c} +17 -17
  218. data/vendor/libgit2/src/hash/sha1/common_crypto.h +19 -0
  219. data/vendor/libgit2/src/hash/{hash_generic.c → sha1/generic.c} +22 -10
  220. data/vendor/libgit2/src/hash/{hash_generic.h → sha1/generic.h} +4 -10
  221. data/vendor/libgit2/src/hash/{hash_mbedtls.c → sha1/mbedtls.c} +15 -7
  222. data/vendor/libgit2/src/hash/{hash_mbedtls.h → sha1/mbedtls.h} +6 -7
  223. data/vendor/libgit2/src/hash/sha1/openssl.c +59 -0
  224. data/vendor/libgit2/src/hash/sha1/openssl.h +19 -0
  225. data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/sha1.c +14 -3
  226. data/vendor/libgit2/src/hash/{hash_win32.c → sha1/win32.c} +47 -37
  227. data/vendor/libgit2/src/hash/{hash_win32.h → sha1/win32.h} +6 -19
  228. data/vendor/libgit2/src/hash/sha1.h +38 -0
  229. data/vendor/libgit2/src/hash.c +61 -0
  230. data/vendor/libgit2/src/hash.h +20 -21
  231. data/vendor/libgit2/src/hashsig.c +5 -5
  232. data/vendor/libgit2/src/idxmap.c +107 -61
  233. data/vendor/libgit2/src/idxmap.h +153 -31
  234. data/vendor/libgit2/src/ignore.c +38 -42
  235. data/vendor/libgit2/src/index.c +264 -199
  236. data/vendor/libgit2/src/index.h +7 -1
  237. data/vendor/libgit2/src/indexer.c +338 -167
  238. data/vendor/libgit2/src/integer.h +71 -26
  239. data/vendor/libgit2/src/iterator.c +134 -62
  240. data/vendor/libgit2/src/iterator.h +15 -0
  241. data/vendor/libgit2/src/mailmap.c +8 -8
  242. data/vendor/libgit2/src/map.h +1 -1
  243. data/vendor/libgit2/src/merge.c +137 -93
  244. data/vendor/libgit2/src/merge_driver.c +11 -11
  245. data/vendor/libgit2/src/merge_file.c +2 -2
  246. data/vendor/libgit2/src/mwindow.c +24 -29
  247. data/vendor/libgit2/src/mwindow.h +4 -4
  248. data/vendor/libgit2/src/net.c +184 -0
  249. data/vendor/libgit2/src/net.h +36 -0
  250. data/vendor/libgit2/src/netops.c +55 -156
  251. data/vendor/libgit2/src/netops.h +3 -23
  252. data/vendor/libgit2/src/notes.c +14 -9
  253. data/vendor/libgit2/src/object.c +120 -69
  254. data/vendor/libgit2/src/object.h +22 -9
  255. data/vendor/libgit2/src/object_api.c +8 -8
  256. data/vendor/libgit2/src/odb.c +111 -88
  257. data/vendor/libgit2/src/odb.h +8 -7
  258. data/vendor/libgit2/src/odb_loose.c +58 -47
  259. data/vendor/libgit2/src/odb_mempack.c +21 -34
  260. data/vendor/libgit2/src/odb_pack.c +17 -13
  261. data/vendor/libgit2/src/offmap.c +53 -35
  262. data/vendor/libgit2/src/offmap.h +108 -21
  263. data/vendor/libgit2/src/oid.c +12 -7
  264. data/vendor/libgit2/src/oidmap.c +49 -47
  265. data/vendor/libgit2/src/oidmap.h +101 -24
  266. data/vendor/libgit2/src/pack-objects.c +87 -86
  267. data/vendor/libgit2/src/pack-objects.h +2 -8
  268. data/vendor/libgit2/src/pack.c +94 -96
  269. data/vendor/libgit2/src/pack.h +16 -18
  270. data/vendor/libgit2/src/parse.c +17 -4
  271. data/vendor/libgit2/src/parse.h +3 -3
  272. data/vendor/libgit2/src/patch.c +3 -3
  273. data/vendor/libgit2/src/patch_generate.c +18 -18
  274. data/vendor/libgit2/src/patch_parse.c +147 -79
  275. data/vendor/libgit2/src/path.c +207 -62
  276. data/vendor/libgit2/src/path.h +14 -0
  277. data/vendor/libgit2/src/pathspec.c +18 -18
  278. data/vendor/libgit2/src/pool.c +26 -22
  279. data/vendor/libgit2/src/pool.h +7 -7
  280. data/vendor/libgit2/src/posix.c +10 -10
  281. data/vendor/libgit2/src/posix.h +12 -1
  282. data/vendor/libgit2/src/proxy.c +8 -3
  283. data/vendor/libgit2/src/push.c +35 -29
  284. data/vendor/libgit2/src/push.h +2 -1
  285. data/vendor/libgit2/src/reader.c +265 -0
  286. data/vendor/libgit2/src/reader.h +107 -0
  287. data/vendor/libgit2/src/rebase.c +97 -38
  288. data/vendor/libgit2/src/refdb.c +15 -3
  289. data/vendor/libgit2/src/refdb_fs.c +318 -222
  290. data/vendor/libgit2/src/reflog.c +13 -15
  291. data/vendor/libgit2/src/refs.c +122 -89
  292. data/vendor/libgit2/src/refs.h +5 -3
  293. data/vendor/libgit2/src/refspec.c +27 -33
  294. data/vendor/libgit2/src/regexp.c +221 -0
  295. data/vendor/libgit2/src/regexp.h +97 -0
  296. data/vendor/libgit2/src/remote.c +229 -178
  297. data/vendor/libgit2/src/remote.h +11 -2
  298. data/vendor/libgit2/src/repository.c +227 -172
  299. data/vendor/libgit2/src/repository.h +52 -40
  300. data/vendor/libgit2/src/reset.c +7 -7
  301. data/vendor/libgit2/src/revert.c +11 -6
  302. data/vendor/libgit2/src/revparse.c +46 -46
  303. data/vendor/libgit2/src/revwalk.c +89 -54
  304. data/vendor/libgit2/src/revwalk.h +20 -0
  305. data/vendor/libgit2/src/settings.c +22 -9
  306. data/vendor/libgit2/src/signature.c +15 -13
  307. data/vendor/libgit2/src/sortedcache.c +22 -36
  308. data/vendor/libgit2/src/sortedcache.h +1 -1
  309. data/vendor/libgit2/src/stash.c +56 -76
  310. data/vendor/libgit2/src/status.c +27 -21
  311. data/vendor/libgit2/src/stream.h +17 -2
  312. data/vendor/libgit2/src/streams/mbedtls.c +100 -80
  313. data/vendor/libgit2/src/streams/mbedtls.h +5 -2
  314. data/vendor/libgit2/src/streams/openssl.c +93 -81
  315. data/vendor/libgit2/src/streams/openssl.h +5 -2
  316. data/vendor/libgit2/src/streams/registry.c +118 -0
  317. data/vendor/libgit2/src/streams/registry.h +19 -0
  318. data/vendor/libgit2/src/streams/socket.c +55 -30
  319. data/vendor/libgit2/src/streams/stransport.c +57 -32
  320. data/vendor/libgit2/src/streams/stransport.h +5 -0
  321. data/vendor/libgit2/src/streams/tls.c +48 -20
  322. data/vendor/libgit2/src/streams/tls.h +12 -4
  323. data/vendor/libgit2/src/strmap.c +47 -74
  324. data/vendor/libgit2/src/strmap.h +108 -33
  325. data/vendor/libgit2/src/submodule.c +190 -169
  326. data/vendor/libgit2/src/submodule.h +1 -1
  327. data/vendor/libgit2/src/sysdir.c +25 -15
  328. data/vendor/libgit2/src/tag.c +39 -26
  329. data/vendor/libgit2/src/tag.h +2 -1
  330. data/vendor/libgit2/src/trace.c +2 -2
  331. data/vendor/libgit2/src/trace.h +2 -2
  332. data/vendor/libgit2/src/trailer.c +46 -32
  333. data/vendor/libgit2/src/transaction.c +30 -29
  334. data/vendor/libgit2/src/transport.c +3 -3
  335. data/vendor/libgit2/src/transports/auth.c +14 -10
  336. data/vendor/libgit2/src/transports/auth.h +10 -3
  337. data/vendor/libgit2/src/transports/auth_negotiate.c +31 -16
  338. data/vendor/libgit2/src/transports/auth_negotiate.h +2 -2
  339. data/vendor/libgit2/src/transports/auth_ntlm.c +223 -0
  340. data/vendor/libgit2/src/transports/auth_ntlm.h +35 -0
  341. data/vendor/libgit2/src/transports/cred.c +24 -24
  342. data/vendor/libgit2/src/transports/git.c +25 -30
  343. data/vendor/libgit2/src/transports/http.c +871 -335
  344. data/vendor/libgit2/src/transports/http.h +2 -0
  345. data/vendor/libgit2/src/transports/local.c +28 -28
  346. data/vendor/libgit2/src/transports/smart.c +64 -46
  347. data/vendor/libgit2/src/transports/smart.h +5 -6
  348. data/vendor/libgit2/src/transports/smart_pkt.c +162 -151
  349. data/vendor/libgit2/src/transports/smart_protocol.c +64 -94
  350. data/vendor/libgit2/src/transports/ssh.c +76 -65
  351. data/vendor/libgit2/src/transports/winhttp.c +328 -319
  352. data/vendor/libgit2/src/tree-cache.c +21 -14
  353. data/vendor/libgit2/src/tree.c +119 -112
  354. data/vendor/libgit2/src/tree.h +1 -0
  355. data/vendor/libgit2/src/unix/map.c +3 -3
  356. data/vendor/libgit2/src/unix/posix.h +1 -11
  357. data/vendor/libgit2/src/userdiff.h +3 -1
  358. data/vendor/libgit2/src/util.c +154 -93
  359. data/vendor/libgit2/src/util.h +19 -23
  360. data/vendor/libgit2/src/vector.c +15 -10
  361. data/vendor/libgit2/src/wildmatch.c +320 -0
  362. data/vendor/libgit2/src/wildmatch.h +23 -0
  363. data/vendor/libgit2/src/win32/dir.c +3 -3
  364. data/vendor/libgit2/src/win32/findfile.c +1 -1
  365. data/vendor/libgit2/src/win32/map.c +9 -11
  366. data/vendor/libgit2/src/win32/msvc-compat.h +6 -0
  367. data/vendor/libgit2/src/win32/path_w32.c +113 -9
  368. data/vendor/libgit2/src/win32/path_w32.h +18 -29
  369. data/vendor/libgit2/src/win32/posix.h +1 -4
  370. data/vendor/libgit2/src/win32/posix_w32.c +69 -44
  371. data/vendor/libgit2/src/win32/precompiled.h +0 -2
  372. data/vendor/libgit2/src/win32/thread.c +5 -10
  373. data/vendor/libgit2/src/win32/w32_buffer.c +9 -5
  374. data/vendor/libgit2/src/win32/w32_common.h +39 -0
  375. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +2 -95
  376. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +0 -2
  377. data/vendor/libgit2/src/win32/w32_stack.c +6 -11
  378. data/vendor/libgit2/src/win32/w32_stack.h +3 -3
  379. data/vendor/libgit2/src/win32/w32_util.c +27 -64
  380. data/vendor/libgit2/src/win32/w32_util.h +5 -49
  381. data/vendor/libgit2/src/worktree.c +44 -30
  382. data/vendor/libgit2/src/xdiff/xdiffi.c +5 -5
  383. data/vendor/libgit2/src/xdiff/xhistogram.c +1 -1
  384. data/vendor/libgit2/src/xdiff/xmerge.c +27 -15
  385. data/vendor/libgit2/src/xdiff/xpatience.c +3 -0
  386. data/vendor/libgit2/src/zstream.c +4 -4
  387. metadata +115 -38
  388. data/vendor/libgit2/deps/regex/CMakeLists.txt +0 -2
  389. data/vendor/libgit2/deps/regex/config.h +0 -7
  390. data/vendor/libgit2/deps/regex/regcomp.c +0 -3857
  391. data/vendor/libgit2/deps/regex/regex.c +0 -92
  392. data/vendor/libgit2/deps/regex/regex.h +0 -582
  393. data/vendor/libgit2/deps/regex/regex_internal.c +0 -1744
  394. data/vendor/libgit2/deps/regex/regex_internal.h +0 -819
  395. data/vendor/libgit2/deps/regex/regexec.c +0 -4369
  396. data/vendor/libgit2/include/git2/inttypes.h +0 -309
  397. data/vendor/libgit2/include/git2/sys/time.h +0 -31
  398. data/vendor/libgit2/libgit2.pc.in +0 -13
  399. data/vendor/libgit2/src/config_file.h +0 -73
  400. data/vendor/libgit2/src/fnmatch.c +0 -248
  401. data/vendor/libgit2/src/fnmatch.h +0 -48
  402. data/vendor/libgit2/src/hash/hash_collisiondetect.h +0 -47
  403. data/vendor/libgit2/src/hash/hash_openssl.h +0 -59
  404. data/vendor/libgit2/src/streams/curl.c +0 -385
  405. data/vendor/libgit2/src/streams/curl.h +0 -17
  406. /data/vendor/libgit2/deps/http-parser/{LICENSE-MIT → COPYING} +0 -0
  407. /data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/sha1.h +0 -0
  408. /data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/ubc_check.c +0 -0
  409. /data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/ubc_check.h +0 -0
@@ -10,14 +10,16 @@
10
10
  #include "refs.h"
11
11
  #include "hash.h"
12
12
  #include "repository.h"
13
- #include "fileops.h"
13
+ #include "futils.h"
14
14
  #include "filebuf.h"
15
15
  #include "pack.h"
16
+ #include "parse.h"
16
17
  #include "reflog.h"
17
18
  #include "refdb.h"
18
19
  #include "iterator.h"
19
20
  #include "sortedcache.h"
20
21
  #include "signature.h"
22
+ #include "wildmatch.h"
21
23
 
22
24
  #include <git2/tag.h>
23
25
  #include <git2/object.h>
@@ -94,7 +96,7 @@ static int packed_reload(refdb_fs_backend *backend)
94
96
  if (error <= 0) {
95
97
  if (error == GIT_ENOTFOUND) {
96
98
  git_sortedcache_clear(backend->refcache, true);
97
- giterr_clear();
99
+ git_error_clear();
98
100
  error = 0;
99
101
  }
100
102
  return error;
@@ -188,7 +190,7 @@ static int packed_reload(refdb_fs_backend *backend)
188
190
  return 0;
189
191
 
190
192
  parse_failed:
191
- giterr_set(GITERR_REFERENCE, "corrupted packed references file");
193
+ git_error_set(GIT_ERROR_REFERENCE, "corrupted packed references file");
192
194
 
193
195
  git_sortedcache_clear(backend->refcache, false);
194
196
  git_sortedcache_wunlock(backend->refcache);
@@ -215,7 +217,7 @@ static int loose_parse_oid(
215
217
  return 0;
216
218
 
217
219
  corrupted:
218
- giterr_set(GITERR_REFERENCE, "corrupted loose reference file: %s", filename);
220
+ git_error_set(GIT_ERROR_REFERENCE, "corrupted loose reference file: %s", filename);
219
221
  return -1;
220
222
  }
221
223
 
@@ -242,7 +244,7 @@ static int loose_lookup_to_packfile(refdb_fs_backend *backend, const char *name)
242
244
  * the filesystem under us and skip it...
243
245
  */
244
246
  if (loose_readbuffer(&ref_file, backend->gitpath, name) < 0) {
245
- giterr_clear();
247
+ git_error_clear();
246
248
  goto done;
247
249
  }
248
250
 
@@ -283,7 +285,7 @@ static int _dirent_loose_load(void *payload, git_buf *full_path)
283
285
  full_path, backend->direach_flags, _dirent_loose_load, backend);
284
286
  /* Race with the filesystem, ignore it */
285
287
  if (error == GIT_ENOTFOUND) {
286
- giterr_clear();
288
+ git_error_clear();
287
289
  return 0;
288
290
  }
289
291
 
@@ -327,21 +329,33 @@ static int refdb_fs_backend__exists(
327
329
  git_refdb_backend *_backend,
328
330
  const char *ref_name)
329
331
  {
330
- refdb_fs_backend *backend = (refdb_fs_backend *)_backend;
332
+ refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
331
333
  git_buf ref_path = GIT_BUF_INIT;
332
334
  int error;
333
335
 
334
336
  assert(backend);
335
337
 
336
- if ((error = packed_reload(backend)) < 0 ||
337
- (error = git_buf_joinpath(&ref_path, backend->gitpath, ref_name)) < 0)
338
- return error;
338
+ *exists = 0;
339
+
340
+ if ((error = git_buf_joinpath(&ref_path, backend->gitpath, ref_name)) < 0)
341
+ goto out;
342
+
343
+ if (git_path_isfile(ref_path.ptr)) {
344
+ *exists = 1;
345
+ goto out;
346
+ }
339
347
 
340
- *exists = git_path_isfile(ref_path.ptr) ||
341
- (git_sortedcache_lookup(backend->refcache, ref_name) != NULL);
348
+ if ((error = packed_reload(backend)) < 0)
349
+ goto out;
350
+
351
+ if (git_sortedcache_lookup(backend->refcache, ref_name) != NULL) {
352
+ *exists = 1;
353
+ goto out;
354
+ }
342
355
 
356
+ out:
343
357
  git_buf_dispose(&ref_path);
344
- return 0;
358
+ return error;
345
359
  }
346
360
 
347
361
  static const char *loose_parse_symbolic(git_buf *file_content)
@@ -352,7 +366,7 @@ static const char *loose_parse_symbolic(git_buf *file_content)
352
366
  refname_start = (const char *)file_content->ptr;
353
367
 
354
368
  if (git_buf_len(file_content) < header_len + 1) {
355
- giterr_set(GITERR_REFERENCE, "corrupted loose reference file");
369
+ git_error_set(GIT_ERROR_REFERENCE, "corrupted loose reference file");
356
370
  return NULL;
357
371
  }
358
372
 
@@ -420,7 +434,7 @@ static int loose_lookup(
420
434
 
421
435
  static int ref_error_notfound(const char *name)
422
436
  {
423
- giterr_set(GITERR_REFERENCE, "reference '%s' not found", name);
437
+ git_error_set(GIT_ERROR_REFERENCE, "reference '%s' not found", name);
424
438
  return GIT_ENOTFOUND;
425
439
  }
426
440
 
@@ -457,7 +471,7 @@ static int refdb_fs_backend__lookup(
457
471
  git_refdb_backend *_backend,
458
472
  const char *ref_name)
459
473
  {
460
- refdb_fs_backend *backend = (refdb_fs_backend *)_backend;
474
+ refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
461
475
  int error;
462
476
 
463
477
  assert(backend);
@@ -468,7 +482,7 @@ static int refdb_fs_backend__lookup(
468
482
  /* only try to lookup this reference on the packfile if it
469
483
  * wasn't found on the loose refs; not if there was a critical error */
470
484
  if (error == GIT_ENOTFOUND) {
471
- giterr_clear();
485
+ git_error_clear();
472
486
  error = packed_lookup(out, backend, ref_name);
473
487
  }
474
488
 
@@ -490,7 +504,7 @@ typedef struct {
490
504
 
491
505
  static void refdb_fs_backend__iterator_free(git_reference_iterator *_iter)
492
506
  {
493
- refdb_fs_iter *iter = (refdb_fs_iter *) _iter;
507
+ refdb_fs_iter *iter = GIT_CONTAINER_OF(_iter, refdb_fs_iter, parent);
494
508
 
495
509
  git_vector_free(&iter->loose);
496
510
  git_pool_clear(&iter->pool);
@@ -552,7 +566,6 @@ static int iter_load_loose_paths(refdb_fs_backend *backend, refdb_fs_iter *iter)
552
566
 
553
567
  while (!error && !git_iterator_advance(&entry, fsit)) {
554
568
  const char *ref_name;
555
- struct packref *ref;
556
569
  char *ref_dup;
557
570
 
558
571
  git_buf_truncate(&path, ref_prefix_len);
@@ -560,15 +573,9 @@ static int iter_load_loose_paths(refdb_fs_backend *backend, refdb_fs_iter *iter)
560
573
  ref_name = git_buf_cstr(&path);
561
574
 
562
575
  if (git__suffixcmp(ref_name, ".lock") == 0 ||
563
- (iter->glob && p_fnmatch(iter->glob, ref_name, 0) != 0))
576
+ (iter->glob && wildmatch(iter->glob, ref_name, 0) != 0))
564
577
  continue;
565
578
 
566
- git_sortedcache_rlock(backend->refcache);
567
- ref = git_sortedcache_lookup(backend->refcache, ref_name);
568
- if (ref)
569
- ref->flags |= PACKREF_SHADOWED;
570
- git_sortedcache_runlock(backend->refcache);
571
-
572
579
  ref_dup = git_pool_strdup(&iter->pool, ref_name);
573
580
  if (!ref_dup)
574
581
  error = -1;
@@ -586,22 +593,22 @@ static int refdb_fs_backend__iterator_next(
586
593
  git_reference **out, git_reference_iterator *_iter)
587
594
  {
588
595
  int error = GIT_ITEROVER;
589
- refdb_fs_iter *iter = (refdb_fs_iter *)_iter;
590
- refdb_fs_backend *backend = (refdb_fs_backend *)iter->parent.db->backend;
596
+ refdb_fs_iter *iter = GIT_CONTAINER_OF(_iter, refdb_fs_iter, parent);
597
+ refdb_fs_backend *backend = GIT_CONTAINER_OF(iter->parent.db->backend, refdb_fs_backend, parent);
591
598
  struct packref *ref;
592
599
 
593
600
  while (iter->loose_pos < iter->loose.length) {
594
601
  const char *path = git_vector_get(&iter->loose, iter->loose_pos++);
595
602
 
596
- if (loose_lookup(out, backend, path) == 0)
597
- return 0;
603
+ if (loose_lookup(out, backend, path) == 0) {
604
+ ref = git_sortedcache_lookup(iter->cache, path);
605
+ if (ref)
606
+ ref->flags |= PACKREF_SHADOWED;
598
607
 
599
- giterr_clear();
600
- }
608
+ return 0;
609
+ }
601
610
 
602
- if (!iter->cache) {
603
- if ((error = git_sortedcache_copy(&iter->cache, backend->refcache, 1, NULL, NULL)) < 0)
604
- return error;
611
+ git_error_clear();
605
612
  }
606
613
 
607
614
  error = GIT_ITEROVER;
@@ -612,7 +619,7 @@ static int refdb_fs_backend__iterator_next(
612
619
 
613
620
  if (ref->flags & PACKREF_SHADOWED)
614
621
  continue;
615
- if (iter->glob && p_fnmatch(iter->glob, ref->name, 0) != 0)
622
+ if (iter->glob && wildmatch(iter->glob, ref->name, 0) != 0)
616
623
  continue;
617
624
 
618
625
  *out = git_reference__alloc(ref->name, &ref->oid, &ref->peel);
@@ -627,24 +634,24 @@ static int refdb_fs_backend__iterator_next_name(
627
634
  const char **out, git_reference_iterator *_iter)
628
635
  {
629
636
  int error = GIT_ITEROVER;
630
- refdb_fs_iter *iter = (refdb_fs_iter *)_iter;
631
- refdb_fs_backend *backend = (refdb_fs_backend *)iter->parent.db->backend;
637
+ refdb_fs_iter *iter = GIT_CONTAINER_OF(_iter, refdb_fs_iter, parent);
638
+ refdb_fs_backend *backend = GIT_CONTAINER_OF(iter->parent.db->backend, refdb_fs_backend, parent);
632
639
  struct packref *ref;
633
640
 
634
641
  while (iter->loose_pos < iter->loose.length) {
635
642
  const char *path = git_vector_get(&iter->loose, iter->loose_pos++);
643
+ struct packref *ref;
636
644
 
637
645
  if (loose_lookup(NULL, backend, path) == 0) {
646
+ ref = git_sortedcache_lookup(iter->cache, path);
647
+ if (ref)
648
+ ref->flags |= PACKREF_SHADOWED;
649
+
638
650
  *out = path;
639
651
  return 0;
640
652
  }
641
653
 
642
- giterr_clear();
643
- }
644
-
645
- if (!iter->cache) {
646
- if ((error = git_sortedcache_copy(&iter->cache, backend->refcache, 1, NULL, NULL)) < 0)
647
- return error;
654
+ git_error_clear();
648
655
  }
649
656
 
650
657
  error = GIT_ITEROVER;
@@ -655,7 +662,7 @@ static int refdb_fs_backend__iterator_next_name(
655
662
 
656
663
  if (ref->flags & PACKREF_SHADOWED)
657
664
  continue;
658
- if (iter->glob && p_fnmatch(iter->glob, ref->name, 0) != 0)
665
+ if (iter->glob && wildmatch(iter->glob, ref->name, 0) != 0)
659
666
  continue;
660
667
 
661
668
  *out = ref->name;
@@ -669,40 +676,44 @@ static int refdb_fs_backend__iterator_next_name(
669
676
  static int refdb_fs_backend__iterator(
670
677
  git_reference_iterator **out, git_refdb_backend *_backend, const char *glob)
671
678
  {
679
+ refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
680
+ refdb_fs_iter *iter = NULL;
672
681
  int error;
673
- refdb_fs_iter *iter;
674
- refdb_fs_backend *backend = (refdb_fs_backend *)_backend;
675
682
 
676
683
  assert(backend);
677
684
 
678
- if ((error = packed_reload(backend)) < 0)
679
- return error;
680
-
681
685
  iter = git__calloc(1, sizeof(refdb_fs_iter));
682
- GITERR_CHECK_ALLOC(iter);
686
+ GIT_ERROR_CHECK_ALLOC(iter);
683
687
 
684
688
  git_pool_init(&iter->pool, 1);
685
689
 
686
- if (git_vector_init(&iter->loose, 8, NULL) < 0)
687
- goto fail;
690
+ if ((error = git_vector_init(&iter->loose, 8, NULL)) < 0)
691
+ goto out;
688
692
 
689
693
  if (glob != NULL &&
690
- (iter->glob = git_pool_strdup(&iter->pool, glob)) == NULL)
691
- goto fail;
694
+ (iter->glob = git_pool_strdup(&iter->pool, glob)) == NULL) {
695
+ error = GIT_ERROR_NOMEMORY;
696
+ goto out;
697
+ }
698
+
699
+ if ((error = iter_load_loose_paths(backend, iter)) < 0)
700
+ goto out;
701
+
702
+ if ((error = packed_reload(backend)) < 0)
703
+ goto out;
704
+
705
+ if ((error = git_sortedcache_copy(&iter->cache, backend->refcache, 1, NULL, NULL)) < 0)
706
+ goto out;
692
707
 
693
708
  iter->parent.next = refdb_fs_backend__iterator_next;
694
709
  iter->parent.next_name = refdb_fs_backend__iterator_next_name;
695
710
  iter->parent.free = refdb_fs_backend__iterator_free;
696
711
 
697
- if (iter_load_loose_paths(backend, iter) < 0)
698
- goto fail;
699
-
700
712
  *out = (git_reference_iterator *)iter;
701
- return 0;
702
-
703
- fail:
704
- refdb_fs_backend__iterator_free((git_reference_iterator *)iter);
705
- return -1;
713
+ out:
714
+ if (error)
715
+ refdb_fs_backend__iterator_free((git_reference_iterator *)iter);
716
+ return error;
706
717
  }
707
718
 
708
719
  static bool ref_is_available(
@@ -743,7 +754,7 @@ static int reference_path_available(
743
754
  }
744
755
 
745
756
  if (exists) {
746
- giterr_set(GITERR_REFERENCE,
757
+ git_error_set(GIT_ERROR_REFERENCE,
747
758
  "failed to write reference '%s': a reference with "
748
759
  "that name already exists.", new_ref);
749
760
  return GIT_EEXISTS;
@@ -757,7 +768,7 @@ static int reference_path_available(
757
768
 
758
769
  if (ref && !ref_is_available(old_ref, new_ref, ref->name)) {
759
770
  git_sortedcache_runlock(backend->refcache);
760
- giterr_set(GITERR_REFERENCE,
771
+ git_error_set(GIT_ERROR_REFERENCE,
761
772
  "path to reference '%s' collides with existing one", new_ref);
762
773
  return -1;
763
774
  }
@@ -776,7 +787,7 @@ static int loose_lock(git_filebuf *file, refdb_fs_backend *backend, const char *
776
787
  assert(file && backend && name);
777
788
 
778
789
  if (!git_path_isvalid(backend->repo, name, 0, GIT_PATH_REJECT_FILESYSTEM_DEFAULTS)) {
779
- giterr_set(GITERR_INVALID, "invalid reference name '%s'", name);
790
+ git_error_set(GIT_ERROR_INVALID, "invalid reference name '%s'", name);
780
791
  return GIT_EINVALIDSPEC;
781
792
  }
782
793
 
@@ -794,14 +805,14 @@ static int loose_lock(git_filebuf *file, refdb_fs_backend *backend, const char *
794
805
  if (git_buf_joinpath(&ref_path, basedir, name) < 0)
795
806
  return -1;
796
807
 
797
- filebuf_flags = GIT_FILEBUF_FORCE;
808
+ filebuf_flags = GIT_FILEBUF_CREATE_LEADING_DIRS;
798
809
  if (backend->fsync)
799
810
  filebuf_flags |= GIT_FILEBUF_FSYNC;
800
811
 
801
812
  error = git_filebuf_open(file, ref_path.ptr, filebuf_flags, GIT_REFS_FILE_MODE);
802
813
 
803
814
  if (error == GIT_EDIRECTORY)
804
- giterr_set(GITERR_REFERENCE, "cannot lock ref '%s', there are refs beneath that folder", name);
815
+ git_error_set(GIT_ERROR_REFERENCE, "cannot lock ref '%s', there are refs beneath that folder", name);
805
816
 
806
817
  git_buf_dispose(&ref_path);
807
818
  return error;
@@ -811,12 +822,12 @@ static int loose_commit(git_filebuf *file, const git_reference *ref)
811
822
  {
812
823
  assert(file && ref);
813
824
 
814
- if (ref->type == GIT_REF_OID) {
825
+ if (ref->type == GIT_REFERENCE_DIRECT) {
815
826
  char oid[GIT_OID_HEXSZ + 1];
816
827
  git_oid_nfmt(oid, sizeof(oid), &ref->target.oid);
817
828
 
818
829
  git_filebuf_printf(file, "%s\n", oid);
819
- } else if (ref->type == GIT_REF_SYMBOLIC) {
830
+ } else if (ref->type == GIT_REFERENCE_SYMBOLIC) {
820
831
  git_filebuf_printf(file, GIT_SYMREF "%s\n", ref->target.symbolic);
821
832
  } else {
822
833
  assert(0); /* don't let this happen */
@@ -829,10 +840,10 @@ static int refdb_fs_backend__lock(void **out, git_refdb_backend *_backend, const
829
840
  {
830
841
  int error;
831
842
  git_filebuf *lock;
832
- refdb_fs_backend *backend = (refdb_fs_backend *) _backend;
843
+ refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
833
844
 
834
845
  lock = git__calloc(1, sizeof(git_filebuf));
835
- GITERR_CHECK_ALLOC(lock);
846
+ GIT_ERROR_CHECK_ALLOC(lock);
836
847
 
837
848
  if ((error = loose_lock(lock, backend, refname)) < 0) {
838
849
  git__free(lock);
@@ -848,16 +859,17 @@ static int refdb_fs_backend__write_tail(
848
859
  const git_reference *ref,
849
860
  git_filebuf *file,
850
861
  int update_reflog,
851
- const git_signature *who,
852
- const char *message,
853
862
  const git_oid *old_id,
854
- const char *old_target);
863
+ const char *old_target,
864
+ const git_signature *who,
865
+ const char *message);
855
866
 
856
867
  static int refdb_fs_backend__delete_tail(
857
868
  git_refdb_backend *_backend,
858
869
  git_filebuf *file,
859
870
  const char *ref_name,
860
- const git_oid *old_id, const char *old_target);
871
+ const git_oid *old_id,
872
+ const char *old_target);
861
873
 
862
874
  static int refdb_fs_backend__unlock(git_refdb_backend *backend, void *payload, int success, int update_reflog,
863
875
  const git_reference *ref, const git_signature *sig, const char *message)
@@ -868,7 +880,7 @@ static int refdb_fs_backend__unlock(git_refdb_backend *backend, void *payload, i
868
880
  if (success == 2)
869
881
  error = refdb_fs_backend__delete_tail(backend, lock, ref->name, NULL, NULL);
870
882
  else if (success)
871
- error = refdb_fs_backend__write_tail(backend, ref, lock, update_reflog, sig, message, NULL, NULL);
883
+ error = refdb_fs_backend__write_tail(backend, ref, lock, update_reflog, NULL, NULL, sig, message);
872
884
  else
873
885
  git_filebuf_cleanup(lock);
874
886
 
@@ -894,7 +906,7 @@ static int packed_find_peel(refdb_fs_backend *backend, struct packref *ref)
894
906
  /*
895
907
  * Find the tagged object in the repository
896
908
  */
897
- if (git_object_lookup(&object, backend->repo, &ref->oid, GIT_OBJ_ANY) < 0)
909
+ if (git_object_lookup(&object, backend->repo, &ref->oid, GIT_OBJECT_ANY) < 0)
898
910
  return -1;
899
911
 
900
912
  /*
@@ -902,7 +914,7 @@ static int packed_find_peel(refdb_fs_backend *backend, struct packref *ref)
902
914
  * if the ref is actually a 'weak' ref, we don't need to resolve
903
915
  * anything.
904
916
  */
905
- if (git_object_type(object) == GIT_OBJ_TAG) {
917
+ if (git_object_type(object) == GIT_OBJECT_TAG) {
906
918
  git_tag *tag = (git_tag *)object;
907
919
 
908
920
  /*
@@ -991,7 +1003,7 @@ static int packed_remove_loose(refdb_fs_backend *backend)
991
1003
 
992
1004
  if (error < 0) {
993
1005
  git_buf_dispose(&ref_content);
994
- giterr_set(GITERR_REFERENCE, "failed to lock loose reference '%s'", ref->name);
1006
+ git_error_set(GIT_ERROR_REFERENCE, "failed to lock loose reference '%s'", ref->name);
995
1007
  return error;
996
1008
  }
997
1009
 
@@ -1087,15 +1099,43 @@ fail:
1087
1099
  return error;
1088
1100
  }
1089
1101
 
1102
+ static int packed_delete(refdb_fs_backend *backend, const char *ref_name)
1103
+ {
1104
+ size_t pack_pos;
1105
+ int error, found = 0;
1106
+
1107
+ if ((error = packed_reload(backend)) < 0)
1108
+ goto cleanup;
1109
+
1110
+ if ((error = git_sortedcache_wlock(backend->refcache)) < 0)
1111
+ goto cleanup;
1112
+
1113
+ /* If a packed reference exists, remove it from the packfile and repack if necessary */
1114
+ error = git_sortedcache_lookup_index(&pack_pos, backend->refcache, ref_name);
1115
+ if (error == 0) {
1116
+ error = git_sortedcache_remove(backend->refcache, pack_pos);
1117
+ found = 1;
1118
+ }
1119
+ if (error == GIT_ENOTFOUND)
1120
+ error = 0;
1121
+
1122
+ git_sortedcache_wunlock(backend->refcache);
1123
+
1124
+ if (found)
1125
+ error = packed_write(backend);
1126
+
1127
+ cleanup:
1128
+ return error;
1129
+ }
1130
+
1090
1131
  static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, const git_oid *old, const git_oid *new, const git_signature *author, const char *message);
1091
1132
  static int has_reflog(git_repository *repo, const char *name);
1092
1133
 
1093
- /* We only write if it's under heads/, remotes/ or notes/ or if it already has a log */
1094
1134
  static int should_write_reflog(int *write, git_repository *repo, const char *name)
1095
1135
  {
1096
1136
  int error, logall;
1097
1137
 
1098
- error = git_repository__cvar(&logall, repo, GIT_CVAR_LOGALLREFUPDATES);
1138
+ error = git_repository__configmap_lookup(&logall, repo, GIT_CONFIGMAP_LOGALLREFUPDATES);
1099
1139
  if (error < 0)
1100
1140
  return error;
1101
1141
 
@@ -1103,17 +1143,26 @@ static int should_write_reflog(int *write, git_repository *repo, const char *nam
1103
1143
  if (logall == GIT_LOGALLREFUPDATES_UNSET)
1104
1144
  logall = !git_repository_is_bare(repo);
1105
1145
 
1106
- if (!logall) {
1146
+ *write = 0;
1147
+ switch (logall) {
1148
+ case GIT_LOGALLREFUPDATES_FALSE:
1107
1149
  *write = 0;
1108
- } else if (has_reflog(repo, name)) {
1109
- *write = 1;
1110
- } else if (!git__prefixcmp(name, GIT_REFS_HEADS_DIR) ||
1111
- !git__strcmp(name, GIT_HEAD_FILE) ||
1112
- !git__prefixcmp(name, GIT_REFS_REMOTES_DIR) ||
1113
- !git__prefixcmp(name, GIT_REFS_NOTES_DIR)) {
1150
+ break;
1151
+
1152
+ case GIT_LOGALLREFUPDATES_TRUE:
1153
+ /* Only write if it already has a log,
1154
+ * or if it's under heads/, remotes/ or notes/
1155
+ */
1156
+ *write = has_reflog(repo, name) ||
1157
+ !git__prefixcmp(name, GIT_REFS_HEADS_DIR) ||
1158
+ !git__strcmp(name, GIT_HEAD_FILE) ||
1159
+ !git__prefixcmp(name, GIT_REFS_REMOTES_DIR) ||
1160
+ !git__prefixcmp(name, GIT_REFS_NOTES_DIR);
1161
+ break;
1162
+
1163
+ case GIT_LOGALLREFUPDATES_ALWAYS:
1114
1164
  *write = 1;
1115
- } else {
1116
- *write = 0;
1165
+ break;
1117
1166
  }
1118
1167
 
1119
1168
  return 0;
@@ -1134,19 +1183,19 @@ static int cmp_old_ref(int *cmp, git_refdb_backend *backend, const char *name,
1134
1183
  goto out;
1135
1184
 
1136
1185
  /* If the types don't match, there's no way the values do */
1137
- if (old_id && old_ref->type != GIT_REF_OID) {
1186
+ if (old_id && old_ref->type != GIT_REFERENCE_DIRECT) {
1138
1187
  *cmp = -1;
1139
1188
  goto out;
1140
1189
  }
1141
- if (old_target && old_ref->type != GIT_REF_SYMBOLIC) {
1190
+ if (old_target && old_ref->type != GIT_REFERENCE_SYMBOLIC) {
1142
1191
  *cmp = 1;
1143
1192
  goto out;
1144
1193
  }
1145
1194
 
1146
- if (old_id && old_ref->type == GIT_REF_OID)
1195
+ if (old_id && old_ref->type == GIT_REFERENCE_DIRECT)
1147
1196
  *cmp = git_oid_cmp(old_id, &old_ref->target.oid);
1148
1197
 
1149
- if (old_target && old_ref->type == GIT_REF_SYMBOLIC)
1198
+ if (old_target && old_ref->type == GIT_REFERENCE_SYMBOLIC)
1150
1199
  *cmp = git__strcmp(old_target, old_ref->target.symbolic);
1151
1200
 
1152
1201
  out:
@@ -1176,7 +1225,7 @@ static int maybe_append_head(refdb_fs_backend *backend, const git_reference *ref
1176
1225
  git_reference *tmp = NULL, *head = NULL, *peeled = NULL;
1177
1226
  const char *name;
1178
1227
 
1179
- if (ref->type == GIT_REF_SYMBOLIC)
1228
+ if (ref->type == GIT_REFERENCE_SYMBOLIC)
1180
1229
  return 0;
1181
1230
 
1182
1231
  /* if we can't resolve, we use {0}*40 as old id */
@@ -1186,14 +1235,14 @@ static int maybe_append_head(refdb_fs_backend *backend, const git_reference *ref
1186
1235
  if ((error = git_reference_lookup(&head, backend->repo, GIT_HEAD_FILE)) < 0)
1187
1236
  return error;
1188
1237
 
1189
- if (git_reference_type(head) == GIT_REF_OID)
1238
+ if (git_reference_type(head) == GIT_REFERENCE_DIRECT)
1190
1239
  goto cleanup;
1191
1240
 
1192
1241
  if ((error = git_reference_lookup(&tmp, backend->repo, GIT_HEAD_FILE)) < 0)
1193
1242
  goto cleanup;
1194
1243
 
1195
1244
  /* Go down the symref chain until we find the branch */
1196
- while (git_reference_type(tmp) == GIT_REF_SYMBOLIC) {
1245
+ while (git_reference_type(tmp) == GIT_REFERENCE_SYMBOLIC) {
1197
1246
  error = git_reference_lookup(&peeled, backend->repo, git_reference_symbolic_target(tmp));
1198
1247
  if (error < 0)
1199
1248
  break;
@@ -1231,7 +1280,7 @@ static int refdb_fs_backend__write(
1231
1280
  const git_oid *old_id,
1232
1281
  const char *old_target)
1233
1282
  {
1234
- refdb_fs_backend *backend = (refdb_fs_backend *)_backend;
1283
+ refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1235
1284
  git_filebuf file = GIT_FILEBUF_INIT;
1236
1285
  int error = 0;
1237
1286
 
@@ -1244,7 +1293,7 @@ static int refdb_fs_backend__write(
1244
1293
  if ((error = loose_lock(&file, backend, ref->name)) < 0)
1245
1294
  return error;
1246
1295
 
1247
- return refdb_fs_backend__write_tail(_backend, ref, &file, true, who, message, old_id, old_target);
1296
+ return refdb_fs_backend__write_tail(_backend, ref, &file, true, old_id, old_target, who, message);
1248
1297
  }
1249
1298
 
1250
1299
  static int refdb_fs_backend__write_tail(
@@ -1252,12 +1301,12 @@ static int refdb_fs_backend__write_tail(
1252
1301
  const git_reference *ref,
1253
1302
  git_filebuf *file,
1254
1303
  int update_reflog,
1255
- const git_signature *who,
1256
- const char *message,
1257
1304
  const git_oid *old_id,
1258
- const char *old_target)
1305
+ const char *old_target,
1306
+ const git_signature *who,
1307
+ const char *message)
1259
1308
  {
1260
- refdb_fs_backend *backend = (refdb_fs_backend *)_backend;
1309
+ refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1261
1310
  int error = 0, cmp = 0, should_write;
1262
1311
  const char *new_target = NULL;
1263
1312
  const git_oid *new_id = NULL;
@@ -1266,12 +1315,12 @@ static int refdb_fs_backend__write_tail(
1266
1315
  goto on_error;
1267
1316
 
1268
1317
  if (cmp) {
1269
- giterr_set(GITERR_REFERENCE, "old reference value does not match");
1318
+ git_error_set(GIT_ERROR_REFERENCE, "old reference value does not match");
1270
1319
  error = GIT_EMODIFIED;
1271
1320
  goto on_error;
1272
1321
  }
1273
1322
 
1274
- if (ref->type == GIT_REF_SYMBOLIC)
1323
+ if (ref->type == GIT_REFERENCE_SYMBOLIC)
1275
1324
  new_target = ref->target.symbolic;
1276
1325
  else
1277
1326
  new_id = &ref->target.oid;
@@ -1305,12 +1354,49 @@ on_error:
1305
1354
  return error;
1306
1355
  }
1307
1356
 
1357
+ static void refdb_fs_backend__prune_refs(
1358
+ refdb_fs_backend *backend,
1359
+ const char *ref_name,
1360
+ const char *prefix)
1361
+ {
1362
+ git_buf relative_path = GIT_BUF_INIT;
1363
+ git_buf base_path = GIT_BUF_INIT;
1364
+ size_t commonlen;
1365
+
1366
+ assert(backend && ref_name);
1367
+
1368
+ if (git_buf_sets(&relative_path, ref_name) < 0)
1369
+ goto cleanup;
1370
+
1371
+ git_path_squash_slashes(&relative_path);
1372
+ if ((commonlen = git_path_common_dirlen("refs/heads/", git_buf_cstr(&relative_path))) == strlen("refs/heads/") ||
1373
+ (commonlen = git_path_common_dirlen("refs/tags/", git_buf_cstr(&relative_path))) == strlen("refs/tags/") ||
1374
+ (commonlen = git_path_common_dirlen("refs/remotes/", git_buf_cstr(&relative_path))) == strlen("refs/remotes/")) {
1375
+
1376
+ git_buf_truncate(&relative_path, commonlen);
1377
+
1378
+ if (prefix) {
1379
+ if (git_buf_join3(&base_path, '/', backend->commonpath, prefix, git_buf_cstr(&relative_path)) < 0)
1380
+ goto cleanup;
1381
+ } else {
1382
+ if (git_buf_joinpath(&base_path, backend->commonpath, git_buf_cstr(&relative_path)) < 0)
1383
+ goto cleanup;
1384
+ }
1385
+
1386
+ git_futils_rmdir_r(ref_name + commonlen, git_buf_cstr(&base_path), GIT_RMDIR_EMPTY_PARENTS | GIT_RMDIR_SKIP_ROOT);
1387
+ }
1388
+
1389
+ cleanup:
1390
+ git_buf_dispose(&relative_path);
1391
+ git_buf_dispose(&base_path);
1392
+ }
1393
+
1308
1394
  static int refdb_fs_backend__delete(
1309
1395
  git_refdb_backend *_backend,
1310
1396
  const char *ref_name,
1311
1397
  const git_oid *old_id, const char *old_target)
1312
1398
  {
1313
- refdb_fs_backend *backend = (refdb_fs_backend *)_backend;
1399
+ refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1314
1400
  git_filebuf file = GIT_FILEBUF_INIT;
1315
1401
  int error = 0;
1316
1402
 
@@ -1327,65 +1413,80 @@ static int refdb_fs_backend__delete(
1327
1413
  return refdb_fs_backend__delete_tail(_backend, &file, ref_name, old_id, old_target);
1328
1414
  }
1329
1415
 
1416
+ static int loose_delete(refdb_fs_backend *backend, const char *ref_name)
1417
+ {
1418
+ git_buf loose_path = GIT_BUF_INIT;
1419
+ int error = 0;
1420
+
1421
+ if (git_buf_joinpath(&loose_path, backend->commonpath, ref_name) < 0)
1422
+ return -1;
1423
+
1424
+ error = p_unlink(loose_path.ptr);
1425
+ if (error < 0 && errno == ENOENT)
1426
+ error = GIT_ENOTFOUND;
1427
+ else if (error != 0)
1428
+ error = -1;
1429
+
1430
+ git_buf_dispose(&loose_path);
1431
+
1432
+ return error;
1433
+ }
1434
+
1330
1435
  static int refdb_fs_backend__delete_tail(
1331
1436
  git_refdb_backend *_backend,
1332
1437
  git_filebuf *file,
1333
1438
  const char *ref_name,
1334
1439
  const git_oid *old_id, const char *old_target)
1335
1440
  {
1336
- refdb_fs_backend *backend = (refdb_fs_backend *)_backend;
1337
- git_buf loose_path = GIT_BUF_INIT;
1338
- size_t pack_pos;
1441
+ refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1339
1442
  int error = 0, cmp = 0;
1340
- bool loose_deleted = 0;
1443
+ bool packed_deleted = 0;
1341
1444
 
1342
1445
  error = cmp_old_ref(&cmp, _backend, ref_name, old_id, old_target);
1343
1446
  if (error < 0)
1344
1447
  goto cleanup;
1345
1448
 
1346
1449
  if (cmp) {
1347
- giterr_set(GITERR_REFERENCE, "old reference value does not match");
1450
+ git_error_set(GIT_ERROR_REFERENCE, "old reference value does not match");
1348
1451
  error = GIT_EMODIFIED;
1349
1452
  goto cleanup;
1350
1453
  }
1351
1454
 
1352
- /* If a loose reference exists, remove it from the filesystem */
1353
- if (git_buf_joinpath(&loose_path, backend->commonpath, ref_name) < 0)
1354
- return -1;
1355
-
1356
-
1357
- error = p_unlink(loose_path.ptr);
1358
- if (error < 0 && errno == ENOENT)
1359
- error = 0;
1360
- else if (error < 0)
1455
+ /*
1456
+ * To ensure that an external observer will see either the current ref value
1457
+ * (because the loose ref still exists), or a missing ref (after the packed-file is
1458
+ * unlocked, there will be nothing left), we must ensure things happen in the
1459
+ * following order:
1460
+ *
1461
+ * - the packed-ref file is locked and loaded, as well as a loose one, if it exists
1462
+ * - we optimistically delete a packed ref, keeping track of whether it existed
1463
+ * - we delete the loose ref, note that we have its .lock
1464
+ * - the loose ref is "unlocked", then the packed-ref file is rewritten and unlocked
1465
+ * - we should prune the path components if a loose ref was deleted
1466
+ *
1467
+ * Note that, because our packed backend doesn't expose its filesystem lock,
1468
+ * we might not be able to guarantee that this is what actually happens (ie.
1469
+ * as our current code never write packed-refs.lock, nothing stops observers
1470
+ * from grabbing a "stale" value from there).
1471
+ */
1472
+ if ((error = packed_delete(backend, ref_name)) < 0 && error != GIT_ENOTFOUND)
1361
1473
  goto cleanup;
1362
- else if (error == 0)
1363
- loose_deleted = 1;
1364
1474
 
1365
- if ((error = packed_reload(backend)) < 0)
1366
- goto cleanup;
1475
+ if (error == 0)
1476
+ packed_deleted = 1;
1367
1477
 
1368
- /* If a packed reference exists, remove it from the packfile and repack */
1369
- if ((error = git_sortedcache_wlock(backend->refcache)) < 0)
1478
+ if ((error = loose_delete(backend, ref_name)) < 0 && error != GIT_ENOTFOUND)
1370
1479
  goto cleanup;
1371
1480
 
1372
- if (!(error = git_sortedcache_lookup_index(
1373
- &pack_pos, backend->refcache, ref_name)))
1374
- error = git_sortedcache_remove(backend->refcache, pack_pos);
1375
-
1376
- git_sortedcache_wunlock(backend->refcache);
1377
-
1378
1481
  if (error == GIT_ENOTFOUND) {
1379
- error = loose_deleted ? 0 : ref_error_notfound(ref_name);
1482
+ error = packed_deleted ? 0 : ref_error_notfound(ref_name);
1380
1483
  goto cleanup;
1381
1484
  }
1382
1485
 
1383
- error = packed_write(backend);
1384
-
1385
1486
  cleanup:
1386
- git_buf_dispose(&loose_path);
1387
1487
  git_filebuf_cleanup(file);
1388
-
1488
+ if (error == 0)
1489
+ refdb_fs_backend__prune_refs(backend, ref_name, "");
1389
1490
  return error;
1390
1491
  }
1391
1492
 
@@ -1400,7 +1501,7 @@ static int refdb_fs_backend__rename(
1400
1501
  const git_signature *who,
1401
1502
  const char *message)
1402
1503
  {
1403
- refdb_fs_backend *backend = (refdb_fs_backend *)_backend;
1504
+ refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1404
1505
  git_reference *old, *new;
1405
1506
  git_filebuf file = GIT_FILEBUF_INIT;
1406
1507
  int error;
@@ -1456,7 +1557,7 @@ static int refdb_fs_backend__rename(
1456
1557
  static int refdb_fs_backend__compress(git_refdb_backend *_backend)
1457
1558
  {
1458
1559
  int error;
1459
- refdb_fs_backend *backend = (refdb_fs_backend *)_backend;
1560
+ refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1460
1561
 
1461
1562
  assert(backend);
1462
1563
 
@@ -1470,7 +1571,7 @@ static int refdb_fs_backend__compress(git_refdb_backend *_backend)
1470
1571
 
1471
1572
  static void refdb_fs_backend__free(git_refdb_backend *_backend)
1472
1573
  {
1473
- refdb_fs_backend *backend = (refdb_fs_backend *)_backend;
1574
+ refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1474
1575
 
1475
1576
  assert(backend);
1476
1577
 
@@ -1533,10 +1634,10 @@ static int reflog_alloc(git_reflog **reflog, const char *name)
1533
1634
  *reflog = NULL;
1534
1635
 
1535
1636
  log = git__calloc(1, sizeof(git_reflog));
1536
- GITERR_CHECK_ALLOC(log);
1637
+ GIT_ERROR_CHECK_ALLOC(log);
1537
1638
 
1538
1639
  log->ref_name = git__strdup(name);
1539
- GITERR_CHECK_ALLOC(log->ref_name);
1640
+ GIT_ERROR_CHECK_ALLOC(log->ref_name);
1540
1641
 
1541
1642
  if (git_vector_init(&log->entries, 0, NULL) < 0) {
1542
1643
  git__free(log->ref_name);
@@ -1551,70 +1652,57 @@ static int reflog_alloc(git_reflog **reflog, const char *name)
1551
1652
 
1552
1653
  static int reflog_parse(git_reflog *log, const char *buf, size_t buf_size)
1553
1654
  {
1554
- const char *ptr;
1555
- git_reflog_entry *entry;
1655
+ git_parse_ctx parser = GIT_PARSE_CTX_INIT;
1556
1656
 
1557
- #define seek_forward(_increase) do { \
1558
- if (_increase >= buf_size) { \
1559
- giterr_set(GITERR_INVALID, "ran out of data while parsing reflog"); \
1560
- goto fail; \
1561
- } \
1562
- buf += _increase; \
1563
- buf_size -= _increase; \
1564
- } while (0)
1657
+ if ((git_parse_ctx_init(&parser, buf, buf_size)) < 0)
1658
+ return -1;
1565
1659
 
1566
- while (buf_size > GIT_REFLOG_SIZE_MIN) {
1567
- entry = git__calloc(1, sizeof(git_reflog_entry));
1568
- GITERR_CHECK_ALLOC(entry);
1660
+ for (; parser.remain_len; git_parse_advance_line(&parser)) {
1661
+ git_reflog_entry *entry;
1662
+ const char *sig;
1663
+ char c;
1569
1664
 
1570
- entry->committer = git__calloc(1, sizeof(git_signature));
1571
- GITERR_CHECK_ALLOC(entry->committer);
1665
+ entry = git__calloc(1, sizeof(*entry));
1666
+ GIT_ERROR_CHECK_ALLOC(entry);
1667
+ entry->committer = git__calloc(1, sizeof(*entry->committer));
1668
+ GIT_ERROR_CHECK_ALLOC(entry->committer);
1572
1669
 
1573
- if (git_oid_fromstrn(&entry->oid_old, buf, GIT_OID_HEXSZ) < 0)
1574
- goto fail;
1575
- seek_forward(GIT_OID_HEXSZ + 1);
1670
+ if (git_parse_advance_oid(&entry->oid_old, &parser) < 0 ||
1671
+ git_parse_advance_expected(&parser, " ", 1) < 0 ||
1672
+ git_parse_advance_oid(&entry->oid_cur, &parser) < 0)
1673
+ goto next;
1576
1674
 
1577
- if (git_oid_fromstrn(&entry->oid_cur, buf, GIT_OID_HEXSZ) < 0)
1578
- goto fail;
1579
- seek_forward(GIT_OID_HEXSZ + 1);
1580
-
1581
- ptr = buf;
1675
+ sig = parser.line;
1676
+ while (git_parse_peek(&c, &parser, 0) == 0 && c != '\t' && c != '\n')
1677
+ git_parse_advance_chars(&parser, 1);
1582
1678
 
1583
- /* Seek forward to the end of the signature. */
1584
- while (*buf && *buf != '\t' && *buf != '\n')
1585
- seek_forward(1);
1679
+ if (git_signature__parse(entry->committer, &sig, parser.line, NULL, 0) < 0)
1680
+ goto next;
1586
1681
 
1587
- if (git_signature__parse(entry->committer, &ptr, buf + 1, NULL, *buf) < 0)
1588
- goto fail;
1682
+ if (c == '\t') {
1683
+ size_t len;
1684
+ git_parse_advance_chars(&parser, 1);
1589
1685
 
1590
- if (*buf == '\t') {
1591
- /* We got a message. Read everything till we reach LF. */
1592
- seek_forward(1);
1593
- ptr = buf;
1686
+ len = parser.line_len;
1687
+ if (parser.line[len - 1] == '\n')
1688
+ len--;
1594
1689
 
1595
- while (*buf && *buf != '\n')
1596
- seek_forward(1);
1690
+ entry->msg = git__strndup(parser.line, len);
1691
+ GIT_ERROR_CHECK_ALLOC(entry->msg);
1692
+ }
1597
1693
 
1598
- entry->msg = git__strndup(ptr, buf - ptr);
1599
- GITERR_CHECK_ALLOC(entry->msg);
1600
- } else
1601
- entry->msg = NULL;
1694
+ if ((git_vector_insert(&log->entries, entry)) < 0) {
1695
+ git_reflog_entry__free(entry);
1696
+ return -1;
1697
+ }
1602
1698
 
1603
- while (*buf && *buf == '\n' && buf_size > 1)
1604
- seek_forward(1);
1699
+ continue;
1605
1700
 
1606
- if (git_vector_insert(&log->entries, entry) < 0)
1607
- goto fail;
1701
+ next:
1702
+ git_reflog_entry__free(entry);
1608
1703
  }
1609
1704
 
1610
1705
  return 0;
1611
-
1612
- #undef seek_forward
1613
-
1614
- fail:
1615
- git_reflog_entry__free(entry);
1616
-
1617
- return -1;
1618
1706
  }
1619
1707
 
1620
1708
  static int create_new_reflog_file(const char *filepath)
@@ -1648,7 +1736,7 @@ static int refdb_reflog_fs__ensure_log(git_refdb_backend *_backend, const char *
1648
1736
 
1649
1737
  assert(_backend && name);
1650
1738
 
1651
- backend = (refdb_fs_backend *) _backend;
1739
+ backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1652
1740
  repo = backend->repo;
1653
1741
 
1654
1742
  if ((error = retrieve_reflog_path(&path, repo, name)) < 0)
@@ -1681,7 +1769,7 @@ static int refdb_reflog_fs__has_log(git_refdb_backend *_backend, const char *nam
1681
1769
 
1682
1770
  assert(_backend && name);
1683
1771
 
1684
- backend = (refdb_fs_backend *) _backend;
1772
+ backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1685
1773
 
1686
1774
  return has_reflog(backend->repo, name);
1687
1775
  }
@@ -1697,7 +1785,7 @@ static int refdb_reflog_fs__read(git_reflog **out, git_refdb_backend *_backend,
1697
1785
 
1698
1786
  assert(out && _backend && name);
1699
1787
 
1700
- backend = (refdb_fs_backend *) _backend;
1788
+ backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1701
1789
  repo = backend->repo;
1702
1790
 
1703
1791
  if (reflog_alloc(&log, name) < 0)
@@ -1713,7 +1801,7 @@ static int refdb_reflog_fs__read(git_reflog **out, git_refdb_backend *_backend,
1713
1801
  if ((error == GIT_ENOTFOUND) &&
1714
1802
  ((error = create_new_reflog_file(git_buf_cstr(&log_path))) < 0))
1715
1803
  goto cleanup;
1716
-
1804
+
1717
1805
  if ((error = reflog_parse(log,
1718
1806
  git_buf_cstr(&log_file), git_buf_len(&log_file))) < 0)
1719
1807
  goto cleanup;
@@ -1756,8 +1844,15 @@ static int serialize_reflog_entry(
1756
1844
  git_buf_rtrim(buf);
1757
1845
 
1758
1846
  if (msg) {
1847
+ size_t i;
1848
+
1759
1849
  git_buf_putc(buf, '\t');
1760
1850
  git_buf_puts(buf, msg);
1851
+
1852
+ for (i = 0; i < buf->size - 2; i++)
1853
+ if (buf->ptr[i] == '\n')
1854
+ buf->ptr[i] = ' ';
1855
+ git_buf_rtrim(buf);
1761
1856
  }
1762
1857
 
1763
1858
  git_buf_putc(buf, '\n');
@@ -1774,7 +1869,7 @@ static int lock_reflog(git_filebuf *file, refdb_fs_backend *backend, const char
1774
1869
  repo = backend->repo;
1775
1870
 
1776
1871
  if (!git_path_isvalid(backend->repo, refname, 0, GIT_PATH_REJECT_FILESYSTEM_DEFAULTS)) {
1777
- giterr_set(GITERR_INVALID, "invalid reference name '%s'", refname);
1872
+ git_error_set(GIT_ERROR_INVALID, "invalid reference name '%s'", refname);
1778
1873
  return GIT_EINVALIDSPEC;
1779
1874
  }
1780
1875
 
@@ -1782,7 +1877,7 @@ static int lock_reflog(git_filebuf *file, refdb_fs_backend *backend, const char
1782
1877
  return -1;
1783
1878
 
1784
1879
  if (!git_path_isfile(git_buf_cstr(&log_path))) {
1785
- giterr_set(GITERR_INVALID,
1880
+ git_error_set(GIT_ERROR_INVALID,
1786
1881
  "log file for reference '%s' doesn't exist", refname);
1787
1882
  error = -1;
1788
1883
  goto cleanup;
@@ -1807,7 +1902,7 @@ static int refdb_reflog_fs__write(git_refdb_backend *_backend, git_reflog *reflo
1807
1902
 
1808
1903
  assert(_backend && reflog);
1809
1904
 
1810
- backend = (refdb_fs_backend *) _backend;
1905
+ backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1811
1906
 
1812
1907
  if ((error = lock_reflog(&fbuf, backend, reflog->ref_name)) < 0)
1813
1908
  return -1;
@@ -1840,7 +1935,7 @@ static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, co
1840
1935
  git_buf buf = GIT_BUF_INIT, path = GIT_BUF_INIT;
1841
1936
  git_repository *repo = backend->repo;
1842
1937
 
1843
- is_symbolic = ref->type == GIT_REF_SYMBOLIC;
1938
+ is_symbolic = ref->type == GIT_REFERENCE_SYMBOLIC;
1844
1939
 
1845
1940
  /* "normal" symbolic updates do not write */
1846
1941
  if (is_symbolic &&
@@ -1848,7 +1943,7 @@ static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, co
1848
1943
  !(old && new))
1849
1944
  return 0;
1850
1945
 
1851
- /* From here on is_symoblic also means that it's HEAD */
1946
+ /* From here on is_symbolic also means that it's HEAD */
1852
1947
 
1853
1948
  if (old) {
1854
1949
  git_oid_cpy(&old_id, old);
@@ -1871,7 +1966,7 @@ static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, co
1871
1966
  if (error == GIT_ENOTFOUND)
1872
1967
  return 0;
1873
1968
 
1874
- giterr_clear();
1969
+ git_error_clear();
1875
1970
  }
1876
1971
  }
1877
1972
 
@@ -1894,7 +1989,7 @@ static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, co
1894
1989
  if (error == GIT_ENOTFOUND)
1895
1990
  error = 0;
1896
1991
  } else if (git_path_isdir(git_buf_cstr(&path))) {
1897
- giterr_set(GITERR_REFERENCE, "cannot create reflog at '%s', there are reflogs beneath that folder",
1992
+ git_error_set(GIT_ERROR_REFERENCE, "cannot create reflog at '%s', there are reflogs beneath that folder",
1898
1993
  ref->name);
1899
1994
  error = GIT_EDIRECTORY;
1900
1995
  }
@@ -1929,11 +2024,11 @@ static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_
1929
2024
 
1930
2025
  assert(_backend && old_name && new_name);
1931
2026
 
1932
- backend = (refdb_fs_backend *) _backend;
2027
+ backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1933
2028
  repo = backend->repo;
1934
2029
 
1935
2030
  if ((error = git_reference__normalize_name(
1936
- &normalized, new_name, GIT_REF_FORMAT_ALLOW_ONELEVEL)) < 0)
2031
+ &normalized, new_name, GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL)) < 0)
1937
2032
  return error;
1938
2033
 
1939
2034
  if (git_buf_joinpath(&temp_path, repo->gitdir, GIT_REFLOG_DIR) < 0)
@@ -1968,12 +2063,12 @@ static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_
1968
2063
  p_close(fd);
1969
2064
 
1970
2065
  if (p_rename(git_buf_cstr(&old_path), git_buf_cstr(&temp_path)) < 0) {
1971
- giterr_set(GITERR_OS, "failed to rename reflog for %s", new_name);
2066
+ git_error_set(GIT_ERROR_OS, "failed to rename reflog for %s", new_name);
1972
2067
  error = -1;
1973
2068
  goto cleanup;
1974
2069
  }
1975
2070
 
1976
- if (git_path_isdir(git_buf_cstr(&new_path)) &&
2071
+ if (git_path_isdir(git_buf_cstr(&new_path)) &&
1977
2072
  (git_futils_rmdir_r(git_buf_cstr(&new_path), NULL, GIT_RMDIR_SKIP_NONEMPTY) < 0)) {
1978
2073
  error = -1;
1979
2074
  goto cleanup;
@@ -1985,7 +2080,7 @@ static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_
1985
2080
  }
1986
2081
 
1987
2082
  if (p_rename(git_buf_cstr(&temp_path), git_buf_cstr(&new_path)) < 0) {
1988
- giterr_set(GITERR_OS, "failed to rename reflog for %s", new_name);
2083
+ git_error_set(GIT_ERROR_OS, "failed to rename reflog for %s", new_name);
1989
2084
  error = -1;
1990
2085
  }
1991
2086
 
@@ -2000,26 +2095,27 @@ cleanup:
2000
2095
 
2001
2096
  static int refdb_reflog_fs__delete(git_refdb_backend *_backend, const char *name)
2002
2097
  {
2003
- int error;
2098
+ refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
2004
2099
  git_buf path = GIT_BUF_INIT;
2005
-
2006
- git_repository *repo;
2007
- refdb_fs_backend *backend;
2100
+ int error;
2008
2101
 
2009
2102
  assert(_backend && name);
2010
2103
 
2011
- backend = (refdb_fs_backend *) _backend;
2012
- repo = backend->repo;
2104
+ if ((error = retrieve_reflog_path(&path, backend->repo, name)) < 0)
2105
+ goto out;
2013
2106
 
2014
- error = retrieve_reflog_path(&path, repo, name);
2107
+ if (!git_path_exists(path.ptr))
2108
+ goto out;
2109
+
2110
+ if ((error = p_unlink(path.ptr)) < 0)
2111
+ goto out;
2015
2112
 
2016
- if (!error && git_path_exists(path.ptr))
2017
- error = p_unlink(path.ptr);
2113
+ refdb_fs_backend__prune_refs(backend, name, GIT_REFLOG_DIR);
2018
2114
 
2115
+ out:
2019
2116
  git_buf_dispose(&path);
2020
2117
 
2021
2118
  return error;
2022
-
2023
2119
  }
2024
2120
 
2025
2121
  int git_refdb_backend_fs(
@@ -2031,7 +2127,7 @@ int git_refdb_backend_fs(
2031
2127
  refdb_fs_backend *backend;
2032
2128
 
2033
2129
  backend = git__calloc(1, sizeof(refdb_fs_backend));
2034
- GITERR_CHECK_ALLOC(backend);
2130
+ GIT_ERROR_CHECK_ALLOC(backend);
2035
2131
 
2036
2132
  backend->repo = repository;
2037
2133
 
@@ -2057,15 +2153,15 @@ int git_refdb_backend_fs(
2057
2153
 
2058
2154
  git_buf_dispose(&gitpath);
2059
2155
 
2060
- if (!git_repository__cvar(&t, backend->repo, GIT_CVAR_IGNORECASE) && t) {
2156
+ if (!git_repository__configmap_lookup(&t, backend->repo, GIT_CONFIGMAP_IGNORECASE) && t) {
2061
2157
  backend->iterator_flags |= GIT_ITERATOR_IGNORE_CASE;
2062
2158
  backend->direach_flags |= GIT_PATH_DIR_IGNORE_CASE;
2063
2159
  }
2064
- if (!git_repository__cvar(&t, backend->repo, GIT_CVAR_PRECOMPOSE) && t) {
2160
+ if (!git_repository__configmap_lookup(&t, backend->repo, GIT_CONFIGMAP_PRECOMPOSE) && t) {
2065
2161
  backend->iterator_flags |= GIT_ITERATOR_PRECOMPOSE_UNICODE;
2066
2162
  backend->direach_flags |= GIT_PATH_DIR_PRECOMPOSE_UNICODE;
2067
2163
  }
2068
- if ((!git_repository__cvar(&t, backend->repo, GIT_CVAR_FSYNCOBJECTFILES) && t) ||
2164
+ if ((!git_repository__configmap_lookup(&t, backend->repo, GIT_CONFIGMAP_FSYNCOBJECTFILES) && t) ||
2069
2165
  git_repository__fsync_gitdir)
2070
2166
  backend->fsync = 1;
2071
2167
  backend->iterator_flags |= GIT_ITERATOR_DESCEND_SYMLINKS;