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
@@ -9,48 +9,123 @@
9
9
 
10
10
  #include "common.h"
11
11
 
12
- #define kmalloc git__malloc
13
- #define kcalloc git__calloc
14
- #define krealloc git__realloc
15
- #define kreallocarray git__reallocarray
16
- #define kfree git__free
17
- #include "khash.h"
18
-
19
- __KHASH_TYPE(str, const char *, void *)
20
- typedef khash_t(str) git_strmap;
21
- typedef khiter_t git_strmap_iter;
22
-
23
- int git_strmap_alloc(git_strmap **map);
12
+ /** A map with C strings as key. */
13
+ typedef struct kh_str_s git_strmap;
14
+
15
+ /**
16
+ * Allocate a new string map.
17
+ *
18
+ * @param out Pointer to the map that shall be allocated.
19
+ * @return 0 on success, an error code if allocation has failed.
20
+ */
21
+ int git_strmap_new(git_strmap **out);
22
+
23
+ /**
24
+ * Free memory associated with the map.
25
+ *
26
+ * Note that this function will _not_ free keys or values added
27
+ * to this map.
28
+ *
29
+ * @param map Pointer to the map that is to be free'd. May be
30
+ * `NULL`.
31
+ */
24
32
  void git_strmap_free(git_strmap *map);
33
+
34
+ /**
35
+ * Clear all entries from the map.
36
+ *
37
+ * This function will remove all entries from the associated map.
38
+ * Memory associated with it will not be released, though.
39
+ *
40
+ * @param map Pointer to the map that shall be cleared. May be
41
+ * `NULL`.
42
+ */
25
43
  void git_strmap_clear(git_strmap *map);
26
44
 
27
- size_t git_strmap_num_entries(git_strmap *map);
45
+ /**
46
+ * Return the number of elements in the map.
47
+ *
48
+ * @parameter map map containing the elements
49
+ * @return number of elements in the map
50
+ */
51
+ size_t git_strmap_size(git_strmap *map);
28
52
 
29
- size_t git_strmap_lookup_index(git_strmap *map, const char *key);
30
- int git_strmap_valid_index(git_strmap *map, size_t idx);
53
+ /**
54
+ * Return value associated with the given key.
55
+ *
56
+ * @param map map to search key in
57
+ * @param key key to search for
58
+ * @return value associated with the given key or NULL if the key was not found
59
+ */
60
+ void *git_strmap_get(git_strmap *map, const char *key);
31
61
 
32
- int git_strmap_exists(git_strmap *map, const char *key);
33
- int git_strmap_has_data(git_strmap *map, size_t idx);
62
+ /**
63
+ * Set the entry for key to value.
64
+ *
65
+ * If the map has no corresponding entry for the given key, a new
66
+ * entry will be created with the given value. If an entry exists
67
+ * already, its value will be updated to match the given value.
68
+ *
69
+ * @param map map to create new entry in
70
+ * @param key key to set
71
+ * @param value value to associate the key with; may be NULL
72
+ * @return zero if the key was successfully set, a negative error
73
+ * code otherwise
74
+ */
75
+ int git_strmap_set(git_strmap *map, const char *key, void *value);
34
76
 
35
- const char *git_strmap_key(git_strmap *map, size_t idx);
36
- void git_strmap_set_key_at(git_strmap *map, size_t idx, char *key);
37
- void *git_strmap_value_at(git_strmap *map, size_t idx);
38
- void git_strmap_set_value_at(git_strmap *map, size_t idx, void *value);
39
- void git_strmap_delete_at(git_strmap *map, size_t idx);
77
+ /**
78
+ * Delete an entry from the map.
79
+ *
80
+ * Delete the given key and its value from the map. If no such
81
+ * key exists, this will do nothing.
82
+ *
83
+ * @param map map to delete key in
84
+ * @param key key to delete
85
+ * @return `0` if the key has been deleted, GIT_ENOTFOUND if no
86
+ * such key was found, a negative code in case of an
87
+ * error
88
+ */
89
+ int git_strmap_delete(git_strmap *map, const char *key);
40
90
 
41
- int git_strmap_put(git_strmap *map, const char *key, int *err);
42
- void git_strmap_insert(git_strmap *map, const char *key, void *value, int *rval);
43
- void git_strmap_delete(git_strmap *map, const char *key);
91
+ /**
92
+ * Check whether a key exists in the given map.
93
+ *
94
+ * @param map map to query for the key
95
+ * @param key key to search for
96
+ * @return 0 if the key has not been found, 1 otherwise
97
+ */
98
+ int git_strmap_exists(git_strmap *map, const char *key);
44
99
 
45
- #define git_strmap_foreach kh_foreach
46
- #define git_strmap_foreach_value kh_foreach_value
100
+ /**
101
+ * Iterate over entries of the map.
102
+ *
103
+ * This functions allows to iterate over all key-value entries of
104
+ * the map. The current position is stored in the `iter` variable
105
+ * and should be initialized to `0` before the first call to this
106
+ * function.
107
+ *
108
+ * @param map map to iterate over
109
+ * @param value pointer to the variable where to store the current
110
+ * value. May be NULL.
111
+ * @param iter iterator storing the current position. Initialize
112
+ * with zero previous to the first call.
113
+ * @param key pointer to the variable where to store the current
114
+ * key. May be NULL.
115
+ * @return `0` if the next entry was correctly retrieved.
116
+ * GIT_ITEROVER if no entries are left. A negative error
117
+ * code otherwise.
118
+ */
119
+ int git_strmap_iterate(void **value, git_strmap *map, size_t *iter, const char **key);
47
120
 
48
- #define git_strmap_begin kh_begin
49
- #define git_strmap_end kh_end
121
+ #define git_strmap_foreach(h, kvar, vvar, code) { size_t __i = 0; \
122
+ while (git_strmap_iterate((void **) &(vvar), h, &__i, &(kvar)) == 0) { \
123
+ code; \
124
+ } }
50
125
 
51
- int git_strmap_next(
52
- void **data,
53
- git_strmap_iter* iter,
54
- git_strmap *map);
126
+ #define git_strmap_foreach_value(h, vvar, code) { size_t __i = 0; \
127
+ while (git_strmap_iterate((void **) &(vvar), h, &__i, NULL) == 0) { \
128
+ code; \
129
+ } }
55
130
 
56
131
  #endif
@@ -15,7 +15,7 @@
15
15
  #include "buf_text.h"
16
16
  #include "vector.h"
17
17
  #include "posix.h"
18
- #include "config_file.h"
18
+ #include "config_backend.h"
19
19
  #include "config.h"
20
20
  #include "repository.h"
21
21
  #include "tree.h"
@@ -23,31 +23,32 @@
23
23
  #include "path.h"
24
24
  #include "index.h"
25
25
  #include "worktree.h"
26
+ #include "clone.h"
26
27
 
27
28
  #define GIT_MODULES_FILE ".gitmodules"
28
29
 
29
- static git_cvar_map _sm_update_map[] = {
30
- {GIT_CVAR_STRING, "checkout", GIT_SUBMODULE_UPDATE_CHECKOUT},
31
- {GIT_CVAR_STRING, "rebase", GIT_SUBMODULE_UPDATE_REBASE},
32
- {GIT_CVAR_STRING, "merge", GIT_SUBMODULE_UPDATE_MERGE},
33
- {GIT_CVAR_STRING, "none", GIT_SUBMODULE_UPDATE_NONE},
34
- {GIT_CVAR_FALSE, NULL, GIT_SUBMODULE_UPDATE_NONE},
35
- {GIT_CVAR_TRUE, NULL, GIT_SUBMODULE_UPDATE_CHECKOUT},
30
+ static git_configmap _sm_update_map[] = {
31
+ {GIT_CONFIGMAP_STRING, "checkout", GIT_SUBMODULE_UPDATE_CHECKOUT},
32
+ {GIT_CONFIGMAP_STRING, "rebase", GIT_SUBMODULE_UPDATE_REBASE},
33
+ {GIT_CONFIGMAP_STRING, "merge", GIT_SUBMODULE_UPDATE_MERGE},
34
+ {GIT_CONFIGMAP_STRING, "none", GIT_SUBMODULE_UPDATE_NONE},
35
+ {GIT_CONFIGMAP_FALSE, NULL, GIT_SUBMODULE_UPDATE_NONE},
36
+ {GIT_CONFIGMAP_TRUE, NULL, GIT_SUBMODULE_UPDATE_CHECKOUT},
36
37
  };
37
38
 
38
- static git_cvar_map _sm_ignore_map[] = {
39
- {GIT_CVAR_STRING, "none", GIT_SUBMODULE_IGNORE_NONE},
40
- {GIT_CVAR_STRING, "untracked", GIT_SUBMODULE_IGNORE_UNTRACKED},
41
- {GIT_CVAR_STRING, "dirty", GIT_SUBMODULE_IGNORE_DIRTY},
42
- {GIT_CVAR_STRING, "all", GIT_SUBMODULE_IGNORE_ALL},
43
- {GIT_CVAR_FALSE, NULL, GIT_SUBMODULE_IGNORE_NONE},
44
- {GIT_CVAR_TRUE, NULL, GIT_SUBMODULE_IGNORE_ALL},
39
+ static git_configmap _sm_ignore_map[] = {
40
+ {GIT_CONFIGMAP_STRING, "none", GIT_SUBMODULE_IGNORE_NONE},
41
+ {GIT_CONFIGMAP_STRING, "untracked", GIT_SUBMODULE_IGNORE_UNTRACKED},
42
+ {GIT_CONFIGMAP_STRING, "dirty", GIT_SUBMODULE_IGNORE_DIRTY},
43
+ {GIT_CONFIGMAP_STRING, "all", GIT_SUBMODULE_IGNORE_ALL},
44
+ {GIT_CONFIGMAP_FALSE, NULL, GIT_SUBMODULE_IGNORE_NONE},
45
+ {GIT_CONFIGMAP_TRUE, NULL, GIT_SUBMODULE_IGNORE_ALL},
45
46
  };
46
47
 
47
- static git_cvar_map _sm_recurse_map[] = {
48
- {GIT_CVAR_STRING, "on-demand", GIT_SUBMODULE_RECURSE_ONDEMAND},
49
- {GIT_CVAR_FALSE, NULL, GIT_SUBMODULE_RECURSE_NO},
50
- {GIT_CVAR_TRUE, NULL, GIT_SUBMODULE_RECURSE_YES},
48
+ static git_configmap _sm_recurse_map[] = {
49
+ {GIT_CONFIGMAP_STRING, "on-demand", GIT_SUBMODULE_RECURSE_ONDEMAND},
50
+ {GIT_CONFIGMAP_FALSE, NULL, GIT_SUBMODULE_RECURSE_NO},
51
+ {GIT_CONFIGMAP_TRUE, NULL, GIT_SUBMODULE_RECURSE_YES},
51
52
  };
52
53
 
53
54
  enum {
@@ -60,35 +61,6 @@ enum {
60
61
  GITMODULES_CREATE = 1,
61
62
  };
62
63
 
63
- static kh_inline khint_t str_hash_no_trailing_slash(const char *s)
64
- {
65
- khint_t h;
66
-
67
- for (h = 0; *s; ++s)
68
- if (s[1] != '\0' || *s != '/')
69
- h = (h << 5) - h + *s;
70
-
71
- return h;
72
- }
73
-
74
- static kh_inline int str_equal_no_trailing_slash(const char *a, const char *b)
75
- {
76
- size_t alen = a ? strlen(a) : 0;
77
- size_t blen = b ? strlen(b) : 0;
78
-
79
- if (alen > 0 && a[alen - 1] == '/')
80
- alen--;
81
- if (blen > 0 && b[blen - 1] == '/')
82
- blen--;
83
-
84
- return (alen == 0 && blen == 0) ||
85
- (alen == blen && strncmp(a, b, alen) == 0);
86
- }
87
-
88
- __KHASH_IMPL(
89
- str, static kh_inline, const char *, void *, 1,
90
- str_hash_no_trailing_slash, str_equal_no_trailing_slash)
91
-
92
64
  static int submodule_alloc(git_submodule **out, git_repository *repo, const char *name);
93
65
  static git_config_backend *open_gitmodules(git_repository *repo, int gitmod);
94
66
  static int gitmodules_snapshot(git_config **snap, git_repository *repo);
@@ -124,7 +96,7 @@ static void submodule_set_lookup_error(int error, const char *name)
124
96
  if (!error)
125
97
  return;
126
98
 
127
- giterr_set(GITERR_SUBMODULE, (error == GIT_ENOTFOUND) ?
99
+ git_error_set(GIT_ERROR_SUBMODULE, (error == GIT_ENOTFOUND) ?
128
100
  "no submodule named '%s'" :
129
101
  "submodule '%s' has not been added yet", name);
130
102
  }
@@ -143,24 +115,74 @@ static int find_by_path(const git_config_entry *entry, void *payload)
143
115
  fdot = strchr(entry->name, '.');
144
116
  ldot = strrchr(entry->name, '.');
145
117
  data->name = git__strndup(fdot + 1, ldot - fdot - 1);
146
- GITERR_CHECK_ALLOC(data->name);
118
+ GIT_ERROR_CHECK_ALLOC(data->name);
147
119
  }
148
120
 
149
121
  return 0;
150
122
  }
151
123
 
124
+ /*
125
+ * Checks to see if the submodule shares its name with a file or directory that
126
+ * already exists on the index. If so, the submodule cannot be added.
127
+ */
128
+ static int is_path_occupied(bool *occupied, git_repository *repo, const char *path)
129
+ {
130
+ int error = 0;
131
+ git_index *index;
132
+ git_buf dir = GIT_BUF_INIT;
133
+ *occupied = false;
134
+
135
+ if ((error = git_repository_index__weakptr(&index, repo)) < 0)
136
+ goto out;
137
+
138
+ if ((error = git_index_find(NULL, index, path)) != GIT_ENOTFOUND) {
139
+ if (!error) {
140
+ git_error_set(GIT_ERROR_SUBMODULE,
141
+ "File '%s' already exists in the index", path);
142
+ *occupied = true;
143
+ }
144
+ goto out;
145
+ }
146
+
147
+ if ((error = git_buf_sets(&dir, path)) < 0)
148
+ goto out;
149
+
150
+ if ((error = git_path_to_dir(&dir)) < 0)
151
+ goto out;
152
+
153
+ if ((error = git_index_find_prefix(NULL, index, dir.ptr)) != GIT_ENOTFOUND) {
154
+ if (!error) {
155
+ git_error_set(GIT_ERROR_SUBMODULE,
156
+ "Directory '%s' already exists in the index", path);
157
+ *occupied = true;
158
+ }
159
+ goto out;
160
+ }
161
+
162
+ error = 0;
163
+
164
+ out:
165
+ git_buf_dispose(&dir);
166
+ return error;
167
+ }
168
+
152
169
  /**
153
170
  * Release the name map returned by 'load_submodule_names'.
154
171
  */
155
172
  static void free_submodule_names(git_strmap *names)
156
173
  {
157
- git_buf *name = 0;
174
+ const char *key;
175
+ char *value;
176
+
158
177
  if (names == NULL)
159
178
  return;
160
- git_strmap_foreach_value(names, name, {
161
- git__free(name);
179
+
180
+ git_strmap_foreach(names, key, value, {
181
+ git__free((char *) key);
182
+ git__free(value);
162
183
  });
163
184
  git_strmap_free(names);
185
+
164
186
  return;
165
187
  }
166
188
 
@@ -169,25 +191,30 @@ static void free_submodule_names(git_strmap *names)
169
191
  * TODO: for some use-cases, this might need case-folding on a
170
192
  * case-insensitive filesystem
171
193
  */
172
- static int load_submodule_names(git_strmap *out, git_repository *repo, git_config *cfg)
194
+ static int load_submodule_names(git_strmap **out, git_repository *repo, git_config *cfg)
173
195
  {
174
196
  const char *key = "submodule\\..*\\.path";
175
- git_config_iterator *iter;
197
+ git_config_iterator *iter = NULL;
176
198
  git_config_entry *entry;
177
199
  git_buf buf = GIT_BUF_INIT;
178
- int rval, isvalid;
179
- int error = 0;
200
+ git_strmap *names;
201
+ int isvalid, error;
202
+
203
+ *out = NULL;
204
+
205
+ if ((error = git_strmap_new(&names)) < 0)
206
+ goto out;
180
207
 
181
208
  if ((error = git_config_iterator_glob_new(&iter, cfg, key)) < 0)
182
- return error;
209
+ goto out;
183
210
 
184
211
  while ((error = git_config_next(&entry, iter)) == 0) {
185
212
  const char *fdot, *ldot;
186
213
  fdot = strchr(entry->name, '.');
187
214
  ldot = strrchr(entry->name, '.');
188
215
 
189
- if (git_strmap_exists(out, entry->value)) {
190
- giterr_set(GITERR_SUBMODULE,
216
+ if (git_strmap_exists(names, entry->value)) {
217
+ git_error_set(GIT_ERROR_SUBMODULE,
191
218
  "duplicated submodule path '%s'", entry->value);
192
219
  error = -1;
193
220
  goto out;
@@ -203,17 +230,21 @@ static int load_submodule_names(git_strmap *out, git_repository *repo, git_confi
203
230
  if (!isvalid)
204
231
  continue;
205
232
 
206
- git_strmap_insert(out, entry->value, git_buf_detach(&buf), &rval);
207
- if (rval < 0) {
208
- giterr_set(GITERR_NOMEMORY, "error inserting submodule into hash table");
209
- return -1;
233
+ if ((error = git_strmap_set(names, git__strdup(entry->value), git_buf_detach(&buf))) < 0) {
234
+ git_error_set(GIT_ERROR_NOMEMORY, "error inserting submodule into hash table");
235
+ error = -1;
236
+ goto out;
210
237
  }
211
238
  }
212
239
  if (error == GIT_ITEROVER)
213
240
  error = 0;
214
241
 
242
+ *out = names;
243
+ names = NULL;
244
+
215
245
  out:
216
- git_buf_free(&buf);
246
+ free_submodule_names(names);
247
+ git_buf_dispose(&buf);
217
248
  git_config_iterator_free(iter);
218
249
  return error;
219
250
  }
@@ -230,15 +261,14 @@ int git_submodule_lookup(
230
261
  assert(repo && name);
231
262
 
232
263
  if (repo->is_bare) {
233
- giterr_set(GITERR_SUBMODULE, "cannot get submodules without a working tree");
264
+ git_error_set(GIT_ERROR_SUBMODULE, "cannot get submodules without a working tree");
234
265
  return -1;
235
266
  }
236
267
 
237
268
  if (repo->submodule_cache != NULL) {
238
- khiter_t pos = git_strmap_lookup_index(repo->submodule_cache, name);
239
- if (git_strmap_valid_index(repo->submodule_cache, pos)) {
269
+ if ((sm = git_strmap_get(repo->submodule_cache, name)) != NULL) {
240
270
  if (out) {
241
- *out = git_strmap_value_at(repo->submodule_cache, pos);
271
+ *out = sm;
242
272
  GIT_REFCOUNT_INC(*out);
243
273
  }
244
274
  return 0;
@@ -274,13 +304,13 @@ int git_submodule_lookup(
274
304
  mods = open_gitmodules(repo, GITMODULES_EXISTING);
275
305
 
276
306
  if (mods)
277
- error = git_config_file_foreach_match(mods, pattern, find_by_path, &data);
307
+ error = git_config_backend_foreach_match(mods, pattern, find_by_path, &data);
278
308
 
279
- git_config_file_free(mods);
309
+ git_config_backend_free(mods);
280
310
 
281
311
  if (error < 0) {
282
312
  git_submodule_free(sm);
283
- git_buf_free(&path);
313
+ git_buf_dispose(&path);
284
314
  return error;
285
315
  }
286
316
 
@@ -296,7 +326,7 @@ int git_submodule_lookup(
296
326
  }
297
327
  }
298
328
 
299
- git_buf_free(&path);
329
+ git_buf_dispose(&path);
300
330
  }
301
331
 
302
332
  if ((error = git_submodule_location(&location, sm)) < 0) {
@@ -319,7 +349,7 @@ int git_submodule_lookup(
319
349
  if (git_path_exists(path.ptr))
320
350
  error = GIT_EEXISTS;
321
351
 
322
- git_buf_free(&path);
352
+ git_buf_dispose(&path);
323
353
  }
324
354
 
325
355
  submodule_set_lookup_error(error, name);
@@ -351,7 +381,7 @@ int git_submodule_name_is_valid(git_repository *repo, const char *name, int flag
351
381
  }
352
382
 
353
383
  isvalid = git_path_isvalid(repo, buf.ptr, 0, flags);
354
- git_buf_free(&buf);
384
+ git_buf_dispose(&buf);
355
385
 
356
386
  return isvalid;
357
387
  }
@@ -363,30 +393,21 @@ static void submodule_free_dup(void *sm)
363
393
 
364
394
  static int submodule_get_or_create(git_submodule **out, git_repository *repo, git_strmap *map, const char *name)
365
395
  {
366
- int error = 0;
367
- khiter_t pos;
368
396
  git_submodule *sm = NULL;
397
+ int error;
369
398
 
370
- pos = git_strmap_lookup_index(map, name);
371
- if (git_strmap_valid_index(map, pos)) {
372
- sm = git_strmap_value_at(map, pos);
399
+ if ((sm = git_strmap_get(map, name)) != NULL)
373
400
  goto done;
374
- }
375
401
 
376
402
  /* if the submodule doesn't exist yet in the map, create it */
377
403
  if ((error = submodule_alloc(&sm, repo, name)) < 0)
378
404
  return error;
379
405
 
380
- pos = git_strmap_put(map, sm->name, &error);
381
- /* nobody can beat us to adding it */
382
- assert(error != 0);
383
- if (error < 0) {
406
+ if ((error = git_strmap_set(map, sm->name, sm)) < 0) {
384
407
  git_submodule_free(sm);
385
408
  return error;
386
409
  }
387
410
 
388
- git_strmap_set_value_at(map, pos, sm);
389
-
390
411
  done:
391
412
  GIT_REFCOUNT_INC(sm);
392
413
  *out = sm;
@@ -398,36 +419,27 @@ static int submodules_from_index(git_strmap *map, git_index *idx, git_config *cf
398
419
  int error;
399
420
  git_iterator *i = NULL;
400
421
  const git_index_entry *entry;
401
- git_strmap *names = 0;
422
+ git_strmap *names;
402
423
 
403
- git_strmap_alloc(&names);
404
- if ((error = load_submodule_names(names, git_index_owner(idx), cfg)))
424
+ if ((error = load_submodule_names(&names, git_index_owner(idx), cfg)))
405
425
  goto done;
406
426
 
407
427
  if ((error = git_iterator_for_index(&i, git_index_owner(idx), idx, NULL)) < 0)
408
428
  goto done;
409
429
 
410
430
  while (!(error = git_iterator_advance(&entry, i))) {
411
- khiter_t pos = git_strmap_lookup_index(map, entry->path);
412
431
  git_submodule *sm;
413
432
 
414
- if (git_strmap_valid_index(map, pos)) {
415
- sm = git_strmap_value_at(map, pos);
416
-
433
+ if ((sm = git_strmap_get(map, entry->path)) != NULL) {
417
434
  if (S_ISGITLINK(entry->mode))
418
435
  submodule_update_from_index_entry(sm, entry);
419
436
  else
420
437
  sm->flags |= GIT_SUBMODULE_STATUS__INDEX_NOT_SUBMODULE;
421
438
  } else if (S_ISGITLINK(entry->mode)) {
422
- khiter_t name_pos;
423
439
  const char *name;
424
440
 
425
- name_pos = git_strmap_lookup_index(names, entry->path);
426
- if (git_strmap_valid_index(names, name_pos)) {
427
- name = git_strmap_value_at(names, name_pos);
428
- } else {
441
+ if ((name = git_strmap_get(names, entry->path)) == NULL)
429
442
  name = entry->path;
430
- }
431
443
 
432
444
  if (!submodule_get_or_create(&sm, git_index_owner(idx), map, name)) {
433
445
  submodule_update_from_index_entry(sm, entry);
@@ -451,35 +463,27 @@ static int submodules_from_head(git_strmap *map, git_tree *head, git_config *cfg
451
463
  int error;
452
464
  git_iterator *i = NULL;
453
465
  const git_index_entry *entry;
454
- git_strmap *names = 0;
455
- git_strmap_alloc(&names);
456
- if ((error = load_submodule_names(names, git_tree_owner(head), cfg)))
466
+ git_strmap *names;
467
+
468
+ if ((error = load_submodule_names(&names, git_tree_owner(head), cfg)))
457
469
  goto done;
458
470
 
459
471
  if ((error = git_iterator_for_tree(&i, head, NULL)) < 0)
460
472
  goto done;
461
473
 
462
474
  while (!(error = git_iterator_advance(&entry, i))) {
463
- khiter_t pos = git_strmap_lookup_index(map, entry->path);
464
475
  git_submodule *sm;
465
476
 
466
- if (git_strmap_valid_index(map, pos)) {
467
- sm = git_strmap_value_at(map, pos);
468
-
477
+ if ((sm = git_strmap_get(map, entry->path)) != NULL) {
469
478
  if (S_ISGITLINK(entry->mode))
470
479
  submodule_update_from_head_data(sm, entry->mode, &entry->id);
471
480
  else
472
481
  sm->flags |= GIT_SUBMODULE_STATUS__HEAD_NOT_SUBMODULE;
473
482
  } else if (S_ISGITLINK(entry->mode)) {
474
- khiter_t name_pos;
475
483
  const char *name;
476
484
 
477
- name_pos = git_strmap_lookup_index(names, entry->path);
478
- if (git_strmap_valid_index(names, name_pos)) {
479
- name = git_strmap_value_at(names, name_pos);
480
- } else {
485
+ if ((name = git_strmap_get(names, entry->path)) == NULL)
481
486
  name = entry->path;
482
- }
483
487
 
484
488
  if (!submodule_get_or_create(&sm, git_tree_owner(head), map, name)) {
485
489
  submodule_update_from_head_data(
@@ -515,36 +519,19 @@ int git_submodule__map(git_repository *repo, git_strmap *map)
515
519
  git_buf path = GIT_BUF_INIT;
516
520
  git_submodule *sm;
517
521
  git_config *mods = NULL;
518
- uint32_t mask;
519
522
 
520
523
  assert(repo && map);
521
524
 
522
525
  /* get sources that we will need to check */
523
526
  if (git_repository_index(&idx, repo) < 0)
524
- giterr_clear();
527
+ git_error_clear();
525
528
  if (git_repository_head_tree(&head, repo) < 0)
526
- giterr_clear();
529
+ git_error_clear();
527
530
 
528
531
  wd = git_repository_workdir(repo);
529
532
  if (wd && (error = git_buf_joinpath(&path, wd, GIT_MODULES_FILE)) < 0)
530
533
  goto cleanup;
531
534
 
532
- /* clear submodule flags that are to be refreshed */
533
- mask = 0;
534
- mask |= GIT_SUBMODULE_STATUS_IN_INDEX |
535
- GIT_SUBMODULE_STATUS__INDEX_FLAGS |
536
- GIT_SUBMODULE_STATUS__INDEX_OID_VALID |
537
- GIT_SUBMODULE_STATUS__INDEX_MULTIPLE_ENTRIES;
538
-
539
- mask |= GIT_SUBMODULE_STATUS_IN_HEAD |
540
- GIT_SUBMODULE_STATUS__HEAD_OID_VALID;
541
- mask |= GIT_SUBMODULE_STATUS_IN_CONFIG;
542
- if (mask != 0)
543
- mask |= GIT_SUBMODULE_STATUS_IN_WD |
544
- GIT_SUBMODULE_STATUS__WD_SCANNED |
545
- GIT_SUBMODULE_STATUS__WD_FLAGS |
546
- GIT_SUBMODULE_STATUS__WD_OID_VALID;
547
-
548
535
  /* add submodule information from .gitmodules */
549
536
  if (wd) {
550
537
  lfc_data data = { 0 };
@@ -573,7 +560,7 @@ int git_submodule__map(git_repository *repo, git_strmap *map)
573
560
  goto cleanup;
574
561
  }
575
562
  /* shallow scan submodules in work tree as needed */
576
- if (wd && mask != 0) {
563
+ if (wd) {
577
564
  git_strmap_foreach_value(map, sm, {
578
565
  submodule_load_from_wd_lite(sm);
579
566
  });
@@ -584,7 +571,7 @@ cleanup:
584
571
  /* TODO: if we got an error, mark submodule config as invalid? */
585
572
  git_index_free(idx);
586
573
  git_tree_free(head);
587
- git_buf_free(&path);
574
+ git_buf_dispose(&path);
588
575
  return error;
589
576
  }
590
577
 
@@ -600,18 +587,18 @@ int git_submodule_foreach(
600
587
  size_t i;
601
588
 
602
589
  if (repo->is_bare) {
603
- giterr_set(GITERR_SUBMODULE, "cannot get submodules without a working tree");
590
+ git_error_set(GIT_ERROR_SUBMODULE, "cannot get submodules without a working tree");
604
591
  return -1;
605
592
  }
606
593
 
607
- if ((error = git_strmap_alloc(&submodules)) < 0)
594
+ if ((error = git_strmap_new(&submodules)) < 0)
608
595
  return error;
609
596
 
610
597
  if ((error = git_submodule__map(repo, submodules)) < 0)
611
598
  goto done;
612
599
 
613
600
  if (!(error = git_vector_init(
614
- &snapshot, git_strmap_num_entries(submodules), submodule_cmp))) {
601
+ &snapshot, git_strmap_size(submodules), submodule_cmp))) {
615
602
 
616
603
  git_strmap_foreach_value(submodules, sm, {
617
604
  if ((error = git_vector_insert(&snapshot, sm)) < 0)
@@ -627,7 +614,7 @@ int git_submodule_foreach(
627
614
 
628
615
  git_vector_foreach(&snapshot, i, sm) {
629
616
  if ((error = callback(sm, sm->name, payload)) != 0) {
630
- giterr_set_after_callback(error);
617
+ git_error_set_after_callback(error);
631
618
  break;
632
619
  }
633
620
  }
@@ -689,8 +676,8 @@ static int submodule_repo_init(
689
676
  error = git_repository_init_ext(&subrepo, workdir.ptr, &initopt);
690
677
 
691
678
  cleanup:
692
- git_buf_free(&workdir);
693
- git_buf_free(&repodir);
679
+ git_buf_dispose(&workdir);
680
+ git_buf_dispose(&repodir);
694
681
 
695
682
  *out = subrepo;
696
683
 
@@ -709,15 +696,16 @@ int git_submodule_add_setup(
709
696
  git_submodule *sm = NULL;
710
697
  git_buf name = GIT_BUF_INIT, real_url = GIT_BUF_INIT;
711
698
  git_repository *subrepo = NULL;
699
+ bool path_occupied;
712
700
 
713
701
  assert(repo && url && path);
714
702
 
715
703
  /* see if there is already an entry for this submodule */
716
704
 
717
705
  if (git_submodule_lookup(NULL, repo, path) < 0)
718
- giterr_clear();
706
+ git_error_clear();
719
707
  else {
720
- giterr_set(GITERR_SUBMODULE,
708
+ git_error_set(GIT_ERROR_SUBMODULE,
721
709
  "attempt to add submodule '%s' that already exists", path);
722
710
  return GIT_EEXISTS;
723
711
  }
@@ -728,25 +716,33 @@ int git_submodule_add_setup(
728
716
  path += strlen(git_repository_workdir(repo));
729
717
 
730
718
  if (git_path_root(path) >= 0) {
731
- giterr_set(GITERR_SUBMODULE, "submodule path must be a relative path");
719
+ git_error_set(GIT_ERROR_SUBMODULE, "submodule path must be a relative path");
732
720
  error = -1;
733
721
  goto cleanup;
734
722
  }
735
723
 
724
+ if ((error = is_path_occupied(&path_occupied, repo, path)) < 0)
725
+ goto cleanup;
726
+
727
+ if (path_occupied) {
728
+ error = GIT_EEXISTS;
729
+ goto cleanup;
730
+ }
731
+
736
732
  /* update .gitmodules */
737
733
 
738
734
  if (!(mods = open_gitmodules(repo, GITMODULES_CREATE))) {
739
- giterr_set(GITERR_SUBMODULE,
735
+ git_error_set(GIT_ERROR_SUBMODULE,
740
736
  "adding submodules to a bare repository is not supported");
741
737
  return -1;
742
738
  }
743
739
 
744
740
  if ((error = git_buf_printf(&name, "submodule.%s.path", path)) < 0 ||
745
- (error = git_config_file_set_string(mods, name.ptr, path)) < 0)
741
+ (error = git_config_backend_set_string(mods, name.ptr, path)) < 0)
746
742
  goto cleanup;
747
743
 
748
744
  if ((error = submodule_config_key_trunc_puts(&name, "url")) < 0 ||
749
- (error = git_config_file_set_string(mods, name.ptr, url)) < 0)
745
+ (error = git_config_backend_set_string(mods, name.ptr, url)) < 0)
750
746
  goto cleanup;
751
747
 
752
748
  git_buf_clear(&name);
@@ -784,10 +780,10 @@ cleanup:
784
780
  if (out != NULL)
785
781
  *out = sm;
786
782
 
787
- git_config_file_free(mods);
783
+ git_config_backend_free(mods);
788
784
  git_repository_free(subrepo);
789
- git_buf_free(&real_url);
790
- git_buf_free(&name);
785
+ git_buf_dispose(&real_url);
786
+ git_buf_dispose(&name);
791
787
 
792
788
  return error;
793
789
  }
@@ -816,7 +812,65 @@ int git_submodule_repo_init(
816
812
 
817
813
  done:
818
814
  git_config_free(cfg);
819
- git_buf_free(&buf);
815
+ git_buf_dispose(&buf);
816
+ return error;
817
+ }
818
+
819
+ static int clone_return_origin(git_remote **out, git_repository *repo, const char *name, const char *url, void *payload)
820
+ {
821
+ GIT_UNUSED(url);
822
+ GIT_UNUSED(payload);
823
+ return git_remote_lookup(out, repo, name);
824
+ }
825
+
826
+ static int clone_return_repo(git_repository **out, const char *path, int bare, void *payload)
827
+ {
828
+ git_submodule *sm = payload;
829
+
830
+ GIT_UNUSED(path);
831
+ GIT_UNUSED(bare);
832
+ return git_submodule_open(out, sm);
833
+ }
834
+
835
+ int git_submodule_clone(git_repository **out, git_submodule *submodule, const git_submodule_update_options *given_opts)
836
+ {
837
+ int error;
838
+ git_repository *clone;
839
+ git_buf rel_path = GIT_BUF_INIT;
840
+ git_submodule_update_options sub_opts = GIT_SUBMODULE_UPDATE_OPTIONS_INIT;
841
+ git_clone_options opts = GIT_CLONE_OPTIONS_INIT;
842
+
843
+ assert(submodule);
844
+
845
+ if (given_opts)
846
+ memcpy(&sub_opts, given_opts, sizeof(sub_opts));
847
+
848
+ GIT_ERROR_CHECK_VERSION(&sub_opts, GIT_SUBMODULE_UPDATE_OPTIONS_VERSION, "git_submodule_update_options");
849
+
850
+ memcpy(&opts.checkout_opts, &sub_opts.checkout_opts, sizeof(sub_opts.checkout_opts));
851
+ memcpy(&opts.fetch_opts, &sub_opts.fetch_opts, sizeof(sub_opts.fetch_opts));
852
+ opts.repository_cb = clone_return_repo;
853
+ opts.repository_cb_payload = submodule;
854
+ opts.remote_cb = clone_return_origin;
855
+ opts.remote_cb_payload = submodule;
856
+
857
+ git_buf_puts(&rel_path, git_repository_workdir(git_submodule_owner(submodule)));
858
+ git_buf_joinpath(&rel_path, git_buf_cstr(&rel_path), git_submodule_path(submodule));
859
+
860
+ GIT_ERROR_CHECK_ALLOC_BUF(&rel_path);
861
+
862
+ error = git_clone__submodule(&clone, git_submodule_url(submodule), git_buf_cstr(&rel_path), &opts);
863
+ if (error < 0)
864
+ goto cleanup;
865
+
866
+ if (!out)
867
+ git_repository_free(clone);
868
+ else
869
+ *out = clone;
870
+
871
+ cleanup:
872
+ git_buf_dispose(&rel_path);
873
+
820
874
  return error;
821
875
  }
822
876
 
@@ -857,7 +911,7 @@ int git_submodule_add_to_index(git_submodule *sm, int write_index)
857
911
 
858
912
  /* read stat information for submodule working directory */
859
913
  if (p_stat(path.ptr, &st) < 0) {
860
- giterr_set(GITERR_SUBMODULE,
914
+ git_error_set(GIT_ERROR_SUBMODULE,
861
915
  "cannot add submodule without working directory");
862
916
  error = -1;
863
917
  goto cleanup;
@@ -866,11 +920,11 @@ int git_submodule_add_to_index(git_submodule *sm, int write_index)
866
920
  memset(&entry, 0, sizeof(entry));
867
921
  entry.path = sm->path;
868
922
  git_index_entry__init_from_stat(
869
- &entry, &st, !(git_index_caps(index) & GIT_INDEXCAP_NO_FILEMODE));
923
+ &entry, &st, !(git_index_caps(index) & GIT_INDEX_CAPABILITY_NO_FILEMODE));
870
924
 
871
925
  /* calling git_submodule_open will have set sm->wd_oid if possible */
872
926
  if ((sm->flags & GIT_SUBMODULE_STATUS__WD_OID_VALID) == 0) {
873
- giterr_set(GITERR_SUBMODULE,
927
+ git_error_set(GIT_ERROR_SUBMODULE,
874
928
  "cannot add submodule without HEAD to index");
875
929
  error = -1;
876
930
  goto cleanup;
@@ -900,7 +954,7 @@ int git_submodule_add_to_index(git_submodule *sm, int write_index)
900
954
 
901
955
  cleanup:
902
956
  git_repository_free(sm_repo);
903
- git_buf_free(&path);
957
+ git_buf_dispose(&path);
904
958
  return error;
905
959
  }
906
960
 
@@ -961,11 +1015,11 @@ int git_submodule_resolve_url(git_buf *out, git_repository *repo, const char *ur
961
1015
  } else if (strchr(url, ':') != NULL || url[0] == '/') {
962
1016
  error = git_buf_sets(out, url);
963
1017
  } else {
964
- giterr_set(GITERR_SUBMODULE, "invalid format for submodule URL");
1018
+ git_error_set(GIT_ERROR_SUBMODULE, "invalid format for submodule URL");
965
1019
  error = -1;
966
1020
  }
967
1021
 
968
- git_buf_free(&normalized);
1022
+ git_buf_dispose(&normalized);
969
1023
  return error;
970
1024
  }
971
1025
 
@@ -983,28 +1037,28 @@ static int write_var(git_repository *repo, const char *name, const char *var, co
983
1037
  goto cleanup;
984
1038
 
985
1039
  if (val)
986
- error = git_config_file_set_string(mods, key.ptr, val);
1040
+ error = git_config_backend_set_string(mods, key.ptr, val);
987
1041
  else
988
- error = git_config_file_delete(mods, key.ptr);
1042
+ error = git_config_backend_delete(mods, key.ptr);
989
1043
 
990
- git_buf_free(&key);
1044
+ git_buf_dispose(&key);
991
1045
 
992
1046
  cleanup:
993
- git_config_file_free(mods);
1047
+ git_config_backend_free(mods);
994
1048
  return error;
995
1049
  }
996
1050
 
997
- static int write_mapped_var(git_repository *repo, const char *name, git_cvar_map *maps, size_t nmaps, const char *var, int ival)
1051
+ static int write_mapped_var(git_repository *repo, const char *name, git_configmap *maps, size_t nmaps, const char *var, int ival)
998
1052
  {
999
- git_cvar_t type;
1053
+ git_configmap_t type;
1000
1054
  const char *val;
1001
1055
 
1002
1056
  if (git_config_lookup_map_enum(&type, &val, maps, nmaps, ival) < 0) {
1003
- giterr_set(GITERR_SUBMODULE, "invalid value for %s", var);
1057
+ git_error_set(GIT_ERROR_SUBMODULE, "invalid value for %s", var);
1004
1058
  return -1;
1005
1059
  }
1006
1060
 
1007
- if (type == GIT_CVAR_TRUE)
1061
+ if (type == GIT_CONFIGMAP_TRUE)
1008
1062
  val = "true";
1009
1063
 
1010
1064
  return write_var(repo, name, var, val);
@@ -1063,7 +1117,7 @@ const git_oid *git_submodule_wd_id(git_submodule *submodule)
1063
1117
  if (!git_submodule_open_bare(&subrepo, submodule))
1064
1118
  git_repository_free(subrepo);
1065
1119
  else
1066
- giterr_clear();
1120
+ git_error_clear();
1067
1121
  }
1068
1122
 
1069
1123
  if (submodule->flags & GIT_SUBMODULE_STATUS__WD_OID_VALID)
@@ -1152,8 +1206,8 @@ static int submodule_repo_create(
1152
1206
  error = git_repository_init_ext(&subrepo, repodir.ptr, &initopt);
1153
1207
 
1154
1208
  cleanup:
1155
- git_buf_free(&workdir);
1156
- git_buf_free(&repodir);
1209
+ git_buf_dispose(&workdir);
1210
+ git_buf_dispose(&repodir);
1157
1211
 
1158
1212
  *out = subrepo;
1159
1213
 
@@ -1179,13 +1233,18 @@ static int git_submodule_update_repo_init_cb(
1179
1233
  return submodule_repo_create(out, sm->repo, path);
1180
1234
  }
1181
1235
 
1182
- int git_submodule_update_init_options(git_submodule_update_options *opts, unsigned int version)
1236
+ int git_submodule_update_options_init(git_submodule_update_options *opts, unsigned int version)
1183
1237
  {
1184
1238
  GIT_INIT_STRUCTURE_FROM_TEMPLATE(
1185
1239
  opts, version, git_submodule_update_options, GIT_SUBMODULE_UPDATE_OPTIONS_INIT);
1186
1240
  return 0;
1187
1241
  }
1188
1242
 
1243
+ int git_submodule_update_init_options(git_submodule_update_options *opts, unsigned int version)
1244
+ {
1245
+ return git_submodule_update_options_init(opts, version);
1246
+ }
1247
+
1189
1248
  int git_submodule_update(git_submodule *sm, int init, git_submodule_update_options *_update_options)
1190
1249
  {
1191
1250
  int error;
@@ -1204,7 +1263,7 @@ int git_submodule_update(git_submodule *sm, int init, git_submodule_update_optio
1204
1263
  if (_update_options)
1205
1264
  memcpy(&update_options, _update_options, sizeof(git_submodule_update_options));
1206
1265
 
1207
- GITERR_CHECK_VERSION(&update_options, GIT_SUBMODULE_UPDATE_OPTIONS_VERSION, "git_submodule_update_options");
1266
+ GIT_ERROR_CHECK_VERSION(&update_options, GIT_SUBMODULE_UPDATE_OPTIONS_VERSION, "git_submodule_update_options");
1208
1267
 
1209
1268
  /* Copy over the remote callbacks */
1210
1269
  memcpy(&clone_options.fetch_opts, &update_options.fetch_opts, sizeof(git_fetch_options));
@@ -1235,7 +1294,7 @@ int git_submodule_update(git_submodule *sm, int init, git_submodule_update_optio
1235
1294
  goto done;
1236
1295
 
1237
1296
  if (!init) {
1238
- giterr_set(GITERR_SUBMODULE, "submodule is not initialized");
1297
+ git_error_set(GIT_ERROR_SUBMODULE, "submodule is not initialized");
1239
1298
  error = GIT_ERROR;
1240
1299
  goto done;
1241
1300
  }
@@ -1279,18 +1338,18 @@ int git_submodule_update(git_submodule *sm, int init, git_submodule_update_optio
1279
1338
  goto done;
1280
1339
 
1281
1340
  if ((oid = git_submodule_index_id(sm)) == NULL) {
1282
- giterr_set(GITERR_SUBMODULE, "could not get ID of submodule in index");
1341
+ git_error_set(GIT_ERROR_SUBMODULE, "could not get ID of submodule in index");
1283
1342
  error = -1;
1284
1343
  goto done;
1285
1344
  }
1286
1345
 
1287
1346
  /* Look up the target commit in the submodule. */
1288
- if ((error = git_object_lookup(&target_commit, sub_repo, oid, GIT_OBJ_COMMIT)) < 0) {
1347
+ if ((error = git_object_lookup(&target_commit, sub_repo, oid, GIT_OBJECT_COMMIT)) < 0) {
1289
1348
  /* If it isn't found then fetch and try again. */
1290
1349
  if (error != GIT_ENOTFOUND || !update_options.allow_fetch ||
1291
1350
  (error = lookup_default_remote(&remote, sub_repo)) < 0 ||
1292
1351
  (error = git_remote_fetch(remote, NULL, &update_options.fetch_opts, NULL)) < 0 ||
1293
- (error = git_object_lookup(&target_commit, sub_repo, git_submodule_index_id(sm), GIT_OBJ_COMMIT)) < 0)
1352
+ (error = git_object_lookup(&target_commit, sub_repo, git_submodule_index_id(sm), GIT_OBJECT_COMMIT)) < 0)
1294
1353
  goto done;
1295
1354
  }
1296
1355
 
@@ -1306,7 +1365,7 @@ int git_submodule_update(git_submodule *sm, int init, git_submodule_update_optio
1306
1365
  }
1307
1366
 
1308
1367
  done:
1309
- git_buf_free(&buf);
1368
+ git_buf_dispose(&buf);
1310
1369
  git_config_free(config);
1311
1370
  git_object_free(target_commit);
1312
1371
  git_remote_free(remote);
@@ -1323,7 +1382,7 @@ int git_submodule_init(git_submodule *sm, int overwrite)
1323
1382
  git_config *cfg = NULL;
1324
1383
 
1325
1384
  if (!sm->url) {
1326
- giterr_set(GITERR_SUBMODULE,
1385
+ git_error_set(GIT_ERROR_SUBMODULE,
1327
1386
  "no URL configured for submodule '%s'", sm->name);
1328
1387
  return -1;
1329
1388
  }
@@ -1353,8 +1412,8 @@ int git_submodule_init(git_submodule *sm, int overwrite)
1353
1412
 
1354
1413
  cleanup:
1355
1414
  git_config_free(cfg);
1356
- git_buf_free(&key);
1357
- git_buf_free(&effective_submodule_url);
1415
+ git_buf_dispose(&key);
1416
+ git_buf_dispose(&effective_submodule_url);
1358
1417
 
1359
1418
  return error;
1360
1419
  }
@@ -1367,7 +1426,7 @@ int git_submodule_sync(git_submodule *sm)
1367
1426
  git_repository *smrepo = NULL;
1368
1427
 
1369
1428
  if (!sm->url) {
1370
- giterr_set(GITERR_SUBMODULE,
1429
+ git_error_set(GIT_ERROR_SUBMODULE,
1371
1430
  "no URL configured for submodule '%s'", sm->name);
1372
1431
  return -1;
1373
1432
  }
@@ -1389,12 +1448,12 @@ int git_submodule_sync(git_submodule *sm)
1389
1448
  if ((error = git_repository_config__weakptr(&cfg, smrepo)) < 0)
1390
1449
  /* return error from reading submodule config */;
1391
1450
  else if ((error = lookup_head_remote_key(&remote_name, smrepo)) < 0) {
1392
- giterr_clear();
1451
+ git_error_clear();
1393
1452
  error = git_buf_sets(&key, "remote.origin.url");
1394
1453
  } else {
1395
1454
  error = git_buf_join3(
1396
1455
  &key, '.', "remote", remote_name.ptr, "url");
1397
- git_buf_free(&remote_name);
1456
+ git_buf_dispose(&remote_name);
1398
1457
  }
1399
1458
 
1400
1459
  if (!error)
@@ -1403,7 +1462,7 @@ int git_submodule_sync(git_submodule *sm)
1403
1462
  git_repository_free(smrepo);
1404
1463
  }
1405
1464
 
1406
- git_buf_free(&key);
1465
+ git_buf_dispose(&key);
1407
1466
 
1408
1467
  return error;
1409
1468
  }
@@ -1446,7 +1505,7 @@ static int git_submodule__open(
1446
1505
  if (!git_reference_name_to_id(&sm->wd_oid, *subrepo, GIT_HEAD_FILE))
1447
1506
  sm->flags |= GIT_SUBMODULE_STATUS__WD_OID_VALID;
1448
1507
  else
1449
- giterr_clear();
1508
+ git_error_clear();
1450
1509
  } else if (git_path_exists(path.ptr)) {
1451
1510
  sm->flags |= GIT_SUBMODULE_STATUS__WD_SCANNED |
1452
1511
  GIT_SUBMODULE_STATUS_IN_WD;
@@ -1457,7 +1516,7 @@ static int git_submodule__open(
1457
1516
  sm->flags |= GIT_SUBMODULE_STATUS__WD_SCANNED;
1458
1517
  }
1459
1518
 
1460
- git_buf_free(&path);
1519
+ git_buf_dispose(&path);
1461
1520
 
1462
1521
  return error;
1463
1522
  }
@@ -1536,7 +1595,7 @@ static int submodule_update_head(git_submodule *submodule)
1536
1595
  /* if we can't look up file in current head, then done */
1537
1596
  if (git_repository_head_tree(&head, submodule->repo) < 0 ||
1538
1597
  git_tree_entry_bypath(&te, head, submodule->path) < 0)
1539
- giterr_clear();
1598
+ git_error_clear();
1540
1599
  else
1541
1600
  submodule_update_from_head_data(submodule, te->attr, git_tree_entry_id(te));
1542
1601
 
@@ -1639,12 +1698,12 @@ int git_submodule__status(
1639
1698
  if (ign == GIT_SUBMODULE_IGNORE_DIRTY) {
1640
1699
  /* git_submodule_open_bare will load WD OID data */
1641
1700
  if (git_submodule_open_bare(&smrepo, sm) < 0)
1642
- giterr_clear();
1701
+ git_error_clear();
1643
1702
  else
1644
1703
  git_repository_free(smrepo);
1645
1704
  smrepo = NULL;
1646
1705
  } else if (git_submodule_open(&smrepo, sm) < 0) {
1647
- giterr_clear();
1706
+ git_error_clear();
1648
1707
  smrepo = NULL;
1649
1708
  }
1650
1709
 
@@ -1702,12 +1761,12 @@ static int submodule_alloc(
1702
1761
  git_submodule *sm;
1703
1762
 
1704
1763
  if (!name || !(namelen = strlen(name))) {
1705
- giterr_set(GITERR_SUBMODULE, "invalid submodule name");
1764
+ git_error_set(GIT_ERROR_SUBMODULE, "invalid submodule name");
1706
1765
  return -1;
1707
1766
  }
1708
1767
 
1709
1768
  sm = git__calloc(1, sizeof(git_submodule));
1710
- GITERR_CHECK_ALLOC(sm);
1769
+ GIT_ERROR_CHECK_ALLOC(sm);
1711
1770
 
1712
1771
  sm->name = sm->path = git__strdup(name);
1713
1772
  if (!sm->name) {
@@ -1753,7 +1812,7 @@ void git_submodule_free(git_submodule *sm)
1753
1812
 
1754
1813
  static int submodule_config_error(const char *property, const char *value)
1755
1814
  {
1756
- giterr_set(GITERR_INVALID,
1815
+ git_error_set(GIT_ERROR_INVALID,
1757
1816
  "invalid value for submodule '%s' property: '%s'", property, value);
1758
1817
  return -1;
1759
1818
  }
@@ -1844,7 +1903,7 @@ static int submodule_read_config(git_submodule *sm, git_config *cfg)
1844
1903
  if (sm->path != sm->name)
1845
1904
  git__free(sm->path);
1846
1905
  sm->path = git__strdup(value);
1847
- GITERR_CHECK_ALLOC(sm->path);
1906
+ GIT_ERROR_CHECK_ALLOC(sm->path);
1848
1907
  }
1849
1908
 
1850
1909
  }
@@ -1857,7 +1916,7 @@ static int submodule_read_config(git_submodule *sm, git_config *cfg)
1857
1916
  if (!looks_like_command_line_option(value)) {
1858
1917
  in_config = 1;
1859
1918
  sm->url = git__strdup(value);
1860
- GITERR_CHECK_ALLOC(sm->url);
1919
+ GIT_ERROR_CHECK_ALLOC(sm->url);
1861
1920
  }
1862
1921
  } else if (error != GIT_ENOTFOUND) {
1863
1922
  goto cleanup;
@@ -1866,7 +1925,7 @@ static int submodule_read_config(git_submodule *sm, git_config *cfg)
1866
1925
  if ((error = get_value(&value, cfg, &key, sm->name, "branch")) == 0) {
1867
1926
  in_config = 1;
1868
1927
  sm->branch = git__strdup(value);
1869
- GITERR_CHECK_ALLOC(sm->branch);
1928
+ GIT_ERROR_CHECK_ALLOC(sm->branch);
1870
1929
  } else if (error != GIT_ENOTFOUND) {
1871
1930
  goto cleanup;
1872
1931
  }
@@ -1904,7 +1963,7 @@ static int submodule_read_config(git_submodule *sm, git_config *cfg)
1904
1963
  error = 0;
1905
1964
 
1906
1965
  cleanup:
1907
- git_buf_free(&key);
1966
+ git_buf_dispose(&key);
1908
1967
  return error;
1909
1968
  }
1910
1969
 
@@ -1912,7 +1971,6 @@ static int submodule_load_each(const git_config_entry *entry, void *payload)
1912
1971
  {
1913
1972
  lfc_data *data = payload;
1914
1973
  const char *namestart, *property;
1915
- git_strmap_iter pos;
1916
1974
  git_strmap *map = data->map;
1917
1975
  git_buf name = GIT_BUF_INIT;
1918
1976
  git_submodule *sm;
@@ -1944,8 +2002,7 @@ static int submodule_load_each(const git_config_entry *entry, void *payload)
1944
2002
  * a new submodule, load the config and insert it. If it's
1945
2003
  * already inserted, we've already loaded it, so we skip.
1946
2004
  */
1947
- pos = git_strmap_lookup_index(map, name.ptr);
1948
- if (git_strmap_valid_index(map, pos)) {
2005
+ if (git_strmap_exists(map, name.ptr)) {
1949
2006
  error = 0;
1950
2007
  goto done;
1951
2008
  }
@@ -1958,15 +2015,13 @@ static int submodule_load_each(const git_config_entry *entry, void *payload)
1958
2015
  goto done;
1959
2016
  }
1960
2017
 
1961
- git_strmap_insert(map, sm->name, sm, &error);
1962
- assert(error != 0);
1963
- if (error < 0)
2018
+ if ((error = git_strmap_set(map, sm->name, sm)) < 0)
1964
2019
  goto done;
1965
2020
 
1966
2021
  error = 0;
1967
2022
 
1968
2023
  done:
1969
- git_buf_free(&name);
2024
+ git_buf_dispose(&name);
1970
2025
  return error;
1971
2026
  }
1972
2027
 
@@ -1983,7 +2038,7 @@ static int submodule_load_from_wd_lite(git_submodule *sm)
1983
2038
  if (git_path_contains(&path, DOT_GIT))
1984
2039
  sm->flags |= GIT_SUBMODULE_STATUS_IN_WD;
1985
2040
 
1986
- git_buf_free(&path);
2041
+ git_buf_dispose(&path);
1987
2042
  return 0;
1988
2043
  }
1989
2044
 
@@ -2007,6 +2062,7 @@ static int gitmodules_snapshot(git_config **snap, git_repository *repo)
2007
2062
 
2008
2063
  if ((error = git_config_open_ondisk(&mods, path.ptr)) < 0)
2009
2064
  goto cleanup;
2065
+ git_buf_dispose(&path);
2010
2066
 
2011
2067
  if ((error = git_config_snapshot(snap, mods)) < 0)
2012
2068
  goto cleanup;
@@ -2016,7 +2072,7 @@ static int gitmodules_snapshot(git_config **snap, git_repository *repo)
2016
2072
  cleanup:
2017
2073
  if (mods)
2018
2074
  git_config_free(mods);
2019
- git_buf_free(&path);
2075
+ git_buf_dispose(&path);
2020
2076
 
2021
2077
  return error;
2022
2078
  }
@@ -2034,18 +2090,18 @@ static git_config_backend *open_gitmodules(
2034
2090
  return NULL;
2035
2091
 
2036
2092
  if (okay_to_create || git_path_isfile(path.ptr)) {
2037
- /* git_config_file__ondisk should only fail if OOM */
2038
- if (git_config_file__ondisk(&mods, path.ptr) < 0)
2093
+ /* git_config_backend_from_file should only fail if OOM */
2094
+ if (git_config_backend_from_file(&mods, path.ptr) < 0)
2039
2095
  mods = NULL;
2040
2096
  /* open should only fail here if the file is malformed */
2041
- else if (git_config_file_open(mods, GIT_CONFIG_LEVEL_LOCAL, repo) < 0) {
2042
- git_config_file_free(mods);
2097
+ else if (git_config_backend_open(mods, GIT_CONFIG_LEVEL_LOCAL, repo) < 0) {
2098
+ git_config_backend_free(mods);
2043
2099
  mods = NULL;
2044
2100
  }
2045
2101
  }
2046
2102
  }
2047
2103
 
2048
- git_buf_free(&path);
2104
+ git_buf_dispose(&path);
2049
2105
 
2050
2106
  return mods;
2051
2107
  }
@@ -2067,7 +2123,7 @@ static int lookup_head_remote_key(git_buf *remote_name, git_repository *repo)
2067
2123
  * a remote key for the local tracking branch HEAD points to.
2068
2124
  **/
2069
2125
  if (!git_reference_is_branch(head)) {
2070
- giterr_set(GITERR_INVALID,
2126
+ git_error_set(GIT_ERROR_INVALID,
2071
2127
  "HEAD does not refer to a branch.");
2072
2128
  error = GIT_ENOTFOUND;
2073
2129
  goto done;
@@ -2085,7 +2141,7 @@ static int lookup_head_remote_key(git_buf *remote_name, git_repository *repo)
2085
2141
  goto done;
2086
2142
 
2087
2143
  done:
2088
- git_buf_free(&upstream_name);
2144
+ git_buf_dispose(&upstream_name);
2089
2145
  git_reference_free(head);
2090
2146
 
2091
2147
  return error;
@@ -2101,7 +2157,7 @@ static int lookup_head_remote(git_remote **remote, git_repository *repo)
2101
2157
  if (!(error = lookup_head_remote_key(&remote_name, repo)))
2102
2158
  error = git_remote_lookup(remote, repo, remote_name.ptr);
2103
2159
 
2104
- git_buf_free(&remote_name);
2160
+ git_buf_dispose(&remote_name);
2105
2161
 
2106
2162
  return error;
2107
2163
  }
@@ -2116,8 +2172,8 @@ static int lookup_default_remote(git_remote **remote, git_repository *repo)
2116
2172
  error = git_remote_lookup(remote, repo, "origin");
2117
2173
 
2118
2174
  if (error == GIT_ENOTFOUND)
2119
- giterr_set(
2120
- GITERR_SUBMODULE,
2175
+ git_error_set(
2176
+ GIT_ERROR_SUBMODULE,
2121
2177
  "cannot get default remote for submodule - no local tracking "
2122
2178
  "branch for HEAD and origin does not exist");
2123
2179
 
@@ -2136,7 +2192,7 @@ static int get_url_base(git_buf *url, git_repository *repo)
2136
2192
  } else if (error != GIT_ENOTFOUND)
2137
2193
  goto out;
2138
2194
  else
2139
- giterr_clear();
2195
+ git_error_clear();
2140
2196
 
2141
2197
  /* if repository does not have a default remote, use workdir instead */
2142
2198
  if (git_repository_is_worktree(repo)) {
@@ -2217,11 +2273,11 @@ static void submodule_get_wd_status(
2217
2273
 
2218
2274
  /* if we don't have an unborn head, check diff with index */
2219
2275
  if (git_repository_head_tree(&sm_head, sm_repo) < 0)
2220
- giterr_clear();
2276
+ git_error_clear();
2221
2277
  else {
2222
2278
  /* perform head to index diff on submodule */
2223
2279
  if (git_diff_tree_to_index(&diff, sm_repo, sm_head, index, &opt) < 0)
2224
- giterr_clear();
2280
+ git_error_clear();
2225
2281
  else {
2226
2282
  if (git_diff_num_deltas(diff) > 0)
2227
2283
  *status |= GIT_SUBMODULE_STATUS_WD_INDEX_MODIFIED;
@@ -2234,7 +2290,7 @@ static void submodule_get_wd_status(
2234
2290
 
2235
2291
  /* perform index-to-workdir diff on submodule */
2236
2292
  if (git_diff_index_to_workdir(&diff, sm_repo, index, &opt) < 0)
2237
- giterr_clear();
2293
+ git_error_clear();
2238
2294
  else {
2239
2295
  size_t untracked =
2240
2296
  git_diff_num_deltas_of_type(diff, GIT_DELTA_UNTRACKED);