rugged 1.0.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (349) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -0
  3. data/README.md +1 -1
  4. data/ext/rugged/rugged.c +7 -4
  5. data/ext/rugged/rugged_commit.c +1 -1
  6. data/ext/rugged/rugged_object.c +1 -1
  7. data/ext/rugged/rugged_repo.c +3 -3
  8. data/lib/rugged/commit.rb +16 -2
  9. data/lib/rugged/repository.rb +2 -2
  10. data/lib/rugged/version.rb +1 -1
  11. data/vendor/libgit2/CMakeLists.txt +41 -74
  12. data/vendor/libgit2/COPYING +109 -1
  13. data/vendor/libgit2/cmake/{Modules/AddCFlagIfSupported.cmake → AddCFlagIfSupported.cmake} +0 -0
  14. data/vendor/libgit2/cmake/{Modules/EnableWarnings.cmake → EnableWarnings.cmake} +0 -0
  15. data/vendor/libgit2/cmake/{Modules/FindCoreFoundation.cmake → FindCoreFoundation.cmake} +0 -0
  16. data/vendor/libgit2/cmake/{Modules/FindGSSAPI.cmake → FindGSSAPI.cmake} +0 -0
  17. data/vendor/libgit2/cmake/{Modules/FindGSSFramework.cmake → FindGSSFramework.cmake} +0 -0
  18. data/vendor/libgit2/cmake/{Modules/FindHTTP_Parser.cmake → FindHTTP_Parser.cmake} +0 -0
  19. data/vendor/libgit2/cmake/{Modules/FindIconv.cmake → FindIconv.cmake} +0 -0
  20. data/vendor/libgit2/cmake/FindLibSSH2.cmake +13 -0
  21. data/vendor/libgit2/cmake/{Modules/FindPCRE.cmake → FindPCRE.cmake} +0 -0
  22. data/vendor/libgit2/cmake/{Modules/FindPCRE2.cmake → FindPCRE2.cmake} +0 -0
  23. data/vendor/libgit2/cmake/{Modules/FindPkgLibraries.cmake → FindPkgLibraries.cmake} +0 -0
  24. data/vendor/libgit2/cmake/{Modules/FindSecurity.cmake → FindSecurity.cmake} +0 -0
  25. data/vendor/libgit2/cmake/{Modules/FindStatNsec.cmake → FindStatNsec.cmake} +0 -0
  26. data/vendor/libgit2/cmake/Findfutimens.cmake +14 -0
  27. data/vendor/libgit2/cmake/{Modules/FindmbedTLS.cmake → FindmbedTLS.cmake} +0 -0
  28. data/vendor/libgit2/cmake/{Modules/IdeSplitSources.cmake → IdeSplitSources.cmake} +0 -0
  29. data/vendor/libgit2/cmake/{Modules/PkgBuildConfig.cmake → PkgBuildConfig.cmake} +0 -0
  30. data/vendor/libgit2/cmake/{Modules/SanitizeBool.cmake → SanitizeBool.cmake} +0 -0
  31. data/vendor/libgit2/cmake/{Modules/SelectGSSAPI.cmake → SelectGSSAPI.cmake} +18 -26
  32. data/vendor/libgit2/cmake/{Modules/SelectHTTPSBackend.cmake → SelectHTTPSBackend.cmake} +29 -32
  33. data/vendor/libgit2/cmake/{Modules/SelectHashes.cmake → SelectHashes.cmake} +21 -28
  34. data/vendor/libgit2/deps/chromium-zlib/CMakeLists.txt +101 -0
  35. data/vendor/libgit2/deps/http-parser/CMakeLists.txt +4 -3
  36. data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +24 -10
  37. data/vendor/libgit2/deps/ntlmclient/compat.h +0 -27
  38. data/vendor/libgit2/deps/ntlmclient/crypt.h +14 -9
  39. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +20 -20
  40. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +3 -3
  41. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +37 -36
  42. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +4 -3
  43. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +178 -51
  44. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +74 -5
  45. data/vendor/libgit2/deps/ntlmclient/ntlm.c +164 -135
  46. data/vendor/libgit2/deps/ntlmclient/ntlm.h +13 -9
  47. data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +16 -3
  48. data/vendor/libgit2/deps/ntlmclient/unicode.h +10 -4
  49. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +16 -27
  50. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.h +20 -0
  51. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +28 -52
  52. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.h +22 -0
  53. data/vendor/libgit2/deps/ntlmclient/util.c +15 -1
  54. data/vendor/libgit2/deps/ntlmclient/util.h +2 -1
  55. data/vendor/libgit2/deps/pcre/LICENCE +93 -0
  56. data/vendor/libgit2/deps/pcre/pcre.h +2 -2
  57. data/vendor/libgit2/deps/pcre/pcre_compile.c +29 -17
  58. data/vendor/libgit2/deps/pcre/pcre_jit_compile.c +4 -4
  59. data/vendor/libgit2/deps/pcre/pcreposix.c +2 -3
  60. data/vendor/libgit2/deps/zlib/CMakeLists.txt +6 -5
  61. data/vendor/libgit2/deps/zlib/deflate.c +1 -0
  62. data/vendor/libgit2/include/git2/annotated_commit.h +1 -1
  63. data/vendor/libgit2/include/git2/apply.h +2 -0
  64. data/vendor/libgit2/include/git2/attr.h +95 -0
  65. data/vendor/libgit2/include/git2/blame.h +95 -42
  66. data/vendor/libgit2/include/git2/blob.h +37 -3
  67. data/vendor/libgit2/include/git2/branch.h +25 -0
  68. data/vendor/libgit2/include/git2/cert.h +42 -5
  69. data/vendor/libgit2/include/git2/checkout.h +28 -12
  70. data/vendor/libgit2/include/git2/clone.h +1 -1
  71. data/vendor/libgit2/include/git2/commit.h +35 -19
  72. data/vendor/libgit2/include/git2/common.h +51 -6
  73. data/vendor/libgit2/include/git2/config.h +1 -1
  74. data/vendor/libgit2/include/git2/deprecated.h +368 -8
  75. data/vendor/libgit2/include/git2/diff.h +34 -113
  76. data/vendor/libgit2/include/git2/email.h +127 -0
  77. data/vendor/libgit2/include/git2/errors.h +8 -7
  78. data/vendor/libgit2/include/git2/filter.h +63 -17
  79. data/vendor/libgit2/include/git2/graph.h +20 -2
  80. data/vendor/libgit2/include/git2/index.h +4 -5
  81. data/vendor/libgit2/include/git2/indexer.h +2 -1
  82. data/vendor/libgit2/include/git2/notes.h +2 -2
  83. data/vendor/libgit2/include/git2/odb.h +44 -20
  84. data/vendor/libgit2/include/git2/oidarray.h +5 -8
  85. data/vendor/libgit2/include/git2/pack.h +1 -1
  86. data/vendor/libgit2/include/git2/patch.h +8 -0
  87. data/vendor/libgit2/include/git2/rebase.h +25 -1
  88. data/vendor/libgit2/include/git2/refs.h +9 -5
  89. data/vendor/libgit2/include/git2/remote.h +62 -9
  90. data/vendor/libgit2/include/git2/repository.h +107 -62
  91. data/vendor/libgit2/include/git2/revparse.h +5 -5
  92. data/vendor/libgit2/include/git2/stash.h +1 -1
  93. data/vendor/libgit2/include/git2/status.h +115 -59
  94. data/vendor/libgit2/include/git2/stdint.h +3 -3
  95. data/vendor/libgit2/include/git2/strarray.h +6 -10
  96. data/vendor/libgit2/include/git2/submodule.h +9 -0
  97. data/vendor/libgit2/include/git2/sys/commit_graph.h +174 -0
  98. data/vendor/libgit2/include/git2/sys/email.h +45 -0
  99. data/vendor/libgit2/include/git2/sys/filter.h +49 -28
  100. data/vendor/libgit2/include/git2/sys/midx.h +74 -0
  101. data/vendor/libgit2/include/git2/sys/odb_backend.h +7 -0
  102. data/vendor/libgit2/include/git2/sys/transport.h +1 -0
  103. data/vendor/libgit2/include/git2/tag.h +12 -0
  104. data/vendor/libgit2/include/git2/transport.h +1 -1
  105. data/vendor/libgit2/include/git2/tree.h +2 -14
  106. data/vendor/libgit2/include/git2/types.h +9 -0
  107. data/vendor/libgit2/include/git2/version.h +4 -4
  108. data/vendor/libgit2/include/git2/worktree.h +1 -0
  109. data/vendor/libgit2/include/git2.h +1 -0
  110. data/vendor/libgit2/src/CMakeLists.txt +84 -44
  111. data/vendor/libgit2/src/alloc.c +21 -8
  112. data/vendor/libgit2/src/allocators/failalloc.c +92 -0
  113. data/vendor/libgit2/src/allocators/failalloc.h +23 -0
  114. data/vendor/libgit2/src/allocators/stdalloc.c +41 -10
  115. data/vendor/libgit2/src/allocators/win32_leakcheck.c +118 -0
  116. data/vendor/libgit2/src/allocators/{win32_crtdbg.h → win32_leakcheck.h} +3 -3
  117. data/vendor/libgit2/src/annotated_commit.c +21 -9
  118. data/vendor/libgit2/src/apply.c +21 -8
  119. data/vendor/libgit2/src/array.h +11 -11
  120. data/vendor/libgit2/src/assert_safe.h +58 -0
  121. data/vendor/libgit2/src/attr.c +192 -70
  122. data/vendor/libgit2/src/attr_file.c +99 -41
  123. data/vendor/libgit2/src/attr_file.h +32 -11
  124. data/vendor/libgit2/src/attrcache.c +44 -40
  125. data/vendor/libgit2/src/attrcache.h +4 -5
  126. data/vendor/libgit2/src/blame.c +32 -19
  127. data/vendor/libgit2/src/blame_git.c +7 -4
  128. data/vendor/libgit2/src/blob.c +60 -32
  129. data/vendor/libgit2/src/branch.c +87 -37
  130. data/vendor/libgit2/src/buffer.c +349 -29
  131. data/vendor/libgit2/src/buffer.h +154 -2
  132. data/vendor/libgit2/src/cache.c +3 -24
  133. data/vendor/libgit2/src/cache.h +7 -7
  134. data/vendor/libgit2/src/cc-compat.h +10 -8
  135. data/vendor/libgit2/src/checkout.c +103 -105
  136. data/vendor/libgit2/src/cherrypick.c +8 -2
  137. data/vendor/libgit2/src/clone.c +105 -30
  138. data/vendor/libgit2/src/commit.c +41 -28
  139. data/vendor/libgit2/src/commit_graph.c +1209 -0
  140. data/vendor/libgit2/src/commit_graph.h +162 -0
  141. data/vendor/libgit2/src/commit_list.c +46 -0
  142. data/vendor/libgit2/src/commit_list.h +2 -0
  143. data/vendor/libgit2/src/common.h +26 -2
  144. data/vendor/libgit2/src/config.c +41 -23
  145. data/vendor/libgit2/src/config_cache.c +9 -4
  146. data/vendor/libgit2/src/config_entries.c +35 -27
  147. data/vendor/libgit2/src/config_file.c +17 -9
  148. data/vendor/libgit2/src/config_parse.c +6 -8
  149. data/vendor/libgit2/src/config_snapshot.c +2 -1
  150. data/vendor/libgit2/src/crlf.c +16 -6
  151. data/vendor/libgit2/src/date.c +4 -3
  152. data/vendor/libgit2/src/delta.c +1 -1
  153. data/vendor/libgit2/src/describe.c +12 -5
  154. data/vendor/libgit2/src/diff.c +55 -183
  155. data/vendor/libgit2/src/diff_driver.c +21 -17
  156. data/vendor/libgit2/src/diff_file.c +5 -7
  157. data/vendor/libgit2/src/diff_generate.c +56 -28
  158. data/vendor/libgit2/src/diff_parse.c +2 -3
  159. data/vendor/libgit2/src/diff_print.c +81 -65
  160. data/vendor/libgit2/src/diff_stats.c +19 -16
  161. data/vendor/libgit2/src/diff_tform.c +13 -13
  162. data/vendor/libgit2/src/diff_xdiff.c +4 -2
  163. data/vendor/libgit2/src/diff_xdiff.h +1 -1
  164. data/vendor/libgit2/src/email.c +299 -0
  165. data/vendor/libgit2/src/email.h +25 -0
  166. data/vendor/libgit2/src/errors.c +26 -19
  167. data/vendor/libgit2/src/features.h.in +5 -1
  168. data/vendor/libgit2/src/fetch.c +7 -2
  169. data/vendor/libgit2/src/fetchhead.c +8 -4
  170. data/vendor/libgit2/src/filebuf.c +9 -7
  171. data/vendor/libgit2/src/filter.c +215 -113
  172. data/vendor/libgit2/src/filter.h +24 -5
  173. data/vendor/libgit2/src/futils.c +8 -8
  174. data/vendor/libgit2/src/futils.h +4 -4
  175. data/vendor/libgit2/src/graph.c +64 -9
  176. data/vendor/libgit2/src/hash/sha1/collisiondetect.c +3 -3
  177. data/vendor/libgit2/src/hash/sha1/common_crypto.c +3 -3
  178. data/vendor/libgit2/src/hash/sha1/generic.h +1 -1
  179. data/vendor/libgit2/src/hash/sha1/mbedtls.c +12 -12
  180. data/vendor/libgit2/src/hash/sha1/openssl.c +3 -3
  181. data/vendor/libgit2/src/hash/sha1/sha1dc/sha1.c +8 -10
  182. data/vendor/libgit2/src/hash/sha1/win32.c +15 -11
  183. data/vendor/libgit2/src/hash.c +16 -13
  184. data/vendor/libgit2/src/hash.h +1 -1
  185. data/vendor/libgit2/src/hashsig.c +23 -10
  186. data/vendor/libgit2/src/ident.c +13 -3
  187. data/vendor/libgit2/src/idxmap.c +0 -22
  188. data/vendor/libgit2/src/ignore.c +33 -17
  189. data/vendor/libgit2/src/index.c +124 -82
  190. data/vendor/libgit2/src/index.h +1 -1
  191. data/vendor/libgit2/src/indexer.c +95 -37
  192. data/vendor/libgit2/src/integer.h +79 -2
  193. data/vendor/libgit2/src/iterator.c +40 -28
  194. data/vendor/libgit2/src/iterator.h +1 -1
  195. data/vendor/libgit2/src/khash.h +2 -11
  196. data/vendor/libgit2/src/{settings.c → libgit2.c} +148 -49
  197. data/vendor/libgit2/src/libgit2.h +15 -0
  198. data/vendor/libgit2/src/mailmap.c +23 -10
  199. data/vendor/libgit2/src/map.h +3 -3
  200. data/vendor/libgit2/src/merge.c +95 -43
  201. data/vendor/libgit2/src/merge.h +2 -1
  202. data/vendor/libgit2/src/merge_driver.c +19 -13
  203. data/vendor/libgit2/src/merge_file.c +15 -9
  204. data/vendor/libgit2/src/message.c +3 -1
  205. data/vendor/libgit2/src/midx.c +879 -0
  206. data/vendor/libgit2/src/midx.h +110 -0
  207. data/vendor/libgit2/src/mwindow.c +214 -95
  208. data/vendor/libgit2/src/mwindow.h +3 -3
  209. data/vendor/libgit2/src/net.c +133 -4
  210. data/vendor/libgit2/src/net.h +16 -2
  211. data/vendor/libgit2/src/netops.c +6 -4
  212. data/vendor/libgit2/src/netops.h +2 -2
  213. data/vendor/libgit2/src/notes.c +40 -40
  214. data/vendor/libgit2/src/object.c +24 -15
  215. data/vendor/libgit2/src/odb.c +298 -57
  216. data/vendor/libgit2/src/odb.h +16 -2
  217. data/vendor/libgit2/src/odb_loose.c +31 -21
  218. data/vendor/libgit2/src/odb_mempack.c +3 -1
  219. data/vendor/libgit2/src/odb_pack.c +391 -114
  220. data/vendor/libgit2/src/oid.c +7 -4
  221. data/vendor/libgit2/src/oidarray.c +10 -1
  222. data/vendor/libgit2/src/pack-objects.c +83 -69
  223. data/vendor/libgit2/src/pack.c +383 -150
  224. data/vendor/libgit2/src/pack.h +44 -9
  225. data/vendor/libgit2/src/patch.c +14 -7
  226. data/vendor/libgit2/src/patch_generate.c +3 -5
  227. data/vendor/libgit2/src/patch_parse.c +6 -3
  228. data/vendor/libgit2/src/path.c +103 -58
  229. data/vendor/libgit2/src/path.h +80 -7
  230. data/vendor/libgit2/src/pathspec.c +12 -11
  231. data/vendor/libgit2/src/pool.c +34 -22
  232. data/vendor/libgit2/src/pool.h +9 -1
  233. data/vendor/libgit2/src/posix.c +43 -12
  234. data/vendor/libgit2/src/posix.h +9 -0
  235. data/vendor/libgit2/src/proxy.c +2 -0
  236. data/vendor/libgit2/src/push.c +2 -0
  237. data/vendor/libgit2/src/reader.c +10 -6
  238. data/vendor/libgit2/src/rebase.c +95 -49
  239. data/vendor/libgit2/src/refdb.c +165 -13
  240. data/vendor/libgit2/src/refdb.h +69 -0
  241. data/vendor/libgit2/src/refdb_fs.c +145 -153
  242. data/vendor/libgit2/src/reflog.c +21 -20
  243. data/vendor/libgit2/src/refs.c +153 -233
  244. data/vendor/libgit2/src/refs.h +2 -20
  245. data/vendor/libgit2/src/refspec.c +81 -45
  246. data/vendor/libgit2/src/regexp.c +2 -2
  247. data/vendor/libgit2/src/remote.c +320 -122
  248. data/vendor/libgit2/src/remote.h +2 -1
  249. data/vendor/libgit2/src/repository.c +476 -203
  250. data/vendor/libgit2/src/repository.h +27 -29
  251. data/vendor/libgit2/src/reset.c +8 -7
  252. data/vendor/libgit2/src/revert.c +8 -2
  253. data/vendor/libgit2/src/revparse.c +23 -17
  254. data/vendor/libgit2/src/revwalk.c +35 -20
  255. data/vendor/libgit2/src/runtime.c +162 -0
  256. data/vendor/libgit2/src/runtime.h +62 -0
  257. data/vendor/libgit2/src/{refdb_fs.h → settings.h} +3 -11
  258. data/vendor/libgit2/src/signature.c +6 -5
  259. data/vendor/libgit2/src/sortedcache.c +2 -3
  260. data/vendor/libgit2/src/sortedcache.h +10 -8
  261. data/vendor/libgit2/src/stash.c +6 -2
  262. data/vendor/libgit2/src/status.c +9 -4
  263. data/vendor/libgit2/src/strarray.c +64 -0
  264. data/vendor/libgit2/src/streams/mbedtls.c +14 -17
  265. data/vendor/libgit2/src/streams/mbedtls.h +1 -1
  266. data/vendor/libgit2/src/streams/openssl.c +113 -207
  267. data/vendor/libgit2/src/streams/openssl.h +9 -1
  268. data/vendor/libgit2/src/streams/openssl_dynamic.c +309 -0
  269. data/vendor/libgit2/src/streams/openssl_dynamic.h +348 -0
  270. data/vendor/libgit2/src/streams/openssl_legacy.c +203 -0
  271. data/vendor/libgit2/src/streams/openssl_legacy.h +63 -0
  272. data/vendor/libgit2/src/streams/registry.c +10 -9
  273. data/vendor/libgit2/src/streams/socket.c +6 -2
  274. data/vendor/libgit2/src/streams/stransport.c +6 -3
  275. data/vendor/libgit2/src/streams/tls.c +5 -3
  276. data/vendor/libgit2/src/submodule.c +134 -66
  277. data/vendor/libgit2/src/submodule.h +9 -9
  278. data/vendor/libgit2/src/sysdir.c +8 -26
  279. data/vendor/libgit2/src/sysdir.h +0 -11
  280. data/vendor/libgit2/src/tag.c +49 -11
  281. data/vendor/libgit2/src/thread.c +140 -0
  282. data/vendor/libgit2/src/thread.h +479 -0
  283. data/vendor/libgit2/src/threadstate.c +84 -0
  284. data/vendor/libgit2/src/threadstate.h +24 -0
  285. data/vendor/libgit2/src/trace.c +2 -2
  286. data/vendor/libgit2/src/trace.h +17 -13
  287. data/vendor/libgit2/src/trailer.c +1 -1
  288. data/vendor/libgit2/src/transaction.c +21 -9
  289. data/vendor/libgit2/src/transport.c +3 -3
  290. data/vendor/libgit2/src/transports/auth.c +1 -1
  291. data/vendor/libgit2/src/transports/auth_negotiate.c +11 -4
  292. data/vendor/libgit2/src/transports/auth_ntlm.c +10 -6
  293. data/vendor/libgit2/src/transports/credential.c +17 -7
  294. data/vendor/libgit2/src/transports/credential_helpers.c +2 -0
  295. data/vendor/libgit2/src/transports/git.c +1 -3
  296. data/vendor/libgit2/src/transports/http.c +19 -17
  297. data/vendor/libgit2/src/transports/http.h +1 -0
  298. data/vendor/libgit2/src/transports/httpclient.c +68 -38
  299. data/vendor/libgit2/src/transports/httpclient.h +1 -1
  300. data/vendor/libgit2/src/transports/local.c +5 -5
  301. data/vendor/libgit2/src/transports/smart.c +14 -9
  302. data/vendor/libgit2/src/transports/smart.h +1 -1
  303. data/vendor/libgit2/src/transports/smart_protocol.c +11 -5
  304. data/vendor/libgit2/src/transports/ssh.c +55 -21
  305. data/vendor/libgit2/src/transports/winhttp.c +157 -89
  306. data/vendor/libgit2/src/tree.c +100 -77
  307. data/vendor/libgit2/src/tree.h +1 -0
  308. data/vendor/libgit2/src/tsort.c +0 -2
  309. data/vendor/libgit2/src/unix/map.c +3 -1
  310. data/vendor/libgit2/src/unix/posix.h +16 -1
  311. data/vendor/libgit2/src/unix/pthread.h +2 -1
  312. data/vendor/libgit2/src/utf8.c +150 -0
  313. data/vendor/libgit2/src/utf8.h +52 -0
  314. data/vendor/libgit2/src/util.c +75 -184
  315. data/vendor/libgit2/src/util.h +34 -40
  316. data/vendor/libgit2/src/vector.c +23 -19
  317. data/vendor/libgit2/src/vector.h +4 -2
  318. data/vendor/libgit2/src/win32/findfile.c +5 -3
  319. data/vendor/libgit2/src/win32/git2.rc +18 -3
  320. data/vendor/libgit2/src/win32/map.c +1 -1
  321. data/vendor/libgit2/src/win32/msvc-compat.h +9 -1
  322. data/vendor/libgit2/src/win32/path_w32.c +23 -25
  323. data/vendor/libgit2/src/win32/path_w32.h +0 -1
  324. data/vendor/libgit2/src/win32/posix.h +6 -6
  325. data/vendor/libgit2/src/win32/posix_w32.c +86 -7
  326. data/vendor/libgit2/src/win32/precompiled.h +0 -1
  327. data/vendor/libgit2/src/win32/reparse.h +4 -4
  328. data/vendor/libgit2/src/win32/thread.c +24 -15
  329. data/vendor/libgit2/src/win32/thread.h +1 -1
  330. data/vendor/libgit2/src/win32/w32_buffer.c +3 -3
  331. data/vendor/libgit2/src/win32/w32_common.h +18 -9
  332. data/vendor/libgit2/src/win32/{w32_crtdbg_stacktrace.c → w32_leakcheck.c} +269 -33
  333. data/vendor/libgit2/src/win32/w32_leakcheck.h +222 -0
  334. data/vendor/libgit2/src/win32/w32_util.h +6 -6
  335. data/vendor/libgit2/src/worktree.c +36 -14
  336. data/vendor/libgit2/src/zstream.c +1 -1
  337. metadata +65 -42
  338. data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.c.in +0 -29
  339. data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.cmake +0 -96
  340. data/vendor/libgit2/src/allocators/win32_crtdbg.c +0 -118
  341. data/vendor/libgit2/src/buf_text.c +0 -316
  342. data/vendor/libgit2/src/buf_text.h +0 -122
  343. data/vendor/libgit2/src/global.c +0 -361
  344. data/vendor/libgit2/src/global.h +0 -41
  345. data/vendor/libgit2/src/thread-utils.c +0 -58
  346. data/vendor/libgit2/src/thread-utils.h +0 -246
  347. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +0 -127
  348. data/vendor/libgit2/src/win32/w32_stack.c +0 -188
  349. data/vendor/libgit2/src/win32/w32_stack.h +0 -140
@@ -5,8 +5,6 @@
5
5
  * a Linking Exception. For full terms see the included COPYING file.
6
6
  */
7
7
 
8
- #include "refdb_fs.h"
9
-
10
8
  #include "refs.h"
11
9
  #include "hash.h"
12
10
  #include "repository.h"
@@ -70,6 +68,35 @@ typedef struct refdb_fs_backend {
70
68
 
71
69
  static int refdb_reflog_fs__delete(git_refdb_backend *_backend, const char *name);
72
70
 
71
+ GIT_INLINE(int) loose_path(
72
+ git_buf *out,
73
+ const char *base,
74
+ const char *refname)
75
+ {
76
+ if (git_buf_joinpath(out, base, refname) < 0)
77
+ return -1;
78
+
79
+ return git_path_validate_filesystem_with_suffix(out->ptr, out->size,
80
+ CONST_STRLEN(".lock"));
81
+ }
82
+
83
+ GIT_INLINE(int) reflog_path(
84
+ git_buf *out,
85
+ git_repository *repo,
86
+ const char *refname)
87
+ {
88
+ const char *base;
89
+ int error;
90
+
91
+ base = (strcmp(refname, GIT_HEAD_FILE) == 0) ? repo->gitdir :
92
+ repo->commondir;
93
+
94
+ if ((error = git_buf_joinpath(out, base, GIT_REFLOG_DIR)) < 0)
95
+ return error;
96
+
97
+ return loose_path(out, out->ptr, refname);
98
+ }
99
+
73
100
  static int packref_cmp(const void *a_, const void *b_)
74
101
  {
75
102
  const struct packref *a = a_, *b = b_;
@@ -95,7 +122,7 @@ static int packed_reload(refdb_fs_backend *backend)
95
122
  */
96
123
  if (error <= 0) {
97
124
  if (error == GIT_ENOTFOUND) {
98
- git_sortedcache_clear(backend->refcache, true);
125
+ GIT_UNUSED(git_sortedcache_clear(backend->refcache, true));
99
126
  git_error_clear();
100
127
  error = 0;
101
128
  }
@@ -104,7 +131,7 @@ static int packed_reload(refdb_fs_backend *backend)
104
131
 
105
132
  /* At this point, refresh the packed refs from the loaded buffer. */
106
133
 
107
- git_sortedcache_clear(backend->refcache, false);
134
+ GIT_UNUSED(git_sortedcache_clear(backend->refcache, false));
108
135
 
109
136
  scan = (char *)packedrefs.ptr;
110
137
  eof = scan + packedrefs.size;
@@ -192,7 +219,7 @@ static int packed_reload(refdb_fs_backend *backend)
192
219
  parse_failed:
193
220
  git_error_set(GIT_ERROR_REFERENCE, "corrupted packed references file");
194
221
 
195
- git_sortedcache_clear(backend->refcache, false);
222
+ GIT_UNUSED(git_sortedcache_clear(backend->refcache, false));
196
223
  git_sortedcache_wunlock(backend->refcache);
197
224
  git_buf_dispose(&packedrefs);
198
225
 
@@ -225,9 +252,8 @@ static int loose_readbuffer(git_buf *buf, const char *base, const char *path)
225
252
  {
226
253
  int error;
227
254
 
228
- /* build full path to file */
229
- if ((error = git_buf_joinpath(buf, base, path)) < 0 ||
230
- (error = git_futils_readbuffer(buf, buf->ptr)) < 0)
255
+ if ((error = loose_path(buf, base, path)) < 0 ||
256
+ (error = git_futils_readbuffer(buf, buf->ptr)) < 0)
231
257
  git_buf_dispose(buf);
232
258
 
233
259
  return error;
@@ -256,7 +282,8 @@ static int loose_lookup_to_packfile(refdb_fs_backend *backend, const char *name)
256
282
  if ((error = loose_parse_oid(&oid, name, &ref_file)) < 0)
257
283
  goto done;
258
284
 
259
- git_sortedcache_wlock(backend->refcache);
285
+ if ((error = git_sortedcache_wlock(backend->refcache)) < 0)
286
+ goto done;
260
287
 
261
288
  if (!(error = git_sortedcache_upsert(
262
289
  (void **)&ref, backend->refcache, name))) {
@@ -333,11 +360,11 @@ static int refdb_fs_backend__exists(
333
360
  git_buf ref_path = GIT_BUF_INIT;
334
361
  int error;
335
362
 
336
- assert(backend);
363
+ GIT_ASSERT_ARG(backend);
337
364
 
338
365
  *exists = 0;
339
366
 
340
- if ((error = git_buf_joinpath(&ref_path, backend->gitpath, ref_name)) < 0)
367
+ if ((error = loose_path(&ref_path, backend->gitpath, ref_name)) < 0)
341
368
  goto out;
342
369
 
343
370
  if (git_path_isfile(ref_path.ptr)) {
@@ -474,7 +501,7 @@ static int refdb_fs_backend__lookup(
474
501
  refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
475
502
  int error;
476
503
 
477
- assert(backend);
504
+ GIT_ASSERT_ARG(backend);
478
505
 
479
506
  if (!(error = loose_lookup(out, backend, ref_name)))
480
507
  return 0;
@@ -551,7 +578,7 @@ static int iter_load_loose_paths(refdb_fs_backend *backend, refdb_fs_iter *iter)
551
578
  }
552
579
  }
553
580
 
554
- if ((error = git_buf_printf(&path, "%s/", backend->commonpath)) < 0 ||
581
+ if ((error = git_buf_puts(&path, backend->commonpath)) < 0 ||
555
582
  (error = git_buf_put(&path, ref_prefix, ref_prefix_len)) < 0) {
556
583
  git_buf_dispose(&path);
557
584
  return error;
@@ -680,12 +707,13 @@ static int refdb_fs_backend__iterator(
680
707
  refdb_fs_iter *iter = NULL;
681
708
  int error;
682
709
 
683
- assert(backend);
710
+ GIT_ASSERT_ARG(backend);
684
711
 
685
712
  iter = git__calloc(1, sizeof(refdb_fs_iter));
686
713
  GIT_ERROR_CHECK_ALLOC(iter);
687
714
 
688
- git_pool_init(&iter->pool, 1);
715
+ if ((error = git_pool_init(&iter->pool, 1)) < 0)
716
+ goto out;
689
717
 
690
718
  if ((error = git_vector_init(&iter->loose, 8, NULL)) < 0)
691
719
  goto out;
@@ -736,7 +764,7 @@ static bool ref_is_available(
736
764
  static int reference_path_available(
737
765
  refdb_fs_backend *backend,
738
766
  const char *new_ref,
739
- const char* old_ref,
767
+ const char *old_ref,
740
768
  int force)
741
769
  {
742
770
  size_t i;
@@ -761,7 +789,8 @@ static int reference_path_available(
761
789
  }
762
790
  }
763
791
 
764
- git_sortedcache_rlock(backend->refcache);
792
+ if ((error = git_sortedcache_rlock(backend->refcache)) < 0)
793
+ return error;
765
794
 
766
795
  for (i = 0; i < git_sortedcache_entrycount(backend->refcache); ++i) {
767
796
  struct packref *ref = git_sortedcache_entry(backend->refcache, i);
@@ -784,9 +813,11 @@ static int loose_lock(git_filebuf *file, refdb_fs_backend *backend, const char *
784
813
  git_buf ref_path = GIT_BUF_INIT;
785
814
  const char *basedir;
786
815
 
787
- assert(file && backend && name);
816
+ GIT_ASSERT_ARG(file);
817
+ GIT_ASSERT_ARG(backend);
818
+ GIT_ASSERT_ARG(name);
788
819
 
789
- if (!git_path_isvalid(backend->repo, name, 0, GIT_PATH_REJECT_FILESYSTEM_DEFAULTS)) {
820
+ if (!git_path_validate(backend->repo, name, 0, GIT_PATH_REJECT_FILESYSTEM_DEFAULTS)) {
790
821
  git_error_set(GIT_ERROR_INVALID, "invalid reference name '%s'", name);
791
822
  return GIT_EINVALIDSPEC;
792
823
  }
@@ -802,8 +833,8 @@ static int loose_lock(git_filebuf *file, refdb_fs_backend *backend, const char *
802
833
  if ((error = git_futils_rmdir_r(name, basedir, GIT_RMDIR_SKIP_NONEMPTY)) < 0)
803
834
  return error;
804
835
 
805
- if (git_buf_joinpath(&ref_path, basedir, name) < 0)
806
- return -1;
836
+ if ((error = loose_path(&ref_path, basedir, name)) < 0)
837
+ return error;
807
838
 
808
839
  filebuf_flags = GIT_FILEBUF_CREATE_LEADING_DIRS;
809
840
  if (backend->fsync)
@@ -820,7 +851,8 @@ static int loose_lock(git_filebuf *file, refdb_fs_backend *backend, const char *
820
851
 
821
852
  static int loose_commit(git_filebuf *file, const git_reference *ref)
822
853
  {
823
- assert(file && ref);
854
+ GIT_ASSERT_ARG(file);
855
+ GIT_ASSERT_ARG(ref);
824
856
 
825
857
  if (ref->type == GIT_REFERENCE_DIRECT) {
826
858
  char oid[GIT_OID_HEXSZ + 1];
@@ -830,7 +862,7 @@ static int loose_commit(git_filebuf *file, const git_reference *ref)
830
862
  } else if (ref->type == GIT_REFERENCE_SYMBOLIC) {
831
863
  git_filebuf_printf(file, GIT_SYMREF "%s\n", ref->target.symbolic);
832
864
  } else {
833
- assert(0); /* don't let this happen */
865
+ GIT_ASSERT(0);
834
866
  }
835
867
 
836
868
  return git_filebuf_commit(file);
@@ -1067,7 +1099,7 @@ static int packed_write(refdb_fs_backend *backend)
1067
1099
 
1068
1100
  for (i = 0; i < git_sortedcache_entrycount(refcache); ++i) {
1069
1101
  struct packref *ref = git_sortedcache_entry(refcache, i);
1070
- assert(ref);
1102
+ GIT_ASSERT(ref);
1071
1103
 
1072
1104
  if ((error = packed_find_peel(backend, ref)) < 0)
1073
1105
  goto fail;
@@ -1129,44 +1161,6 @@ cleanup:
1129
1161
  }
1130
1162
 
1131
1163
  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);
1132
- static int has_reflog(git_repository *repo, const char *name);
1133
-
1134
- static int should_write_reflog(int *write, git_repository *repo, const char *name)
1135
- {
1136
- int error, logall;
1137
-
1138
- error = git_repository__configmap_lookup(&logall, repo, GIT_CONFIGMAP_LOGALLREFUPDATES);
1139
- if (error < 0)
1140
- return error;
1141
-
1142
- /* Defaults to the opposite of the repo being bare */
1143
- if (logall == GIT_LOGALLREFUPDATES_UNSET)
1144
- logall = !git_repository_is_bare(repo);
1145
-
1146
- *write = 0;
1147
- switch (logall) {
1148
- case GIT_LOGALLREFUPDATES_FALSE:
1149
- *write = 0;
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:
1164
- *write = 1;
1165
- break;
1166
- }
1167
-
1168
- return 0;
1169
- }
1170
1164
 
1171
1165
  static int cmp_old_ref(int *cmp, git_refdb_backend *backend, const char *name,
1172
1166
  const git_oid *old_id, const char *old_target)
@@ -1179,8 +1173,11 @@ static int cmp_old_ref(int *cmp, git_refdb_backend *backend, const char *name,
1179
1173
  if (!old_id && !old_target)
1180
1174
  return 0;
1181
1175
 
1182
- if ((error = refdb_fs_backend__lookup(&old_ref, backend, name)) < 0)
1176
+ if ((error = refdb_fs_backend__lookup(&old_ref, backend, name)) < 0) {
1177
+ if (error == GIT_ENOTFOUND && old_id && git_oid_is_zero(old_id))
1178
+ return 0;
1183
1179
  goto out;
1180
+ }
1184
1181
 
1185
1182
  /* If the types don't match, there's no way the values do */
1186
1183
  if (old_id && old_ref->type != GIT_REFERENCE_DIRECT) {
@@ -1220,54 +1217,28 @@ out:
1220
1217
  */
1221
1218
  static int maybe_append_head(refdb_fs_backend *backend, const git_reference *ref, const git_signature *who, const char *message)
1222
1219
  {
1223
- int error;
1220
+ git_reference *head = NULL;
1221
+ git_refdb *refdb = NULL;
1222
+ int error, write_reflog;
1224
1223
  git_oid old_id;
1225
- git_reference *tmp = NULL, *head = NULL, *peeled = NULL;
1226
- const char *name;
1227
1224
 
1228
- if (ref->type == GIT_REFERENCE_SYMBOLIC)
1229
- return 0;
1225
+ if ((error = git_repository_refdb(&refdb, backend->repo)) < 0 ||
1226
+ (error = git_refdb_should_write_head_reflog(&write_reflog, refdb, ref)) < 0)
1227
+ goto out;
1228
+ if (!write_reflog)
1229
+ goto out;
1230
1230
 
1231
1231
  /* if we can't resolve, we use {0}*40 as old id */
1232
1232
  if (git_reference_name_to_id(&old_id, backend->repo, ref->name) < 0)
1233
1233
  memset(&old_id, 0, sizeof(old_id));
1234
1234
 
1235
- if ((error = git_reference_lookup(&head, backend->repo, GIT_HEAD_FILE)) < 0)
1236
- return error;
1237
-
1238
- if (git_reference_type(head) == GIT_REFERENCE_DIRECT)
1239
- goto cleanup;
1240
-
1241
- if ((error = git_reference_lookup(&tmp, backend->repo, GIT_HEAD_FILE)) < 0)
1242
- goto cleanup;
1243
-
1244
- /* Go down the symref chain until we find the branch */
1245
- while (git_reference_type(tmp) == GIT_REFERENCE_SYMBOLIC) {
1246
- error = git_reference_lookup(&peeled, backend->repo, git_reference_symbolic_target(tmp));
1247
- if (error < 0)
1248
- break;
1249
-
1250
- git_reference_free(tmp);
1251
- tmp = peeled;
1252
- }
1253
-
1254
- if (error == GIT_ENOTFOUND) {
1255
- error = 0;
1256
- name = git_reference_symbolic_target(tmp);
1257
- } else if (error < 0) {
1258
- goto cleanup;
1259
- } else {
1260
- name = git_reference_name(tmp);
1261
- }
1262
-
1263
- if (strcmp(name, ref->name))
1264
- goto cleanup;
1265
-
1266
- error = reflog_append(backend, head, &old_id, git_reference_target(ref), who, message);
1235
+ if ((error = git_reference_lookup(&head, backend->repo, GIT_HEAD_FILE)) < 0 ||
1236
+ (error = reflog_append(backend, head, &old_id, git_reference_target(ref), who, message)) < 0)
1237
+ goto out;
1267
1238
 
1268
- cleanup:
1269
- git_reference_free(tmp);
1239
+ out:
1270
1240
  git_reference_free(head);
1241
+ git_refdb_free(refdb);
1271
1242
  return error;
1272
1243
  }
1273
1244
 
@@ -1284,7 +1255,7 @@ static int refdb_fs_backend__write(
1284
1255
  git_filebuf file = GIT_FILEBUF_INIT;
1285
1256
  int error = 0;
1286
1257
 
1287
- assert(backend);
1258
+ GIT_ASSERT_ARG(backend);
1288
1259
 
1289
1260
  if ((error = reference_path_available(backend, ref->name, NULL, force)) < 0)
1290
1261
  return error;
@@ -1336,7 +1307,10 @@ static int refdb_fs_backend__write_tail(
1336
1307
  }
1337
1308
 
1338
1309
  if (update_reflog) {
1339
- if ((error = should_write_reflog(&should_write, backend->repo, ref->name)) < 0)
1310
+ git_refdb *refdb;
1311
+
1312
+ if ((error = git_repository_refdb__weakptr(&refdb, backend->repo)) < 0 ||
1313
+ (error = git_refdb_should_write_reflog(&should_write, refdb, ref)) < 0)
1340
1314
  goto on_error;
1341
1315
 
1342
1316
  if (should_write) {
@@ -1354,7 +1328,7 @@ on_error:
1354
1328
  return error;
1355
1329
  }
1356
1330
 
1357
- static void refdb_fs_backend__prune_refs(
1331
+ static int refdb_fs_backend__prune_refs(
1358
1332
  refdb_fs_backend *backend,
1359
1333
  const char *ref_name,
1360
1334
  const char *prefix)
@@ -1362,10 +1336,12 @@ static void refdb_fs_backend__prune_refs(
1362
1336
  git_buf relative_path = GIT_BUF_INIT;
1363
1337
  git_buf base_path = GIT_BUF_INIT;
1364
1338
  size_t commonlen;
1339
+ int error;
1365
1340
 
1366
- assert(backend && ref_name);
1341
+ GIT_ASSERT_ARG(backend);
1342
+ GIT_ASSERT_ARG(ref_name);
1367
1343
 
1368
- if (git_buf_sets(&relative_path, ref_name) < 0)
1344
+ if ((error = git_buf_sets(&relative_path, ref_name)) < 0)
1369
1345
  goto cleanup;
1370
1346
 
1371
1347
  git_path_squash_slashes(&relative_path);
@@ -1375,20 +1351,33 @@ static void refdb_fs_backend__prune_refs(
1375
1351
 
1376
1352
  git_buf_truncate(&relative_path, commonlen);
1377
1353
 
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
- }
1354
+ if (prefix)
1355
+ error = git_buf_join3(&base_path, '/',
1356
+ backend->commonpath, prefix,
1357
+ git_buf_cstr(&relative_path));
1358
+ else
1359
+ error = git_buf_joinpath(&base_path,
1360
+ backend->commonpath,
1361
+ git_buf_cstr(&relative_path));
1362
+
1363
+ if (!error)
1364
+ error = git_path_validate_filesystem(base_path.ptr, base_path.size);
1365
+
1366
+ if (error < 0)
1367
+ goto cleanup;
1385
1368
 
1386
- git_futils_rmdir_r(ref_name + commonlen, git_buf_cstr(&base_path), GIT_RMDIR_EMPTY_PARENTS | GIT_RMDIR_SKIP_ROOT);
1369
+ error = git_futils_rmdir_r(ref_name + commonlen,
1370
+ git_buf_cstr(&base_path),
1371
+ GIT_RMDIR_EMPTY_PARENTS | GIT_RMDIR_SKIP_ROOT);
1372
+
1373
+ if (error == GIT_ENOTFOUND)
1374
+ error = 0;
1387
1375
  }
1388
1376
 
1389
1377
  cleanup:
1390
1378
  git_buf_dispose(&relative_path);
1391
1379
  git_buf_dispose(&base_path);
1380
+ return error;
1392
1381
  }
1393
1382
 
1394
1383
  static int refdb_fs_backend__delete(
@@ -1400,7 +1389,8 @@ static int refdb_fs_backend__delete(
1400
1389
  git_filebuf file = GIT_FILEBUF_INIT;
1401
1390
  int error = 0;
1402
1391
 
1403
- assert(backend && ref_name);
1392
+ GIT_ASSERT_ARG(backend);
1393
+ GIT_ASSERT_ARG(ref_name);
1404
1394
 
1405
1395
  if ((error = loose_lock(&file, backend, ref_name)) < 0)
1406
1396
  return error;
@@ -1415,19 +1405,19 @@ static int refdb_fs_backend__delete(
1415
1405
 
1416
1406
  static int loose_delete(refdb_fs_backend *backend, const char *ref_name)
1417
1407
  {
1418
- git_buf loose_path = GIT_BUF_INIT;
1408
+ git_buf path = GIT_BUF_INIT;
1419
1409
  int error = 0;
1420
1410
 
1421
- if (git_buf_joinpath(&loose_path, backend->commonpath, ref_name) < 0)
1422
- return -1;
1411
+ if ((error = loose_path(&path, backend->commonpath, ref_name)) < 0)
1412
+ return error;
1423
1413
 
1424
- error = p_unlink(loose_path.ptr);
1414
+ error = p_unlink(path.ptr);
1425
1415
  if (error < 0 && errno == ENOENT)
1426
1416
  error = GIT_ENOTFOUND;
1427
1417
  else if (error != 0)
1428
1418
  error = -1;
1429
1419
 
1430
- git_buf_dispose(&loose_path);
1420
+ git_buf_dispose(&path);
1431
1421
 
1432
1422
  return error;
1433
1423
  }
@@ -1486,7 +1476,7 @@ static int refdb_fs_backend__delete_tail(
1486
1476
  cleanup:
1487
1477
  git_filebuf_cleanup(file);
1488
1478
  if (error == 0)
1489
- refdb_fs_backend__prune_refs(backend, ref_name, "");
1479
+ error = refdb_fs_backend__prune_refs(backend, ref_name, "");
1490
1480
  return error;
1491
1481
  }
1492
1482
 
@@ -1506,7 +1496,7 @@ static int refdb_fs_backend__rename(
1506
1496
  git_filebuf file = GIT_FILEBUF_INIT;
1507
1497
  int error;
1508
1498
 
1509
- assert(backend);
1499
+ GIT_ASSERT_ARG(backend);
1510
1500
 
1511
1501
  if ((error = reference_path_available(
1512
1502
  backend, new_name, old_name, force)) < 0 ||
@@ -1559,7 +1549,7 @@ static int refdb_fs_backend__compress(git_refdb_backend *_backend)
1559
1549
  int error;
1560
1550
  refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1561
1551
 
1562
- assert(backend);
1552
+ GIT_ASSERT_ARG(backend);
1563
1553
 
1564
1554
  if ((error = packed_reload(backend)) < 0 || /* load the existing packfile */
1565
1555
  (error = packed_loadloose(backend)) < 0 || /* add all the loose refs */
@@ -1573,7 +1563,8 @@ static void refdb_fs_backend__free(git_refdb_backend *_backend)
1573
1563
  {
1574
1564
  refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1575
1565
 
1576
- assert(backend);
1566
+ if (!backend)
1567
+ return;
1577
1568
 
1578
1569
  git_sortedcache_free(backend->refcache);
1579
1570
  git__free(backend->gitpath);
@@ -1618,8 +1609,9 @@ static char *setup_namespace(git_repository *repo, const char *in)
1618
1609
  GIT_MKDIR_PATH, NULL) < 0)
1619
1610
  goto done;
1620
1611
 
1621
- /* Return root of the namespaced gitpath, i.e. without the trailing '/refs' */
1612
+ /* Return root of the namespaced gitpath, i.e. without the trailing 'refs' */
1622
1613
  git_buf_rtruncate_at_char(&path, '/');
1614
+ git_buf_putc(&path, '/');
1623
1615
  out = git_buf_detach(&path);
1624
1616
 
1625
1617
  done:
@@ -1720,13 +1712,6 @@ static int create_new_reflog_file(const char *filepath)
1720
1712
  return p_close(fd);
1721
1713
  }
1722
1714
 
1723
- GIT_INLINE(int) retrieve_reflog_path(git_buf *path, git_repository *repo, const char *name)
1724
- {
1725
- if (strcmp(name, GIT_HEAD_FILE) == 0)
1726
- return git_buf_join3(path, '/', repo->gitdir, GIT_REFLOG_DIR, name);
1727
- return git_buf_join3(path, '/', repo->commondir, GIT_REFLOG_DIR, name);
1728
- }
1729
-
1730
1715
  static int refdb_reflog_fs__ensure_log(git_refdb_backend *_backend, const char *name)
1731
1716
  {
1732
1717
  refdb_fs_backend *backend;
@@ -1734,12 +1719,12 @@ static int refdb_reflog_fs__ensure_log(git_refdb_backend *_backend, const char *
1734
1719
  git_buf path = GIT_BUF_INIT;
1735
1720
  int error;
1736
1721
 
1737
- assert(_backend && name);
1722
+ GIT_ASSERT_ARG(_backend && name);
1738
1723
 
1739
1724
  backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1740
1725
  repo = backend->repo;
1741
1726
 
1742
- if ((error = retrieve_reflog_path(&path, repo, name)) < 0)
1727
+ if ((error = reflog_path(&path, repo, name)) < 0)
1743
1728
  return error;
1744
1729
 
1745
1730
  error = create_new_reflog_file(git_buf_cstr(&path));
@@ -1753,7 +1738,7 @@ static int has_reflog(git_repository *repo, const char *name)
1753
1738
  int ret = 0;
1754
1739
  git_buf path = GIT_BUF_INIT;
1755
1740
 
1756
- if (retrieve_reflog_path(&path, repo, name) < 0)
1741
+ if (reflog_path(&path, repo, name) < 0)
1757
1742
  goto cleanup;
1758
1743
 
1759
1744
  ret = git_path_isfile(git_buf_cstr(&path));
@@ -1767,7 +1752,8 @@ static int refdb_reflog_fs__has_log(git_refdb_backend *_backend, const char *nam
1767
1752
  {
1768
1753
  refdb_fs_backend *backend;
1769
1754
 
1770
- assert(_backend && name);
1755
+ GIT_ASSERT_ARG(_backend);
1756
+ GIT_ASSERT_ARG(name);
1771
1757
 
1772
1758
  backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1773
1759
 
@@ -1783,7 +1769,9 @@ static int refdb_reflog_fs__read(git_reflog **out, git_refdb_backend *_backend,
1783
1769
  git_repository *repo;
1784
1770
  refdb_fs_backend *backend;
1785
1771
 
1786
- assert(out && _backend && name);
1772
+ GIT_ASSERT_ARG(out);
1773
+ GIT_ASSERT_ARG(_backend);
1774
+ GIT_ASSERT_ARG(name);
1787
1775
 
1788
1776
  backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1789
1777
  repo = backend->repo;
@@ -1791,7 +1779,7 @@ static int refdb_reflog_fs__read(git_reflog **out, git_refdb_backend *_backend,
1791
1779
  if (reflog_alloc(&log, name) < 0)
1792
1780
  return -1;
1793
1781
 
1794
- if (retrieve_reflog_path(&log_path, repo, name) < 0)
1782
+ if (reflog_path(&log_path, repo, name) < 0)
1795
1783
  goto cleanup;
1796
1784
 
1797
1785
  error = git_futils_readbuffer(&log_file, git_buf_cstr(&log_path));
@@ -1868,12 +1856,12 @@ static int lock_reflog(git_filebuf *file, refdb_fs_backend *backend, const char
1868
1856
 
1869
1857
  repo = backend->repo;
1870
1858
 
1871
- if (!git_path_isvalid(backend->repo, refname, 0, GIT_PATH_REJECT_FILESYSTEM_DEFAULTS)) {
1859
+ if (!git_path_validate(backend->repo, refname, 0, GIT_PATH_REJECT_FILESYSTEM_DEFAULTS)) {
1872
1860
  git_error_set(GIT_ERROR_INVALID, "invalid reference name '%s'", refname);
1873
1861
  return GIT_EINVALIDSPEC;
1874
1862
  }
1875
1863
 
1876
- if (retrieve_reflog_path(&log_path, repo, refname) < 0)
1864
+ if (reflog_path(&log_path, repo, refname) < 0)
1877
1865
  return -1;
1878
1866
 
1879
1867
  if (!git_path_isfile(git_buf_cstr(&log_path))) {
@@ -1900,7 +1888,8 @@ static int refdb_reflog_fs__write(git_refdb_backend *_backend, git_reflog *reflo
1900
1888
  git_buf log = GIT_BUF_INIT;
1901
1889
  git_filebuf fbuf = GIT_FILEBUF_INIT;
1902
1890
 
1903
- assert(_backend && reflog);
1891
+ GIT_ASSERT_ARG(_backend);
1892
+ GIT_ASSERT_ARG(reflog);
1904
1893
 
1905
1894
  backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1906
1895
 
@@ -1973,7 +1962,7 @@ static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, co
1973
1962
  if ((error = serialize_reflog_entry(&buf, &old_id, &new_id, who, message)) < 0)
1974
1963
  goto cleanup;
1975
1964
 
1976
- if ((error = retrieve_reflog_path(&path, repo, ref->name)) < 0)
1965
+ if ((error = reflog_path(&path, repo, ref->name)) < 0)
1977
1966
  goto cleanup;
1978
1967
 
1979
1968
  if (((error = git_futils_mkpath2file(git_buf_cstr(&path), 0777)) < 0) &&
@@ -2022,7 +2011,9 @@ static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_
2022
2011
  git_repository *repo;
2023
2012
  refdb_fs_backend *backend;
2024
2013
 
2025
- assert(_backend && old_name && new_name);
2014
+ GIT_ASSERT_ARG(_backend);
2015
+ GIT_ASSERT_ARG(old_name);
2016
+ GIT_ASSERT_ARG(new_name);
2026
2017
 
2027
2018
  backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
2028
2019
  repo = backend->repo;
@@ -2034,11 +2025,11 @@ static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_
2034
2025
  if (git_buf_joinpath(&temp_path, repo->gitdir, GIT_REFLOG_DIR) < 0)
2035
2026
  return -1;
2036
2027
 
2037
- if (git_buf_joinpath(&old_path, git_buf_cstr(&temp_path), old_name) < 0)
2038
- return -1;
2028
+ if ((error = loose_path(&old_path, git_buf_cstr(&temp_path), old_name)) < 0)
2029
+ return error;
2039
2030
 
2040
- if (git_buf_joinpath(&new_path, git_buf_cstr(&temp_path), git_buf_cstr(&normalized)) < 0)
2041
- return -1;
2031
+ if ((error = loose_path(&new_path, git_buf_cstr(&temp_path), git_buf_cstr(&normalized))) < 0)
2032
+ return error;
2042
2033
 
2043
2034
  if (!git_path_exists(git_buf_cstr(&old_path))) {
2044
2035
  error = GIT_ENOTFOUND;
@@ -2052,8 +2043,8 @@ static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_
2052
2043
  * - a/b -> a/b/c
2053
2044
  * - a/b/c/d -> a/b/c
2054
2045
  */
2055
- if (git_buf_joinpath(&temp_path, git_buf_cstr(&temp_path), "temp_reflog") < 0)
2056
- return -1;
2046
+ if ((error = loose_path(&temp_path, git_buf_cstr(&temp_path), "temp_reflog")) < 0)
2047
+ return error;
2057
2048
 
2058
2049
  if ((fd = git_futils_mktmp(&temp_path, git_buf_cstr(&temp_path), GIT_REFLOG_FILE_MODE)) < 0) {
2059
2050
  error = -1;
@@ -2099,9 +2090,10 @@ static int refdb_reflog_fs__delete(git_refdb_backend *_backend, const char *name
2099
2090
  git_buf path = GIT_BUF_INIT;
2100
2091
  int error;
2101
2092
 
2102
- assert(_backend && name);
2093
+ GIT_ASSERT_ARG(_backend);
2094
+ GIT_ASSERT_ARG(name);
2103
2095
 
2104
- if ((error = retrieve_reflog_path(&path, backend->repo, name)) < 0)
2096
+ if ((error = reflog_path(&path, backend->repo, name)) < 0)
2105
2097
  goto out;
2106
2098
 
2107
2099
  if (!git_path_exists(path.ptr))
@@ -2110,7 +2102,7 @@ static int refdb_reflog_fs__delete(git_refdb_backend *_backend, const char *name
2110
2102
  if ((error = p_unlink(path.ptr)) < 0)
2111
2103
  goto out;
2112
2104
 
2113
- refdb_fs_backend__prune_refs(backend, name, GIT_REFLOG_DIR);
2105
+ error = refdb_fs_backend__prune_refs(backend, name, GIT_REFLOG_DIR);
2114
2106
 
2115
2107
  out:
2116
2108
  git_buf_dispose(&path);