rugged 0.28.3.1 → 0.28.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (350) 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 +36 -16
  5. data/vendor/libgit2/COPYING +28 -0
  6. data/vendor/libgit2/cmake/Modules/EnableWarnings.cmake +5 -1
  7. data/vendor/libgit2/cmake/Modules/FindCoreFoundation.cmake +2 -2
  8. data/vendor/libgit2/cmake/Modules/FindGSSAPI.cmake +1 -1
  9. data/vendor/libgit2/cmake/Modules/FindGSSFramework.cmake +28 -0
  10. data/vendor/libgit2/cmake/Modules/FindPCRE.cmake +38 -0
  11. data/vendor/libgit2/cmake/Modules/FindPCRE2.cmake +37 -0
  12. data/vendor/libgit2/cmake/Modules/FindSecurity.cmake +2 -2
  13. data/vendor/libgit2/cmake/Modules/FindStatNsec.cmake +6 -0
  14. data/vendor/libgit2/cmake/Modules/PkgBuildConfig.cmake +110 -0
  15. data/vendor/libgit2/cmake/Modules/SelectGSSAPI.cmake +53 -0
  16. data/vendor/libgit2/cmake/Modules/SelectHTTPSBackend.cmake +124 -0
  17. data/vendor/libgit2/cmake/Modules/SelectHashes.cmake +66 -0
  18. data/vendor/libgit2/deps/http-parser/http_parser.c +11 -6
  19. data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +21 -0
  20. data/vendor/libgit2/deps/ntlmclient/compat.h +33 -0
  21. data/vendor/libgit2/deps/ntlmclient/crypt.h +64 -0
  22. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +120 -0
  23. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +18 -0
  24. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +145 -0
  25. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +18 -0
  26. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +130 -0
  27. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +21 -0
  28. data/vendor/libgit2/deps/ntlmclient/ntlm.c +1420 -0
  29. data/vendor/libgit2/deps/ntlmclient/ntlm.h +174 -0
  30. data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +320 -0
  31. data/vendor/libgit2/deps/ntlmclient/unicode.h +36 -0
  32. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +445 -0
  33. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +201 -0
  34. data/vendor/libgit2/deps/ntlmclient/utf8.h +1257 -0
  35. data/vendor/libgit2/deps/ntlmclient/util.c +21 -0
  36. data/vendor/libgit2/deps/ntlmclient/util.h +14 -0
  37. data/vendor/libgit2/deps/pcre/CMakeLists.txt +140 -0
  38. data/vendor/libgit2/deps/pcre/COPYING +5 -0
  39. data/vendor/libgit2/deps/pcre/cmake/COPYING-CMAKE-SCRIPTS +22 -0
  40. data/vendor/libgit2/deps/pcre/cmake/FindEditline.cmake +17 -0
  41. data/vendor/libgit2/deps/pcre/cmake/FindPackageHandleStandardArgs.cmake +58 -0
  42. data/vendor/libgit2/deps/pcre/cmake/FindReadline.cmake +29 -0
  43. data/vendor/libgit2/deps/pcre/config.h.in +57 -0
  44. data/vendor/libgit2/deps/pcre/pcre.h +641 -0
  45. data/vendor/libgit2/deps/pcre/pcre_byte_order.c +319 -0
  46. data/vendor/libgit2/deps/pcre/pcre_chartables.c +198 -0
  47. data/vendor/libgit2/deps/pcre/pcre_compile.c +9800 -0
  48. data/vendor/libgit2/deps/pcre/pcre_config.c +190 -0
  49. data/vendor/libgit2/deps/pcre/pcre_dfa_exec.c +3676 -0
  50. data/vendor/libgit2/deps/pcre/pcre_exec.c +7173 -0
  51. data/vendor/libgit2/deps/pcre/pcre_fullinfo.c +245 -0
  52. data/vendor/libgit2/deps/pcre/pcre_get.c +669 -0
  53. data/vendor/libgit2/deps/pcre/pcre_globals.c +86 -0
  54. data/vendor/libgit2/deps/pcre/pcre_internal.h +2787 -0
  55. data/vendor/libgit2/deps/pcre/pcre_jit_compile.c +11913 -0
  56. data/vendor/libgit2/deps/pcre/pcre_maketables.c +156 -0
  57. data/vendor/libgit2/deps/pcre/pcre_newline.c +210 -0
  58. data/vendor/libgit2/deps/pcre/pcre_ord2utf8.c +94 -0
  59. data/vendor/libgit2/deps/pcre/pcre_printint.c +834 -0
  60. data/vendor/libgit2/deps/pcre/pcre_refcount.c +92 -0
  61. data/vendor/libgit2/deps/pcre/pcre_string_utils.c +211 -0
  62. data/vendor/libgit2/deps/pcre/pcre_study.c +1686 -0
  63. data/vendor/libgit2/deps/pcre/pcre_tables.c +727 -0
  64. data/vendor/libgit2/deps/pcre/pcre_ucd.c +3644 -0
  65. data/vendor/libgit2/deps/pcre/pcre_valid_utf8.c +301 -0
  66. data/vendor/libgit2/deps/pcre/pcre_version.c +98 -0
  67. data/vendor/libgit2/deps/pcre/pcre_xclass.c +268 -0
  68. data/vendor/libgit2/deps/pcre/pcreposix.c +421 -0
  69. data/vendor/libgit2/deps/pcre/pcreposix.h +117 -0
  70. data/vendor/libgit2/deps/pcre/ucp.h +224 -0
  71. data/vendor/libgit2/deps/zlib/adler32.c +0 -7
  72. data/vendor/libgit2/deps/zlib/crc32.c +0 -7
  73. data/vendor/libgit2/include/git2.h +2 -0
  74. data/vendor/libgit2/include/git2/apply.h +22 -2
  75. data/vendor/libgit2/include/git2/attr.h +19 -12
  76. data/vendor/libgit2/include/git2/blame.h +2 -2
  77. data/vendor/libgit2/include/git2/blob.h +44 -12
  78. data/vendor/libgit2/include/git2/buffer.h +20 -14
  79. data/vendor/libgit2/include/git2/cert.h +135 -0
  80. data/vendor/libgit2/include/git2/checkout.h +46 -14
  81. data/vendor/libgit2/include/git2/cherrypick.h +3 -3
  82. data/vendor/libgit2/include/git2/clone.h +2 -2
  83. data/vendor/libgit2/include/git2/commit.h +23 -1
  84. data/vendor/libgit2/include/git2/common.h +7 -5
  85. data/vendor/libgit2/include/git2/config.h +12 -12
  86. data/vendor/libgit2/include/git2/cred.h +308 -0
  87. data/vendor/libgit2/include/git2/deprecated.h +243 -3
  88. data/vendor/libgit2/include/git2/describe.h +4 -4
  89. data/vendor/libgit2/include/git2/diff.h +16 -14
  90. data/vendor/libgit2/include/git2/filter.h +8 -0
  91. data/vendor/libgit2/include/git2/index.h +2 -1
  92. data/vendor/libgit2/include/git2/indexer.h +48 -4
  93. data/vendor/libgit2/include/git2/merge.h +6 -10
  94. data/vendor/libgit2/include/git2/net.h +0 -5
  95. data/vendor/libgit2/include/git2/object.h +2 -14
  96. data/vendor/libgit2/include/git2/odb.h +3 -2
  97. data/vendor/libgit2/include/git2/odb_backend.h +5 -4
  98. data/vendor/libgit2/include/git2/oid.h +1 -1
  99. data/vendor/libgit2/include/git2/pack.h +12 -1
  100. data/vendor/libgit2/include/git2/proxy.h +5 -3
  101. data/vendor/libgit2/include/git2/rebase.h +46 -2
  102. data/vendor/libgit2/include/git2/refs.h +19 -0
  103. data/vendor/libgit2/include/git2/remote.h +35 -12
  104. data/vendor/libgit2/include/git2/repository.h +24 -2
  105. data/vendor/libgit2/include/git2/revert.h +1 -1
  106. data/vendor/libgit2/include/git2/stash.h +3 -3
  107. data/vendor/libgit2/include/git2/status.h +25 -16
  108. data/vendor/libgit2/include/git2/submodule.h +20 -3
  109. data/vendor/libgit2/include/git2/sys/alloc.h +9 -9
  110. data/vendor/libgit2/include/git2/sys/cred.h +90 -0
  111. data/vendor/libgit2/include/git2/sys/odb_backend.h +48 -4
  112. data/vendor/libgit2/include/git2/sys/refdb_backend.h +57 -21
  113. data/vendor/libgit2/include/git2/sys/repository.h +5 -1
  114. data/vendor/libgit2/include/git2/sys/transport.h +2 -2
  115. data/vendor/libgit2/include/git2/tag.h +11 -2
  116. data/vendor/libgit2/include/git2/trace.h +2 -2
  117. data/vendor/libgit2/include/git2/transport.h +11 -340
  118. data/vendor/libgit2/include/git2/tree.h +1 -1
  119. data/vendor/libgit2/include/git2/types.h +4 -89
  120. data/vendor/libgit2/include/git2/version.h +2 -2
  121. data/vendor/libgit2/include/git2/worktree.h +5 -5
  122. data/vendor/libgit2/src/CMakeLists.txt +88 -222
  123. data/vendor/libgit2/src/alloc.c +2 -14
  124. data/vendor/libgit2/src/{stdalloc.c → allocators/stdalloc.c} +3 -4
  125. data/vendor/libgit2/src/{stdalloc.h → allocators/stdalloc.h} +4 -4
  126. data/vendor/libgit2/src/allocators/win32_crtdbg.c +118 -0
  127. data/vendor/libgit2/src/{transports/cred.h → allocators/win32_crtdbg.h} +5 -4
  128. data/vendor/libgit2/src/apply.c +60 -30
  129. data/vendor/libgit2/src/attr.c +70 -64
  130. data/vendor/libgit2/src/attr_file.c +189 -96
  131. data/vendor/libgit2/src/attr_file.h +9 -9
  132. data/vendor/libgit2/src/attrcache.c +44 -46
  133. data/vendor/libgit2/src/attrcache.h +2 -1
  134. data/vendor/libgit2/src/blame.c +17 -5
  135. data/vendor/libgit2/src/blame.h +1 -1
  136. data/vendor/libgit2/src/blame_git.c +21 -7
  137. data/vendor/libgit2/src/blob.c +81 -17
  138. data/vendor/libgit2/src/blob.h +2 -2
  139. data/vendor/libgit2/src/branch.c +29 -5
  140. data/vendor/libgit2/src/buffer.c +14 -7
  141. data/vendor/libgit2/src/cache.c +26 -33
  142. data/vendor/libgit2/src/cache.h +1 -1
  143. data/vendor/libgit2/src/cc-compat.h +5 -0
  144. data/vendor/libgit2/src/checkout.c +26 -16
  145. data/vendor/libgit2/src/cherrypick.c +9 -3
  146. data/vendor/libgit2/src/clone.c +29 -7
  147. data/vendor/libgit2/src/clone.h +4 -0
  148. data/vendor/libgit2/src/commit.c +69 -21
  149. data/vendor/libgit2/src/commit.h +6 -0
  150. data/vendor/libgit2/src/commit_list.c +28 -76
  151. data/vendor/libgit2/src/commit_list.h +2 -2
  152. data/vendor/libgit2/src/common.h +3 -75
  153. data/vendor/libgit2/src/config.c +31 -40
  154. data/vendor/libgit2/src/config.h +7 -6
  155. data/vendor/libgit2/src/config_backend.h +12 -0
  156. data/vendor/libgit2/src/config_cache.c +39 -39
  157. data/vendor/libgit2/src/config_entries.c +69 -99
  158. data/vendor/libgit2/src/config_entries.h +1 -0
  159. data/vendor/libgit2/src/config_file.c +337 -380
  160. data/vendor/libgit2/src/config_mem.c +12 -16
  161. data/vendor/libgit2/src/config_parse.c +49 -29
  162. data/vendor/libgit2/src/config_parse.h +13 -12
  163. data/vendor/libgit2/src/config_snapshot.c +206 -0
  164. data/vendor/libgit2/src/crlf.c +14 -14
  165. data/vendor/libgit2/src/describe.c +21 -20
  166. data/vendor/libgit2/src/diff.c +43 -58
  167. data/vendor/libgit2/src/diff.h +2 -1
  168. data/vendor/libgit2/src/diff_driver.c +37 -38
  169. data/vendor/libgit2/src/diff_file.c +9 -7
  170. data/vendor/libgit2/src/diff_file.h +1 -1
  171. data/vendor/libgit2/src/diff_generate.c +135 -85
  172. data/vendor/libgit2/src/diff_generate.h +2 -2
  173. data/vendor/libgit2/src/diff_parse.c +1 -1
  174. data/vendor/libgit2/src/diff_print.c +25 -13
  175. data/vendor/libgit2/src/diff_stats.c +1 -1
  176. data/vendor/libgit2/src/diff_tform.c +4 -4
  177. data/vendor/libgit2/src/errors.c +12 -22
  178. data/vendor/libgit2/src/errors.h +81 -0
  179. data/vendor/libgit2/src/features.h.in +9 -2
  180. data/vendor/libgit2/src/fetch.c +7 -2
  181. data/vendor/libgit2/src/fetchhead.c +1 -1
  182. data/vendor/libgit2/src/filebuf.c +6 -10
  183. data/vendor/libgit2/src/filebuf.h +2 -2
  184. data/vendor/libgit2/src/filter.c +16 -8
  185. data/vendor/libgit2/src/{fileops.c → futils.c} +21 -17
  186. data/vendor/libgit2/src/{fileops.h → futils.h} +5 -5
  187. data/vendor/libgit2/src/global.c +12 -40
  188. data/vendor/libgit2/src/global.h +0 -2
  189. data/vendor/libgit2/src/hash.c +61 -0
  190. data/vendor/libgit2/src/hash.h +19 -21
  191. data/vendor/libgit2/src/hash/sha1.h +38 -0
  192. data/vendor/libgit2/src/hash/{hash_collisiondetect.h → sha1/collisiondetect.c} +14 -17
  193. data/vendor/libgit2/src/hash/sha1/collisiondetect.h +19 -0
  194. data/vendor/libgit2/src/hash/{hash_common_crypto.h → sha1/common_crypto.c} +15 -19
  195. data/vendor/libgit2/src/hash/sha1/common_crypto.h +19 -0
  196. data/vendor/libgit2/src/hash/{hash_generic.c → sha1/generic.c} +22 -10
  197. data/vendor/libgit2/src/hash/{hash_generic.h → sha1/generic.h} +4 -14
  198. data/vendor/libgit2/src/hash/{hash_mbedtls.c → sha1/mbedtls.c} +15 -7
  199. data/vendor/libgit2/src/hash/{hash_mbedtls.h → sha1/mbedtls.h} +6 -11
  200. data/vendor/libgit2/src/hash/{hash_openssl.h → sha1/openssl.c} +14 -18
  201. data/vendor/libgit2/src/hash/sha1/openssl.h +19 -0
  202. data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/sha1.c +14 -3
  203. data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/sha1.h +0 -0
  204. data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/ubc_check.c +0 -0
  205. data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/ubc_check.h +0 -0
  206. data/vendor/libgit2/src/hash/{hash_win32.c → sha1/win32.c} +34 -24
  207. data/vendor/libgit2/src/hash/{hash_win32.h → sha1/win32.h} +6 -19
  208. data/vendor/libgit2/src/hashsig.c +1 -1
  209. data/vendor/libgit2/src/idxmap.c +91 -65
  210. data/vendor/libgit2/src/idxmap.h +151 -15
  211. data/vendor/libgit2/src/ignore.c +32 -38
  212. data/vendor/libgit2/src/index.c +66 -43
  213. data/vendor/libgit2/src/index.h +1 -1
  214. data/vendor/libgit2/src/indexer.c +69 -70
  215. data/vendor/libgit2/src/integer.h +39 -4
  216. data/vendor/libgit2/src/iterator.c +27 -22
  217. data/vendor/libgit2/src/map.h +1 -1
  218. data/vendor/libgit2/src/merge.c +58 -44
  219. data/vendor/libgit2/src/merge_driver.c +4 -4
  220. data/vendor/libgit2/src/merge_file.c +1 -1
  221. data/vendor/libgit2/src/mwindow.c +18 -23
  222. data/vendor/libgit2/src/mwindow.h +4 -4
  223. data/vendor/libgit2/src/net.c +184 -0
  224. data/vendor/libgit2/src/net.h +36 -0
  225. data/vendor/libgit2/src/netops.c +55 -165
  226. data/vendor/libgit2/src/netops.h +3 -25
  227. data/vendor/libgit2/src/notes.c +2 -2
  228. data/vendor/libgit2/src/object.c +2 -2
  229. data/vendor/libgit2/src/object.h +2 -0
  230. data/vendor/libgit2/src/odb.c +41 -23
  231. data/vendor/libgit2/src/odb.h +3 -2
  232. data/vendor/libgit2/src/odb_loose.c +17 -10
  233. data/vendor/libgit2/src/odb_mempack.c +10 -23
  234. data/vendor/libgit2/src/odb_pack.c +4 -4
  235. data/vendor/libgit2/src/offmap.c +43 -55
  236. data/vendor/libgit2/src/offmap.h +102 -24
  237. data/vendor/libgit2/src/oid.c +6 -1
  238. data/vendor/libgit2/src/oidmap.c +39 -57
  239. data/vendor/libgit2/src/oidmap.h +99 -19
  240. data/vendor/libgit2/src/pack-objects.c +25 -32
  241. data/vendor/libgit2/src/pack-objects.h +1 -1
  242. data/vendor/libgit2/src/pack.c +45 -47
  243. data/vendor/libgit2/src/pack.h +12 -14
  244. data/vendor/libgit2/src/parse.c +10 -0
  245. data/vendor/libgit2/src/parse.h +3 -3
  246. data/vendor/libgit2/src/patch.c +1 -1
  247. data/vendor/libgit2/src/patch_generate.c +2 -2
  248. data/vendor/libgit2/src/patch_parse.c +124 -31
  249. data/vendor/libgit2/src/path.c +95 -27
  250. data/vendor/libgit2/src/path.h +2 -0
  251. data/vendor/libgit2/src/pathspec.c +13 -13
  252. data/vendor/libgit2/src/pool.c +26 -22
  253. data/vendor/libgit2/src/pool.h +7 -7
  254. data/vendor/libgit2/src/posix.c +7 -7
  255. data/vendor/libgit2/src/posix.h +12 -1
  256. data/vendor/libgit2/src/proxy.c +7 -2
  257. data/vendor/libgit2/src/push.c +10 -5
  258. data/vendor/libgit2/src/reader.c +2 -2
  259. data/vendor/libgit2/src/rebase.c +66 -7
  260. data/vendor/libgit2/src/refdb.c +12 -0
  261. data/vendor/libgit2/src/refdb_fs.c +214 -165
  262. data/vendor/libgit2/src/reflog.c +11 -13
  263. data/vendor/libgit2/src/refs.c +24 -18
  264. data/vendor/libgit2/src/refspec.c +9 -16
  265. data/vendor/libgit2/src/regexp.c +221 -0
  266. data/vendor/libgit2/src/regexp.h +97 -0
  267. data/vendor/libgit2/src/remote.c +50 -52
  268. data/vendor/libgit2/src/remote.h +2 -2
  269. data/vendor/libgit2/src/repository.c +115 -100
  270. data/vendor/libgit2/src/repository.h +49 -40
  271. data/vendor/libgit2/src/revert.c +8 -3
  272. data/vendor/libgit2/src/revparse.c +18 -19
  273. data/vendor/libgit2/src/revwalk.c +63 -30
  274. data/vendor/libgit2/src/revwalk.h +20 -0
  275. data/vendor/libgit2/src/settings.c +5 -0
  276. data/vendor/libgit2/src/sortedcache.c +12 -26
  277. data/vendor/libgit2/src/sortedcache.h +1 -1
  278. data/vendor/libgit2/src/stash.c +45 -65
  279. data/vendor/libgit2/src/status.c +15 -9
  280. data/vendor/libgit2/src/streams/openssl.c +20 -0
  281. data/vendor/libgit2/src/streams/socket.c +2 -2
  282. data/vendor/libgit2/src/strmap.c +37 -84
  283. data/vendor/libgit2/src/strmap.h +105 -33
  284. data/vendor/libgit2/src/submodule.c +102 -70
  285. data/vendor/libgit2/src/submodule.h +1 -1
  286. data/vendor/libgit2/src/sysdir.c +11 -1
  287. data/vendor/libgit2/src/tag.c +10 -2
  288. data/vendor/libgit2/src/trace.c +1 -1
  289. data/vendor/libgit2/src/trace.h +2 -2
  290. data/vendor/libgit2/src/trailer.c +46 -32
  291. data/vendor/libgit2/src/transaction.c +10 -9
  292. data/vendor/libgit2/src/transports/auth.c +10 -9
  293. data/vendor/libgit2/src/transports/auth.h +11 -4
  294. data/vendor/libgit2/src/transports/auth_negotiate.c +23 -9
  295. data/vendor/libgit2/src/transports/auth_negotiate.h +2 -2
  296. data/vendor/libgit2/src/transports/auth_ntlm.c +223 -0
  297. data/vendor/libgit2/src/transports/auth_ntlm.h +35 -0
  298. data/vendor/libgit2/src/transports/cred.c +6 -6
  299. data/vendor/libgit2/src/transports/git.c +11 -16
  300. data/vendor/libgit2/src/transports/http.c +419 -276
  301. data/vendor/libgit2/src/transports/http.h +1 -1
  302. data/vendor/libgit2/src/transports/local.c +9 -9
  303. data/vendor/libgit2/src/transports/smart.c +17 -17
  304. data/vendor/libgit2/src/transports/smart.h +2 -2
  305. data/vendor/libgit2/src/transports/smart_protocol.c +36 -60
  306. data/vendor/libgit2/src/transports/ssh.c +46 -36
  307. data/vendor/libgit2/src/transports/winhttp.c +231 -207
  308. data/vendor/libgit2/src/tree-cache.c +14 -7
  309. data/vendor/libgit2/src/tree.c +10 -24
  310. data/vendor/libgit2/src/unix/map.c +1 -1
  311. data/vendor/libgit2/src/unix/posix.h +1 -11
  312. data/vendor/libgit2/src/userdiff.h +3 -1
  313. data/vendor/libgit2/src/util.c +51 -53
  314. data/vendor/libgit2/src/util.h +16 -21
  315. data/vendor/libgit2/src/wildmatch.c +320 -0
  316. data/vendor/libgit2/src/wildmatch.h +23 -0
  317. data/vendor/libgit2/src/win32/map.c +3 -5
  318. data/vendor/libgit2/src/win32/path_w32.c +12 -2
  319. data/vendor/libgit2/src/win32/path_w32.h +0 -29
  320. data/vendor/libgit2/src/win32/posix.h +1 -4
  321. data/vendor/libgit2/src/win32/posix_w32.c +40 -5
  322. data/vendor/libgit2/src/win32/precompiled.h +0 -2
  323. data/vendor/libgit2/src/win32/thread.c +5 -10
  324. data/vendor/libgit2/src/win32/w32_buffer.c +7 -3
  325. data/vendor/libgit2/src/win32/w32_common.h +39 -0
  326. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +0 -93
  327. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +0 -2
  328. data/vendor/libgit2/src/win32/w32_stack.c +4 -9
  329. data/vendor/libgit2/src/win32/w32_stack.h +3 -3
  330. data/vendor/libgit2/src/win32/w32_util.c +31 -0
  331. data/vendor/libgit2/src/win32/w32_util.h +6 -32
  332. data/vendor/libgit2/src/worktree.c +36 -22
  333. data/vendor/libgit2/src/xdiff/xdiffi.c +1 -1
  334. data/vendor/libgit2/src/xdiff/xmerge.c +12 -0
  335. data/vendor/libgit2/src/xdiff/xpatience.c +3 -0
  336. metadata +98 -34
  337. data/vendor/libgit2/deps/regex/CMakeLists.txt +0 -2
  338. data/vendor/libgit2/deps/regex/COPYING +0 -502
  339. data/vendor/libgit2/deps/regex/config.h +0 -7
  340. data/vendor/libgit2/deps/regex/regcomp.c +0 -3857
  341. data/vendor/libgit2/deps/regex/regex.c +0 -92
  342. data/vendor/libgit2/deps/regex/regex.h +0 -582
  343. data/vendor/libgit2/deps/regex/regex_internal.c +0 -1744
  344. data/vendor/libgit2/deps/regex/regex_internal.h +0 -819
  345. data/vendor/libgit2/deps/regex/regexec.c +0 -4369
  346. data/vendor/libgit2/include/git2/inttypes.h +0 -309
  347. data/vendor/libgit2/include/git2/sys/time.h +0 -31
  348. data/vendor/libgit2/libgit2.pc.in +0 -13
  349. data/vendor/libgit2/src/fnmatch.c +0 -248
  350. data/vendor/libgit2/src/fnmatch.h +0 -48
@@ -32,8 +32,8 @@ typedef struct git_pool_page git_pool_page;
32
32
  */
33
33
  typedef struct {
34
34
  git_pool_page *pages; /* allocated pages */
35
- uint32_t item_size; /* size of single alloc unit in bytes */
36
- uint32_t page_size; /* size of page in bytes */
35
+ size_t item_size; /* size of single alloc unit in bytes */
36
+ size_t page_size; /* size of page in bytes */
37
37
  } git_pool;
38
38
 
39
39
  #define GIT_POOL_INIT { NULL, 0, 0 }
@@ -57,8 +57,8 @@ typedef struct {
57
57
  */
58
58
  typedef struct {
59
59
  git_vector allocations;
60
- uint32_t item_size;
61
- uint32_t page_size;
60
+ size_t item_size;
61
+ size_t page_size;
62
62
  } git_pool;
63
63
 
64
64
  #define GIT_POOL_INIT { GIT_VECTOR_INIT, 0, 0 }
@@ -81,7 +81,7 @@ typedef struct {
81
81
  * Of course, you can use this in other ways, but those are the
82
82
  * two most common patterns.
83
83
  */
84
- extern void git_pool_init(git_pool *pool, uint32_t item_size);
84
+ extern void git_pool_init(git_pool *pool, size_t item_size);
85
85
 
86
86
  /**
87
87
  * Free all items in pool
@@ -96,8 +96,8 @@ extern void git_pool_swap(git_pool *a, git_pool *b);
96
96
  /**
97
97
  * Allocate space for one or more items from a pool.
98
98
  */
99
- extern void *git_pool_malloc(git_pool *pool, uint32_t items);
100
- extern void *git_pool_mallocz(git_pool *pool, uint32_t items);
99
+ extern void *git_pool_malloc(git_pool *pool, size_t items);
100
+ extern void *git_pool_mallocz(git_pool *pool, size_t items);
101
101
 
102
102
  /**
103
103
  * Allocate space and duplicate string data into it.
@@ -28,11 +28,11 @@ int p_getaddrinfo(
28
28
 
29
29
  GIT_UNUSED(hints);
30
30
 
31
- if ((ainfo = malloc(sizeof(struct addrinfo))) == NULL)
31
+ if ((ainfo = git__malloc(sizeof(struct addrinfo))) == NULL)
32
32
  return -1;
33
33
 
34
34
  if ((ainfo->ai_hostent = gethostbyname(host)) == NULL) {
35
- free(ainfo);
35
+ git__free(ainfo);
36
36
  return -2;
37
37
  }
38
38
 
@@ -65,7 +65,7 @@ int p_getaddrinfo(
65
65
  ai = ainfo;
66
66
 
67
67
  for (p = 1; ainfo->ai_hostent->h_addr_list[p] != NULL; p++) {
68
- if (!(ai->ai_next = malloc(sizeof(struct addrinfo)))) {
68
+ if (!(ai->ai_next = git__malloc(sizeof(struct addrinfo)))) {
69
69
  p_freeaddrinfo(ainfo);
70
70
  return -1;
71
71
  }
@@ -89,7 +89,7 @@ void p_freeaddrinfo(struct addrinfo *info)
89
89
 
90
90
  while(p != NULL) {
91
91
  next = p->ai_next;
92
- free(p);
92
+ git__free(p);
93
93
  p = next;
94
94
  }
95
95
  }
@@ -235,7 +235,7 @@ int git__mmap_alignment(size_t *alignment)
235
235
  }
236
236
 
237
237
 
238
- int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offset)
238
+ int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, off64_t offset)
239
239
  {
240
240
  GIT_MMAP_VALIDATE(out, len, prot, flags);
241
241
 
@@ -247,7 +247,7 @@ int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offs
247
247
  return -1;
248
248
  }
249
249
 
250
- out->data = malloc(len);
250
+ out->data = git__malloc(len);
251
251
  GIT_ERROR_CHECK_ALLOC(out->data);
252
252
 
253
253
  if (!git__is_ssizet(len) ||
@@ -264,7 +264,7 @@ int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offs
264
264
  int p_munmap(git_map *map)
265
265
  {
266
266
  assert(map != NULL);
267
- free(map->data);
267
+ git__free(map->data);
268
268
 
269
269
  return 0;
270
270
  }
@@ -11,7 +11,6 @@
11
11
 
12
12
  #include <fcntl.h>
13
13
  #include <time.h>
14
- #include "fnmatch.h"
15
14
 
16
15
  /* stat: file mode type testing macros */
17
16
  #ifndef S_IFGITLINK
@@ -90,6 +89,18 @@
90
89
  #define EAFNOSUPPORT (INT_MAX-1)
91
90
  #endif
92
91
 
92
+ /* Provide a 64-bit size for offsets. */
93
+
94
+ #if defined(_MSC_VER)
95
+ typedef __int64 off64_t;
96
+ #elif defined(__HAIKU__)
97
+ typedef __haiku_std_int64 off64_t;
98
+ #elif defined(__APPLE__)
99
+ typedef __int64_t off64_t;
100
+ #else
101
+ typedef int64_t off64_t;
102
+ #endif
103
+
93
104
  typedef int git_file;
94
105
 
95
106
  /**
@@ -9,17 +9,22 @@
9
9
 
10
10
  #include "git2/proxy.h"
11
11
 
12
- int git_proxy_init_options(git_proxy_options *opts, unsigned int version)
12
+ int git_proxy_options_init(git_proxy_options *opts, unsigned int version)
13
13
  {
14
14
  GIT_INIT_STRUCTURE_FROM_TEMPLATE(
15
15
  opts, version, git_proxy_options, GIT_PROXY_OPTIONS_INIT);
16
16
  return 0;
17
17
  }
18
18
 
19
+ int git_proxy_init_options(git_proxy_options *opts, unsigned int version)
20
+ {
21
+ return git_proxy_options_init(opts, version);
22
+ }
23
+
19
24
  int git_proxy_options_dup(git_proxy_options *tgt, const git_proxy_options *src)
20
25
  {
21
26
  if (!src) {
22
- git_proxy_init_options(tgt, GIT_PROXY_OPTIONS_VERSION);
27
+ git_proxy_options_init(tgt, GIT_PROXY_OPTIONS_VERSION);
23
28
  return 0;
24
29
  }
25
30
 
@@ -196,7 +196,7 @@ int git_push_update_tips(git_push *push, const git_remote_callbacks *callbacks)
196
196
  continue;
197
197
 
198
198
  /* Update the remote ref */
199
- if (git_oid_iszero(&push_spec->loid)) {
199
+ if (git_oid_is_zero(&push_spec->loid)) {
200
200
  error = git_reference_lookup(&remote_ref, push->remote->repo, git_buf_cstr(&remote_ref_name));
201
201
 
202
202
  if (error >= 0) {
@@ -281,7 +281,7 @@ static int queue_objects(git_push *push)
281
281
  git_object_t type;
282
282
  size_t size;
283
283
 
284
- if (git_oid_iszero(&spec->loid))
284
+ if (git_oid_is_zero(&spec->loid))
285
285
  /*
286
286
  * Delete reference on remote side;
287
287
  * nothing to do here.
@@ -319,7 +319,7 @@ static int queue_objects(git_push *push)
319
319
  if (!spec->refspec.force) {
320
320
  git_oid base;
321
321
 
322
- if (git_oid_iszero(&spec->roid))
322
+ if (git_oid_is_zero(&spec->roid))
323
323
  continue;
324
324
 
325
325
  if (!git_odb_exists(push->repo->_odb, &spec->roid)) {
@@ -346,7 +346,7 @@ static int queue_objects(git_push *push)
346
346
  }
347
347
 
348
348
  git_vector_foreach(&push->remote->refs, i, head) {
349
- if (git_oid_iszero(&head->oid))
349
+ if (git_oid_is_zero(&head->oid))
350
350
  continue;
351
351
 
352
352
  /* TODO */
@@ -547,9 +547,14 @@ void git_push_free(git_push *push)
547
547
  git__free(push);
548
548
  }
549
549
 
550
- int git_push_init_options(git_push_options *opts, unsigned int version)
550
+ int git_push_options_init(git_push_options *opts, unsigned int version)
551
551
  {
552
552
  GIT_INIT_STRUCTURE_FROM_TEMPLATE(
553
553
  opts, version, git_push_options, GIT_PUSH_OPTIONS_INIT);
554
554
  return 0;
555
555
  }
556
+
557
+ int git_push_init_options(git_push_options *opts, unsigned int version)
558
+ {
559
+ return git_push_options_init(opts, version);
560
+ }
@@ -7,7 +7,7 @@
7
7
 
8
8
  #include "reader.h"
9
9
 
10
- #include "fileops.h"
10
+ #include "futils.h"
11
11
  #include "blob.h"
12
12
 
13
13
  #include "git2/tree.h"
@@ -32,7 +32,7 @@ static int tree_reader_read(
32
32
  tree_reader *reader = (tree_reader *)_reader;
33
33
  git_tree_entry *tree_entry = NULL;
34
34
  git_blob *blob = NULL;
35
- git_off_t blobsize;
35
+ git_object_size_t blobsize;
36
36
  int error;
37
37
 
38
38
  if ((error = git_tree_entry_bypath(&tree_entry, reader->tree, filename)) < 0 ||
@@ -268,7 +268,7 @@ static int rebase_alloc(git_rebase **out, const git_rebase_options *rebase_opts)
268
268
  if (rebase_opts)
269
269
  memcpy(&rebase->options, rebase_opts, sizeof(git_rebase_options));
270
270
  else
271
- git_rebase_init_options(&rebase->options, GIT_REBASE_OPTIONS_VERSION);
271
+ git_rebase_options_init(&rebase->options, GIT_REBASE_OPTIONS_VERSION);
272
272
 
273
273
  if (rebase_opts && rebase_opts->rewrite_notes_ref) {
274
274
  rebase->options.rewrite_notes_ref = git__strdup(rebase_opts->rewrite_notes_ref);
@@ -298,7 +298,8 @@ int git_rebase_open(
298
298
  git_rebase *rebase;
299
299
  git_buf path = GIT_BUF_INIT, orig_head_name = GIT_BUF_INIT,
300
300
  orig_head_id = GIT_BUF_INIT, onto_id = GIT_BUF_INIT;
301
- int state_path_len, error;
301
+ size_t state_path_len;
302
+ int error;
302
303
 
303
304
  assert(repo);
304
305
 
@@ -493,13 +494,18 @@ static int rebase_setupfiles(git_rebase *rebase)
493
494
  return rebase_setupfiles_merge(rebase);
494
495
  }
495
496
 
496
- int git_rebase_init_options(git_rebase_options *opts, unsigned int version)
497
+ int git_rebase_options_init(git_rebase_options *opts, unsigned int version)
497
498
  {
498
499
  GIT_INIT_STRUCTURE_FROM_TEMPLATE(
499
500
  opts, version, git_rebase_options, GIT_REBASE_OPTIONS_INIT);
500
501
  return 0;
501
502
  }
502
503
 
504
+ int git_rebase_init_options(git_rebase_options *opts, unsigned int version)
505
+ {
506
+ return git_rebase_options_init(opts, version);
507
+ }
508
+
503
509
  static int rebase_ensure_not_in_progress(git_repository *repo)
504
510
  {
505
511
  int error;
@@ -945,6 +951,10 @@ static int rebase_commit__create(
945
951
  git_commit *current_commit = NULL, *commit = NULL;
946
952
  git_tree *parent_tree = NULL, *tree = NULL;
947
953
  git_oid tree_id, commit_id;
954
+ git_buf commit_content = GIT_BUF_INIT, commit_signature = GIT_BUF_INIT,
955
+ signature_field = GIT_BUF_INIT;
956
+ const char *signature_field_string = NULL,
957
+ *commit_signature_string = NULL;
948
958
  int error;
949
959
 
950
960
  operation = git_array_get(rebase->operations, rebase->current);
@@ -975,10 +985,40 @@ static int rebase_commit__create(
975
985
  message = git_commit_message(current_commit);
976
986
  }
977
987
 
978
- if ((error = git_commit_create(&commit_id, rebase->repo, NULL, author,
979
- committer, message_encoding, message, tree, 1,
980
- (const git_commit **)&parent_commit)) < 0 ||
981
- (error = git_commit_lookup(&commit, rebase->repo, &commit_id)) < 0)
988
+ if ((error = git_commit_create_buffer(&commit_content, rebase->repo, author, committer,
989
+ message_encoding, message, tree, 1, (const git_commit **)&parent_commit)) < 0)
990
+ goto done;
991
+
992
+ if (rebase->options.signing_cb) {
993
+ git_error_clear();
994
+ error = git_error_set_after_callback_function(rebase->options.signing_cb(
995
+ &commit_signature, &signature_field, git_buf_cstr(&commit_content),
996
+ rebase->options.payload), "commit signing_cb failed");
997
+ if (error == GIT_PASSTHROUGH) {
998
+ git_buf_dispose(&commit_signature);
999
+ git_buf_dispose(&signature_field);
1000
+ git_error_clear();
1001
+ error = GIT_OK;
1002
+ } else if (error < 0)
1003
+ goto done;
1004
+ }
1005
+
1006
+ if (git_buf_is_allocated(&commit_signature)) {
1007
+ assert(git_buf_contains_nul(&commit_signature));
1008
+ commit_signature_string = git_buf_cstr(&commit_signature);
1009
+ }
1010
+
1011
+ if (git_buf_is_allocated(&signature_field)) {
1012
+ assert(git_buf_contains_nul(&signature_field));
1013
+ signature_field_string = git_buf_cstr(&signature_field);
1014
+ }
1015
+
1016
+ if ((error = git_commit_create_with_signature(&commit_id, rebase->repo,
1017
+ git_buf_cstr(&commit_content), commit_signature_string,
1018
+ signature_field_string)))
1019
+ goto done;
1020
+
1021
+ if ((error = git_commit_lookup(&commit, rebase->repo, &commit_id)) < 0)
982
1022
  goto done;
983
1023
 
984
1024
  *out = commit;
@@ -987,6 +1027,9 @@ done:
987
1027
  if (error < 0)
988
1028
  git_commit_free(commit);
989
1029
 
1030
+ git_buf_dispose(&commit_signature);
1031
+ git_buf_dispose(&signature_field);
1032
+ git_buf_dispose(&commit_content);
990
1033
  git_commit_free(current_commit);
991
1034
  git_tree_free(parent_tree);
992
1035
  git_tree_free(tree);
@@ -1327,6 +1370,22 @@ int git_rebase_finish(
1327
1370
  return error;
1328
1371
  }
1329
1372
 
1373
+ const char *git_rebase_orig_head_name(git_rebase *rebase) {
1374
+ return rebase->orig_head_name;
1375
+ }
1376
+
1377
+ const git_oid *git_rebase_orig_head_id(git_rebase *rebase) {
1378
+ return &rebase->orig_head_id;
1379
+ }
1380
+
1381
+ const char *git_rebase_onto_name(git_rebase *rebase) {
1382
+ return rebase->onto_name;
1383
+ }
1384
+
1385
+ const git_oid *git_rebase_onto_id(git_rebase *rebase) {
1386
+ return &rebase->onto_id;
1387
+ }
1388
+
1330
1389
  size_t git_rebase_operation_entrycount(git_rebase *rebase)
1331
1390
  {
1332
1391
  assert(rebase);
@@ -66,6 +66,18 @@ static void refdb_free_backend(git_refdb *db)
66
66
 
67
67
  int git_refdb_set_backend(git_refdb *db, git_refdb_backend *backend)
68
68
  {
69
+ GIT_ERROR_CHECK_VERSION(backend, GIT_REFDB_BACKEND_VERSION, "git_refdb_backend");
70
+
71
+ if (!backend->exists || !backend->lookup || !backend->iterator ||
72
+ !backend->write || !backend->rename || !backend->del ||
73
+ !backend->has_log || !backend->ensure_log || !backend->free ||
74
+ !backend->reflog_read || !backend->reflog_write ||
75
+ !backend->reflog_rename || !backend->reflog_delete ||
76
+ (backend->lock && !backend->unlock)) {
77
+ git_error_set(GIT_ERROR_REFERENCE, "incomplete refdb backend implementation");
78
+ return GIT_EINVALID;
79
+ }
80
+
69
81
  refdb_free_backend(db);
70
82
  db->backend = backend;
71
83
 
@@ -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>
@@ -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
+ }
347
+
348
+ if ((error = packed_reload(backend)) < 0)
349
+ goto out;
339
350
 
340
- *exists = git_path_isfile(ref_path.ptr) ||
341
- (git_sortedcache_lookup(backend->refcache, ref_name) != NULL);
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)
@@ -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);
@@ -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,24 +593,24 @@ 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)
603
+ if (loose_lookup(out, backend, path) == 0) {
604
+ ref = git_sortedcache_lookup(iter->cache, path);
605
+ if (ref)
606
+ ref->flags |= PACKREF_SHADOWED;
607
+
597
608
  return 0;
609
+ }
598
610
 
599
611
  git_error_clear();
600
612
  }
601
613
 
602
- if (!iter->cache) {
603
- if ((error = git_sortedcache_copy(&iter->cache, backend->refcache, 1, NULL, NULL)) < 0)
604
- return error;
605
- }
606
-
607
614
  error = GIT_ITEROVER;
608
615
  while (iter->packed_pos < git_sortedcache_entrycount(iter->cache)) {
609
616
  ref = git_sortedcache_entry(iter->cache, iter->packed_pos++);
@@ -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,14 +634,19 @@ 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
  }
@@ -642,11 +654,6 @@ static int refdb_fs_backend__iterator_next_name(
642
654
  git_error_clear();
643
655
  }
644
656
 
645
- if (!iter->cache) {
646
- if ((error = git_sortedcache_copy(&iter->cache, backend->refcache, 1, NULL, NULL)) < 0)
647
- return error;
648
- }
649
-
650
657
  error = GIT_ITEROVER;
651
658
  while (iter->packed_pos < git_sortedcache_entrycount(iter->cache)) {
652
659
  ref = git_sortedcache_entry(iter->cache, iter->packed_pos++);
@@ -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
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(
@@ -794,7 +805,7 @@ 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
 
@@ -829,7 +840,7 @@ 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
846
  GIT_ERROR_CHECK_ALLOC(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
 
@@ -1087,6 +1099,35 @@ 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
 
@@ -1094,7 +1135,7 @@ static int should_write_reflog(int *write, git_repository *repo, const char *nam
1094
1135
  {
1095
1136
  int error, logall;
1096
1137
 
1097
- error = git_repository__cvar(&logall, repo, GIT_CVAR_LOGALLREFUPDATES);
1138
+ error = git_repository__configmap_lookup(&logall, repo, GIT_CONFIGMAP_LOGALLREFUPDATES);
1098
1139
  if (error < 0)
1099
1140
  return error;
1100
1141
 
@@ -1239,7 +1280,7 @@ static int refdb_fs_backend__write(
1239
1280
  const git_oid *old_id,
1240
1281
  const char *old_target)
1241
1282
  {
1242
- refdb_fs_backend *backend = (refdb_fs_backend *)_backend;
1283
+ refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1243
1284
  git_filebuf file = GIT_FILEBUF_INIT;
1244
1285
  int error = 0;
1245
1286
 
@@ -1252,7 +1293,7 @@ static int refdb_fs_backend__write(
1252
1293
  if ((error = loose_lock(&file, backend, ref->name)) < 0)
1253
1294
  return error;
1254
1295
 
1255
- 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);
1256
1297
  }
1257
1298
 
1258
1299
  static int refdb_fs_backend__write_tail(
@@ -1260,12 +1301,12 @@ static int refdb_fs_backend__write_tail(
1260
1301
  const git_reference *ref,
1261
1302
  git_filebuf *file,
1262
1303
  int update_reflog,
1263
- const git_signature *who,
1264
- const char *message,
1265
1304
  const git_oid *old_id,
1266
- const char *old_target)
1305
+ const char *old_target,
1306
+ const git_signature *who,
1307
+ const char *message)
1267
1308
  {
1268
- refdb_fs_backend *backend = (refdb_fs_backend *)_backend;
1309
+ refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1269
1310
  int error = 0, cmp = 0, should_write;
1270
1311
  const char *new_target = NULL;
1271
1312
  const git_oid *new_id = NULL;
@@ -1313,10 +1354,10 @@ on_error:
1313
1354
  return error;
1314
1355
  }
1315
1356
 
1316
- static void refdb_fs_backend__try_delete_empty_ref_hierarchie(
1357
+ static void refdb_fs_backend__prune_refs(
1317
1358
  refdb_fs_backend *backend,
1318
1359
  const char *ref_name,
1319
- bool reflog)
1360
+ const char *prefix)
1320
1361
  {
1321
1362
  git_buf relative_path = GIT_BUF_INIT;
1322
1363
  git_buf base_path = GIT_BUF_INIT;
@@ -1334,8 +1375,8 @@ static void refdb_fs_backend__try_delete_empty_ref_hierarchie(
1334
1375
 
1335
1376
  git_buf_truncate(&relative_path, commonlen);
1336
1377
 
1337
- if (reflog) {
1338
- if (git_buf_join3(&base_path, '/', backend->commonpath, GIT_REFLOG_DIR, git_buf_cstr(&relative_path)) < 0)
1378
+ if (prefix) {
1379
+ if (git_buf_join3(&base_path, '/', backend->commonpath, prefix, git_buf_cstr(&relative_path)) < 0)
1339
1380
  goto cleanup;
1340
1381
  } else {
1341
1382
  if (git_buf_joinpath(&base_path, backend->commonpath, git_buf_cstr(&relative_path)) < 0)
@@ -1355,7 +1396,7 @@ static int refdb_fs_backend__delete(
1355
1396
  const char *ref_name,
1356
1397
  const git_oid *old_id, const char *old_target)
1357
1398
  {
1358
- refdb_fs_backend *backend = (refdb_fs_backend *)_backend;
1399
+ refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1359
1400
  git_filebuf file = GIT_FILEBUF_INIT;
1360
1401
  int error = 0;
1361
1402
 
@@ -1372,17 +1413,34 @@ static int refdb_fs_backend__delete(
1372
1413
  return refdb_fs_backend__delete_tail(_backend, &file, ref_name, old_id, old_target);
1373
1414
  }
1374
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
+
1375
1435
  static int refdb_fs_backend__delete_tail(
1376
1436
  git_refdb_backend *_backend,
1377
1437
  git_filebuf *file,
1378
1438
  const char *ref_name,
1379
1439
  const git_oid *old_id, const char *old_target)
1380
1440
  {
1381
- refdb_fs_backend *backend = (refdb_fs_backend *)_backend;
1382
- git_buf loose_path = GIT_BUF_INIT;
1383
- size_t pack_pos;
1441
+ refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1384
1442
  int error = 0, cmp = 0;
1385
- bool loose_deleted = 0;
1443
+ bool packed_deleted = 0;
1386
1444
 
1387
1445
  error = cmp_old_ref(&cmp, _backend, ref_name, old_id, old_target);
1388
1446
  if (error < 0)
@@ -1394,44 +1452,41 @@ static int refdb_fs_backend__delete_tail(
1394
1452
  goto cleanup;
1395
1453
  }
1396
1454
 
1397
- /* If a loose reference exists, remove it from the filesystem */
1398
- if (git_buf_joinpath(&loose_path, backend->commonpath, ref_name) < 0)
1399
- return -1;
1400
-
1401
-
1402
- error = p_unlink(loose_path.ptr);
1403
- if (error < 0 && errno == ENOENT)
1404
- error = 0;
1405
- 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)
1406
1473
  goto cleanup;
1407
- else if (error == 0)
1408
- loose_deleted = 1;
1409
1474
 
1410
- if ((error = packed_reload(backend)) < 0)
1411
- goto cleanup;
1475
+ if (error == 0)
1476
+ packed_deleted = 1;
1412
1477
 
1413
- /* If a packed reference exists, remove it from the packfile and repack */
1414
- if ((error = git_sortedcache_wlock(backend->refcache)) < 0)
1478
+ if ((error = loose_delete(backend, ref_name)) < 0 && error != GIT_ENOTFOUND)
1415
1479
  goto cleanup;
1416
1480
 
1417
- if (!(error = git_sortedcache_lookup_index(
1418
- &pack_pos, backend->refcache, ref_name)))
1419
- error = git_sortedcache_remove(backend->refcache, pack_pos);
1420
-
1421
- git_sortedcache_wunlock(backend->refcache);
1422
-
1423
1481
  if (error == GIT_ENOTFOUND) {
1424
- error = loose_deleted ? 0 : ref_error_notfound(ref_name);
1482
+ error = packed_deleted ? 0 : ref_error_notfound(ref_name);
1425
1483
  goto cleanup;
1426
1484
  }
1427
1485
 
1428
- error = packed_write(backend);
1429
-
1430
1486
  cleanup:
1431
- git_buf_dispose(&loose_path);
1432
1487
  git_filebuf_cleanup(file);
1433
- if (loose_deleted)
1434
- refdb_fs_backend__try_delete_empty_ref_hierarchie(backend, ref_name, false);
1488
+ if (error == 0)
1489
+ refdb_fs_backend__prune_refs(backend, ref_name, "");
1435
1490
  return error;
1436
1491
  }
1437
1492
 
@@ -1446,7 +1501,7 @@ static int refdb_fs_backend__rename(
1446
1501
  const git_signature *who,
1447
1502
  const char *message)
1448
1503
  {
1449
- refdb_fs_backend *backend = (refdb_fs_backend *)_backend;
1504
+ refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1450
1505
  git_reference *old, *new;
1451
1506
  git_filebuf file = GIT_FILEBUF_INIT;
1452
1507
  int error;
@@ -1502,7 +1557,7 @@ static int refdb_fs_backend__rename(
1502
1557
  static int refdb_fs_backend__compress(git_refdb_backend *_backend)
1503
1558
  {
1504
1559
  int error;
1505
- refdb_fs_backend *backend = (refdb_fs_backend *)_backend;
1560
+ refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1506
1561
 
1507
1562
  assert(backend);
1508
1563
 
@@ -1516,7 +1571,7 @@ static int refdb_fs_backend__compress(git_refdb_backend *_backend)
1516
1571
 
1517
1572
  static void refdb_fs_backend__free(git_refdb_backend *_backend)
1518
1573
  {
1519
- refdb_fs_backend *backend = (refdb_fs_backend *)_backend;
1574
+ refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1520
1575
 
1521
1576
  assert(backend);
1522
1577
 
@@ -1597,70 +1652,57 @@ static int reflog_alloc(git_reflog **reflog, const char *name)
1597
1652
 
1598
1653
  static int reflog_parse(git_reflog *log, const char *buf, size_t buf_size)
1599
1654
  {
1600
- const char *ptr;
1601
- git_reflog_entry *entry;
1655
+ git_parse_ctx parser = GIT_PARSE_CTX_INIT;
1602
1656
 
1603
- #define seek_forward(_increase) do { \
1604
- if (_increase >= buf_size) { \
1605
- git_error_set(GIT_ERROR_INVALID, "ran out of data while parsing reflog"); \
1606
- goto fail; \
1607
- } \
1608
- buf += _increase; \
1609
- buf_size -= _increase; \
1610
- } while (0)
1611
-
1612
- while (buf_size > GIT_REFLOG_SIZE_MIN) {
1613
- entry = git__calloc(1, sizeof(git_reflog_entry));
1614
- GIT_ERROR_CHECK_ALLOC(entry);
1657
+ if ((git_parse_ctx_init(&parser, buf, buf_size)) < 0)
1658
+ return -1;
1615
1659
 
1616
- entry->committer = git__calloc(1, sizeof(git_signature));
1617
- GIT_ERROR_CHECK_ALLOC(entry->committer);
1660
+ for (; parser.remain_len; git_parse_advance_line(&parser)) {
1661
+ git_reflog_entry *entry;
1662
+ const char *sig;
1663
+ char c;
1618
1664
 
1619
- if (git_oid_fromstrn(&entry->oid_old, buf, GIT_OID_HEXSZ) < 0)
1620
- goto fail;
1621
- seek_forward(GIT_OID_HEXSZ + 1);
1622
-
1623
- if (git_oid_fromstrn(&entry->oid_cur, buf, GIT_OID_HEXSZ) < 0)
1624
- goto fail;
1625
- seek_forward(GIT_OID_HEXSZ + 1);
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);
1626
1669
 
1627
- ptr = buf;
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;
1628
1674
 
1629
- /* Seek forward to the end of the signature. */
1630
- while (*buf && *buf != '\t' && *buf != '\n')
1631
- seek_forward(1);
1675
+ sig = parser.line;
1676
+ while (git_parse_peek(&c, &parser, 0) == 0 && c != '\t' && c != '\n')
1677
+ git_parse_advance_chars(&parser, 1);
1632
1678
 
1633
- if (git_signature__parse(entry->committer, &ptr, buf + 1, NULL, *buf) < 0)
1634
- goto fail;
1679
+ if (git_signature__parse(entry->committer, &sig, parser.line, NULL, 0) < 0)
1680
+ goto next;
1635
1681
 
1636
- if (*buf == '\t') {
1637
- /* We got a message. Read everything till we reach LF. */
1638
- seek_forward(1);
1639
- ptr = buf;
1682
+ if (c == '\t') {
1683
+ size_t len;
1684
+ git_parse_advance_chars(&parser, 1);
1640
1685
 
1641
- while (*buf && *buf != '\n')
1642
- seek_forward(1);
1686
+ len = parser.line_len;
1687
+ if (parser.line[len - 1] == '\n')
1688
+ len--;
1643
1689
 
1644
- entry->msg = git__strndup(ptr, buf - ptr);
1690
+ entry->msg = git__strndup(parser.line, len);
1645
1691
  GIT_ERROR_CHECK_ALLOC(entry->msg);
1646
- } else
1647
- entry->msg = NULL;
1692
+ }
1648
1693
 
1649
- while (*buf && *buf == '\n' && buf_size > 1)
1650
- seek_forward(1);
1694
+ if ((git_vector_insert(&log->entries, entry)) < 0) {
1695
+ git_reflog_entry__free(entry);
1696
+ return -1;
1697
+ }
1651
1698
 
1652
- if (git_vector_insert(&log->entries, entry) < 0)
1653
- goto fail;
1699
+ continue;
1700
+
1701
+ next:
1702
+ git_reflog_entry__free(entry);
1654
1703
  }
1655
1704
 
1656
1705
  return 0;
1657
-
1658
- #undef seek_forward
1659
-
1660
- fail:
1661
- git_reflog_entry__free(entry);
1662
-
1663
- return -1;
1664
1706
  }
1665
1707
 
1666
1708
  static int create_new_reflog_file(const char *filepath)
@@ -1694,7 +1736,7 @@ static int refdb_reflog_fs__ensure_log(git_refdb_backend *_backend, const char *
1694
1736
 
1695
1737
  assert(_backend && name);
1696
1738
 
1697
- backend = (refdb_fs_backend *) _backend;
1739
+ backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1698
1740
  repo = backend->repo;
1699
1741
 
1700
1742
  if ((error = retrieve_reflog_path(&path, repo, name)) < 0)
@@ -1727,7 +1769,7 @@ static int refdb_reflog_fs__has_log(git_refdb_backend *_backend, const char *nam
1727
1769
 
1728
1770
  assert(_backend && name);
1729
1771
 
1730
- backend = (refdb_fs_backend *) _backend;
1772
+ backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1731
1773
 
1732
1774
  return has_reflog(backend->repo, name);
1733
1775
  }
@@ -1743,7 +1785,7 @@ static int refdb_reflog_fs__read(git_reflog **out, git_refdb_backend *_backend,
1743
1785
 
1744
1786
  assert(out && _backend && name);
1745
1787
 
1746
- backend = (refdb_fs_backend *) _backend;
1788
+ backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1747
1789
  repo = backend->repo;
1748
1790
 
1749
1791
  if (reflog_alloc(&log, name) < 0)
@@ -1802,8 +1844,15 @@ static int serialize_reflog_entry(
1802
1844
  git_buf_rtrim(buf);
1803
1845
 
1804
1846
  if (msg) {
1847
+ size_t i;
1848
+
1805
1849
  git_buf_putc(buf, '\t');
1806
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);
1807
1856
  }
1808
1857
 
1809
1858
  git_buf_putc(buf, '\n');
@@ -1853,7 +1902,7 @@ static int refdb_reflog_fs__write(git_refdb_backend *_backend, git_reflog *reflo
1853
1902
 
1854
1903
  assert(_backend && reflog);
1855
1904
 
1856
- backend = (refdb_fs_backend *) _backend;
1905
+ backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1857
1906
 
1858
1907
  if ((error = lock_reflog(&fbuf, backend, reflog->ref_name)) < 0)
1859
1908
  return -1;
@@ -1894,7 +1943,7 @@ static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, co
1894
1943
  !(old && new))
1895
1944
  return 0;
1896
1945
 
1897
- /* From here on is_symoblic also means that it's HEAD */
1946
+ /* From here on is_symbolic also means that it's HEAD */
1898
1947
 
1899
1948
  if (old) {
1900
1949
  git_oid_cpy(&old_id, old);
@@ -1975,7 +2024,7 @@ static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_
1975
2024
 
1976
2025
  assert(_backend && old_name && new_name);
1977
2026
 
1978
- backend = (refdb_fs_backend *) _backend;
2027
+ backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1979
2028
  repo = backend->repo;
1980
2029
 
1981
2030
  if ((error = git_reference__normalize_name(
@@ -2046,7 +2095,7 @@ cleanup:
2046
2095
 
2047
2096
  static int refdb_reflog_fs__delete(git_refdb_backend *_backend, const char *name)
2048
2097
  {
2049
- refdb_fs_backend *backend = (refdb_fs_backend *) _backend;
2098
+ refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
2050
2099
  git_buf path = GIT_BUF_INIT;
2051
2100
  int error;
2052
2101
 
@@ -2061,7 +2110,7 @@ static int refdb_reflog_fs__delete(git_refdb_backend *_backend, const char *name
2061
2110
  if ((error = p_unlink(path.ptr)) < 0)
2062
2111
  goto out;
2063
2112
 
2064
- refdb_fs_backend__try_delete_empty_ref_hierarchie(backend, name, true);
2113
+ refdb_fs_backend__prune_refs(backend, name, GIT_REFLOG_DIR);
2065
2114
 
2066
2115
  out:
2067
2116
  git_buf_dispose(&path);
@@ -2104,15 +2153,15 @@ int git_refdb_backend_fs(
2104
2153
 
2105
2154
  git_buf_dispose(&gitpath);
2106
2155
 
2107
- if (!git_repository__cvar(&t, backend->repo, GIT_CVAR_IGNORECASE) && t) {
2156
+ if (!git_repository__configmap_lookup(&t, backend->repo, GIT_CONFIGMAP_IGNORECASE) && t) {
2108
2157
  backend->iterator_flags |= GIT_ITERATOR_IGNORE_CASE;
2109
2158
  backend->direach_flags |= GIT_PATH_DIR_IGNORE_CASE;
2110
2159
  }
2111
- if (!git_repository__cvar(&t, backend->repo, GIT_CVAR_PRECOMPOSE) && t) {
2160
+ if (!git_repository__configmap_lookup(&t, backend->repo, GIT_CONFIGMAP_PRECOMPOSE) && t) {
2112
2161
  backend->iterator_flags |= GIT_ITERATOR_PRECOMPOSE_UNICODE;
2113
2162
  backend->direach_flags |= GIT_PATH_DIR_PRECOMPOSE_UNICODE;
2114
2163
  }
2115
- if ((!git_repository__cvar(&t, backend->repo, GIT_CVAR_FSYNCOBJECTFILES) && t) ||
2164
+ if ((!git_repository__configmap_lookup(&t, backend->repo, GIT_CONFIGMAP_FSYNCOBJECTFILES) && t) ||
2116
2165
  git_repository__fsync_gitdir)
2117
2166
  backend->fsync = 1;
2118
2167
  backend->iterator_flags |= GIT_ITERATOR_DESCEND_SYMLINKS;