rugged 0.27.9 → 0.27.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (420) 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 +98 -54
  5. data/vendor/libgit2/COPYING +28 -0
  6. data/vendor/libgit2/cmake/Modules/AddCFlagIfSupported.cmake +15 -1
  7. data/vendor/libgit2/cmake/Modules/EnableWarnings.cmake +9 -8
  8. data/vendor/libgit2/cmake/Modules/FindCoreFoundation.cmake +2 -2
  9. data/vendor/libgit2/cmake/Modules/FindGSSAPI.cmake +1 -1
  10. data/vendor/libgit2/cmake/Modules/FindGSSFramework.cmake +28 -0
  11. data/vendor/libgit2/cmake/Modules/FindPCRE.cmake +38 -0
  12. data/vendor/libgit2/cmake/Modules/FindPCRE2.cmake +37 -0
  13. data/vendor/libgit2/cmake/Modules/FindSecurity.cmake +2 -2
  14. data/vendor/libgit2/cmake/Modules/FindStatNsec.cmake +6 -0
  15. data/vendor/libgit2/cmake/Modules/FindmbedTLS.cmake +93 -0
  16. data/vendor/libgit2/cmake/Modules/PkgBuildConfig.cmake +110 -0
  17. data/vendor/libgit2/cmake/Modules/SelectGSSAPI.cmake +53 -0
  18. data/vendor/libgit2/cmake/Modules/SelectHTTPSBackend.cmake +124 -0
  19. data/vendor/libgit2/cmake/Modules/SelectHashes.cmake +66 -0
  20. data/vendor/libgit2/deps/http-parser/CMakeLists.txt +2 -0
  21. data/vendor/libgit2/deps/http-parser/{LICENSE-MIT → COPYING} +0 -0
  22. data/vendor/libgit2/deps/http-parser/http_parser.c +11 -6
  23. data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +21 -0
  24. data/vendor/libgit2/deps/ntlmclient/compat.h +33 -0
  25. data/vendor/libgit2/deps/ntlmclient/crypt.h +64 -0
  26. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +120 -0
  27. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +18 -0
  28. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +145 -0
  29. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +18 -0
  30. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +130 -0
  31. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +21 -0
  32. data/vendor/libgit2/deps/ntlmclient/ntlm.c +1420 -0
  33. data/vendor/libgit2/deps/ntlmclient/ntlm.h +174 -0
  34. data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +320 -0
  35. data/vendor/libgit2/deps/ntlmclient/unicode.h +36 -0
  36. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +445 -0
  37. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +201 -0
  38. data/vendor/libgit2/deps/ntlmclient/utf8.h +1257 -0
  39. data/vendor/libgit2/deps/ntlmclient/util.c +21 -0
  40. data/vendor/libgit2/deps/ntlmclient/util.h +14 -0
  41. data/vendor/libgit2/deps/pcre/CMakeLists.txt +140 -0
  42. data/vendor/libgit2/deps/pcre/COPYING +5 -0
  43. data/vendor/libgit2/deps/pcre/cmake/COPYING-CMAKE-SCRIPTS +22 -0
  44. data/vendor/libgit2/deps/pcre/cmake/FindEditline.cmake +17 -0
  45. data/vendor/libgit2/deps/pcre/cmake/FindPackageHandleStandardArgs.cmake +58 -0
  46. data/vendor/libgit2/deps/pcre/cmake/FindReadline.cmake +29 -0
  47. data/vendor/libgit2/deps/pcre/config.h.in +57 -0
  48. data/vendor/libgit2/deps/pcre/pcre.h +641 -0
  49. data/vendor/libgit2/deps/pcre/pcre_byte_order.c +319 -0
  50. data/vendor/libgit2/deps/pcre/pcre_chartables.c +198 -0
  51. data/vendor/libgit2/deps/pcre/pcre_compile.c +9800 -0
  52. data/vendor/libgit2/deps/pcre/pcre_config.c +190 -0
  53. data/vendor/libgit2/deps/pcre/pcre_dfa_exec.c +3676 -0
  54. data/vendor/libgit2/deps/pcre/pcre_exec.c +7173 -0
  55. data/vendor/libgit2/deps/pcre/pcre_fullinfo.c +245 -0
  56. data/vendor/libgit2/deps/pcre/pcre_get.c +669 -0
  57. data/vendor/libgit2/deps/pcre/pcre_globals.c +86 -0
  58. data/vendor/libgit2/deps/pcre/pcre_internal.h +2787 -0
  59. data/vendor/libgit2/deps/pcre/pcre_jit_compile.c +11913 -0
  60. data/vendor/libgit2/deps/pcre/pcre_maketables.c +156 -0
  61. data/vendor/libgit2/deps/pcre/pcre_newline.c +210 -0
  62. data/vendor/libgit2/deps/pcre/pcre_ord2utf8.c +94 -0
  63. data/vendor/libgit2/deps/pcre/pcre_printint.c +834 -0
  64. data/vendor/libgit2/deps/pcre/pcre_refcount.c +92 -0
  65. data/vendor/libgit2/deps/pcre/pcre_string_utils.c +211 -0
  66. data/vendor/libgit2/deps/pcre/pcre_study.c +1686 -0
  67. data/vendor/libgit2/deps/pcre/pcre_tables.c +727 -0
  68. data/vendor/libgit2/deps/pcre/pcre_ucd.c +3644 -0
  69. data/vendor/libgit2/deps/pcre/pcre_valid_utf8.c +301 -0
  70. data/vendor/libgit2/deps/pcre/pcre_version.c +98 -0
  71. data/vendor/libgit2/deps/pcre/pcre_xclass.c +268 -0
  72. data/vendor/libgit2/deps/pcre/pcreposix.c +421 -0
  73. data/vendor/libgit2/deps/pcre/pcreposix.h +117 -0
  74. data/vendor/libgit2/deps/pcre/ucp.h +224 -0
  75. data/vendor/libgit2/deps/winhttp/COPYING.GPL +993 -0
  76. data/vendor/libgit2/deps/winhttp/COPYING.LGPL +502 -0
  77. data/vendor/libgit2/deps/zlib/CMakeLists.txt +1 -0
  78. data/vendor/libgit2/deps/zlib/COPYING +27 -0
  79. data/vendor/libgit2/deps/zlib/adler32.c +0 -7
  80. data/vendor/libgit2/deps/zlib/crc32.c +0 -7
  81. data/vendor/libgit2/include/git2.h +5 -0
  82. data/vendor/libgit2/include/git2/annotated_commit.h +9 -0
  83. data/vendor/libgit2/include/git2/apply.h +149 -0
  84. data/vendor/libgit2/include/git2/attr.h +38 -20
  85. data/vendor/libgit2/include/git2/blame.h +42 -25
  86. data/vendor/libgit2/include/git2/blob.h +45 -13
  87. data/vendor/libgit2/include/git2/branch.h +1 -1
  88. data/vendor/libgit2/include/git2/buffer.h +22 -16
  89. data/vendor/libgit2/include/git2/cert.h +135 -0
  90. data/vendor/libgit2/include/git2/checkout.h +65 -32
  91. data/vendor/libgit2/include/git2/cherrypick.h +9 -7
  92. data/vendor/libgit2/include/git2/clone.h +12 -10
  93. data/vendor/libgit2/include/git2/commit.h +53 -3
  94. data/vendor/libgit2/include/git2/common.h +60 -8
  95. data/vendor/libgit2/include/git2/config.h +30 -19
  96. data/vendor/libgit2/include/git2/cred.h +308 -0
  97. data/vendor/libgit2/include/git2/deprecated.h +493 -0
  98. data/vendor/libgit2/include/git2/describe.h +32 -9
  99. data/vendor/libgit2/include/git2/diff.h +208 -156
  100. data/vendor/libgit2/include/git2/errors.h +54 -46
  101. data/vendor/libgit2/include/git2/filter.h +8 -0
  102. data/vendor/libgit2/include/git2/ignore.h +2 -2
  103. data/vendor/libgit2/include/git2/index.h +74 -52
  104. data/vendor/libgit2/include/git2/indexer.h +76 -6
  105. data/vendor/libgit2/include/git2/mailmap.h +115 -0
  106. data/vendor/libgit2/include/git2/merge.h +35 -18
  107. data/vendor/libgit2/include/git2/net.h +0 -5
  108. data/vendor/libgit2/include/git2/notes.h +1 -1
  109. data/vendor/libgit2/include/git2/object.h +17 -29
  110. data/vendor/libgit2/include/git2/odb.h +12 -11
  111. data/vendor/libgit2/include/git2/odb_backend.h +10 -9
  112. data/vendor/libgit2/include/git2/oid.h +2 -2
  113. data/vendor/libgit2/include/git2/pack.h +14 -3
  114. data/vendor/libgit2/include/git2/proxy.h +14 -8
  115. data/vendor/libgit2/include/git2/rebase.h +53 -6
  116. data/vendor/libgit2/include/git2/refs.h +33 -15
  117. data/vendor/libgit2/include/git2/refspec.h +17 -0
  118. data/vendor/libgit2/include/git2/remote.h +123 -24
  119. data/vendor/libgit2/include/git2/repository.h +76 -39
  120. data/vendor/libgit2/include/git2/revert.h +6 -4
  121. data/vendor/libgit2/include/git2/revwalk.h +7 -7
  122. data/vendor/libgit2/include/git2/signature.h +2 -2
  123. data/vendor/libgit2/include/git2/stash.h +15 -12
  124. data/vendor/libgit2/include/git2/status.h +33 -20
  125. data/vendor/libgit2/include/git2/submodule.h +30 -12
  126. data/vendor/libgit2/include/git2/sys/alloc.h +101 -0
  127. data/vendor/libgit2/include/git2/sys/commit.h +1 -1
  128. data/vendor/libgit2/include/git2/sys/config.h +13 -13
  129. data/vendor/libgit2/include/git2/sys/cred.h +90 -0
  130. data/vendor/libgit2/include/git2/sys/filter.h +6 -6
  131. data/vendor/libgit2/include/git2/sys/index.h +3 -0
  132. data/vendor/libgit2/include/git2/sys/mempack.h +35 -35
  133. data/vendor/libgit2/include/git2/sys/merge.h +9 -4
  134. data/vendor/libgit2/include/git2/sys/odb_backend.h +66 -22
  135. data/vendor/libgit2/include/git2/sys/path.h +64 -0
  136. data/vendor/libgit2/include/git2/sys/refdb_backend.h +76 -40
  137. data/vendor/libgit2/include/git2/sys/repository.h +5 -1
  138. data/vendor/libgit2/include/git2/sys/stream.h +92 -12
  139. data/vendor/libgit2/include/git2/sys/transport.h +129 -83
  140. data/vendor/libgit2/include/git2/tag.h +13 -4
  141. data/vendor/libgit2/include/git2/trace.h +2 -2
  142. data/vendor/libgit2/include/git2/transaction.h +1 -0
  143. data/vendor/libgit2/include/git2/transport.h +11 -311
  144. data/vendor/libgit2/include/git2/tree.h +4 -4
  145. data/vendor/libgit2/include/git2/types.h +33 -111
  146. data/vendor/libgit2/include/git2/version.h +4 -4
  147. data/vendor/libgit2/include/git2/worktree.h +48 -13
  148. data/vendor/libgit2/src/CMakeLists.txt +96 -164
  149. data/vendor/libgit2/src/alloc.c +43 -0
  150. data/vendor/libgit2/src/alloc.h +40 -0
  151. data/vendor/libgit2/src/allocators/stdalloc.c +119 -0
  152. data/vendor/libgit2/src/{streams/curl.h → allocators/stdalloc.h} +5 -5
  153. data/vendor/libgit2/src/allocators/win32_crtdbg.c +118 -0
  154. data/vendor/libgit2/src/{transports/cred.h → allocators/win32_crtdbg.h} +5 -4
  155. data/vendor/libgit2/src/annotated_commit.c +15 -8
  156. data/vendor/libgit2/src/apply.c +537 -31
  157. data/vendor/libgit2/src/apply.h +3 -1
  158. data/vendor/libgit2/src/array.h +2 -2
  159. data/vendor/libgit2/src/attr.c +81 -75
  160. data/vendor/libgit2/src/attr_file.c +207 -121
  161. data/vendor/libgit2/src/attr_file.h +9 -9
  162. data/vendor/libgit2/src/attrcache.c +51 -53
  163. data/vendor/libgit2/src/attrcache.h +2 -1
  164. data/vendor/libgit2/src/blame.c +47 -20
  165. data/vendor/libgit2/src/blame.h +2 -1
  166. data/vendor/libgit2/src/blame_git.c +37 -20
  167. data/vendor/libgit2/src/blob.c +128 -42
  168. data/vendor/libgit2/src/blob.h +19 -2
  169. data/vendor/libgit2/src/branch.c +67 -43
  170. data/vendor/libgit2/src/buf_text.c +7 -6
  171. data/vendor/libgit2/src/buffer.c +69 -57
  172. data/vendor/libgit2/src/buffer.h +1 -1
  173. data/vendor/libgit2/src/cache.c +38 -45
  174. data/vendor/libgit2/src/cache.h +3 -3
  175. data/vendor/libgit2/src/cc-compat.h +20 -3
  176. data/vendor/libgit2/src/checkout.c +109 -90
  177. data/vendor/libgit2/src/cherrypick.c +15 -9
  178. data/vendor/libgit2/src/clone.c +49 -27
  179. data/vendor/libgit2/src/clone.h +4 -0
  180. data/vendor/libgit2/src/commit.c +117 -49
  181. data/vendor/libgit2/src/commit.h +7 -0
  182. data/vendor/libgit2/src/commit_list.c +30 -78
  183. data/vendor/libgit2/src/commit_list.h +2 -2
  184. data/vendor/libgit2/src/common.h +27 -91
  185. data/vendor/libgit2/src/config.c +194 -176
  186. data/vendor/libgit2/src/config.h +8 -20
  187. data/vendor/libgit2/src/config_backend.h +96 -0
  188. data/vendor/libgit2/src/config_cache.c +41 -35
  189. data/vendor/libgit2/src/config_entries.c +229 -0
  190. data/vendor/libgit2/src/config_entries.h +24 -0
  191. data/vendor/libgit2/src/config_file.c +439 -753
  192. data/vendor/libgit2/src/config_mem.c +220 -0
  193. data/vendor/libgit2/src/config_parse.c +114 -63
  194. data/vendor/libgit2/src/config_parse.h +17 -16
  195. data/vendor/libgit2/src/config_snapshot.c +206 -0
  196. data/vendor/libgit2/src/crlf.c +219 -190
  197. data/vendor/libgit2/src/delta.c +25 -18
  198. data/vendor/libgit2/src/describe.c +42 -41
  199. data/vendor/libgit2/src/diff.c +53 -68
  200. data/vendor/libgit2/src/diff.h +2 -1
  201. data/vendor/libgit2/src/diff_driver.c +47 -49
  202. data/vendor/libgit2/src/diff_file.c +19 -17
  203. data/vendor/libgit2/src/diff_file.h +1 -1
  204. data/vendor/libgit2/src/diff_generate.c +162 -106
  205. data/vendor/libgit2/src/diff_generate.h +3 -3
  206. data/vendor/libgit2/src/diff_parse.c +4 -4
  207. data/vendor/libgit2/src/diff_print.c +42 -30
  208. data/vendor/libgit2/src/diff_stats.c +22 -7
  209. data/vendor/libgit2/src/diff_tform.c +16 -16
  210. data/vendor/libgit2/src/diff_xdiff.c +15 -3
  211. data/vendor/libgit2/src/errors.c +51 -39
  212. data/vendor/libgit2/src/errors.h +81 -0
  213. data/vendor/libgit2/src/features.h.in +11 -3
  214. data/vendor/libgit2/src/fetch.c +10 -5
  215. data/vendor/libgit2/src/fetchhead.c +17 -17
  216. data/vendor/libgit2/src/filebuf.c +32 -36
  217. data/vendor/libgit2/src/filebuf.h +2 -2
  218. data/vendor/libgit2/src/filter.c +46 -38
  219. data/vendor/libgit2/src/filter.h +0 -10
  220. data/vendor/libgit2/src/{fileops.c → futils.c} +80 -73
  221. data/vendor/libgit2/src/{fileops.h → futils.h} +6 -6
  222. data/vendor/libgit2/src/global.c +48 -63
  223. data/vendor/libgit2/src/global.h +0 -2
  224. data/vendor/libgit2/src/hash.c +61 -0
  225. data/vendor/libgit2/src/hash.h +20 -19
  226. data/vendor/libgit2/src/hash/sha1.h +38 -0
  227. data/vendor/libgit2/src/hash/sha1/collisiondetect.c +48 -0
  228. data/vendor/libgit2/src/hash/sha1/collisiondetect.h +19 -0
  229. data/vendor/libgit2/src/hash/{hash_common_crypto.h → sha1/common_crypto.c} +17 -17
  230. data/vendor/libgit2/src/hash/sha1/common_crypto.h +19 -0
  231. data/vendor/libgit2/src/hash/{hash_generic.c → sha1/generic.c} +22 -10
  232. data/vendor/libgit2/src/hash/{hash_generic.h → sha1/generic.h} +4 -10
  233. data/vendor/libgit2/src/hash/sha1/mbedtls.c +46 -0
  234. data/vendor/libgit2/src/hash/sha1/mbedtls.h +19 -0
  235. data/vendor/libgit2/src/hash/sha1/openssl.c +59 -0
  236. data/vendor/libgit2/src/hash/sha1/openssl.h +19 -0
  237. data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/sha1.c +14 -3
  238. data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/sha1.h +0 -0
  239. data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/ubc_check.c +0 -0
  240. data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/ubc_check.h +0 -0
  241. data/vendor/libgit2/src/hash/{hash_win32.c → sha1/win32.c} +47 -37
  242. data/vendor/libgit2/src/hash/{hash_win32.h → sha1/win32.h} +6 -19
  243. data/vendor/libgit2/src/hashsig.c +5 -5
  244. data/vendor/libgit2/src/idxmap.c +107 -61
  245. data/vendor/libgit2/src/idxmap.h +153 -31
  246. data/vendor/libgit2/src/ignore.c +43 -47
  247. data/vendor/libgit2/src/index.c +337 -232
  248. data/vendor/libgit2/src/index.h +17 -1
  249. data/vendor/libgit2/src/indexer.c +346 -175
  250. data/vendor/libgit2/src/integer.h +71 -26
  251. data/vendor/libgit2/src/iterator.c +142 -70
  252. data/vendor/libgit2/src/iterator.h +15 -0
  253. data/vendor/libgit2/src/khash.h +3 -1
  254. data/vendor/libgit2/src/mailmap.c +485 -0
  255. data/vendor/libgit2/src/mailmap.h +35 -0
  256. data/vendor/libgit2/src/map.h +1 -1
  257. data/vendor/libgit2/src/merge.c +144 -100
  258. data/vendor/libgit2/src/merge_driver.c +11 -11
  259. data/vendor/libgit2/src/merge_file.c +2 -2
  260. data/vendor/libgit2/src/mwindow.c +24 -29
  261. data/vendor/libgit2/src/mwindow.h +4 -4
  262. data/vendor/libgit2/src/net.c +184 -0
  263. data/vendor/libgit2/src/net.h +36 -0
  264. data/vendor/libgit2/src/netops.c +55 -156
  265. data/vendor/libgit2/src/netops.h +3 -23
  266. data/vendor/libgit2/src/notes.c +16 -11
  267. data/vendor/libgit2/src/object.c +120 -69
  268. data/vendor/libgit2/src/object.h +22 -9
  269. data/vendor/libgit2/src/object_api.c +8 -8
  270. data/vendor/libgit2/src/odb.c +116 -93
  271. data/vendor/libgit2/src/odb.h +8 -7
  272. data/vendor/libgit2/src/odb_loose.c +62 -55
  273. data/vendor/libgit2/src/odb_mempack.c +21 -34
  274. data/vendor/libgit2/src/odb_pack.c +18 -14
  275. data/vendor/libgit2/src/offmap.c +53 -35
  276. data/vendor/libgit2/src/offmap.h +108 -21
  277. data/vendor/libgit2/src/oid.c +12 -7
  278. data/vendor/libgit2/src/oidmap.c +49 -47
  279. data/vendor/libgit2/src/oidmap.h +101 -24
  280. data/vendor/libgit2/src/pack-objects.c +88 -87
  281. data/vendor/libgit2/src/pack-objects.h +2 -8
  282. data/vendor/libgit2/src/pack.c +99 -101
  283. data/vendor/libgit2/src/pack.h +17 -19
  284. data/vendor/libgit2/src/parse.c +10 -0
  285. data/vendor/libgit2/src/parse.h +3 -3
  286. data/vendor/libgit2/src/patch.c +4 -4
  287. data/vendor/libgit2/src/patch_generate.c +20 -20
  288. data/vendor/libgit2/src/patch_parse.c +151 -63
  289. data/vendor/libgit2/src/path.c +169 -125
  290. data/vendor/libgit2/src/path.h +3 -71
  291. data/vendor/libgit2/src/pathspec.c +19 -19
  292. data/vendor/libgit2/src/pool.c +26 -22
  293. data/vendor/libgit2/src/pool.h +7 -7
  294. data/vendor/libgit2/src/posix.c +10 -10
  295. data/vendor/libgit2/src/posix.h +12 -1
  296. data/vendor/libgit2/src/proxy.c +8 -3
  297. data/vendor/libgit2/src/push.c +37 -31
  298. data/vendor/libgit2/src/push.h +2 -1
  299. data/vendor/libgit2/src/reader.c +265 -0
  300. data/vendor/libgit2/src/reader.h +107 -0
  301. data/vendor/libgit2/src/rebase.c +115 -59
  302. data/vendor/libgit2/src/refdb.c +15 -3
  303. data/vendor/libgit2/src/refdb_fs.c +381 -254
  304. data/vendor/libgit2/src/reflog.c +13 -15
  305. data/vendor/libgit2/src/refs.c +118 -88
  306. data/vendor/libgit2/src/refs.h +5 -3
  307. data/vendor/libgit2/src/refspec.c +56 -37
  308. data/vendor/libgit2/src/refspec.h +1 -1
  309. data/vendor/libgit2/src/regexp.c +221 -0
  310. data/vendor/libgit2/src/regexp.h +97 -0
  311. data/vendor/libgit2/src/remote.c +266 -215
  312. data/vendor/libgit2/src/remote.h +11 -2
  313. data/vendor/libgit2/src/repository.c +280 -225
  314. data/vendor/libgit2/src/repository.h +52 -40
  315. data/vendor/libgit2/src/reset.c +8 -8
  316. data/vendor/libgit2/src/revert.c +14 -9
  317. data/vendor/libgit2/src/revparse.c +47 -48
  318. data/vendor/libgit2/src/revwalk.c +120 -57
  319. data/vendor/libgit2/src/revwalk.h +22 -1
  320. data/vendor/libgit2/src/settings.c +47 -10
  321. data/vendor/libgit2/src/signature.c +11 -11
  322. data/vendor/libgit2/src/sortedcache.c +22 -36
  323. data/vendor/libgit2/src/sortedcache.h +1 -1
  324. data/vendor/libgit2/src/stash.c +125 -99
  325. data/vendor/libgit2/src/status.c +28 -22
  326. data/vendor/libgit2/src/stream.h +17 -2
  327. data/vendor/libgit2/src/streams/mbedtls.c +483 -0
  328. data/vendor/libgit2/src/streams/mbedtls.h +23 -0
  329. data/vendor/libgit2/src/streams/openssl.c +224 -114
  330. data/vendor/libgit2/src/streams/openssl.h +4 -108
  331. data/vendor/libgit2/src/streams/registry.c +118 -0
  332. data/vendor/libgit2/src/streams/registry.h +19 -0
  333. data/vendor/libgit2/src/streams/socket.c +55 -30
  334. data/vendor/libgit2/src/streams/stransport.c +57 -32
  335. data/vendor/libgit2/src/streams/stransport.h +5 -0
  336. data/vendor/libgit2/src/streams/tls.c +50 -19
  337. data/vendor/libgit2/src/streams/tls.h +12 -4
  338. data/vendor/libgit2/src/strmap.c +47 -74
  339. data/vendor/libgit2/src/strmap.h +108 -33
  340. data/vendor/libgit2/src/submodule.c +272 -216
  341. data/vendor/libgit2/src/submodule.h +1 -1
  342. data/vendor/libgit2/src/sysdir.c +29 -19
  343. data/vendor/libgit2/src/tag.c +41 -28
  344. data/vendor/libgit2/src/tag.h +2 -1
  345. data/vendor/libgit2/src/trace.c +2 -2
  346. data/vendor/libgit2/src/trace.h +3 -3
  347. data/vendor/libgit2/src/trailer.c +52 -38
  348. data/vendor/libgit2/src/transaction.c +30 -29
  349. data/vendor/libgit2/src/transport.c +5 -5
  350. data/vendor/libgit2/src/transports/auth.c +15 -11
  351. data/vendor/libgit2/src/transports/auth.h +10 -3
  352. data/vendor/libgit2/src/transports/auth_negotiate.c +33 -18
  353. data/vendor/libgit2/src/transports/auth_negotiate.h +2 -2
  354. data/vendor/libgit2/src/transports/auth_ntlm.c +223 -0
  355. data/vendor/libgit2/src/transports/auth_ntlm.h +35 -0
  356. data/vendor/libgit2/src/transports/cred.c +24 -24
  357. data/vendor/libgit2/src/transports/git.c +26 -31
  358. data/vendor/libgit2/src/transports/http.c +881 -348
  359. data/vendor/libgit2/src/transports/http.h +2 -0
  360. data/vendor/libgit2/src/transports/local.c +35 -35
  361. data/vendor/libgit2/src/transports/smart.c +70 -47
  362. data/vendor/libgit2/src/transports/smart.h +3 -4
  363. data/vendor/libgit2/src/transports/smart_pkt.c +43 -40
  364. data/vendor/libgit2/src/transports/smart_protocol.c +96 -116
  365. data/vendor/libgit2/src/transports/ssh.c +77 -66
  366. data/vendor/libgit2/src/transports/winhttp.c +318 -314
  367. data/vendor/libgit2/src/tree-cache.c +19 -12
  368. data/vendor/libgit2/src/tree.c +103 -142
  369. data/vendor/libgit2/src/tree.h +1 -12
  370. data/vendor/libgit2/src/unix/map.c +3 -3
  371. data/vendor/libgit2/src/unix/posix.h +1 -11
  372. data/vendor/libgit2/src/userdiff.h +3 -1
  373. data/vendor/libgit2/src/util.c +70 -56
  374. data/vendor/libgit2/src/util.h +28 -156
  375. data/vendor/libgit2/src/vector.c +4 -4
  376. data/vendor/libgit2/src/wildmatch.c +320 -0
  377. data/vendor/libgit2/src/wildmatch.h +23 -0
  378. data/vendor/libgit2/src/win32/dir.c +3 -3
  379. data/vendor/libgit2/src/win32/findfile.c +3 -3
  380. data/vendor/libgit2/src/win32/map.c +9 -11
  381. data/vendor/libgit2/src/win32/msvc-compat.h +6 -0
  382. data/vendor/libgit2/src/win32/path_w32.c +113 -9
  383. data/vendor/libgit2/src/win32/path_w32.h +18 -29
  384. data/vendor/libgit2/src/win32/posix.h +1 -4
  385. data/vendor/libgit2/src/win32/posix_w32.c +70 -45
  386. data/vendor/libgit2/src/win32/precompiled.h +0 -2
  387. data/vendor/libgit2/src/win32/thread.c +5 -10
  388. data/vendor/libgit2/src/win32/w32_buffer.c +9 -5
  389. data/vendor/libgit2/src/win32/w32_common.h +39 -0
  390. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +3 -2
  391. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +26 -75
  392. data/vendor/libgit2/src/win32/w32_stack.c +6 -11
  393. data/vendor/libgit2/src/win32/w32_stack.h +3 -3
  394. data/vendor/libgit2/src/win32/w32_util.c +27 -64
  395. data/vendor/libgit2/src/win32/w32_util.h +5 -49
  396. data/vendor/libgit2/src/worktree.c +95 -60
  397. data/vendor/libgit2/src/worktree.h +2 -0
  398. data/vendor/libgit2/src/xdiff/xdiffi.c +7 -5
  399. data/vendor/libgit2/src/xdiff/xhistogram.c +1 -1
  400. data/vendor/libgit2/src/xdiff/xmerge.c +27 -15
  401. data/vendor/libgit2/src/xdiff/xpatience.c +3 -0
  402. data/vendor/libgit2/src/zstream.c +4 -4
  403. metadata +122 -33
  404. data/vendor/libgit2/deps/regex/CMakeLists.txt +0 -2
  405. data/vendor/libgit2/deps/regex/config.h +0 -7
  406. data/vendor/libgit2/deps/regex/regcomp.c +0 -3857
  407. data/vendor/libgit2/deps/regex/regex.c +0 -92
  408. data/vendor/libgit2/deps/regex/regex.h +0 -582
  409. data/vendor/libgit2/deps/regex/regex_internal.c +0 -1744
  410. data/vendor/libgit2/deps/regex/regex_internal.h +0 -819
  411. data/vendor/libgit2/deps/regex/regexec.c +0 -4369
  412. data/vendor/libgit2/include/git2/inttypes.h +0 -309
  413. data/vendor/libgit2/include/git2/sys/time.h +0 -31
  414. data/vendor/libgit2/libgit2.pc.in +0 -13
  415. data/vendor/libgit2/src/config_file.h +0 -73
  416. data/vendor/libgit2/src/fnmatch.c +0 -248
  417. data/vendor/libgit2/src/fnmatch.h +0 -48
  418. data/vendor/libgit2/src/hash/hash_collisiondetect.h +0 -47
  419. data/vendor/libgit2/src/hash/hash_openssl.h +0 -59
  420. data/vendor/libgit2/src/streams/curl.c +0 -385
@@ -35,5 +35,12 @@ struct git_commit {
35
35
 
36
36
  void git_commit__free(void *commit);
37
37
  int git_commit__parse(void *commit, git_odb_object *obj);
38
+ int git_commit__parse_raw(void *commit, const char *data, size_t size);
39
+
40
+ typedef enum {
41
+ GIT_COMMIT_PARSE_QUICK = (1 << 0), /**< Only parse parents and committer info */
42
+ } git_commit__parse_flags;
43
+
44
+ int git_commit__parse_ext(git_commit *commit, git_odb_object *odb_obj, unsigned int flags);
38
45
 
39
46
  #endif
@@ -10,6 +10,7 @@
10
10
  #include "revwalk.h"
11
11
  #include "pool.h"
12
12
  #include "odb.h"
13
+ #include "commit.h"
13
14
 
14
15
  int git_commit_list_time_cmp(const void *a, const void *b)
15
16
  {
@@ -55,17 +56,6 @@ git_commit_list_node *git_commit_list_alloc_node(git_revwalk *walk)
55
56
  return (git_commit_list_node *)git_pool_mallocz(&walk->commit_pool, 1);
56
57
  }
57
58
 
58
- static int commit_error(git_commit_list_node *commit, const char *msg)
59
- {
60
- char commit_oid[GIT_OID_HEXSZ + 1];
61
- git_oid_fmt(commit_oid, &commit->oid);
62
- commit_oid[GIT_OID_HEXSZ] = '\0';
63
-
64
- giterr_set(GITERR_ODB, "failed to parse commit %s - %s", commit_oid, msg);
65
-
66
- return -1;
67
- }
68
-
69
59
  static git_commit_list_node **alloc_parents(
70
60
  git_revwalk *walk, git_commit_list_node *commit, size_t n_parents)
71
61
  {
@@ -111,77 +101,42 @@ git_commit_list_node *git_commit_list_pop(git_commit_list **stack)
111
101
 
112
102
  static int commit_quick_parse(
113
103
  git_revwalk *walk,
114
- git_commit_list_node *commit,
115
- const uint8_t *buffer,
116
- size_t buffer_len)
104
+ git_commit_list_node *node,
105
+ git_odb_object *obj)
117
106
  {
118
- const size_t parent_len = strlen("parent ") + GIT_OID_HEXSZ + 1;
119
- const uint8_t *buffer_end = buffer + buffer_len;
120
- const uint8_t *parents_start, *committer_start;
121
- int i, parents = 0;
122
- int64_t commit_time;
123
-
124
- buffer += strlen("tree ") + GIT_OID_HEXSZ + 1;
125
-
126
- parents_start = buffer;
127
- while (buffer + parent_len < buffer_end && memcmp(buffer, "parent ", strlen("parent ")) == 0) {
128
- parents++;
129
- buffer += parent_len;
130
- }
131
-
132
- commit->parents = alloc_parents(walk, commit, parents);
133
- GITERR_CHECK_ALLOC(commit->parents);
134
-
135
- buffer = parents_start;
136
- for (i = 0; i < parents; ++i) {
137
- git_oid oid;
138
-
139
- if (git_oid_fromstr(&oid, (const char *)buffer + strlen("parent ")) < 0)
140
- return -1;
107
+ git_oid *parent_oid;
108
+ git_commit *commit;
109
+ int error;
110
+ size_t i;
141
111
 
142
- commit->parents[i] = git_revwalk__commit_lookup(walk, &oid);
143
- if (commit->parents[i] == NULL)
144
- return -1;
112
+ commit = git__calloc(1, sizeof(*commit));
113
+ GIT_ERROR_CHECK_ALLOC(commit);
114
+ commit->object.repo = walk->repo;
145
115
 
146
- buffer += parent_len;
116
+ if ((error = git_commit__parse_ext(commit, obj, GIT_COMMIT_PARSE_QUICK)) < 0) {
117
+ git__free(commit);
118
+ return error;
147
119
  }
148
120
 
149
- commit->out_degree = (unsigned short)parents;
150
-
151
- if ((committer_start = buffer = memchr(buffer, '\n', buffer_end - buffer)) == NULL)
152
- return commit_error(commit, "object is corrupted");
153
-
154
- buffer++;
155
-
156
- if ((buffer = memchr(buffer, '\n', buffer_end - buffer)) == NULL)
157
- return commit_error(commit, "object is corrupted");
158
-
159
- /* Skip trailing spaces */
160
- while (buffer > committer_start && git__isspace(*buffer))
161
- buffer--;
162
-
163
- /* Seek for the beginning of the pack of digits */
164
- while (buffer > committer_start && git__isdigit(*buffer))
165
- buffer--;
166
-
167
- /* Skip potential timezone offset */
168
- if ((buffer > committer_start) && (*buffer == '+' || *buffer == '-')) {
169
- buffer--;
121
+ if (!git__is_uint16(git_array_size(commit->parent_ids))) {
122
+ git__free(commit);
123
+ git_error_set(GIT_ERROR_INVALID, "commit has more than 2^16 parents");
124
+ return -1;
125
+ }
170
126
 
171
- while (buffer > committer_start && git__isspace(*buffer))
172
- buffer--;
127
+ node->time = commit->committer->when.time;
128
+ node->out_degree = (uint16_t) git_array_size(commit->parent_ids);
129
+ node->parents = alloc_parents(walk, node, node->out_degree);
130
+ GIT_ERROR_CHECK_ALLOC(node->parents);
173
131
 
174
- while (buffer > committer_start && git__isdigit(*buffer))
175
- buffer--;
132
+ git_array_foreach(commit->parent_ids, i, parent_oid) {
133
+ node->parents[i] = git_revwalk__commit_lookup(walk, parent_oid);
176
134
  }
177
135
 
178
- if ((buffer == committer_start) ||
179
- (git__strntol64(&commit_time, (char *)(buffer + 1),
180
- buffer_end - buffer + 1, NULL, 10) < 0))
181
- return commit_error(commit, "cannot parse commit time");
136
+ git_commit__free(commit);
137
+
138
+ node->parsed = 1;
182
139
 
183
- commit->time = commit_time;
184
- commit->parsed = 1;
185
140
  return 0;
186
141
  }
187
142
 
@@ -196,14 +151,11 @@ int git_commit_list_parse(git_revwalk *walk, git_commit_list_node *commit)
196
151
  if ((error = git_odb_read(&obj, walk->odb, &commit->oid)) < 0)
197
152
  return error;
198
153
 
199
- if (obj->cached.type != GIT_OBJ_COMMIT) {
200
- giterr_set(GITERR_INVALID, "object is no commit object");
154
+ if (obj->cached.type != GIT_OBJECT_COMMIT) {
155
+ git_error_set(GIT_ERROR_INVALID, "object is no commit object");
201
156
  error = -1;
202
157
  } else
203
- error = commit_quick_parse(
204
- walk, commit,
205
- (const uint8_t *)git_odb_object_data(obj),
206
- git_odb_object_size(obj));
158
+ error = commit_quick_parse(walk, commit, obj);
207
159
 
208
160
  git_odb_object_free(obj);
209
161
  return error;
@@ -33,8 +33,8 @@ typedef struct git_commit_list_node {
33
33
  added:1,
34
34
  flags : FLAG_BITS;
35
35
 
36
- unsigned short in_degree;
37
- unsigned short out_degree;
36
+ uint16_t in_degree;
37
+ uint16_t out_degree;
38
38
 
39
39
  struct git_commit_list_node **parents;
40
40
  } git_commit_list_node;
@@ -17,8 +17,10 @@
17
17
  /** Declare a function as always inlined. */
18
18
  #if defined(_MSC_VER)
19
19
  # define GIT_INLINE(type) static __inline type
20
+ #elif defined(__GNUC__)
21
+ # define GIT_INLINE(type) static __inline__ type
20
22
  #else
21
- # define GIT_INLINE(type) static inline type
23
+ # define GIT_INLINE(type) static type
22
24
  #endif
23
25
 
24
26
  /** Support for gcc/clang __has_builtin intrinsic */
@@ -45,6 +47,7 @@
45
47
  # include <ws2tcpip.h>
46
48
  # include "win32/msvc-compat.h"
47
49
  # include "win32/mingw-compat.h"
50
+ # include "win32/w32_common.h"
48
51
  # include "win32/win32-compat.h"
49
52
  # include "win32/error.h"
50
53
  # include "win32/version.h"
@@ -74,10 +77,17 @@
74
77
 
75
78
  #include "git2/types.h"
76
79
  #include "git2/errors.h"
80
+ #include "errors.h"
77
81
  #include "thread-utils.h"
78
82
  #include "integer.h"
79
83
 
80
- #include <regex.h>
84
+ /*
85
+ * Include the declarations for deprecated functions; this ensures
86
+ * that they're decorated with the proper extern/visibility attributes.
87
+ */
88
+ #include "git2/deprecated.h"
89
+
90
+ #include "posix.h"
81
91
 
82
92
  #define DEFAULT_BUFSIZE 65536
83
93
  #define FILEIO_BUFSIZE DEFAULT_BUFSIZE
@@ -87,97 +97,23 @@
87
97
  /**
88
98
  * Check a pointer allocation result, returning -1 if it failed.
89
99
  */
90
- #define GITERR_CHECK_ALLOC(ptr) if (ptr == NULL) { return -1; }
100
+ #define GIT_ERROR_CHECK_ALLOC(ptr) if (ptr == NULL) { return -1; }
91
101
 
92
102
  /**
93
103
  * Check a buffer allocation result, returning -1 if it failed.
94
104
  */
95
- #define GITERR_CHECK_ALLOC_BUF(buf) if ((void *)(buf) == NULL || git_buf_oom(buf)) { return -1; }
105
+ #define GIT_ERROR_CHECK_ALLOC_BUF(buf) if ((void *)(buf) == NULL || git_buf_oom(buf)) { return -1; }
96
106
 
97
107
  /**
98
108
  * Check a return value and propagate result if non-zero.
99
109
  */
100
- #define GITERR_CHECK_ERROR(code) \
110
+ #define GIT_ERROR_CHECK_ERROR(code) \
101
111
  do { int _err = (code); if (_err) return _err; } while (0)
102
112
 
103
- /**
104
- * Set the error message for this thread, formatting as needed.
105
- */
106
-
107
- void giterr_set(int error_class, const char *string, ...) GIT_FORMAT_PRINTF(2, 3);
108
-
109
- /**
110
- * Set the error message for a regex failure, using the internal regex
111
- * error code lookup and return a libgit error code.
112
- */
113
- int giterr_set_regex(const regex_t *regex, int error_code);
114
-
115
- /**
116
- * Set error message for user callback if needed.
117
- *
118
- * If the error code in non-zero and no error message is set, this
119
- * sets a generic error message.
120
- *
121
- * @return This always returns the `error_code` parameter.
122
- */
123
- GIT_INLINE(int) giterr_set_after_callback_function(
124
- int error_code, const char *action)
125
- {
126
- if (error_code) {
127
- const git_error *e = giterr_last();
128
- if (!e || !e->message)
129
- giterr_set(e ? e->klass : GITERR_CALLBACK,
130
- "%s callback returned %d", action, error_code);
131
- }
132
- return error_code;
133
- }
134
-
135
- #ifdef GIT_WIN32
136
- #define giterr_set_after_callback(code) \
137
- giterr_set_after_callback_function((code), __FUNCTION__)
138
- #else
139
- #define giterr_set_after_callback(code) \
140
- giterr_set_after_callback_function((code), __func__)
141
- #endif
142
-
143
- /**
144
- * Gets the system error code for this thread.
145
- */
146
- int giterr_system_last(void);
147
-
148
- /**
149
- * Sets the system error code for this thread.
150
- */
151
- void giterr_system_set(int code);
152
-
153
- /**
154
- * Structure to preserve libgit2 error state
155
- */
156
- typedef struct {
157
- int error_code;
158
- unsigned int oom : 1;
159
- git_error error_msg;
160
- } git_error_state;
161
-
162
- /**
163
- * Capture current error state to restore later, returning error code.
164
- * If `error_code` is zero, this does not clear the current error state.
165
- * You must either restore this error state, or free it.
166
- */
167
- extern int giterr_state_capture(git_error_state *state, int error_code);
168
-
169
- /**
170
- * Restore error state to a previous value, returning saved error code.
171
- */
172
- extern int giterr_state_restore(git_error_state *state);
173
-
174
- /** Free an error state. */
175
- extern void giterr_state_free(git_error_state *state);
176
-
177
113
  /**
178
114
  * Check a versioned structure for validity
179
115
  */
180
- GIT_INLINE(int) giterr__check_version(const void *structure, unsigned int expected_max, const char *name)
116
+ GIT_INLINE(int) git_error__check_version(const void *structure, unsigned int expected_max, const char *name)
181
117
  {
182
118
  unsigned int actual;
183
119
 
@@ -188,10 +124,10 @@ GIT_INLINE(int) giterr__check_version(const void *structure, unsigned int expect
188
124
  if (actual > 0 && actual <= expected_max)
189
125
  return 0;
190
126
 
191
- giterr_set(GITERR_INVALID, "invalid version %d on %s", actual, name);
127
+ git_error_set(GIT_ERROR_INVALID, "invalid version %d on %s", actual, name);
192
128
  return -1;
193
129
  }
194
- #define GITERR_CHECK_VERSION(S,V,N) if (giterr__check_version(S,V,N) < 0) return -1
130
+ #define GIT_ERROR_CHECK_VERSION(S,V,N) if (git_error__check_version(S,V,N) < 0) return -1
195
131
 
196
132
  /**
197
133
  * Initialize a structure with a version.
@@ -205,42 +141,42 @@ GIT_INLINE(void) git__init_structure(void *structure, size_t len, unsigned int v
205
141
 
206
142
  #define GIT_INIT_STRUCTURE_FROM_TEMPLATE(PTR,VERSION,TYPE,TPL) do { \
207
143
  TYPE _tmpl = TPL; \
208
- GITERR_CHECK_VERSION(&(VERSION), _tmpl.version, #TYPE); \
144
+ GIT_ERROR_CHECK_VERSION(&(VERSION), _tmpl.version, #TYPE); \
209
145
  memcpy((PTR), &_tmpl, sizeof(_tmpl)); } while (0)
210
146
 
211
147
 
212
148
  /** Check for additive overflow, setting an error if would occur. */
213
149
  #define GIT_ADD_SIZET_OVERFLOW(out, one, two) \
214
- (git__add_sizet_overflow(out, one, two) ? (giterr_set_oom(), 1) : 0)
150
+ (git__add_sizet_overflow(out, one, two) ? (git_error_set_oom(), 1) : 0)
215
151
 
216
152
  /** Check for additive overflow, setting an error if would occur. */
217
153
  #define GIT_MULTIPLY_SIZET_OVERFLOW(out, nelem, elsize) \
218
- (git__multiply_sizet_overflow(out, nelem, elsize) ? (giterr_set_oom(), 1) : 0)
154
+ (git__multiply_sizet_overflow(out, nelem, elsize) ? (git_error_set_oom(), 1) : 0)
219
155
 
220
156
  /** Check for additive overflow, failing if it would occur. */
221
- #define GITERR_CHECK_ALLOC_ADD(out, one, two) \
157
+ #define GIT_ERROR_CHECK_ALLOC_ADD(out, one, two) \
222
158
  if (GIT_ADD_SIZET_OVERFLOW(out, one, two)) { return -1; }
223
159
 
224
- #define GITERR_CHECK_ALLOC_ADD3(out, one, two, three) \
160
+ #define GIT_ERROR_CHECK_ALLOC_ADD3(out, one, two, three) \
225
161
  if (GIT_ADD_SIZET_OVERFLOW(out, one, two) || \
226
162
  GIT_ADD_SIZET_OVERFLOW(out, *(out), three)) { return -1; }
227
163
 
228
- #define GITERR_CHECK_ALLOC_ADD4(out, one, two, three, four) \
164
+ #define GIT_ERROR_CHECK_ALLOC_ADD4(out, one, two, three, four) \
229
165
  if (GIT_ADD_SIZET_OVERFLOW(out, one, two) || \
230
166
  GIT_ADD_SIZET_OVERFLOW(out, *(out), three) || \
231
167
  GIT_ADD_SIZET_OVERFLOW(out, *(out), four)) { return -1; }
232
168
 
233
- #define GITERR_CHECK_ALLOC_ADD5(out, one, two, three, four, five) \
169
+ #define GIT_ERROR_CHECK_ALLOC_ADD5(out, one, two, three, four, five) \
234
170
  if (GIT_ADD_SIZET_OVERFLOW(out, one, two) || \
235
171
  GIT_ADD_SIZET_OVERFLOW(out, *(out), three) || \
236
172
  GIT_ADD_SIZET_OVERFLOW(out, *(out), four) || \
237
173
  GIT_ADD_SIZET_OVERFLOW(out, *(out), five)) { return -1; }
238
174
 
239
175
  /** Check for multiplicative overflow, failing if it would occur. */
240
- #define GITERR_CHECK_ALLOC_MULTIPLY(out, nelem, elsize) \
176
+ #define GIT_ERROR_CHECK_ALLOC_MULTIPLY(out, nelem, elsize) \
241
177
  if (GIT_MULTIPLY_SIZET_OVERFLOW(out, nelem, elsize)) { return -1; }
242
178
 
243
- /* NOTE: other giterr functions are in the public errors.h header file */
179
+ /* NOTE: other git_error functions are in the public errors.h header file */
244
180
 
245
181
  #include "util.h"
246
182
 
@@ -7,13 +7,15 @@
7
7
 
8
8
  #include "config.h"
9
9
 
10
- #include "sysdir.h"
11
10
  #include "git2/config.h"
12
11
  #include "git2/sys/config.h"
13
- #include "vector.h"
12
+
14
13
  #include "buf_text.h"
15
- #include "config_file.h"
14
+ #include "config_backend.h"
15
+ #include "regexp.h"
16
+ #include "sysdir.h"
16
17
  #include "transaction.h"
18
+ #include "vector.h"
17
19
  #if GIT_WIN32
18
20
  # include <windows.h>
19
21
  #endif
@@ -31,30 +33,30 @@ void git_config_entry_free(git_config_entry *entry)
31
33
  typedef struct {
32
34
  git_refcount rc;
33
35
 
34
- git_config_backend *file;
36
+ git_config_backend *backend;
35
37
  git_config_level_t level;
36
- } file_internal;
38
+ } backend_internal;
37
39
 
38
- static void file_internal_free(file_internal *internal)
40
+ static void backend_internal_free(backend_internal *internal)
39
41
  {
40
- git_config_backend *file;
42
+ git_config_backend *backend;
41
43
 
42
- file = internal->file;
43
- file->free(file);
44
+ backend = internal->backend;
45
+ backend->free(backend);
44
46
  git__free(internal);
45
47
  }
46
48
 
47
49
  static void config_free(git_config *cfg)
48
50
  {
49
51
  size_t i;
50
- file_internal *internal;
52
+ backend_internal *internal;
51
53
 
52
- for (i = 0; i < cfg->files.length; ++i) {
53
- internal = git_vector_get(&cfg->files, i);
54
- GIT_REFCOUNT_DEC(internal, file_internal_free);
54
+ for (i = 0; i < cfg->backends.length; ++i) {
55
+ internal = git_vector_get(&cfg->backends, i);
56
+ GIT_REFCOUNT_DEC(internal, backend_internal_free);
55
57
  }
56
58
 
57
- git_vector_free(&cfg->files);
59
+ git_vector_free(&cfg->backends);
58
60
 
59
61
  git__memzero(cfg, sizeof(*cfg));
60
62
  git__free(cfg);
@@ -70,8 +72,8 @@ void git_config_free(git_config *cfg)
70
72
 
71
73
  static int config_backend_cmp(const void *a, const void *b)
72
74
  {
73
- const file_internal *bk_a = (const file_internal *)(a);
74
- const file_internal *bk_b = (const file_internal *)(b);
75
+ const backend_internal *bk_a = (const backend_internal *)(a);
76
+ const backend_internal *bk_b = (const backend_internal *)(b);
75
77
 
76
78
  return bk_b->level - bk_a->level;
77
79
  }
@@ -81,11 +83,11 @@ int git_config_new(git_config **out)
81
83
  git_config *cfg;
82
84
 
83
85
  cfg = git__malloc(sizeof(git_config));
84
- GITERR_CHECK_ALLOC(cfg);
86
+ GIT_ERROR_CHECK_ALLOC(cfg);
85
87
 
86
88
  memset(cfg, 0x0, sizeof(git_config));
87
89
 
88
- if (git_vector_init(&cfg->files, 3, config_backend_cmp) < 0) {
90
+ if (git_vector_init(&cfg->backends, 3, config_backend_cmp) < 0) {
89
91
  git__free(cfg);
90
92
  return -1;
91
93
  }
@@ -110,11 +112,11 @@ int git_config_add_file_ondisk(
110
112
 
111
113
  res = p_stat(path, &st);
112
114
  if (res < 0 && errno != ENOENT && errno != ENOTDIR) {
113
- giterr_set(GITERR_CONFIG, "failed to stat '%s'", path);
115
+ git_error_set(GIT_ERROR_CONFIG, "failed to stat '%s'", path);
114
116
  return -1;
115
117
  }
116
118
 
117
- if (git_config_file__ondisk(&file, path) < 0)
119
+ if (git_config_backend_from_file(&file, path) < 0)
118
120
  return -1;
119
121
 
120
122
  if ((res = git_config_add_backend(cfg, file, level, repo, force)) < 0) {
@@ -151,7 +153,7 @@ int git_config_snapshot(git_config **out, git_config *in)
151
153
  {
152
154
  int error = 0;
153
155
  size_t i;
154
- file_internal *internal;
156
+ backend_internal *internal;
155
157
  git_config *config;
156
158
 
157
159
  *out = NULL;
@@ -159,10 +161,10 @@ int git_config_snapshot(git_config **out, git_config *in)
159
161
  if (git_config_new(&config) < 0)
160
162
  return -1;
161
163
 
162
- git_vector_foreach(&in->files, i, internal) {
164
+ git_vector_foreach(&in->backends, i, internal) {
163
165
  git_config_backend *b;
164
166
 
165
- if ((error = internal->file->snapshot(&b, internal->file)) < 0)
167
+ if ((error = internal->backend->snapshot(&b, internal->backend)) < 0)
166
168
  break;
167
169
 
168
170
  if ((error = git_config_add_backend(config, b, internal->level, NULL, 0)) < 0) {
@@ -179,59 +181,59 @@ int git_config_snapshot(git_config **out, git_config *in)
179
181
  return error;
180
182
  }
181
183
 
182
- static int find_internal_file_by_level(
183
- file_internal **internal_out,
184
+ static int find_backend_by_level(
185
+ backend_internal **out,
184
186
  const git_config *cfg,
185
187
  git_config_level_t level)
186
188
  {
187
189
  int pos = -1;
188
- file_internal *internal;
190
+ backend_internal *internal;
189
191
  size_t i;
190
192
 
191
- /* when passing GIT_CONFIG_HIGHEST_LEVEL, the idea is to get the config file
192
- * which has the highest level. As config files are stored in a vector
193
- * sorted by decreasing order of level, getting the file at position 0
193
+ /* when passing GIT_CONFIG_HIGHEST_LEVEL, the idea is to get the config backend
194
+ * which has the highest level. As config backends are stored in a vector
195
+ * sorted by decreasing order of level, getting the backend at position 0
194
196
  * will do the job.
195
197
  */
196
198
  if (level == GIT_CONFIG_HIGHEST_LEVEL) {
197
199
  pos = 0;
198
200
  } else {
199
- git_vector_foreach(&cfg->files, i, internal) {
201
+ git_vector_foreach(&cfg->backends, i, internal) {
200
202
  if (internal->level == level)
201
203
  pos = (int)i;
202
204
  }
203
205
  }
204
206
 
205
207
  if (pos == -1) {
206
- giterr_set(GITERR_CONFIG,
207
- "no config file exists for the given level '%i'", (int)level);
208
+ git_error_set(GIT_ERROR_CONFIG,
209
+ "no configuration exists for the given level '%i'", (int)level);
208
210
  return GIT_ENOTFOUND;
209
211
  }
210
212
 
211
- *internal_out = git_vector_get(&cfg->files, pos);
213
+ *out = git_vector_get(&cfg->backends, pos);
212
214
 
213
215
  return 0;
214
216
  }
215
217
 
216
218
  static int duplicate_level(void **old_raw, void *new_raw)
217
219
  {
218
- file_internal **old = (file_internal **)old_raw;
220
+ backend_internal **old = (backend_internal **)old_raw;
219
221
 
220
222
  GIT_UNUSED(new_raw);
221
223
 
222
- giterr_set(GITERR_CONFIG, "a file with the same level (%i) has already been added to the config", (int)(*old)->level);
224
+ git_error_set(GIT_ERROR_CONFIG, "there already exists a configuration for the given level (%i)", (int)(*old)->level);
223
225
  return GIT_EEXISTS;
224
226
  }
225
227
 
226
- static void try_remove_existing_file_internal(
228
+ static void try_remove_existing_backend(
227
229
  git_config *cfg,
228
230
  git_config_level_t level)
229
231
  {
230
232
  int pos = -1;
231
- file_internal *internal;
233
+ backend_internal *internal;
232
234
  size_t i;
233
235
 
234
- git_vector_foreach(&cfg->files, i, internal) {
236
+ git_vector_foreach(&cfg->backends, i, internal) {
235
237
  if (internal->level == level)
236
238
  pos = (int)i;
237
239
  }
@@ -239,32 +241,32 @@ static void try_remove_existing_file_internal(
239
241
  if (pos == -1)
240
242
  return;
241
243
 
242
- internal = git_vector_get(&cfg->files, pos);
244
+ internal = git_vector_get(&cfg->backends, pos);
243
245
 
244
- if (git_vector_remove(&cfg->files, pos) < 0)
246
+ if (git_vector_remove(&cfg->backends, pos) < 0)
245
247
  return;
246
248
 
247
- GIT_REFCOUNT_DEC(internal, file_internal_free);
249
+ GIT_REFCOUNT_DEC(internal, backend_internal_free);
248
250
  }
249
251
 
250
252
  static int git_config__add_internal(
251
253
  git_config *cfg,
252
- file_internal *internal,
254
+ backend_internal *internal,
253
255
  git_config_level_t level,
254
256
  int force)
255
257
  {
256
258
  int result;
257
259
 
258
- /* delete existing config file for level if it exists */
260
+ /* delete existing config backend for level if it exists */
259
261
  if (force)
260
- try_remove_existing_file_internal(cfg, level);
262
+ try_remove_existing_backend(cfg, level);
261
263
 
262
- if ((result = git_vector_insert_sorted(&cfg->files,
264
+ if ((result = git_vector_insert_sorted(&cfg->backends,
263
265
  internal, &duplicate_level)) < 0)
264
266
  return result;
265
267
 
266
- git_vector_sort(&cfg->files);
267
- internal->file->cfg = cfg;
268
+ git_vector_sort(&cfg->backends);
269
+ internal->backend->cfg = cfg;
268
270
 
269
271
  GIT_REFCOUNT_INC(internal);
270
272
 
@@ -285,10 +287,10 @@ int git_config_open_level(
285
287
  git_config_level_t level)
286
288
  {
287
289
  git_config *cfg;
288
- file_internal *internal;
290
+ backend_internal *internal;
289
291
  int res;
290
292
 
291
- if ((res = find_internal_file_by_level(&internal, cfg_parent, level)) < 0)
293
+ if ((res = find_backend_by_level(&internal, cfg_parent, level)) < 0)
292
294
  return res;
293
295
 
294
296
  if ((res = git_config_new(&cfg)) < 0)
@@ -306,27 +308,27 @@ int git_config_open_level(
306
308
 
307
309
  int git_config_add_backend(
308
310
  git_config *cfg,
309
- git_config_backend *file,
311
+ git_config_backend *backend,
310
312
  git_config_level_t level,
311
313
  const git_repository *repo,
312
314
  int force)
313
315
  {
314
- file_internal *internal;
316
+ backend_internal *internal;
315
317
  int result;
316
318
 
317
- assert(cfg && file);
319
+ assert(cfg && backend);
318
320
 
319
- GITERR_CHECK_VERSION(file, GIT_CONFIG_BACKEND_VERSION, "git_config_backend");
321
+ GIT_ERROR_CHECK_VERSION(backend, GIT_CONFIG_BACKEND_VERSION, "git_config_backend");
320
322
 
321
- if ((result = file->open(file, level, repo)) < 0)
323
+ if ((result = backend->open(backend, level, repo)) < 0)
322
324
  return result;
323
325
 
324
- internal = git__malloc(sizeof(file_internal));
325
- GITERR_CHECK_ALLOC(internal);
326
+ internal = git__malloc(sizeof(backend_internal));
327
+ GIT_ERROR_CHECK_ALLOC(internal);
326
328
 
327
- memset(internal, 0x0, sizeof(file_internal));
329
+ memset(internal, 0x0, sizeof(backend_internal));
328
330
 
329
- internal->file = file;
331
+ internal->backend = backend;
330
332
  internal->level = level;
331
333
 
332
334
  if ((result = git_config__add_internal(cfg, internal, level, force)) < 0) {
@@ -345,17 +347,17 @@ typedef struct {
345
347
  git_config_iterator parent;
346
348
  git_config_iterator *current;
347
349
  const git_config *cfg;
348
- regex_t regex;
350
+ git_regexp regex;
349
351
  size_t i;
350
352
  } all_iter;
351
353
 
352
354
  static int find_next_backend(size_t *out, const git_config *cfg, size_t i)
353
355
  {
354
- file_internal *internal;
356
+ backend_internal *internal;
355
357
 
356
358
  for (; i > 0; --i) {
357
- internal = git_vector_get(&cfg->files, i - 1);
358
- if (!internal || !internal->file)
359
+ internal = git_vector_get(&cfg->backends, i - 1);
360
+ if (!internal || !internal->backend)
359
361
  continue;
360
362
 
361
363
  *out = i;
@@ -368,7 +370,7 @@ static int find_next_backend(size_t *out, const git_config *cfg, size_t i)
368
370
  static int all_iter_next(git_config_entry **entry, git_config_iterator *_iter)
369
371
  {
370
372
  all_iter *iter = (all_iter *) _iter;
371
- file_internal *internal;
373
+ backend_internal *internal;
372
374
  git_config_backend *backend;
373
375
  size_t i;
374
376
  int error = 0;
@@ -385,8 +387,8 @@ static int all_iter_next(git_config_entry **entry, git_config_iterator *_iter)
385
387
  if (find_next_backend(&i, iter->cfg, iter->i) < 0)
386
388
  return GIT_ITEROVER;
387
389
 
388
- internal = git_vector_get(&iter->cfg->files, i - 1);
389
- backend = internal->file;
390
+ internal = git_vector_get(&iter->cfg->backends, i - 1);
391
+ backend = internal->backend;
390
392
  iter->i = i - 1;
391
393
 
392
394
  if (iter->current)
@@ -423,7 +425,7 @@ static int all_iter_glob_next(git_config_entry **entry, git_config_iterator *_it
423
425
  */
424
426
  while ((error = all_iter_next(entry, _iter)) == 0) {
425
427
  /* skip non-matching keys if regexp was provided */
426
- if (regexec(&iter->regex, (*entry)->name, 0, NULL, 0) != 0)
428
+ if (git_regexp_match(&iter->regex, (*entry)->name) != 0)
427
429
  continue;
428
430
 
429
431
  /* and simply return if we like the entry's name */
@@ -447,7 +449,7 @@ static void all_iter_glob_free(git_config_iterator *_iter)
447
449
  {
448
450
  all_iter *iter = (all_iter *) _iter;
449
451
 
450
- regfree(&iter->regex);
452
+ git_regexp_dispose(&iter->regex);
451
453
  all_iter_free(_iter);
452
454
  }
453
455
 
@@ -456,12 +458,12 @@ int git_config_iterator_new(git_config_iterator **out, const git_config *cfg)
456
458
  all_iter *iter;
457
459
 
458
460
  iter = git__calloc(1, sizeof(all_iter));
459
- GITERR_CHECK_ALLOC(iter);
461
+ GIT_ERROR_CHECK_ALLOC(iter);
460
462
 
461
463
  iter->parent.free = all_iter_free;
462
464
  iter->parent.next = all_iter_next;
463
465
 
464
- iter->i = cfg->files.length;
466
+ iter->i = cfg->backends.length;
465
467
  iter->cfg = cfg;
466
468
 
467
469
  *out = (git_config_iterator *) iter;
@@ -478,17 +480,16 @@ int git_config_iterator_glob_new(git_config_iterator **out, const git_config *cf
478
480
  return git_config_iterator_new(out, cfg);
479
481
 
480
482
  iter = git__calloc(1, sizeof(all_iter));
481
- GITERR_CHECK_ALLOC(iter);
483
+ GIT_ERROR_CHECK_ALLOC(iter);
482
484
 
483
- if ((result = p_regcomp(&iter->regex, regexp, REG_EXTENDED)) != 0) {
484
- giterr_set_regex(&iter->regex, result);
485
+ if ((result = git_regexp_compile(&iter->regex, regexp, 0)) < 0) {
485
486
  git__free(iter);
486
487
  return -1;
487
488
  }
488
489
 
489
490
  iter->parent.next = all_iter_glob_next;
490
491
  iter->parent.free = all_iter_glob_free;
491
- iter->i = cfg->files.length;
492
+ iter->i = cfg->backends.length;
492
493
  iter->cfg = cfg;
493
494
 
494
495
  *out = (git_config_iterator *) iter;
@@ -510,18 +511,13 @@ int git_config_backend_foreach_match(
510
511
  {
511
512
  git_config_entry *entry;
512
513
  git_config_iterator* iter;
513
- regex_t regex;
514
+ git_regexp regex;
514
515
  int error = 0;
515
516
 
516
517
  assert(backend && cb);
517
518
 
518
- if (regexp != NULL) {
519
- if ((error = p_regcomp(&regex, regexp, REG_EXTENDED)) != 0) {
520
- giterr_set_regex(&regex, error);
521
- regfree(&regex);
522
- return -1;
523
- }
524
- }
519
+ if (regexp && git_regexp_compile(&regex, regexp, 0) < 0)
520
+ return -1;
525
521
 
526
522
  if ((error = backend->iterator(&iter, backend)) < 0) {
527
523
  iter = NULL;
@@ -530,18 +526,18 @@ int git_config_backend_foreach_match(
530
526
 
531
527
  while (!(iter->next(&entry, iter) < 0)) {
532
528
  /* skip non-matching keys if regexp was provided */
533
- if (regexp && regexec(&regex, entry->name, 0, NULL, 0) != 0)
529
+ if (regexp && git_regexp_match(&regex, entry->name) != 0)
534
530
  continue;
535
531
 
536
532
  /* abort iterator on non-zero return value */
537
533
  if ((error = cb(entry, payload)) != 0) {
538
- giterr_set_after_callback(error);
534
+ git_error_set_after_callback(error);
539
535
  break;
540
536
  }
541
537
  }
542
538
 
543
539
  if (regexp != NULL)
544
- regfree(&regex);
540
+ git_regexp_dispose(&regex);
545
541
 
546
542
  iter->free(iter);
547
543
 
@@ -563,7 +559,7 @@ int git_config_foreach_match(
563
559
 
564
560
  while (!(error = git_config_next(&entry, iter))) {
565
561
  if ((error = cb(entry, payload)) != 0) {
566
- giterr_set_after_callback(error);
562
+ git_error_set_after_callback(error);
567
563
  break;
568
564
  }
569
565
  }
@@ -594,38 +590,38 @@ static int get_backend_for_use(git_config_backend **out,
594
590
  git_config *cfg, const char *name, backend_use use)
595
591
  {
596
592
  size_t i;
597
- file_internal *f;
593
+ backend_internal *backend;
598
594
 
599
595
  *out = NULL;
600
596
 
601
- if (git_vector_length(&cfg->files) == 0) {
602
- giterr_set(GITERR_CONFIG,
603
- "cannot %s value for '%s' when no config files exist",
597
+ if (git_vector_length(&cfg->backends) == 0) {
598
+ git_error_set(GIT_ERROR_CONFIG,
599
+ "cannot %s value for '%s' when no config backends exist",
604
600
  uses[use], name);
605
601
  return GIT_ENOTFOUND;
606
602
  }
607
603
 
608
- git_vector_foreach(&cfg->files, i, f) {
609
- if (!f->file->readonly) {
610
- *out = f->file;
604
+ git_vector_foreach(&cfg->backends, i, backend) {
605
+ if (!backend->backend->readonly) {
606
+ *out = backend->backend;
611
607
  return 0;
612
608
  }
613
609
  }
614
610
 
615
- giterr_set(GITERR_CONFIG,
616
- "cannot %s value for '%s' when all config files are readonly",
611
+ git_error_set(GIT_ERROR_CONFIG,
612
+ "cannot %s value for '%s' when all config backends are readonly",
617
613
  uses[use], name);
618
614
  return GIT_ENOTFOUND;
619
615
  }
620
616
 
621
617
  int git_config_delete_entry(git_config *cfg, const char *name)
622
618
  {
623
- git_config_backend *file;
619
+ git_config_backend *backend;
624
620
 
625
- if (get_backend_for_use(&file, cfg, name, BACKEND_USE_DELETE) < 0)
621
+ if (get_backend_for_use(&backend, cfg, name, BACKEND_USE_DELETE) < 0)
626
622
  return GIT_ENOTFOUND;
627
623
 
628
- return file->del(file, name);
624
+ return backend->del(backend, name);
629
625
  }
630
626
 
631
627
  int git_config_set_int64(git_config *cfg, const char *name, int64_t value)
@@ -648,20 +644,20 @@ int git_config_set_bool(git_config *cfg, const char *name, int value)
648
644
  int git_config_set_string(git_config *cfg, const char *name, const char *value)
649
645
  {
650
646
  int error;
651
- git_config_backend *file;
647
+ git_config_backend *backend;
652
648
 
653
649
  if (!value) {
654
- giterr_set(GITERR_CONFIG, "the value to set cannot be NULL");
650
+ git_error_set(GIT_ERROR_CONFIG, "the value to set cannot be NULL");
655
651
  return -1;
656
652
  }
657
653
 
658
- if (get_backend_for_use(&file, cfg, name, BACKEND_USE_SET) < 0)
654
+ if (get_backend_for_use(&backend, cfg, name, BACKEND_USE_SET) < 0)
659
655
  return GIT_ENOTFOUND;
660
656
 
661
- error = file->set(file, name, value);
657
+ error = backend->set(backend, name, value);
662
658
 
663
659
  if (!error && GIT_REFCOUNT_OWNER(cfg) != NULL)
664
- git_repository__cvar_cache_clear(GIT_REFCOUNT_OWNER(cfg));
660
+ git_repository__configmap_lookup_cache_clear(GIT_REFCOUNT_OWNER(cfg));
665
661
 
666
662
  return error;
667
663
  }
@@ -703,7 +699,7 @@ int git_config__update_entry(
703
699
 
704
700
  static int config_error_notfound(const char *name)
705
701
  {
706
- giterr_set(GITERR_CONFIG, "config value '%s' was not found", name);
702
+ git_error_set(GIT_ERROR_CONFIG, "config value '%s' was not found", name);
707
703
  return GIT_ENOTFOUND;
708
704
  }
709
705
 
@@ -724,7 +720,7 @@ static int get_entry(
724
720
  const char *key = name;
725
721
  char *normalized = NULL;
726
722
  size_t i;
727
- file_internal *internal;
723
+ backend_internal *internal;
728
724
 
729
725
  *out = NULL;
730
726
 
@@ -735,11 +731,11 @@ static int get_entry(
735
731
  }
736
732
 
737
733
  res = GIT_ENOTFOUND;
738
- git_vector_foreach(&cfg->files, i, internal) {
739
- if (!internal || !internal->file)
734
+ git_vector_foreach(&cfg->backends, i, internal) {
735
+ if (!internal || !internal->backend)
740
736
  continue;
741
737
 
742
- res = internal->file->get(internal->file, key, out);
738
+ res = internal->backend->get(internal->backend, key, out);
743
739
  if (res != GIT_ENOTFOUND)
744
740
  break;
745
741
  }
@@ -750,7 +746,7 @@ cleanup:
750
746
  if (res == GIT_ENOTFOUND)
751
747
  res = (want_errors > GET_ALL_ERRORS) ? 0 : config_error_notfound(name);
752
748
  else if (res && (want_errors == GET_NO_ERRORS)) {
753
- giterr_clear();
749
+ git_error_clear();
754
750
  res = 0;
755
751
  }
756
752
 
@@ -777,7 +773,7 @@ int git_config_get_mapped(
777
773
  int *out,
778
774
  const git_config *cfg,
779
775
  const char *name,
780
- const git_cvar_map *maps,
776
+ const git_configmap *maps,
781
777
  size_t map_n)
782
778
  {
783
779
  git_config_entry *entry;
@@ -837,13 +833,13 @@ int git_config_get_bool(int *out, const git_config *cfg, const char *name)
837
833
  static int is_readonly(const git_config *cfg)
838
834
  {
839
835
  size_t i;
840
- file_internal *internal;
836
+ backend_internal *internal;
841
837
 
842
- git_vector_foreach(&cfg->files, i, internal) {
843
- if (!internal || !internal->file)
838
+ git_vector_foreach(&cfg->backends, i, internal) {
839
+ if (!internal || !internal->backend)
844
840
  continue;
845
841
 
846
- if (!internal->file->readonly)
842
+ if (!internal->backend->readonly)
847
843
  return 0;
848
844
  }
849
845
 
@@ -871,7 +867,7 @@ int git_config_get_string(
871
867
  int ret;
872
868
 
873
869
  if (!is_readonly(cfg)) {
874
- giterr_set(GITERR_CONFIG, "get_string called on a live config object");
870
+ git_error_set(GIT_ERROR_CONFIG, "get_string called on a live config object");
875
871
  return -1;
876
872
  }
877
873
 
@@ -925,7 +921,7 @@ int git_config__get_bool_force(
925
921
  get_entry(&entry, cfg, key, false, GET_NO_ERRORS);
926
922
 
927
923
  if (entry && git_config_parse_bool(&val, entry->value) < 0)
928
- giterr_clear();
924
+ git_error_clear();
929
925
 
930
926
  git_config_entry_free(entry);
931
927
  return val;
@@ -940,7 +936,7 @@ int git_config__get_int_force(
940
936
  get_entry(&entry, cfg, key, false, GET_NO_ERRORS);
941
937
 
942
938
  if (entry && git_config_parse_int32(&val, entry->value) < 0)
943
- giterr_clear();
939
+ git_error_clear();
944
940
 
945
941
  git_config_entry_free(entry);
946
942
  return (int)val;
@@ -962,7 +958,7 @@ int git_config_get_multivar_foreach(
962
958
  found = 1;
963
959
 
964
960
  if ((err = cb(entry, payload)) != 0) {
965
- giterr_set_after_callback(err);
961
+ git_error_set_after_callback(err);
966
962
  break;
967
963
  }
968
964
  }
@@ -981,7 +977,7 @@ typedef struct {
981
977
  git_config_iterator parent;
982
978
  git_config_iterator *iter;
983
979
  char *name;
984
- regex_t regex;
980
+ git_regexp regex;
985
981
  int have_regex;
986
982
  } multivar_iter;
987
983
 
@@ -997,7 +993,7 @@ static int multivar_iter_next(git_config_entry **entry, git_config_iterator *_it
997
993
  if (!iter->have_regex)
998
994
  return 0;
999
995
 
1000
- if (regexec(&iter->regex, (*entry)->value, 0, NULL, 0) == 0)
996
+ if (git_regexp_match(&iter->regex, (*entry)->value) == 0)
1001
997
  return 0;
1002
998
  }
1003
999
 
@@ -1012,7 +1008,7 @@ void multivar_iter_free(git_config_iterator *_iter)
1012
1008
 
1013
1009
  git__free(iter->name);
1014
1010
  if (iter->have_regex)
1015
- regfree(&iter->regex);
1011
+ git_regexp_dispose(&iter->regex);
1016
1012
  git__free(iter);
1017
1013
  }
1018
1014
 
@@ -1026,19 +1022,14 @@ int git_config_multivar_iterator_new(git_config_iterator **out, const git_config
1026
1022
  return error;
1027
1023
 
1028
1024
  iter = git__calloc(1, sizeof(multivar_iter));
1029
- GITERR_CHECK_ALLOC(iter);
1025
+ GIT_ERROR_CHECK_ALLOC(iter);
1030
1026
 
1031
1027
  if ((error = git_config__normalize_name(name, &iter->name)) < 0)
1032
1028
  goto on_error;
1033
1029
 
1034
1030
  if (regexp != NULL) {
1035
- error = p_regcomp(&iter->regex, regexp, REG_EXTENDED);
1036
- if (error != 0) {
1037
- giterr_set_regex(&iter->regex, error);
1038
- error = -1;
1039
- regfree(&iter->regex);
1031
+ if ((error = git_regexp_compile(&iter->regex, regexp, 0)) < 0)
1040
1032
  goto on_error;
1041
- }
1042
1033
 
1043
1034
  iter->have_regex = 1;
1044
1035
  }
@@ -1060,22 +1051,22 @@ on_error:
1060
1051
 
1061
1052
  int git_config_set_multivar(git_config *cfg, const char *name, const char *regexp, const char *value)
1062
1053
  {
1063
- git_config_backend *file;
1054
+ git_config_backend *backend;
1064
1055
 
1065
- if (get_backend_for_use(&file, cfg, name, BACKEND_USE_DELETE) < 0)
1056
+ if (get_backend_for_use(&backend, cfg, name, BACKEND_USE_DELETE) < 0)
1066
1057
  return GIT_ENOTFOUND;
1067
1058
 
1068
- return file->set_multivar(file, name, regexp, value);
1059
+ return backend->set_multivar(backend, name, regexp, value);
1069
1060
  }
1070
1061
 
1071
1062
  int git_config_delete_multivar(git_config *cfg, const char *name, const char *regexp)
1072
1063
  {
1073
- git_config_backend *file;
1064
+ git_config_backend *backend;
1074
1065
 
1075
- if (get_backend_for_use(&file, cfg, name, BACKEND_USE_DELETE) < 0)
1066
+ if (get_backend_for_use(&backend, cfg, name, BACKEND_USE_DELETE) < 0)
1076
1067
  return GIT_ENOTFOUND;
1077
1068
 
1078
- return file->del_multivar(file, name, regexp);
1069
+ return backend->del_multivar(backend, name, regexp);
1079
1070
  }
1080
1071
 
1081
1072
  int git_config_next(git_config_entry **entry, git_config_iterator *iter)
@@ -1173,7 +1164,7 @@ int git_config_open_default(git_config **out)
1173
1164
  error = git_config_add_file_ondisk(cfg, buf.ptr,
1174
1165
  GIT_CONFIG_LEVEL_PROGRAMDATA, NULL, 0);
1175
1166
 
1176
- git_buf_free(&buf);
1167
+ git_buf_dispose(&buf);
1177
1168
 
1178
1169
  if (error) {
1179
1170
  git_config_free(cfg);
@@ -1188,17 +1179,19 @@ int git_config_open_default(git_config **out)
1188
1179
  int git_config_lock(git_transaction **out, git_config *cfg)
1189
1180
  {
1190
1181
  int error;
1191
- git_config_backend *file;
1192
- file_internal *internal;
1182
+ git_config_backend *backend;
1183
+ backend_internal *internal;
1193
1184
 
1194
- internal = git_vector_get(&cfg->files, 0);
1195
- if (!internal || !internal->file) {
1196
- giterr_set(GITERR_CONFIG, "cannot lock; the config has no backends/files");
1185
+ assert(cfg);
1186
+
1187
+ internal = git_vector_get(&cfg->backends, 0);
1188
+ if (!internal || !internal->backend) {
1189
+ git_error_set(GIT_ERROR_CONFIG, "cannot lock; the config has no backends");
1197
1190
  return -1;
1198
1191
  }
1199
- file = internal->file;
1192
+ backend = internal->backend;
1200
1193
 
1201
- if ((error = file->lock(file)) < 0)
1194
+ if ((error = backend->lock(backend)) < 0)
1202
1195
  return error;
1203
1196
 
1204
1197
  return git_transaction_config_new(out, cfg);
@@ -1206,18 +1199,20 @@ int git_config_lock(git_transaction **out, git_config *cfg)
1206
1199
 
1207
1200
  int git_config_unlock(git_config *cfg, int commit)
1208
1201
  {
1209
- git_config_backend *file;
1210
- file_internal *internal;
1202
+ git_config_backend *backend;
1203
+ backend_internal *internal;
1211
1204
 
1212
- internal = git_vector_get(&cfg->files, 0);
1213
- if (!internal || !internal->file) {
1214
- giterr_set(GITERR_CONFIG, "cannot lock; the config has no backends/files");
1205
+ assert(cfg);
1206
+
1207
+ internal = git_vector_get(&cfg->backends, 0);
1208
+ if (!internal || !internal->backend) {
1209
+ git_error_set(GIT_ERROR_CONFIG, "cannot lock; the config has no backends");
1215
1210
  return -1;
1216
1211
  }
1217
1212
 
1218
- file = internal->file;
1213
+ backend = internal->backend;
1219
1214
 
1220
- return file->unlock(file, commit);
1215
+ return backend->unlock(backend, commit);
1221
1216
  }
1222
1217
 
1223
1218
  /***********
@@ -1226,7 +1221,7 @@ int git_config_unlock(git_config *cfg, int commit)
1226
1221
 
1227
1222
  int git_config_lookup_map_value(
1228
1223
  int *out,
1229
- const git_cvar_map *maps,
1224
+ const git_configmap *maps,
1230
1225
  size_t map_n,
1231
1226
  const char *value)
1232
1227
  {
@@ -1236,27 +1231,27 @@ int git_config_lookup_map_value(
1236
1231
  goto fail_parse;
1237
1232
 
1238
1233
  for (i = 0; i < map_n; ++i) {
1239
- const git_cvar_map *m = maps + i;
1234
+ const git_configmap *m = maps + i;
1240
1235
 
1241
- switch (m->cvar_type) {
1242
- case GIT_CVAR_FALSE:
1243
- case GIT_CVAR_TRUE: {
1236
+ switch (m->type) {
1237
+ case GIT_CONFIGMAP_FALSE:
1238
+ case GIT_CONFIGMAP_TRUE: {
1244
1239
  int bool_val;
1245
1240
 
1246
1241
  if (git__parse_bool(&bool_val, value) == 0 &&
1247
- bool_val == (int)m->cvar_type) {
1242
+ bool_val == (int)m->type) {
1248
1243
  *out = m->map_value;
1249
1244
  return 0;
1250
1245
  }
1251
1246
  break;
1252
1247
  }
1253
1248
 
1254
- case GIT_CVAR_INT32:
1249
+ case GIT_CONFIGMAP_INT32:
1255
1250
  if (git_config_parse_int32(out, value) == 0)
1256
1251
  return 0;
1257
1252
  break;
1258
1253
 
1259
- case GIT_CVAR_STRING:
1254
+ case GIT_CONFIGMAP_STRING:
1260
1255
  if (strcasecmp(value, m->str_match) == 0) {
1261
1256
  *out = m->map_value;
1262
1257
  return 0;
@@ -1266,27 +1261,27 @@ int git_config_lookup_map_value(
1266
1261
  }
1267
1262
 
1268
1263
  fail_parse:
1269
- giterr_set(GITERR_CONFIG, "failed to map '%s'", value);
1264
+ git_error_set(GIT_ERROR_CONFIG, "failed to map '%s'", value);
1270
1265
  return -1;
1271
1266
  }
1272
1267
 
1273
- int git_config_lookup_map_enum(git_cvar_t *type_out, const char **str_out,
1274
- const git_cvar_map *maps, size_t map_n, int enum_val)
1268
+ int git_config_lookup_map_enum(git_configmap_t *type_out, const char **str_out,
1269
+ const git_configmap *maps, size_t map_n, int enum_val)
1275
1270
  {
1276
1271
  size_t i;
1277
1272
 
1278
1273
  for (i = 0; i < map_n; i++) {
1279
- const git_cvar_map *m = &maps[i];
1274
+ const git_configmap *m = &maps[i];
1280
1275
 
1281
1276
  if (m->map_value != enum_val)
1282
1277
  continue;
1283
1278
 
1284
- *type_out = m->cvar_type;
1279
+ *type_out = m->type;
1285
1280
  *str_out = m->str_match;
1286
1281
  return 0;
1287
1282
  }
1288
1283
 
1289
- giterr_set(GITERR_CONFIG, "invalid enum value");
1284
+ git_error_set(GIT_ERROR_CONFIG, "invalid enum value");
1290
1285
  return GIT_ENOTFOUND;
1291
1286
  }
1292
1287
 
@@ -1300,7 +1295,7 @@ int git_config_parse_bool(int *out, const char *value)
1300
1295
  return 0;
1301
1296
  }
1302
1297
 
1303
- giterr_set(GITERR_CONFIG, "failed to parse '%s' as a boolean value", value);
1298
+ git_error_set(GIT_ERROR_CONFIG, "failed to parse '%s' as a boolean value", value);
1304
1299
  return -1;
1305
1300
  }
1306
1301
 
@@ -1343,7 +1338,7 @@ int git_config_parse_int64(int64_t *out, const char *value)
1343
1338
  }
1344
1339
 
1345
1340
  fail_parse:
1346
- giterr_set(GITERR_CONFIG, "failed to parse '%s' as an integer", value ? value : "(null)");
1341
+ git_error_set(GIT_ERROR_CONFIG, "failed to parse '%s' as an integer", value ? value : "(null)");
1347
1342
  return -1;
1348
1343
  }
1349
1344
 
@@ -1363,7 +1358,7 @@ int git_config_parse_int32(int32_t *out, const char *value)
1363
1358
  return 0;
1364
1359
 
1365
1360
  fail_parse:
1366
- giterr_set(GITERR_CONFIG, "failed to parse '%s' as a 32-bit integer", value ? value : "(null)");
1361
+ git_error_set(GIT_ERROR_CONFIG, "failed to parse '%s' as a 32-bit integer", value ? value : "(null)");
1367
1362
  return -1;
1368
1363
  }
1369
1364
 
@@ -1375,7 +1370,7 @@ int git_config_parse_path(git_buf *out, const char *value)
1375
1370
 
1376
1371
  if (value[0] == '~') {
1377
1372
  if (value[1] != '\0' && value[1] != '/') {
1378
- giterr_set(GITERR_CONFIG, "retrieving a homedir by name is not supported");
1373
+ git_error_set(GIT_ERROR_CONFIG, "retrieving a homedir by name is not supported");
1379
1374
  return -1;
1380
1375
  }
1381
1376
 
@@ -1385,6 +1380,30 @@ int git_config_parse_path(git_buf *out, const char *value)
1385
1380
  return git_buf_sets(out, value);
1386
1381
  }
1387
1382
 
1383
+ static int normalize_section(char *start, char *end)
1384
+ {
1385
+ char *scan;
1386
+
1387
+ if (start == end)
1388
+ return GIT_EINVALIDSPEC;
1389
+
1390
+ /* Validate and downcase range */
1391
+ for (scan = start; *scan; ++scan) {
1392
+ if (end && scan >= end)
1393
+ break;
1394
+ if (isalnum(*scan))
1395
+ *scan = (char)git__tolower(*scan);
1396
+ else if (*scan != '-' || scan == start)
1397
+ return GIT_EINVALIDSPEC;
1398
+ }
1399
+
1400
+ if (scan == start)
1401
+ return GIT_EINVALIDSPEC;
1402
+
1403
+ return 0;
1404
+ }
1405
+
1406
+
1388
1407
  /* Take something the user gave us and make it nice for our hash function */
1389
1408
  int git_config__normalize_name(const char *in, char **out)
1390
1409
  {
@@ -1393,7 +1412,7 @@ int git_config__normalize_name(const char *in, char **out)
1393
1412
  assert(in && out);
1394
1413
 
1395
1414
  name = git__strdup(in);
1396
- GITERR_CHECK_ALLOC(name);
1415
+ GIT_ERROR_CHECK_ALLOC(name);
1397
1416
 
1398
1417
  fdot = strchr(name, '.');
1399
1418
  ldot = strrchr(name, '.');
@@ -1402,8 +1421,8 @@ int git_config__normalize_name(const char *in, char **out)
1402
1421
  goto invalid;
1403
1422
 
1404
1423
  /* Validate and downcase up to first dot and after last dot */
1405
- if (git_config_file_normalize_section(name, fdot) < 0 ||
1406
- git_config_file_normalize_section(ldot + 1, NULL) < 0)
1424
+ if (normalize_section(name, fdot) < 0 ||
1425
+ normalize_section(ldot + 1, NULL) < 0)
1407
1426
  goto invalid;
1408
1427
 
1409
1428
  /* If there is a middle range, make sure it doesn't have newlines */
@@ -1416,7 +1435,7 @@ int git_config__normalize_name(const char *in, char **out)
1416
1435
 
1417
1436
  invalid:
1418
1437
  git__free(name);
1419
- giterr_set(GITERR_CONFIG, "invalid config item name '%s'", in);
1438
+ git_error_set(GIT_ERROR_CONFIG, "invalid config item name '%s'", in);
1420
1439
  return GIT_EINVALIDSPEC;
1421
1440
  }
1422
1441
 
@@ -1475,11 +1494,10 @@ int git_config_rename_section(
1475
1494
  goto cleanup;
1476
1495
 
1477
1496
  if (new_section_name != NULL &&
1478
- (error = git_config_file_normalize_section(
1479
- replace.ptr, strchr(replace.ptr, '.'))) < 0)
1497
+ (error = normalize_section(replace.ptr, strchr(replace.ptr, '.'))) < 0)
1480
1498
  {
1481
- giterr_set(
1482
- GITERR_CONFIG, "invalid config section '%s'", new_section_name);
1499
+ git_error_set(
1500
+ GIT_ERROR_CONFIG, "invalid config section '%s'", new_section_name);
1483
1501
  goto cleanup;
1484
1502
  }
1485
1503
 
@@ -1487,8 +1505,8 @@ int git_config_rename_section(
1487
1505
  config, git_buf_cstr(&pattern), rename_config_entries_cb, &data);
1488
1506
 
1489
1507
  cleanup:
1490
- git_buf_free(&pattern);
1491
- git_buf_free(&replace);
1508
+ git_buf_dispose(&pattern);
1509
+ git_buf_dispose(&replace);
1492
1510
 
1493
1511
  return error;
1494
1512
  }