rugged 0.28.4.1 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (391) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/ext/rugged/extconf.rb +3 -1
  4. data/ext/rugged/rugged.c +35 -31
  5. data/ext/rugged/rugged.h +13 -0
  6. data/ext/rugged/rugged_blob.c +11 -9
  7. data/ext/rugged/rugged_commit.c +17 -15
  8. data/ext/rugged/rugged_config.c +1 -1
  9. data/ext/rugged/rugged_diff.c +4 -26
  10. data/ext/rugged/rugged_index.c +4 -2
  11. data/ext/rugged/rugged_note.c +5 -3
  12. data/ext/rugged/rugged_object.c +57 -10
  13. data/ext/rugged/rugged_rebase.c +3 -1
  14. data/ext/rugged/rugged_remote.c +32 -8
  15. data/ext/rugged/rugged_repo.c +232 -17
  16. data/ext/rugged/rugged_tag.c +8 -6
  17. data/ext/rugged/rugged_tree.c +18 -16
  18. data/lib/rugged/commit.rb +1 -2
  19. data/lib/rugged/repository.rb +5 -6
  20. data/lib/rugged/submodule_collection.rb +4 -4
  21. data/lib/rugged/version.rb +1 -1
  22. data/vendor/libgit2/AUTHORS +1 -0
  23. data/vendor/libgit2/CMakeLists.txt +39 -19
  24. data/vendor/libgit2/COPYING +28 -0
  25. data/vendor/libgit2/cmake/Modules/EnableWarnings.cmake +5 -1
  26. data/vendor/libgit2/cmake/Modules/FindCoreFoundation.cmake +2 -2
  27. data/vendor/libgit2/cmake/Modules/FindGSSAPI.cmake +1 -1
  28. data/vendor/libgit2/cmake/Modules/FindGSSFramework.cmake +28 -0
  29. data/vendor/libgit2/cmake/Modules/FindPCRE.cmake +38 -0
  30. data/vendor/libgit2/cmake/Modules/FindPCRE2.cmake +37 -0
  31. data/vendor/libgit2/cmake/Modules/FindSecurity.cmake +2 -2
  32. data/vendor/libgit2/cmake/Modules/FindStatNsec.cmake +6 -0
  33. data/vendor/libgit2/cmake/Modules/PkgBuildConfig.cmake +77 -0
  34. data/vendor/libgit2/cmake/Modules/SanitizeBool.cmake +20 -0
  35. data/vendor/libgit2/cmake/Modules/SelectGSSAPI.cmake +56 -0
  36. data/vendor/libgit2/cmake/Modules/SelectHTTPSBackend.cmake +127 -0
  37. data/vendor/libgit2/cmake/Modules/SelectHashes.cmake +69 -0
  38. data/vendor/libgit2/deps/http-parser/http_parser.c +11 -6
  39. data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +23 -0
  40. data/vendor/libgit2/deps/ntlmclient/compat.h +55 -0
  41. data/vendor/libgit2/deps/ntlmclient/crypt.h +64 -0
  42. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +120 -0
  43. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +18 -0
  44. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +145 -0
  45. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +18 -0
  46. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +130 -0
  47. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +21 -0
  48. data/vendor/libgit2/deps/ntlmclient/ntlm.c +1422 -0
  49. data/vendor/libgit2/deps/ntlmclient/ntlm.h +174 -0
  50. data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +320 -0
  51. data/vendor/libgit2/deps/ntlmclient/unicode.h +36 -0
  52. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +445 -0
  53. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +201 -0
  54. data/vendor/libgit2/deps/ntlmclient/utf8.h +1257 -0
  55. data/vendor/libgit2/deps/ntlmclient/util.c +21 -0
  56. data/vendor/libgit2/deps/ntlmclient/util.h +14 -0
  57. data/vendor/libgit2/deps/pcre/CMakeLists.txt +140 -0
  58. data/vendor/libgit2/deps/pcre/COPYING +5 -0
  59. data/vendor/libgit2/deps/pcre/cmake/COPYING-CMAKE-SCRIPTS +22 -0
  60. data/vendor/libgit2/deps/pcre/cmake/FindEditline.cmake +17 -0
  61. data/vendor/libgit2/deps/pcre/cmake/FindPackageHandleStandardArgs.cmake +58 -0
  62. data/vendor/libgit2/deps/pcre/cmake/FindReadline.cmake +29 -0
  63. data/vendor/libgit2/deps/pcre/config.h.in +57 -0
  64. data/vendor/libgit2/deps/pcre/pcre.h +641 -0
  65. data/vendor/libgit2/deps/pcre/pcre_byte_order.c +319 -0
  66. data/vendor/libgit2/deps/pcre/pcre_chartables.c +198 -0
  67. data/vendor/libgit2/deps/pcre/pcre_compile.c +9800 -0
  68. data/vendor/libgit2/deps/pcre/pcre_config.c +190 -0
  69. data/vendor/libgit2/deps/pcre/pcre_dfa_exec.c +3676 -0
  70. data/vendor/libgit2/deps/pcre/pcre_exec.c +7173 -0
  71. data/vendor/libgit2/deps/pcre/pcre_fullinfo.c +245 -0
  72. data/vendor/libgit2/deps/pcre/pcre_get.c +669 -0
  73. data/vendor/libgit2/deps/pcre/pcre_globals.c +86 -0
  74. data/vendor/libgit2/deps/pcre/pcre_internal.h +2787 -0
  75. data/vendor/libgit2/deps/pcre/pcre_jit_compile.c +11913 -0
  76. data/vendor/libgit2/deps/pcre/pcre_maketables.c +156 -0
  77. data/vendor/libgit2/deps/pcre/pcre_newline.c +210 -0
  78. data/vendor/libgit2/deps/pcre/pcre_ord2utf8.c +94 -0
  79. data/vendor/libgit2/deps/pcre/pcre_printint.c +834 -0
  80. data/vendor/libgit2/deps/pcre/pcre_refcount.c +92 -0
  81. data/vendor/libgit2/deps/pcre/pcre_string_utils.c +211 -0
  82. data/vendor/libgit2/deps/pcre/pcre_study.c +1686 -0
  83. data/vendor/libgit2/deps/pcre/pcre_tables.c +727 -0
  84. data/vendor/libgit2/deps/pcre/pcre_ucd.c +3644 -0
  85. data/vendor/libgit2/deps/pcre/pcre_valid_utf8.c +301 -0
  86. data/vendor/libgit2/deps/pcre/pcre_version.c +98 -0
  87. data/vendor/libgit2/deps/pcre/pcre_xclass.c +268 -0
  88. data/vendor/libgit2/deps/pcre/pcreposix.c +421 -0
  89. data/vendor/libgit2/deps/pcre/pcreposix.h +117 -0
  90. data/vendor/libgit2/deps/pcre/ucp.h +224 -0
  91. data/vendor/libgit2/deps/zlib/adler32.c +0 -7
  92. data/vendor/libgit2/deps/zlib/crc32.c +0 -7
  93. data/vendor/libgit2/include/git2.h +2 -0
  94. data/vendor/libgit2/include/git2/apply.h +22 -2
  95. data/vendor/libgit2/include/git2/attr.h +23 -13
  96. data/vendor/libgit2/include/git2/blame.h +2 -2
  97. data/vendor/libgit2/include/git2/blob.h +44 -12
  98. data/vendor/libgit2/include/git2/branch.h +74 -57
  99. data/vendor/libgit2/include/git2/buffer.h +20 -14
  100. data/vendor/libgit2/include/git2/cert.h +135 -0
  101. data/vendor/libgit2/include/git2/checkout.h +46 -14
  102. data/vendor/libgit2/include/git2/cherrypick.h +3 -3
  103. data/vendor/libgit2/include/git2/clone.h +2 -2
  104. data/vendor/libgit2/include/git2/commit.h +23 -1
  105. data/vendor/libgit2/include/git2/common.h +15 -6
  106. data/vendor/libgit2/include/git2/config.h +12 -12
  107. data/vendor/libgit2/include/git2/cred_helpers.h +4 -42
  108. data/vendor/libgit2/include/git2/credential.h +314 -0
  109. data/vendor/libgit2/include/git2/credential_helpers.h +52 -0
  110. data/vendor/libgit2/include/git2/deprecated.h +321 -3
  111. data/vendor/libgit2/include/git2/describe.h +4 -4
  112. data/vendor/libgit2/include/git2/diff.h +16 -14
  113. data/vendor/libgit2/include/git2/errors.h +4 -2
  114. data/vendor/libgit2/include/git2/filter.h +8 -0
  115. data/vendor/libgit2/include/git2/index.h +2 -1
  116. data/vendor/libgit2/include/git2/indexer.h +48 -4
  117. data/vendor/libgit2/include/git2/merge.h +6 -10
  118. data/vendor/libgit2/include/git2/net.h +0 -5
  119. data/vendor/libgit2/include/git2/object.h +2 -14
  120. data/vendor/libgit2/include/git2/odb.h +3 -2
  121. data/vendor/libgit2/include/git2/odb_backend.h +5 -4
  122. data/vendor/libgit2/include/git2/oid.h +11 -6
  123. data/vendor/libgit2/include/git2/pack.h +12 -1
  124. data/vendor/libgit2/include/git2/proxy.h +6 -4
  125. data/vendor/libgit2/include/git2/rebase.h +46 -2
  126. data/vendor/libgit2/include/git2/refs.h +19 -0
  127. data/vendor/libgit2/include/git2/remote.h +40 -15
  128. data/vendor/libgit2/include/git2/repository.h +29 -6
  129. data/vendor/libgit2/include/git2/revert.h +1 -1
  130. data/vendor/libgit2/include/git2/revwalk.h +7 -3
  131. data/vendor/libgit2/include/git2/stash.h +4 -4
  132. data/vendor/libgit2/include/git2/status.h +25 -16
  133. data/vendor/libgit2/include/git2/submodule.h +20 -3
  134. data/vendor/libgit2/include/git2/sys/alloc.h +9 -9
  135. data/vendor/libgit2/include/git2/sys/cred.h +15 -0
  136. data/vendor/libgit2/include/git2/sys/credential.h +90 -0
  137. data/vendor/libgit2/include/git2/sys/index.h +4 -2
  138. data/vendor/libgit2/include/git2/sys/mempack.h +2 -1
  139. data/vendor/libgit2/include/git2/sys/merge.h +1 -1
  140. data/vendor/libgit2/include/git2/sys/odb_backend.h +48 -4
  141. data/vendor/libgit2/include/git2/sys/refdb_backend.h +164 -21
  142. data/vendor/libgit2/include/git2/sys/repository.h +17 -6
  143. data/vendor/libgit2/include/git2/sys/transport.h +4 -4
  144. data/vendor/libgit2/include/git2/tag.h +11 -2
  145. data/vendor/libgit2/include/git2/trace.h +2 -2
  146. data/vendor/libgit2/include/git2/transport.h +11 -340
  147. data/vendor/libgit2/include/git2/tree.h +5 -3
  148. data/vendor/libgit2/include/git2/types.h +4 -89
  149. data/vendor/libgit2/include/git2/version.h +5 -5
  150. data/vendor/libgit2/include/git2/worktree.h +5 -5
  151. data/vendor/libgit2/src/CMakeLists.txt +99 -236
  152. data/vendor/libgit2/src/alloc.c +2 -14
  153. data/vendor/libgit2/src/{stdalloc.c → allocators/stdalloc.c} +3 -4
  154. data/vendor/libgit2/src/{stdalloc.h → allocators/stdalloc.h} +4 -4
  155. data/vendor/libgit2/src/allocators/win32_crtdbg.c +118 -0
  156. data/vendor/libgit2/src/{transports/cred.h → allocators/win32_crtdbg.h} +5 -4
  157. data/vendor/libgit2/src/apply.c +60 -30
  158. data/vendor/libgit2/src/attr.c +70 -64
  159. data/vendor/libgit2/src/attr_file.c +189 -96
  160. data/vendor/libgit2/src/attr_file.h +9 -9
  161. data/vendor/libgit2/src/attrcache.c +48 -48
  162. data/vendor/libgit2/src/attrcache.h +2 -1
  163. data/vendor/libgit2/src/blame.c +17 -5
  164. data/vendor/libgit2/src/blame.h +1 -1
  165. data/vendor/libgit2/src/blame_git.c +21 -7
  166. data/vendor/libgit2/src/blob.c +81 -17
  167. data/vendor/libgit2/src/blob.h +2 -2
  168. data/vendor/libgit2/src/branch.c +60 -32
  169. data/vendor/libgit2/src/buffer.c +19 -7
  170. data/vendor/libgit2/src/buffer.h +1 -0
  171. data/vendor/libgit2/src/cache.c +33 -36
  172. data/vendor/libgit2/src/cache.h +1 -1
  173. data/vendor/libgit2/src/cc-compat.h +5 -0
  174. data/vendor/libgit2/src/checkout.c +26 -16
  175. data/vendor/libgit2/src/cherrypick.c +9 -3
  176. data/vendor/libgit2/src/clone.c +29 -7
  177. data/vendor/libgit2/src/clone.h +4 -0
  178. data/vendor/libgit2/src/commit.c +70 -22
  179. data/vendor/libgit2/src/commit.h +6 -0
  180. data/vendor/libgit2/src/commit_list.c +28 -76
  181. data/vendor/libgit2/src/commit_list.h +2 -2
  182. data/vendor/libgit2/src/common.h +3 -75
  183. data/vendor/libgit2/src/config.c +31 -40
  184. data/vendor/libgit2/src/config.h +7 -6
  185. data/vendor/libgit2/src/config_backend.h +12 -0
  186. data/vendor/libgit2/src/config_cache.c +39 -39
  187. data/vendor/libgit2/src/config_entries.c +69 -99
  188. data/vendor/libgit2/src/config_entries.h +1 -0
  189. data/vendor/libgit2/src/config_file.c +346 -380
  190. data/vendor/libgit2/src/config_mem.c +12 -16
  191. data/vendor/libgit2/src/config_parse.c +49 -29
  192. data/vendor/libgit2/src/config_parse.h +13 -12
  193. data/vendor/libgit2/src/config_snapshot.c +206 -0
  194. data/vendor/libgit2/src/crlf.c +14 -14
  195. data/vendor/libgit2/src/describe.c +21 -20
  196. data/vendor/libgit2/src/diff.c +43 -58
  197. data/vendor/libgit2/src/diff.h +4 -3
  198. data/vendor/libgit2/src/diff_driver.c +37 -38
  199. data/vendor/libgit2/src/diff_file.c +12 -10
  200. data/vendor/libgit2/src/diff_file.h +2 -2
  201. data/vendor/libgit2/src/diff_generate.c +148 -98
  202. data/vendor/libgit2/src/diff_generate.h +2 -2
  203. data/vendor/libgit2/src/diff_parse.c +1 -1
  204. data/vendor/libgit2/src/diff_print.c +25 -13
  205. data/vendor/libgit2/src/diff_stats.c +1 -1
  206. data/vendor/libgit2/src/diff_tform.c +11 -11
  207. data/vendor/libgit2/src/errors.c +21 -25
  208. data/vendor/libgit2/src/errors.h +81 -0
  209. data/vendor/libgit2/src/features.h.in +9 -2
  210. data/vendor/libgit2/src/fetch.c +7 -2
  211. data/vendor/libgit2/src/fetchhead.c +36 -4
  212. data/vendor/libgit2/src/filebuf.c +6 -10
  213. data/vendor/libgit2/src/filebuf.h +2 -2
  214. data/vendor/libgit2/src/filter.c +16 -8
  215. data/vendor/libgit2/src/{fileops.c → futils.c} +21 -17
  216. data/vendor/libgit2/src/{fileops.h → futils.h} +5 -5
  217. data/vendor/libgit2/src/global.c +12 -40
  218. data/vendor/libgit2/src/global.h +0 -2
  219. data/vendor/libgit2/src/hash.c +61 -0
  220. data/vendor/libgit2/src/hash.h +19 -21
  221. data/vendor/libgit2/src/hash/sha1.h +38 -0
  222. data/vendor/libgit2/src/hash/{hash_collisiondetect.h → sha1/collisiondetect.c} +14 -17
  223. data/vendor/libgit2/src/{sha1_lookup.h → hash/sha1/collisiondetect.h} +8 -8
  224. data/vendor/libgit2/src/hash/{hash_common_crypto.h → sha1/common_crypto.c} +15 -19
  225. data/vendor/libgit2/src/hash/sha1/common_crypto.h +19 -0
  226. data/vendor/libgit2/src/hash/{hash_generic.c → sha1/generic.c} +22 -10
  227. data/vendor/libgit2/src/hash/{hash_generic.h → sha1/generic.h} +4 -14
  228. data/vendor/libgit2/src/hash/{hash_mbedtls.c → sha1/mbedtls.c} +15 -7
  229. data/vendor/libgit2/src/hash/{hash_mbedtls.h → sha1/mbedtls.h} +6 -11
  230. data/vendor/libgit2/src/hash/{hash_openssl.h → sha1/openssl.c} +14 -18
  231. data/vendor/libgit2/src/hash/sha1/openssl.h +19 -0
  232. data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/sha1.c +14 -3
  233. data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/sha1.h +0 -0
  234. data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/ubc_check.c +0 -0
  235. data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/ubc_check.h +0 -0
  236. data/vendor/libgit2/src/hash/{hash_win32.c → sha1/win32.c} +34 -24
  237. data/vendor/libgit2/src/hash/{hash_win32.h → sha1/win32.h} +6 -19
  238. data/vendor/libgit2/src/hashsig.c +1 -1
  239. data/vendor/libgit2/src/idxmap.c +91 -65
  240. data/vendor/libgit2/src/idxmap.h +151 -15
  241. data/vendor/libgit2/src/ignore.c +32 -38
  242. data/vendor/libgit2/src/index.c +105 -83
  243. data/vendor/libgit2/src/index.h +1 -1
  244. data/vendor/libgit2/src/indexer.c +71 -72
  245. data/vendor/libgit2/src/integer.h +39 -4
  246. data/vendor/libgit2/src/iterator.c +40 -35
  247. data/vendor/libgit2/src/iterator.h +8 -8
  248. data/vendor/libgit2/src/map.h +1 -1
  249. data/vendor/libgit2/src/merge.c +78 -51
  250. data/vendor/libgit2/src/merge.h +2 -2
  251. data/vendor/libgit2/src/merge_driver.c +5 -5
  252. data/vendor/libgit2/src/merge_file.c +1 -1
  253. data/vendor/libgit2/src/mwindow.c +18 -23
  254. data/vendor/libgit2/src/mwindow.h +4 -4
  255. data/vendor/libgit2/src/net.c +411 -0
  256. data/vendor/libgit2/src/net.h +57 -0
  257. data/vendor/libgit2/src/netops.c +6 -193
  258. data/vendor/libgit2/src/netops.h +1 -34
  259. data/vendor/libgit2/src/notes.c +8 -5
  260. data/vendor/libgit2/src/object.c +3 -3
  261. data/vendor/libgit2/src/object.h +2 -0
  262. data/vendor/libgit2/src/odb.c +41 -23
  263. data/vendor/libgit2/src/odb.h +3 -2
  264. data/vendor/libgit2/src/odb_loose.c +17 -10
  265. data/vendor/libgit2/src/odb_mempack.c +13 -24
  266. data/vendor/libgit2/src/odb_pack.c +4 -5
  267. data/vendor/libgit2/src/offmap.c +43 -55
  268. data/vendor/libgit2/src/offmap.h +102 -24
  269. data/vendor/libgit2/src/oid.c +19 -8
  270. data/vendor/libgit2/src/oidmap.c +39 -57
  271. data/vendor/libgit2/src/oidmap.h +99 -19
  272. data/vendor/libgit2/src/pack-objects.c +28 -33
  273. data/vendor/libgit2/src/pack-objects.h +1 -1
  274. data/vendor/libgit2/src/pack.c +117 -129
  275. data/vendor/libgit2/src/pack.h +15 -18
  276. data/vendor/libgit2/src/parse.c +10 -0
  277. data/vendor/libgit2/src/parse.h +3 -3
  278. data/vendor/libgit2/src/patch.c +1 -1
  279. data/vendor/libgit2/src/patch_generate.c +2 -2
  280. data/vendor/libgit2/src/patch_parse.c +130 -33
  281. data/vendor/libgit2/src/path.c +43 -6
  282. data/vendor/libgit2/src/path.h +2 -0
  283. data/vendor/libgit2/src/pathspec.c +14 -14
  284. data/vendor/libgit2/src/pool.c +26 -22
  285. data/vendor/libgit2/src/pool.h +7 -7
  286. data/vendor/libgit2/src/posix.c +7 -7
  287. data/vendor/libgit2/src/posix.h +12 -1
  288. data/vendor/libgit2/src/proxy.c +7 -2
  289. data/vendor/libgit2/src/push.c +13 -7
  290. data/vendor/libgit2/src/reader.c +2 -2
  291. data/vendor/libgit2/src/rebase.c +87 -28
  292. data/vendor/libgit2/src/refdb.c +12 -0
  293. data/vendor/libgit2/src/refdb_fs.c +219 -167
  294. data/vendor/libgit2/src/reflog.c +11 -13
  295. data/vendor/libgit2/src/refs.c +39 -23
  296. data/vendor/libgit2/src/refs.h +8 -1
  297. data/vendor/libgit2/src/refspec.c +9 -16
  298. data/vendor/libgit2/src/regexp.c +221 -0
  299. data/vendor/libgit2/src/regexp.h +97 -0
  300. data/vendor/libgit2/src/remote.c +57 -55
  301. data/vendor/libgit2/src/remote.h +2 -2
  302. data/vendor/libgit2/src/repository.c +187 -154
  303. data/vendor/libgit2/src/repository.h +49 -40
  304. data/vendor/libgit2/src/revert.c +8 -3
  305. data/vendor/libgit2/src/revparse.c +18 -19
  306. data/vendor/libgit2/src/revwalk.c +72 -34
  307. data/vendor/libgit2/src/revwalk.h +20 -0
  308. data/vendor/libgit2/src/settings.c +13 -1
  309. data/vendor/libgit2/src/sortedcache.c +12 -26
  310. data/vendor/libgit2/src/sortedcache.h +1 -1
  311. data/vendor/libgit2/src/stash.c +47 -67
  312. data/vendor/libgit2/src/status.c +17 -11
  313. data/vendor/libgit2/src/streams/openssl.c +54 -2
  314. data/vendor/libgit2/src/streams/socket.c +2 -2
  315. data/vendor/libgit2/src/strmap.c +37 -84
  316. data/vendor/libgit2/src/strmap.h +105 -33
  317. data/vendor/libgit2/src/submodule.c +151 -126
  318. data/vendor/libgit2/src/submodule.h +1 -1
  319. data/vendor/libgit2/src/sysdir.c +11 -1
  320. data/vendor/libgit2/src/tag.c +10 -2
  321. data/vendor/libgit2/src/trace.c +1 -1
  322. data/vendor/libgit2/src/trace.h +3 -3
  323. data/vendor/libgit2/src/trailer.c +46 -32
  324. data/vendor/libgit2/src/transaction.c +10 -9
  325. data/vendor/libgit2/src/transports/auth.c +16 -15
  326. data/vendor/libgit2/src/transports/auth.h +18 -11
  327. data/vendor/libgit2/src/transports/auth_negotiate.c +64 -33
  328. data/vendor/libgit2/src/transports/auth_negotiate.h +2 -2
  329. data/vendor/libgit2/src/transports/auth_ntlm.c +223 -0
  330. data/vendor/libgit2/src/transports/auth_ntlm.h +38 -0
  331. data/vendor/libgit2/src/transports/credential.c +476 -0
  332. data/vendor/libgit2/src/transports/{cred_helpers.c → credential_helpers.c} +21 -8
  333. data/vendor/libgit2/src/transports/git.c +11 -16
  334. data/vendor/libgit2/src/transports/http.c +488 -1248
  335. data/vendor/libgit2/src/transports/http.h +4 -1
  336. data/vendor/libgit2/src/transports/httpclient.c +1549 -0
  337. data/vendor/libgit2/src/transports/httpclient.h +190 -0
  338. data/vendor/libgit2/src/transports/local.c +10 -10
  339. data/vendor/libgit2/src/transports/smart.c +19 -19
  340. data/vendor/libgit2/src/transports/smart.h +3 -3
  341. data/vendor/libgit2/src/transports/smart_pkt.c +1 -1
  342. data/vendor/libgit2/src/transports/smart_protocol.c +40 -64
  343. data/vendor/libgit2/src/transports/ssh.c +77 -59
  344. data/vendor/libgit2/src/transports/winhttp.c +272 -242
  345. data/vendor/libgit2/src/tree-cache.c +14 -7
  346. data/vendor/libgit2/src/tree.c +16 -26
  347. data/vendor/libgit2/src/unix/map.c +1 -1
  348. data/vendor/libgit2/src/unix/posix.h +2 -12
  349. data/vendor/libgit2/src/userdiff.h +3 -1
  350. data/vendor/libgit2/src/util.c +51 -53
  351. data/vendor/libgit2/src/util.h +16 -21
  352. data/vendor/libgit2/src/wildmatch.c +320 -0
  353. data/vendor/libgit2/src/wildmatch.h +23 -0
  354. data/vendor/libgit2/src/win32/map.c +3 -5
  355. data/vendor/libgit2/src/win32/path_w32.c +40 -3
  356. data/vendor/libgit2/src/win32/path_w32.h +15 -29
  357. data/vendor/libgit2/src/win32/posix.h +1 -4
  358. data/vendor/libgit2/src/win32/posix_w32.c +47 -5
  359. data/vendor/libgit2/src/win32/precompiled.h +0 -2
  360. data/vendor/libgit2/src/win32/thread.c +5 -10
  361. data/vendor/libgit2/src/win32/w32_buffer.c +7 -3
  362. data/vendor/libgit2/src/win32/w32_common.h +39 -0
  363. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +0 -93
  364. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +0 -2
  365. data/vendor/libgit2/src/win32/w32_stack.c +4 -9
  366. data/vendor/libgit2/src/win32/w32_stack.h +3 -3
  367. data/vendor/libgit2/src/win32/w32_util.c +31 -0
  368. data/vendor/libgit2/src/win32/w32_util.h +6 -32
  369. data/vendor/libgit2/src/worktree.c +79 -49
  370. data/vendor/libgit2/src/xdiff/xdiffi.c +1 -1
  371. data/vendor/libgit2/src/xdiff/xmerge.c +12 -0
  372. data/vendor/libgit2/src/xdiff/xpatience.c +3 -0
  373. data/vendor/libgit2/src/zstream.c +5 -0
  374. data/vendor/libgit2/src/zstream.h +1 -0
  375. metadata +108 -41
  376. data/vendor/libgit2/deps/regex/CMakeLists.txt +0 -2
  377. data/vendor/libgit2/deps/regex/COPYING +0 -502
  378. data/vendor/libgit2/deps/regex/config.h +0 -7
  379. data/vendor/libgit2/deps/regex/regcomp.c +0 -3857
  380. data/vendor/libgit2/deps/regex/regex.c +0 -92
  381. data/vendor/libgit2/deps/regex/regex.h +0 -582
  382. data/vendor/libgit2/deps/regex/regex_internal.c +0 -1744
  383. data/vendor/libgit2/deps/regex/regex_internal.h +0 -819
  384. data/vendor/libgit2/deps/regex/regexec.c +0 -4369
  385. data/vendor/libgit2/include/git2/inttypes.h +0 -309
  386. data/vendor/libgit2/include/git2/sys/time.h +0 -31
  387. data/vendor/libgit2/libgit2.pc.in +0 -13
  388. data/vendor/libgit2/src/fnmatch.c +0 -248
  389. data/vendor/libgit2/src/fnmatch.h +0 -48
  390. data/vendor/libgit2/src/sha1_lookup.c +0 -35
  391. data/vendor/libgit2/src/transports/cred.c +0 -390
@@ -11,31 +11,167 @@
11
11
 
12
12
  #include "git2/index.h"
13
13
 
14
+ /** A map with `git_index_entry`s as key. */
14
15
  typedef struct kh_idx_s git_idxmap;
16
+ /** A map with case-insensitive `git_index_entry`s as key */
15
17
  typedef struct kh_idxicase_s git_idxmap_icase;
16
18
 
17
- int git_idxmap_alloc(git_idxmap **map);
18
- int git_idxmap_icase_alloc(git_idxmap_icase **map);
19
- void git_idxmap_insert(git_idxmap *map, const git_index_entry *key, void *value, int *rval);
20
- void git_idxmap_icase_insert(git_idxmap_icase *map, const git_index_entry *key, void *value, int *rval);
19
+ /**
20
+ * Allocate a new index entry map.
21
+ *
22
+ * @param out Pointer to the map that shall be allocated.
23
+ * @return 0 on success, an error code if allocation has failed.
24
+ */
25
+ int git_idxmap_new(git_idxmap **out);
21
26
 
22
- size_t git_idxmap_lookup_index(git_idxmap *map, const git_index_entry *key);
23
- size_t git_idxmap_icase_lookup_index(git_idxmap_icase *map, const git_index_entry *key);
24
- void *git_idxmap_value_at(git_idxmap *map, size_t idx);
25
- int git_idxmap_valid_index(git_idxmap *map, size_t idx);
26
- int git_idxmap_has_data(git_idxmap *map, size_t idx);
27
+ /**
28
+ * Allocate a new case-insensitive index entry map.
29
+ *
30
+ * @param out Pointer to the map that shall be allocated.
31
+ * @return 0 on success, an error code if allocation has failed.
32
+ */
33
+ int git_idxmap_icase_new(git_idxmap_icase **out);
27
34
 
28
- void git_idxmap_resize(git_idxmap *map, size_t size);
29
- void git_idxmap_icase_resize(git_idxmap_icase *map, size_t size);
35
+ /**
36
+ * Free memory associated with the map.
37
+ *
38
+ * Note that this function will _not_ free values added to this
39
+ * map.
40
+ *
41
+ * @param map Pointer to the map that is to be free'd. May be
42
+ * `NULL`.
43
+ */
30
44
  void git_idxmap_free(git_idxmap *map);
45
+
46
+ /**
47
+ * Free memory associated with the map.
48
+ *
49
+ * Note that this function will _not_ free values added to this
50
+ * map.
51
+ *
52
+ * @param map Pointer to the map that is to be free'd. May be
53
+ * `NULL`.
54
+ */
31
55
  void git_idxmap_icase_free(git_idxmap_icase *map);
56
+
57
+ /**
58
+ * Clear all entries from the map.
59
+ *
60
+ * This function will remove all entries from the associated map.
61
+ * Memory associated with it will not be released, though.
62
+ *
63
+ * @param map Pointer to the map that shall be cleared. May be
64
+ * `NULL`.
65
+ */
32
66
  void git_idxmap_clear(git_idxmap *map);
67
+
68
+ /**
69
+ * Clear all entries from the map.
70
+ *
71
+ * This function will remove all entries from the associated map.
72
+ * Memory associated with it will not be released, though.
73
+ *
74
+ * @param map Pointer to the map that shall be cleared. May be
75
+ * `NULL`.
76
+ */
33
77
  void git_idxmap_icase_clear(git_idxmap_icase *map);
34
78
 
35
- void git_idxmap_delete_at(git_idxmap *map, size_t idx);
36
- void git_idxmap_icase_delete_at(git_idxmap_icase *map, size_t idx);
79
+ /**
80
+ * Resize the map by allocating more memory.
81
+ *
82
+ * @param map map that shall be resized
83
+ * @param size count of entries that the map shall hold
84
+ * @return `0` if the map was successfully resized, a negative
85
+ * error code otherwise
86
+ */
87
+ int git_idxmap_resize(git_idxmap *map, size_t size);
37
88
 
38
- void git_idxmap_delete(git_idxmap *map, const git_index_entry *key);
39
- void git_idxmap_icase_delete(git_idxmap_icase *map, const git_index_entry *key);
89
+ /**
90
+ * Resize the map by allocating more memory.
91
+ *
92
+ * @param map map that shall be resized
93
+ * @param size count of entries that the map shall hold
94
+ * @return `0` if the map was successfully resized, a negative
95
+ * error code otherwise
96
+ */
97
+ int git_idxmap_icase_resize(git_idxmap_icase *map, size_t size);
98
+
99
+ /**
100
+ * Return value associated with the given key.
101
+ *
102
+ * @param map map to search key in
103
+ * @param key key to search for; the index entry will be searched
104
+ * for by its case-sensitive path
105
+ * @return value associated with the given key or NULL if the key was not found
106
+ */
107
+ void *git_idxmap_get(git_idxmap *map, const git_index_entry *key);
108
+
109
+ /**
110
+ * Return value associated with the given key.
111
+ *
112
+ * @param map map to search key in
113
+ * @param key key to search for; the index entry will be searched
114
+ * for by its case-insensitive path
115
+ * @return value associated with the given key or NULL if the key was not found
116
+ */
117
+ void *git_idxmap_icase_get(git_idxmap_icase *map, const git_index_entry *key);
118
+
119
+ /**
120
+ * Set the entry for key to value.
121
+ *
122
+ * If the map has no corresponding entry for the given key, a new
123
+ * entry will be created with the given value. If an entry exists
124
+ * already, its value will be updated to match the given value.
125
+ *
126
+ * @param map map to create new entry in
127
+ * @param key key to set
128
+ * @param value value to associate the key with; may be NULL
129
+ * @return zero if the key was successfully set, a negative error
130
+ * code otherwise
131
+ */
132
+ int git_idxmap_set(git_idxmap *map, const git_index_entry *key, void *value);
133
+
134
+ /**
135
+ * Set the entry for key to value.
136
+ *
137
+ * If the map has no corresponding entry for the given key, a new
138
+ * entry will be created with the given value. If an entry exists
139
+ * already, its value will be updated to match the given value.
140
+ *
141
+ * @param map map to create new entry in
142
+ * @param key key to set
143
+ * @param value value to associate the key with; may be NULL
144
+ * @return zero if the key was successfully set, a negative error
145
+ * code otherwise
146
+ */
147
+ int git_idxmap_icase_set(git_idxmap_icase *map, const git_index_entry *key, void *value);
148
+
149
+ /**
150
+ * Delete an entry from the map.
151
+ *
152
+ * Delete the given key and its value from the map. If no such
153
+ * key exists, this will do nothing.
154
+ *
155
+ * @param map map to delete key in
156
+ * @param key key to delete
157
+ * @return `0` if the key has been deleted, GIT_ENOTFOUND if no
158
+ * such key was found, a negative code in case of an
159
+ * error
160
+ */
161
+ int git_idxmap_delete(git_idxmap *map, const git_index_entry *key);
162
+
163
+ /**
164
+ * Delete an entry from the map.
165
+ *
166
+ * Delete the given key and its value from the map. If no such
167
+ * key exists, this will do nothing.
168
+ *
169
+ * @param map map to delete key in
170
+ * @param key key to delete
171
+ * @return `0` if the key has been deleted, GIT_ENOTFOUND if no
172
+ * such key was found, a negative code in case of an
173
+ * error
174
+ */
175
+ int git_idxmap_icase_delete(git_idxmap_icase *map, const git_index_entry *key);
40
176
 
41
177
  #endif
@@ -12,7 +12,7 @@
12
12
  #include "attrcache.h"
13
13
  #include "path.h"
14
14
  #include "config.h"
15
- #include "fnmatch.h"
15
+ #include "wildmatch.h"
16
16
 
17
17
  #define GIT_IGNORE_INTERNAL "[internal]exclude"
18
18
 
@@ -101,7 +101,7 @@ static int does_negate_pattern(git_attr_fnmatch *rule, git_attr_fnmatch *neg)
101
101
  */
102
102
  static int does_negate_rule(int *out, git_vector *rules, git_attr_fnmatch *match)
103
103
  {
104
- int error = 0, fnflags;
104
+ int error = 0, wildmatch_flags;
105
105
  size_t i;
106
106
  git_attr_fnmatch *rule;
107
107
  char *path;
@@ -109,9 +109,9 @@ static int does_negate_rule(int *out, git_vector *rules, git_attr_fnmatch *match
109
109
 
110
110
  *out = 0;
111
111
 
112
- fnflags = FNM_PATHNAME;
112
+ wildmatch_flags = WM_PATHNAME;
113
113
  if (match->flags & GIT_ATTR_FNMATCH_ICASE)
114
- fnflags |= FNM_IGNORECASE;
114
+ wildmatch_flags |= WM_CASEFOLD;
115
115
 
116
116
  /* path of the file relative to the workdir, so we match the rules in subdirs */
117
117
  if (match->containing_dir) {
@@ -141,13 +141,8 @@ static int does_negate_rule(int *out, git_vector *rules, git_attr_fnmatch *match
141
141
  if (git_buf_oom(&buf))
142
142
  goto out;
143
143
 
144
- if ((error = p_fnmatch(git_buf_cstr(&buf), path, fnflags)) < 0) {
145
- git_error_set(GIT_ERROR_INVALID, "error matching pattern");
146
- goto out;
147
- }
148
-
149
144
  /* if we found a match, we want to keep this rule */
150
- if (error != FNM_NOMATCH) {
145
+ if ((wildmatch(git_buf_cstr(&buf), path, wildmatch_flags)) == WM_MATCH) {
151
146
  *out = 1;
152
147
  error = 0;
153
148
  goto out;
@@ -163,14 +158,16 @@ out:
163
158
  }
164
159
 
165
160
  static int parse_ignore_file(
166
- git_repository *repo, git_attr_file *attrs, const char *data)
161
+ git_repository *repo, git_attr_file *attrs, const char *data, bool allow_macros)
167
162
  {
168
163
  int error = 0;
169
164
  int ignore_case = false;
170
165
  const char *scan = data, *context = NULL;
171
166
  git_attr_fnmatch *match = NULL;
172
167
 
173
- if (git_repository__cvar(&ignore_case, repo, GIT_CVAR_IGNORECASE) < 0)
168
+ GIT_UNUSED(allow_macros);
169
+
170
+ if (git_repository__configmap_lookup(&ignore_case, repo, GIT_CONFIGMAP_IGNORECASE) < 0)
174
171
  git_error_clear();
175
172
 
176
173
  /* if subdir file path, convert context for file paths */
@@ -193,9 +190,7 @@ static int parse_ignore_file(
193
190
  }
194
191
 
195
192
  match->flags =
196
- GIT_ATTR_FNMATCH_ALLOWSPACE |
197
- GIT_ATTR_FNMATCH_ALLOWNEG |
198
- GIT_ATTR_FNMATCH_NOLEADINGDIR;
193
+ GIT_ATTR_FNMATCH_ALLOWSPACE | GIT_ATTR_FNMATCH_ALLOWNEG;
199
194
 
200
195
  if (!(error = git_attr_fnmatch__parse(
201
196
  match, &attrs->pool, context, &scan)))
@@ -246,9 +241,8 @@ static int push_ignore_file(
246
241
  int error = 0;
247
242
  git_attr_file *file = NULL;
248
243
 
249
- error = git_attr_cache__get(
250
- &file, ignores->repo, NULL, GIT_ATTR_FILE__FROM_FILE,
251
- base, filename, parse_ignore_file);
244
+ error = git_attr_cache__get(&file, ignores->repo, NULL, GIT_ATTR_FILE__FROM_FILE,
245
+ base, filename, parse_ignore_file, false);
252
246
  if (error < 0)
253
247
  return error;
254
248
 
@@ -274,12 +268,12 @@ static int get_internal_ignores(git_attr_file **out, git_repository *repo)
274
268
  if ((error = git_attr_cache__init(repo)) < 0)
275
269
  return error;
276
270
 
277
- error = git_attr_cache__get(
278
- out, repo, NULL, GIT_ATTR_FILE__IN_MEMORY, NULL, GIT_IGNORE_INTERNAL, NULL);
271
+ error = git_attr_cache__get(out, repo, NULL, GIT_ATTR_FILE__IN_MEMORY, NULL,
272
+ GIT_IGNORE_INTERNAL, NULL, false);
279
273
 
280
274
  /* if internal rules list is empty, insert default rules */
281
275
  if (!error && !(*out)->rules.length)
282
- error = parse_ignore_file(repo, *out, GIT_IGNORE_DEFAULT_RULES);
276
+ error = parse_ignore_file(repo, *out, GIT_IGNORE_DEFAULT_RULES, false);
283
277
 
284
278
  return error;
285
279
  }
@@ -299,8 +293,8 @@ int git_ignore__for_path(
299
293
  ignores->repo = repo;
300
294
 
301
295
  /* Read the ignore_case flag */
302
- if ((error = git_repository__cvar(
303
- &ignores->ignore_case, repo, GIT_CVAR_IGNORECASE)) < 0)
296
+ if ((error = git_repository__configmap_lookup(
297
+ &ignores->ignore_case, repo, GIT_CONFIGMAP_IGNORECASE)) < 0)
304
298
  goto cleanup;
305
299
 
306
300
  if ((error = git_attr_cache__init(repo)) < 0)
@@ -337,16 +331,13 @@ int git_ignore__for_path(
337
331
  goto cleanup;
338
332
  }
339
333
 
340
- if ((error = git_repository_item_path(&infopath,
341
- repo, GIT_REPOSITORY_ITEM_INFO)) < 0)
342
- goto cleanup;
343
-
344
- /* load .git/info/exclude */
345
- error = push_ignore_file(
346
- ignores, &ignores->ign_global,
347
- infopath.ptr, GIT_IGNORE_FILE_INREPO);
348
- if (error < 0)
349
- goto cleanup;
334
+ /* load .git/info/exclude if possible */
335
+ if ((error = git_repository_item_path(&infopath, repo, GIT_REPOSITORY_ITEM_INFO)) < 0 ||
336
+ (error = push_ignore_file(ignores, &ignores->ign_global, infopath.ptr, GIT_IGNORE_FILE_INREPO)) < 0) {
337
+ if (error != GIT_ENOTFOUND)
338
+ goto cleanup;
339
+ error = 0;
340
+ }
350
341
 
351
342
  /* load core.excludesfile */
352
343
  if (git_repository_attr_cache(repo)->cfg_excl_file != NULL)
@@ -453,7 +444,7 @@ static bool ignore_lookup_in_rules(
453
444
  int git_ignore__lookup(
454
445
  int *out, git_ignores *ignores, const char *pathname, git_dir_flag dir_flag)
455
446
  {
456
- unsigned int i;
447
+ size_t i;
457
448
  git_attr_file *file;
458
449
  git_attr_path path;
459
450
 
@@ -467,8 +458,11 @@ int git_ignore__lookup(
467
458
  if (ignore_lookup_in_rules(out, ignores->ign_internal, &path))
468
459
  goto cleanup;
469
460
 
470
- /* next process files in the path */
471
- git_vector_foreach(&ignores->ign_path, i, file) {
461
+ /* next process files in the path.
462
+ * this process has to process ignores in reverse order
463
+ * to ensure correct prioritization of rules
464
+ */
465
+ git_vector_rforeach(&ignores->ign_path, i, file) {
472
466
  if (ignore_lookup_in_rules(out, file, &path))
473
467
  goto cleanup;
474
468
  }
@@ -492,7 +486,7 @@ int git_ignore_add_rule(git_repository *repo, const char *rules)
492
486
  if ((error = get_internal_ignores(&ign_internal, repo)) < 0)
493
487
  return error;
494
488
 
495
- error = parse_ignore_file(repo, ign_internal, rules);
489
+ error = parse_ignore_file(repo, ign_internal, rules, false);
496
490
  git_attr_file__free(ign_internal);
497
491
 
498
492
  return error;
@@ -508,7 +502,7 @@ int git_ignore_clear_internal_rules(git_repository *repo)
508
502
 
509
503
  if (!(error = git_attr_file__clear_rules(ign_internal, true)))
510
504
  error = parse_ignore_file(
511
- repo, ign_internal, GIT_IGNORE_DEFAULT_RULES);
505
+ repo, ign_internal, GIT_IGNORE_DEFAULT_RULES, false);
512
506
 
513
507
  git_attr_file__free(ign_internal);
514
508
  return error;
@@ -27,29 +27,6 @@
27
27
  #include "git2/config.h"
28
28
  #include "git2/sys/index.h"
29
29
 
30
- #define INSERT_IN_MAP_EX(idx, map, e, err) do { \
31
- if ((idx)->ignore_case) \
32
- git_idxmap_icase_insert((git_idxmap_icase *) (map), (e), (e), (err)); \
33
- else \
34
- git_idxmap_insert((map), (e), (e), (err)); \
35
- } while (0)
36
-
37
- #define INSERT_IN_MAP(idx, e, err) INSERT_IN_MAP_EX(idx, (idx)->entries_map, e, err)
38
-
39
- #define LOOKUP_IN_MAP(p, idx, k) do { \
40
- if ((idx)->ignore_case) \
41
- (p) = git_idxmap_icase_lookup_index((git_idxmap_icase *) index->entries_map, (k)); \
42
- else \
43
- (p) = git_idxmap_lookup_index(index->entries_map, (k)); \
44
- } while (0)
45
-
46
- #define DELETE_IN_MAP(idx, e) do { \
47
- if ((idx)->ignore_case) \
48
- git_idxmap_icase_delete((git_idxmap_icase *) (idx)->entries_map, (e)); \
49
- else \
50
- git_idxmap_delete((idx)->entries_map, (e)); \
51
- } while (0)
52
-
53
30
  static int index_apply_to_wd_diff(git_index *index, int action, const git_strarray *paths,
54
31
  unsigned int flags,
55
32
  git_index_matched_path_cb cb, void *payload);
@@ -148,6 +125,30 @@ static int write_index(git_oid *checksum, git_index *index, git_filebuf *file);
148
125
  static void index_entry_free(git_index_entry *entry);
149
126
  static void index_entry_reuc_free(git_index_reuc_entry *reuc);
150
127
 
128
+ GIT_INLINE(int) index_map_set(git_idxmap *map, git_index_entry *e, bool ignore_case)
129
+ {
130
+ if (ignore_case)
131
+ return git_idxmap_icase_set((git_idxmap_icase *) map, e, e);
132
+ else
133
+ return git_idxmap_set(map, e, e);
134
+ }
135
+
136
+ GIT_INLINE(int) index_map_delete(git_idxmap *map, git_index_entry *e, bool ignore_case)
137
+ {
138
+ if (ignore_case)
139
+ return git_idxmap_icase_delete((git_idxmap_icase *) map, e);
140
+ else
141
+ return git_idxmap_delete(map, e);
142
+ }
143
+
144
+ GIT_INLINE(int) index_map_resize(git_idxmap *map, size_t count, bool ignore_case)
145
+ {
146
+ if (ignore_case)
147
+ return git_idxmap_icase_resize((git_idxmap_icase *) map, count);
148
+ else
149
+ return git_idxmap_resize(map, count);
150
+ }
151
+
151
152
  int git_index_entry_srch(const void *key, const void *array_member)
152
153
  {
153
154
  const struct entry_srch_key *srch_key = key;
@@ -423,10 +424,10 @@ int git_index_open(git_index **index_out, const char *index_path)
423
424
  }
424
425
 
425
426
  if (git_vector_init(&index->entries, 32, git_index_entry_cmp) < 0 ||
426
- git_idxmap_alloc(&index->entries_map) < 0 ||
427
- git_vector_init(&index->names, 8, conflict_name_cmp) < 0 ||
428
- git_vector_init(&index->reuc, 8, reuc_cmp) < 0 ||
429
- git_vector_init(&index->deleted, 8, git_index_entry_cmp) < 0)
427
+ git_idxmap_new(&index->entries_map) < 0 ||
428
+ git_vector_init(&index->names, 8, conflict_name_cmp) < 0 ||
429
+ git_vector_init(&index->reuc, 8, reuc_cmp) < 0 ||
430
+ git_vector_init(&index->deleted, 8, git_index_entry_cmp) < 0)
430
431
  goto fail;
431
432
 
432
433
  index->entries_cmp_path = git__strcmp_cb;
@@ -507,7 +508,7 @@ static int index_remove_entry(git_index *index, size_t pos)
507
508
 
508
509
  if (entry != NULL) {
509
510
  git_tree_cache_invalidate_path(index->tree, entry->path);
510
- DELETE_IN_MAP(index, entry);
511
+ index_map_delete(index->entries_map, entry, index->ignore_case);
511
512
  }
512
513
 
513
514
  error = git_vector_remove(&index->entries, pos);
@@ -538,13 +539,19 @@ int git_index_clear(git_index *index)
538
539
  git_idxmap_clear(index->entries_map);
539
540
  while (!error && index->entries.length > 0)
540
541
  error = index_remove_entry(index, index->entries.length - 1);
542
+
543
+ if (error)
544
+ goto done;
545
+
541
546
  index_free_deleted(index);
542
547
 
543
- git_index_reuc_clear(index);
544
- git_index_name_clear(index);
548
+ if ((error = git_index_name_clear(index)) < 0 ||
549
+ (error = git_index_reuc_clear(index)) < 0)
550
+ goto done;
545
551
 
546
552
  git_futils_filestamp_set(&index->stamp, NULL);
547
553
 
554
+ done:
548
555
  return error;
549
556
  }
550
557
 
@@ -570,11 +577,11 @@ int git_index_set_caps(git_index *index, int caps)
570
577
  return create_index_error(
571
578
  -1, "cannot access repository to set index caps");
572
579
 
573
- if (!git_repository__cvar(&val, repo, GIT_CVAR_IGNORECASE))
580
+ if (!git_repository__configmap_lookup(&val, repo, GIT_CONFIGMAP_IGNORECASE))
574
581
  index->ignore_case = (val != 0);
575
- if (!git_repository__cvar(&val, repo, GIT_CVAR_FILEMODE))
582
+ if (!git_repository__configmap_lookup(&val, repo, GIT_CONFIGMAP_FILEMODE))
576
583
  index->distrust_filemode = (val == 0);
577
- if (!git_repository__cvar(&val, repo, GIT_CVAR_SYMLINKS))
584
+ if (!git_repository__configmap_lookup(&val, repo, GIT_CONFIGMAP_SYMLINKS))
578
585
  index->no_symlinks = (val == 0);
579
586
  }
580
587
  else {
@@ -852,20 +859,24 @@ const git_index_entry *git_index_get_bypath(
852
859
  git_index *index, const char *path, int stage)
853
860
  {
854
861
  git_index_entry key = {{ 0 }};
855
- size_t pos;
862
+ git_index_entry *value;
856
863
 
857
864
  assert(index);
858
865
 
859
866
  key.path = path;
860
867
  GIT_INDEX_ENTRY_STAGE_SET(&key, stage);
861
868
 
862
- LOOKUP_IN_MAP(pos, index, &key);
869
+ if (index->ignore_case)
870
+ value = git_idxmap_icase_get((git_idxmap_icase *) index->entries_map, &key);
871
+ else
872
+ value = git_idxmap_get(index->entries_map, &key);
863
873
 
864
- if (git_idxmap_valid_index(index->entries_map, pos))
865
- return git_idxmap_value_at(index->entries_map, pos);
874
+ if (!value) {
875
+ git_error_set(GIT_ERROR_INDEX, "index does not contain '%s'", path);
876
+ return NULL;
877
+ }
866
878
 
867
- git_error_set(GIT_ERROR_INDEX, "index does not contain '%s'", path);
868
- return NULL;
879
+ return value;
869
880
  }
870
881
 
871
882
  void git_index_entry__init_from_stat(
@@ -1398,10 +1409,9 @@ static int index_insert(
1398
1409
  * at the sorted position. (Since we re-sort after each insert to
1399
1410
  * check for dups, this is actually cheaper in the long run.)
1400
1411
  */
1401
- if ((error = git_vector_insert_sorted(&index->entries, entry, index_no_dups)) < 0)
1412
+ if ((error = git_vector_insert_sorted(&index->entries, entry, index_no_dups)) < 0 ||
1413
+ (error = index_map_set(index->entries_map, entry, index->ignore_case)) < 0)
1402
1414
  goto out;
1403
-
1404
- INSERT_IN_MAP(index, entry, &error);
1405
1415
  }
1406
1416
 
1407
1417
  index->dirty = 1;
@@ -1453,7 +1463,7 @@ GIT_INLINE(bool) valid_filemode(const int filemode)
1453
1463
  return (is_file_or_link(filemode) || filemode == GIT_FILEMODE_COMMIT);
1454
1464
  }
1455
1465
 
1456
- int git_index_add_frombuffer(
1466
+ int git_index_add_from_buffer(
1457
1467
  git_index *index, const git_index_entry *source_entry,
1458
1468
  const void *buffer, size_t len)
1459
1469
  {
@@ -1473,17 +1483,22 @@ int git_index_add_frombuffer(
1473
1483
  return -1;
1474
1484
  }
1475
1485
 
1486
+ if (len > UINT32_MAX) {
1487
+ git_error_set(GIT_ERROR_INDEX, "buffer is too large");
1488
+ return -1;
1489
+ }
1490
+
1476
1491
  if (index_entry_dup(&entry, index, source_entry) < 0)
1477
1492
  return -1;
1478
1493
 
1479
- error = git_blob_create_frombuffer(&id, INDEX_OWNER(index), buffer, len);
1494
+ error = git_blob_create_from_buffer(&id, INDEX_OWNER(index), buffer, len);
1480
1495
  if (error < 0) {
1481
1496
  index_entry_free(entry);
1482
1497
  return error;
1483
1498
  }
1484
1499
 
1485
1500
  git_oid_cpy(&entry->id, &id);
1486
- entry->file_size = len;
1501
+ entry->file_size = (uint32_t)len;
1487
1502
 
1488
1503
  if ((error = index_insert(index, &entry, 1, true, true, true)) < 0)
1489
1504
  return error;
@@ -1610,41 +1625,42 @@ int git_index_remove_bypath(git_index *index, const char *path)
1610
1625
  int git_index__fill(git_index *index, const git_vector *source_entries)
1611
1626
  {
1612
1627
  const git_index_entry *source_entry = NULL;
1628
+ int error = 0;
1613
1629
  size_t i;
1614
- int ret = 0;
1615
1630
 
1616
1631
  assert(index);
1617
1632
 
1618
1633
  if (!source_entries->length)
1619
1634
  return 0;
1620
1635
 
1621
- git_vector_size_hint(&index->entries, source_entries->length);
1622
- git_idxmap_resize(index->entries_map, (size_t)(source_entries->length * 1.3));
1636
+ if (git_vector_size_hint(&index->entries, source_entries->length) < 0 ||
1637
+ index_map_resize(index->entries_map, (size_t)(source_entries->length * 1.3),
1638
+ index->ignore_case) < 0)
1639
+ return -1;
1623
1640
 
1624
1641
  git_vector_foreach(source_entries, i, source_entry) {
1625
1642
  git_index_entry *entry = NULL;
1626
1643
 
1627
- if ((ret = index_entry_dup(&entry, index, source_entry)) < 0)
1644
+ if ((error = index_entry_dup(&entry, index, source_entry)) < 0)
1628
1645
  break;
1629
1646
 
1630
1647
  index_entry_adjust_namemask(entry, ((struct entry_internal *)entry)->pathlen);
1631
1648
  entry->flags_extended |= GIT_INDEX_ENTRY_UPTODATE;
1632
1649
  entry->mode = git_index__create_mode(entry->mode);
1633
1650
 
1634
- if ((ret = git_vector_insert(&index->entries, entry)) < 0)
1651
+ if ((error = git_vector_insert(&index->entries, entry)) < 0)
1635
1652
  break;
1636
1653
 
1637
- INSERT_IN_MAP(index, entry, &ret);
1638
- if (ret < 0)
1654
+ if ((error = index_map_set(index->entries_map, entry, index->ignore_case)) < 0)
1639
1655
  break;
1640
1656
 
1641
1657
  index->dirty = 1;
1642
1658
  }
1643
1659
 
1644
- if (!ret)
1660
+ if (!error)
1645
1661
  git_vector_sort(&index->entries);
1646
1662
 
1647
- return ret;
1663
+ return error;
1648
1664
  }
1649
1665
 
1650
1666
 
@@ -1677,7 +1693,7 @@ int git_index_remove(git_index *index, const char *path, int stage)
1677
1693
  remove_key.path = path;
1678
1694
  GIT_INDEX_ENTRY_STAGE_SET(&remove_key, stage);
1679
1695
 
1680
- DELETE_IN_MAP(index, &remove_key);
1696
+ index_map_delete(index->entries_map, &remove_key, index->ignore_case);
1681
1697
 
1682
1698
  if (index_find(&position, index, path, 0, stage) < 0) {
1683
1699
  git_error_set(
@@ -2126,7 +2142,7 @@ int git_index_name_add(git_index *index,
2126
2142
  return 0;
2127
2143
  }
2128
2144
 
2129
- void git_index_name_clear(git_index *index)
2145
+ int git_index_name_clear(git_index *index)
2130
2146
  {
2131
2147
  size_t i;
2132
2148
  git_index_name_entry *conflict_name;
@@ -2139,6 +2155,8 @@ void git_index_name_clear(git_index *index)
2139
2155
  git_vector_clear(&index->names);
2140
2156
 
2141
2157
  index->dirty = 1;
2158
+
2159
+ return 0;
2142
2160
  }
2143
2161
 
2144
2162
  size_t git_index_reuc_entrycount(git_index *index)
@@ -2235,7 +2253,7 @@ int git_index_reuc_remove(git_index *index, size_t position)
2235
2253
  return error;
2236
2254
  }
2237
2255
 
2238
- void git_index_reuc_clear(git_index *index)
2256
+ int git_index_reuc_clear(git_index *index)
2239
2257
  {
2240
2258
  size_t i;
2241
2259
 
@@ -2247,6 +2265,8 @@ void git_index_reuc_clear(git_index *index)
2247
2265
  git_vector_clear(&index->reuc);
2248
2266
 
2249
2267
  index->dirty = 1;
2268
+
2269
+ return 0;
2250
2270
  }
2251
2271
 
2252
2272
  static int index_error_invalid(const char *message)
@@ -2607,10 +2627,8 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
2607
2627
 
2608
2628
  assert(!index->entries.length);
2609
2629
 
2610
- if (index->ignore_case)
2611
- git_idxmap_icase_resize((git_idxmap_icase *) index->entries_map, header.entry_count);
2612
- else
2613
- git_idxmap_resize(index->entries_map, header.entry_count);
2630
+ if ((error = index_map_resize(index->entries_map, header.entry_count, index->ignore_case)) < 0)
2631
+ return error;
2614
2632
 
2615
2633
  /* Parse all the entries */
2616
2634
  for (i = 0; i < header.entry_count && buffer_size > INDEX_FOOTER_SIZE; ++i) {
@@ -2627,9 +2645,7 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
2627
2645
  goto done;
2628
2646
  }
2629
2647
 
2630
- INSERT_IN_MAP(index, entry, &error);
2631
-
2632
- if (error < 0) {
2648
+ if ((error = index_map_set(index->entries_map, entry, index->ignore_case)) < 0) {
2633
2649
  index_entry_free(entry);
2634
2650
  goto done;
2635
2651
  }
@@ -2728,7 +2744,7 @@ static int write_disk_entry(git_filebuf *file, git_index_entry *entry, const cha
2728
2744
  ++same_len;
2729
2745
  }
2730
2746
  path_len -= same_len;
2731
- varint_len = git_encode_varint(NULL, 0, same_len);
2747
+ varint_len = git_encode_varint(NULL, 0, strlen(last) - same_len);
2732
2748
  }
2733
2749
 
2734
2750
  disk_size = index_entry_size(path_len, varint_len, entry->flags);
@@ -2779,7 +2795,7 @@ static int write_disk_entry(git_filebuf *file, git_index_entry *entry, const cha
2779
2795
 
2780
2796
  if (last) {
2781
2797
  varint_len = git_encode_varint((unsigned char *) path,
2782
- disk_size, same_len);
2798
+ disk_size, strlen(last) - same_len);
2783
2799
  assert(varint_len > 0);
2784
2800
  path += varint_len;
2785
2801
  disk_size -= varint_len;
@@ -3106,7 +3122,7 @@ int git_index_read_tree(git_index *index, const git_tree *tree)
3106
3122
  size_t i;
3107
3123
  git_index_entry *e;
3108
3124
 
3109
- if (git_idxmap_alloc(&entries_map) < 0)
3125
+ if (git_idxmap_new(&entries_map) < 0)
3110
3126
  return -1;
3111
3127
 
3112
3128
  git_vector_set_cmp(&entries, index->entries._cmp); /* match sort */
@@ -3124,15 +3140,11 @@ int git_index_read_tree(git_index *index, const git_tree *tree)
3124
3140
  if ((error = git_tree_walk(tree, GIT_TREEWALK_POST, read_tree_cb, &data)) < 0)
3125
3141
  goto cleanup;
3126
3142
 
3127
- if (index->ignore_case)
3128
- git_idxmap_icase_resize((git_idxmap_icase *) entries_map, entries.length);
3129
- else
3130
- git_idxmap_resize(entries_map, entries.length);
3143
+ if ((error = index_map_resize(entries_map, entries.length, index->ignore_case)) < 0)
3144
+ goto cleanup;
3131
3145
 
3132
3146
  git_vector_foreach(&entries, i, e) {
3133
- INSERT_IN_MAP_EX(index, entries_map, e, &error);
3134
-
3135
- if (error < 0) {
3147
+ if ((error = index_map_set(entries_map, e, index->ignore_case)) < 0) {
3136
3148
  git_error_set(GIT_ERROR_INDEX, "failed to insert entry into map");
3137
3149
  return error;
3138
3150
  }
@@ -3180,14 +3192,13 @@ static int git_index_read_iterator(
3180
3192
  assert((new_iterator->flags & GIT_ITERATOR_DONT_IGNORE_CASE));
3181
3193
 
3182
3194
  if ((error = git_vector_init(&new_entries, new_length_hint, index->entries._cmp)) < 0 ||
3183
- (error = git_vector_init(&remove_entries, index->entries.length, NULL)) < 0 ||
3184
- (error = git_idxmap_alloc(&new_entries_map)) < 0)
3195
+ (error = git_vector_init(&remove_entries, index->entries.length, NULL)) < 0 ||
3196
+ (error = git_idxmap_new(&new_entries_map)) < 0)
3185
3197
  goto done;
3186
3198
 
3187
- if (index->ignore_case && new_length_hint)
3188
- git_idxmap_icase_resize((git_idxmap_icase *) new_entries_map, new_length_hint);
3189
- else if (new_length_hint)
3190
- git_idxmap_resize(new_entries_map, new_length_hint);
3199
+ if (new_length_hint && (error = index_map_resize(new_entries_map, new_length_hint,
3200
+ index->ignore_case)) < 0)
3201
+ goto done;
3191
3202
 
3192
3203
  opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE |
3193
3204
  GIT_ITERATOR_INCLUDE_CONFLICTS;
@@ -3251,7 +3262,8 @@ static int git_index_read_iterator(
3251
3262
 
3252
3263
  if (add_entry) {
3253
3264
  if ((error = git_vector_insert(&new_entries, add_entry)) == 0)
3254
- INSERT_IN_MAP_EX(index, new_entries_map, add_entry, &error);
3265
+ error = index_map_set(new_entries_map, add_entry,
3266
+ index->ignore_case);
3255
3267
  }
3256
3268
 
3257
3269
  if (remove_entry && error >= 0)
@@ -3275,8 +3287,9 @@ static int git_index_read_iterator(
3275
3287
  }
3276
3288
  }
3277
3289
 
3278
- git_index_name_clear(index);
3279
- git_index_reuc_clear(index);
3290
+ if ((error = git_index_name_clear(index)) < 0 ||
3291
+ (error = git_index_reuc_clear(index)) < 0)
3292
+ goto done;
3280
3293
 
3281
3294
  git_vector_swap(&new_entries, &index->entries);
3282
3295
  new_entries_map = git__swap(index->entries_map, new_entries_map);
@@ -3700,3 +3713,12 @@ void git_indexwriter_cleanup(git_indexwriter *writer)
3700
3713
  git_index_free(writer->index);
3701
3714
  writer->index = NULL;
3702
3715
  }
3716
+
3717
+ /* Deprecated functions */
3718
+
3719
+ int git_index_add_frombuffer(
3720
+ git_index *index, const git_index_entry *source_entry,
3721
+ const void *buffer, size_t len)
3722
+ {
3723
+ return git_index_add_from_buffer(index, source_entry, buffer, len);
3724
+ }