rugged 0.28.4.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (414) 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 +18 -16
  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 +17 -4
  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 +57 -75
  24. data/vendor/libgit2/COPYING +28 -0
  25. data/vendor/libgit2/cmake/{Modules/AddCFlagIfSupported.cmake → AddCFlagIfSupported.cmake} +0 -0
  26. data/vendor/libgit2/cmake/{Modules/EnableWarnings.cmake → EnableWarnings.cmake} +5 -1
  27. data/vendor/libgit2/cmake/{Modules/FindCoreFoundation.cmake → FindCoreFoundation.cmake} +2 -2
  28. data/vendor/libgit2/cmake/{Modules/FindGSSAPI.cmake → FindGSSAPI.cmake} +1 -1
  29. data/vendor/libgit2/cmake/FindGSSFramework.cmake +28 -0
  30. data/vendor/libgit2/cmake/{Modules/FindHTTP_Parser.cmake → FindHTTP_Parser.cmake} +0 -0
  31. data/vendor/libgit2/cmake/{Modules/FindIconv.cmake → FindIconv.cmake} +0 -0
  32. data/vendor/libgit2/cmake/FindPCRE.cmake +38 -0
  33. data/vendor/libgit2/cmake/FindPCRE2.cmake +37 -0
  34. data/vendor/libgit2/cmake/{Modules/FindPkgLibraries.cmake → FindPkgLibraries.cmake} +0 -0
  35. data/vendor/libgit2/cmake/{Modules/FindSecurity.cmake → FindSecurity.cmake} +2 -2
  36. data/vendor/libgit2/cmake/{Modules/FindStatNsec.cmake → FindStatNsec.cmake} +6 -0
  37. data/vendor/libgit2/cmake/{Modules/FindmbedTLS.cmake → FindmbedTLS.cmake} +0 -0
  38. data/vendor/libgit2/cmake/{Modules/IdeSplitSources.cmake → IdeSplitSources.cmake} +0 -0
  39. data/vendor/libgit2/cmake/PkgBuildConfig.cmake +77 -0
  40. data/vendor/libgit2/cmake/SanitizeBool.cmake +20 -0
  41. data/vendor/libgit2/cmake/SelectGSSAPI.cmake +48 -0
  42. data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +120 -0
  43. data/vendor/libgit2/cmake/SelectHashes.cmake +61 -0
  44. data/vendor/libgit2/deps/http-parser/CMakeLists.txt +4 -3
  45. data/vendor/libgit2/deps/http-parser/http_parser.c +11 -6
  46. data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +24 -0
  47. data/vendor/libgit2/deps/ntlmclient/compat.h +62 -0
  48. data/vendor/libgit2/deps/ntlmclient/crypt.h +64 -0
  49. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +120 -0
  50. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +18 -0
  51. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +145 -0
  52. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +18 -0
  53. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +130 -0
  54. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +21 -0
  55. data/vendor/libgit2/deps/ntlmclient/ntlm.c +1419 -0
  56. data/vendor/libgit2/deps/ntlmclient/ntlm.h +174 -0
  57. data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +320 -0
  58. data/vendor/libgit2/deps/ntlmclient/unicode.h +36 -0
  59. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +445 -0
  60. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +201 -0
  61. data/vendor/libgit2/deps/ntlmclient/utf8.h +1257 -0
  62. data/vendor/libgit2/deps/ntlmclient/util.c +21 -0
  63. data/vendor/libgit2/deps/ntlmclient/util.h +14 -0
  64. data/vendor/libgit2/deps/pcre/CMakeLists.txt +140 -0
  65. data/vendor/libgit2/deps/pcre/COPYING +5 -0
  66. data/vendor/libgit2/deps/pcre/LICENCE +93 -0
  67. data/vendor/libgit2/deps/pcre/cmake/COPYING-CMAKE-SCRIPTS +22 -0
  68. data/vendor/libgit2/deps/pcre/cmake/FindEditline.cmake +17 -0
  69. data/vendor/libgit2/deps/pcre/cmake/FindPackageHandleStandardArgs.cmake +58 -0
  70. data/vendor/libgit2/deps/pcre/cmake/FindReadline.cmake +29 -0
  71. data/vendor/libgit2/deps/pcre/config.h.in +57 -0
  72. data/vendor/libgit2/deps/pcre/pcre.h +641 -0
  73. data/vendor/libgit2/deps/pcre/pcre_byte_order.c +319 -0
  74. data/vendor/libgit2/deps/pcre/pcre_chartables.c +198 -0
  75. data/vendor/libgit2/deps/pcre/pcre_compile.c +9812 -0
  76. data/vendor/libgit2/deps/pcre/pcre_config.c +190 -0
  77. data/vendor/libgit2/deps/pcre/pcre_dfa_exec.c +3676 -0
  78. data/vendor/libgit2/deps/pcre/pcre_exec.c +7173 -0
  79. data/vendor/libgit2/deps/pcre/pcre_fullinfo.c +245 -0
  80. data/vendor/libgit2/deps/pcre/pcre_get.c +669 -0
  81. data/vendor/libgit2/deps/pcre/pcre_globals.c +86 -0
  82. data/vendor/libgit2/deps/pcre/pcre_internal.h +2787 -0
  83. data/vendor/libgit2/deps/pcre/pcre_jit_compile.c +11913 -0
  84. data/vendor/libgit2/deps/pcre/pcre_maketables.c +156 -0
  85. data/vendor/libgit2/deps/pcre/pcre_newline.c +210 -0
  86. data/vendor/libgit2/deps/pcre/pcre_ord2utf8.c +94 -0
  87. data/vendor/libgit2/deps/pcre/pcre_printint.c +834 -0
  88. data/vendor/libgit2/deps/pcre/pcre_refcount.c +92 -0
  89. data/vendor/libgit2/deps/pcre/pcre_string_utils.c +211 -0
  90. data/vendor/libgit2/deps/pcre/pcre_study.c +1686 -0
  91. data/vendor/libgit2/deps/pcre/pcre_tables.c +727 -0
  92. data/vendor/libgit2/deps/pcre/pcre_ucd.c +3644 -0
  93. data/vendor/libgit2/deps/pcre/pcre_valid_utf8.c +301 -0
  94. data/vendor/libgit2/deps/pcre/pcre_version.c +98 -0
  95. data/vendor/libgit2/deps/pcre/pcre_xclass.c +268 -0
  96. data/vendor/libgit2/deps/pcre/pcreposix.c +420 -0
  97. data/vendor/libgit2/deps/pcre/pcreposix.h +117 -0
  98. data/vendor/libgit2/deps/pcre/ucp.h +224 -0
  99. data/vendor/libgit2/deps/zlib/CMakeLists.txt +6 -5
  100. data/vendor/libgit2/deps/zlib/adler32.c +0 -7
  101. data/vendor/libgit2/deps/zlib/crc32.c +0 -7
  102. data/vendor/libgit2/deps/zlib/deflate.c +1 -0
  103. data/vendor/libgit2/include/git2.h +2 -0
  104. data/vendor/libgit2/include/git2/annotated_commit.h +1 -1
  105. data/vendor/libgit2/include/git2/apply.h +22 -2
  106. data/vendor/libgit2/include/git2/attr.h +23 -13
  107. data/vendor/libgit2/include/git2/blame.h +4 -2
  108. data/vendor/libgit2/include/git2/blob.h +44 -12
  109. data/vendor/libgit2/include/git2/branch.h +74 -57
  110. data/vendor/libgit2/include/git2/buffer.h +20 -14
  111. data/vendor/libgit2/include/git2/cert.h +135 -0
  112. data/vendor/libgit2/include/git2/checkout.h +46 -14
  113. data/vendor/libgit2/include/git2/cherrypick.h +3 -3
  114. data/vendor/libgit2/include/git2/clone.h +2 -2
  115. data/vendor/libgit2/include/git2/commit.h +23 -1
  116. data/vendor/libgit2/include/git2/common.h +29 -8
  117. data/vendor/libgit2/include/git2/config.h +12 -12
  118. data/vendor/libgit2/include/git2/cred_helpers.h +4 -42
  119. data/vendor/libgit2/include/git2/credential.h +314 -0
  120. data/vendor/libgit2/include/git2/credential_helpers.h +52 -0
  121. data/vendor/libgit2/include/git2/deprecated.h +362 -4
  122. data/vendor/libgit2/include/git2/describe.h +4 -4
  123. data/vendor/libgit2/include/git2/diff.h +16 -14
  124. data/vendor/libgit2/include/git2/errors.h +5 -2
  125. data/vendor/libgit2/include/git2/filter.h +8 -0
  126. data/vendor/libgit2/include/git2/index.h +3 -3
  127. data/vendor/libgit2/include/git2/indexer.h +48 -4
  128. data/vendor/libgit2/include/git2/merge.h +6 -10
  129. data/vendor/libgit2/include/git2/net.h +0 -5
  130. data/vendor/libgit2/include/git2/object.h +2 -14
  131. data/vendor/libgit2/include/git2/odb.h +3 -2
  132. data/vendor/libgit2/include/git2/odb_backend.h +5 -4
  133. data/vendor/libgit2/include/git2/oid.h +11 -6
  134. data/vendor/libgit2/include/git2/pack.h +13 -2
  135. data/vendor/libgit2/include/git2/proxy.h +6 -4
  136. data/vendor/libgit2/include/git2/rebase.h +46 -2
  137. data/vendor/libgit2/include/git2/refs.h +19 -0
  138. data/vendor/libgit2/include/git2/remote.h +40 -15
  139. data/vendor/libgit2/include/git2/repository.h +29 -6
  140. data/vendor/libgit2/include/git2/revert.h +1 -1
  141. data/vendor/libgit2/include/git2/revwalk.h +7 -3
  142. data/vendor/libgit2/include/git2/stash.h +4 -4
  143. data/vendor/libgit2/include/git2/status.h +25 -16
  144. data/vendor/libgit2/include/git2/strarray.h +6 -10
  145. data/vendor/libgit2/include/git2/submodule.h +20 -3
  146. data/vendor/libgit2/include/git2/sys/alloc.h +9 -9
  147. data/vendor/libgit2/include/git2/sys/cred.h +15 -0
  148. data/vendor/libgit2/include/git2/sys/credential.h +90 -0
  149. data/vendor/libgit2/include/git2/sys/index.h +4 -2
  150. data/vendor/libgit2/include/git2/sys/mempack.h +2 -1
  151. data/vendor/libgit2/include/git2/sys/merge.h +1 -1
  152. data/vendor/libgit2/include/git2/sys/odb_backend.h +48 -4
  153. data/vendor/libgit2/include/git2/sys/refdb_backend.h +164 -21
  154. data/vendor/libgit2/include/git2/sys/repository.h +17 -6
  155. data/vendor/libgit2/include/git2/sys/transport.h +4 -4
  156. data/vendor/libgit2/include/git2/tag.h +11 -2
  157. data/vendor/libgit2/include/git2/trace.h +2 -2
  158. data/vendor/libgit2/include/git2/transport.h +11 -340
  159. data/vendor/libgit2/include/git2/tree.h +5 -3
  160. data/vendor/libgit2/include/git2/types.h +4 -89
  161. data/vendor/libgit2/include/git2/version.h +5 -5
  162. data/vendor/libgit2/include/git2/worktree.h +5 -5
  163. data/vendor/libgit2/src/CMakeLists.txt +147 -272
  164. data/vendor/libgit2/src/alloc.c +2 -14
  165. data/vendor/libgit2/src/{stdalloc.c → allocators/stdalloc.c} +3 -4
  166. data/vendor/libgit2/src/{stdalloc.h → allocators/stdalloc.h} +4 -4
  167. data/vendor/libgit2/src/allocators/win32_crtdbg.c +118 -0
  168. data/vendor/libgit2/src/{transports/cred.h → allocators/win32_crtdbg.h} +5 -4
  169. data/vendor/libgit2/src/apply.c +65 -31
  170. data/vendor/libgit2/src/assert_safe.h +58 -0
  171. data/vendor/libgit2/src/attr.c +70 -64
  172. data/vendor/libgit2/src/attr_file.c +197 -99
  173. data/vendor/libgit2/src/attr_file.h +9 -9
  174. data/vendor/libgit2/src/attrcache.c +49 -50
  175. data/vendor/libgit2/src/attrcache.h +2 -1
  176. data/vendor/libgit2/src/blame.c +19 -5
  177. data/vendor/libgit2/src/blame.h +1 -1
  178. data/vendor/libgit2/src/blame_git.c +27 -10
  179. data/vendor/libgit2/src/blob.c +83 -17
  180. data/vendor/libgit2/src/blob.h +2 -2
  181. data/vendor/libgit2/src/branch.c +68 -42
  182. data/vendor/libgit2/src/buffer.c +25 -10
  183. data/vendor/libgit2/src/buffer.h +1 -0
  184. data/vendor/libgit2/src/cache.c +34 -58
  185. data/vendor/libgit2/src/cache.h +1 -1
  186. data/vendor/libgit2/src/cc-compat.h +5 -0
  187. data/vendor/libgit2/src/checkout.c +73 -86
  188. data/vendor/libgit2/src/cherrypick.c +11 -3
  189. data/vendor/libgit2/src/clone.c +107 -25
  190. data/vendor/libgit2/src/clone.h +4 -0
  191. data/vendor/libgit2/src/commit.c +70 -22
  192. data/vendor/libgit2/src/commit.h +6 -0
  193. data/vendor/libgit2/src/commit_list.c +28 -76
  194. data/vendor/libgit2/src/commit_list.h +2 -2
  195. data/vendor/libgit2/src/common.h +4 -75
  196. data/vendor/libgit2/src/config.c +34 -47
  197. data/vendor/libgit2/src/config.h +7 -6
  198. data/vendor/libgit2/src/config_backend.h +12 -0
  199. data/vendor/libgit2/src/config_cache.c +39 -39
  200. data/vendor/libgit2/src/config_entries.c +76 -98
  201. data/vendor/libgit2/src/config_entries.h +1 -0
  202. data/vendor/libgit2/src/config_file.c +346 -380
  203. data/vendor/libgit2/src/config_mem.c +12 -16
  204. data/vendor/libgit2/src/config_parse.c +50 -30
  205. data/vendor/libgit2/src/config_parse.h +13 -12
  206. data/vendor/libgit2/src/config_snapshot.c +207 -0
  207. data/vendor/libgit2/src/crlf.c +14 -14
  208. data/vendor/libgit2/src/describe.c +26 -21
  209. data/vendor/libgit2/src/diff.c +53 -67
  210. data/vendor/libgit2/src/diff.h +4 -3
  211. data/vendor/libgit2/src/diff_driver.c +37 -38
  212. data/vendor/libgit2/src/diff_file.c +15 -11
  213. data/vendor/libgit2/src/diff_file.h +2 -2
  214. data/vendor/libgit2/src/diff_generate.c +158 -109
  215. data/vendor/libgit2/src/diff_generate.h +2 -2
  216. data/vendor/libgit2/src/diff_parse.c +3 -4
  217. data/vendor/libgit2/src/diff_print.c +86 -71
  218. data/vendor/libgit2/src/diff_stats.c +13 -12
  219. data/vendor/libgit2/src/diff_tform.c +13 -14
  220. data/vendor/libgit2/src/errors.c +23 -25
  221. data/vendor/libgit2/src/errors.h +81 -0
  222. data/vendor/libgit2/src/features.h.in +9 -2
  223. data/vendor/libgit2/src/fetch.c +9 -2
  224. data/vendor/libgit2/src/fetchhead.c +36 -4
  225. data/vendor/libgit2/src/filebuf.c +6 -10
  226. data/vendor/libgit2/src/filebuf.h +2 -2
  227. data/vendor/libgit2/src/filter.c +19 -11
  228. data/vendor/libgit2/src/{fileops.c → futils.c} +24 -20
  229. data/vendor/libgit2/src/{fileops.h → futils.h} +8 -8
  230. data/vendor/libgit2/src/global.c +15 -41
  231. data/vendor/libgit2/src/global.h +0 -2
  232. data/vendor/libgit2/src/hash.c +61 -0
  233. data/vendor/libgit2/src/hash.h +19 -21
  234. data/vendor/libgit2/src/hash/sha1.h +38 -0
  235. data/vendor/libgit2/src/hash/{hash_collisiondetect.h → sha1/collisiondetect.c} +14 -17
  236. data/vendor/libgit2/src/{sha1_lookup.h → hash/sha1/collisiondetect.h} +8 -8
  237. data/vendor/libgit2/src/hash/{hash_common_crypto.h → sha1/common_crypto.c} +15 -19
  238. data/vendor/libgit2/src/hash/sha1/common_crypto.h +19 -0
  239. data/vendor/libgit2/src/hash/{hash_generic.c → sha1/generic.c} +22 -10
  240. data/vendor/libgit2/src/hash/{hash_generic.h → sha1/generic.h} +4 -14
  241. data/vendor/libgit2/src/hash/{hash_mbedtls.c → sha1/mbedtls.c} +15 -7
  242. data/vendor/libgit2/src/hash/{hash_mbedtls.h → sha1/mbedtls.h} +6 -11
  243. data/vendor/libgit2/src/hash/{hash_openssl.h → sha1/openssl.c} +14 -18
  244. data/vendor/libgit2/src/{refdb_fs.h → hash/sha1/openssl.h} +8 -8
  245. data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/sha1.c +14 -3
  246. data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/sha1.h +0 -0
  247. data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/ubc_check.c +0 -0
  248. data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/ubc_check.h +0 -0
  249. data/vendor/libgit2/src/hash/{hash_win32.c → sha1/win32.c} +34 -24
  250. data/vendor/libgit2/src/hash/{hash_win32.h → sha1/win32.h} +6 -19
  251. data/vendor/libgit2/src/hashsig.c +1 -1
  252. data/vendor/libgit2/src/idxmap.c +73 -69
  253. data/vendor/libgit2/src/idxmap.h +151 -15
  254. data/vendor/libgit2/src/ignore.c +32 -38
  255. data/vendor/libgit2/src/index.c +117 -90
  256. data/vendor/libgit2/src/index.h +1 -1
  257. data/vendor/libgit2/src/indexer.c +80 -75
  258. data/vendor/libgit2/src/integer.h +39 -4
  259. data/vendor/libgit2/src/iterator.c +44 -39
  260. data/vendor/libgit2/src/iterator.h +8 -8
  261. data/vendor/libgit2/src/map.h +1 -1
  262. data/vendor/libgit2/src/merge.c +91 -58
  263. data/vendor/libgit2/src/merge.h +2 -2
  264. data/vendor/libgit2/src/merge_driver.c +5 -5
  265. data/vendor/libgit2/src/merge_file.c +5 -7
  266. data/vendor/libgit2/src/midx.c +418 -0
  267. data/vendor/libgit2/src/midx.h +83 -0
  268. data/vendor/libgit2/src/mwindow.c +142 -74
  269. data/vendor/libgit2/src/mwindow.h +4 -4
  270. data/vendor/libgit2/src/net.c +416 -0
  271. data/vendor/libgit2/src/net.h +57 -0
  272. data/vendor/libgit2/src/netops.c +6 -193
  273. data/vendor/libgit2/src/netops.h +1 -34
  274. data/vendor/libgit2/src/notes.c +8 -5
  275. data/vendor/libgit2/src/object.c +5 -4
  276. data/vendor/libgit2/src/object.h +2 -0
  277. data/vendor/libgit2/src/odb.c +50 -29
  278. data/vendor/libgit2/src/odb.h +3 -2
  279. data/vendor/libgit2/src/odb_loose.c +20 -13
  280. data/vendor/libgit2/src/odb_mempack.c +15 -24
  281. data/vendor/libgit2/src/odb_pack.c +4 -5
  282. data/vendor/libgit2/src/offmap.c +43 -55
  283. data/vendor/libgit2/src/offmap.h +102 -24
  284. data/vendor/libgit2/src/oid.c +21 -8
  285. data/vendor/libgit2/src/oidmap.c +39 -57
  286. data/vendor/libgit2/src/oidmap.h +99 -19
  287. data/vendor/libgit2/src/pack-objects.c +55 -52
  288. data/vendor/libgit2/src/pack-objects.h +1 -1
  289. data/vendor/libgit2/src/pack.c +154 -147
  290. data/vendor/libgit2/src/pack.h +32 -18
  291. data/vendor/libgit2/src/parse.c +10 -0
  292. data/vendor/libgit2/src/parse.h +3 -3
  293. data/vendor/libgit2/src/patch.c +1 -1
  294. data/vendor/libgit2/src/patch_generate.c +3 -5
  295. data/vendor/libgit2/src/patch_parse.c +134 -35
  296. data/vendor/libgit2/src/path.c +47 -10
  297. data/vendor/libgit2/src/path.h +2 -0
  298. data/vendor/libgit2/src/pathspec.c +18 -17
  299. data/vendor/libgit2/src/pool.c +42 -32
  300. data/vendor/libgit2/src/pool.h +15 -7
  301. data/vendor/libgit2/src/posix.c +7 -7
  302. data/vendor/libgit2/src/posix.h +12 -1
  303. data/vendor/libgit2/src/proxy.c +9 -2
  304. data/vendor/libgit2/src/push.c +15 -7
  305. data/vendor/libgit2/src/reader.c +2 -2
  306. data/vendor/libgit2/src/rebase.c +89 -28
  307. data/vendor/libgit2/src/refdb.c +147 -0
  308. data/vendor/libgit2/src/refdb.h +69 -0
  309. data/vendor/libgit2/src/refdb_fs.c +230 -240
  310. data/vendor/libgit2/src/reflog.c +13 -19
  311. data/vendor/libgit2/src/refs.c +98 -210
  312. data/vendor/libgit2/src/refs.h +9 -20
  313. data/vendor/libgit2/src/refspec.c +9 -16
  314. data/vendor/libgit2/src/regexp.c +221 -0
  315. data/vendor/libgit2/src/regexp.h +97 -0
  316. data/vendor/libgit2/src/remote.c +89 -72
  317. data/vendor/libgit2/src/remote.h +2 -2
  318. data/vendor/libgit2/src/repository.c +317 -195
  319. data/vendor/libgit2/src/repository.h +49 -57
  320. data/vendor/libgit2/src/revert.c +10 -3
  321. data/vendor/libgit2/src/revparse.c +23 -23
  322. data/vendor/libgit2/src/revwalk.c +73 -37
  323. data/vendor/libgit2/src/revwalk.h +20 -0
  324. data/vendor/libgit2/src/settings.c +22 -1
  325. data/vendor/libgit2/src/sortedcache.c +14 -29
  326. data/vendor/libgit2/src/sortedcache.h +1 -1
  327. data/vendor/libgit2/src/stash.c +49 -67
  328. data/vendor/libgit2/src/status.c +19 -11
  329. data/vendor/libgit2/src/strarray.c +63 -0
  330. data/vendor/libgit2/src/streams/openssl.c +66 -8
  331. data/vendor/libgit2/src/streams/registry.c +5 -3
  332. data/vendor/libgit2/src/streams/socket.c +2 -2
  333. data/vendor/libgit2/src/strmap.c +37 -84
  334. data/vendor/libgit2/src/strmap.h +105 -33
  335. data/vendor/libgit2/src/submodule.c +157 -130
  336. data/vendor/libgit2/src/submodule.h +1 -1
  337. data/vendor/libgit2/src/sysdir.c +15 -21
  338. data/vendor/libgit2/src/sysdir.h +0 -11
  339. data/vendor/libgit2/src/tag.c +12 -2
  340. data/vendor/libgit2/src/thread-utils.h +139 -21
  341. data/vendor/libgit2/src/trace.c +1 -1
  342. data/vendor/libgit2/src/trace.h +3 -3
  343. data/vendor/libgit2/src/trailer.c +46 -32
  344. data/vendor/libgit2/src/transaction.c +12 -10
  345. data/vendor/libgit2/src/transports/auth.c +16 -15
  346. data/vendor/libgit2/src/transports/auth.h +18 -11
  347. data/vendor/libgit2/src/transports/auth_negotiate.c +64 -33
  348. data/vendor/libgit2/src/transports/auth_negotiate.h +2 -2
  349. data/vendor/libgit2/src/transports/auth_ntlm.c +223 -0
  350. data/vendor/libgit2/src/transports/auth_ntlm.h +38 -0
  351. data/vendor/libgit2/src/transports/credential.c +478 -0
  352. data/vendor/libgit2/src/transports/{cred_helpers.c → credential_helpers.c} +23 -8
  353. data/vendor/libgit2/src/transports/git.c +11 -16
  354. data/vendor/libgit2/src/transports/http.c +488 -1248
  355. data/vendor/libgit2/src/transports/http.h +4 -1
  356. data/vendor/libgit2/src/transports/httpclient.c +1547 -0
  357. data/vendor/libgit2/src/transports/httpclient.h +190 -0
  358. data/vendor/libgit2/src/transports/local.c +12 -12
  359. data/vendor/libgit2/src/transports/smart.c +21 -21
  360. data/vendor/libgit2/src/transports/smart.h +3 -3
  361. data/vendor/libgit2/src/transports/smart_pkt.c +1 -1
  362. data/vendor/libgit2/src/transports/smart_protocol.c +40 -64
  363. data/vendor/libgit2/src/transports/ssh.c +77 -59
  364. data/vendor/libgit2/src/transports/winhttp.c +290 -249
  365. data/vendor/libgit2/src/tree-cache.c +14 -7
  366. data/vendor/libgit2/src/tree.c +16 -26
  367. data/vendor/libgit2/src/unix/map.c +1 -1
  368. data/vendor/libgit2/src/unix/posix.h +15 -13
  369. data/vendor/libgit2/src/userdiff.h +3 -1
  370. data/vendor/libgit2/src/util.c +75 -110
  371. data/vendor/libgit2/src/util.h +18 -23
  372. data/vendor/libgit2/src/wildmatch.c +320 -0
  373. data/vendor/libgit2/src/wildmatch.h +23 -0
  374. data/vendor/libgit2/src/win32/git2.rc +18 -3
  375. data/vendor/libgit2/src/win32/map.c +3 -5
  376. data/vendor/libgit2/src/win32/path_w32.c +42 -5
  377. data/vendor/libgit2/src/win32/path_w32.h +15 -29
  378. data/vendor/libgit2/src/win32/posix.h +1 -4
  379. data/vendor/libgit2/src/win32/posix_w32.c +47 -5
  380. data/vendor/libgit2/src/win32/precompiled.h +0 -2
  381. data/vendor/libgit2/src/win32/thread.c +5 -10
  382. data/vendor/libgit2/src/win32/w32_buffer.c +7 -3
  383. data/vendor/libgit2/src/win32/w32_common.h +39 -0
  384. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +0 -93
  385. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +0 -2
  386. data/vendor/libgit2/src/win32/w32_stack.c +4 -9
  387. data/vendor/libgit2/src/win32/w32_stack.h +3 -3
  388. data/vendor/libgit2/src/win32/w32_util.c +31 -0
  389. data/vendor/libgit2/src/win32/w32_util.h +6 -32
  390. data/vendor/libgit2/src/worktree.c +83 -49
  391. data/vendor/libgit2/src/xdiff/xdiffi.c +1 -1
  392. data/vendor/libgit2/src/xdiff/xmerge.c +12 -0
  393. data/vendor/libgit2/src/xdiff/xpatience.c +3 -0
  394. data/vendor/libgit2/src/zstream.c +5 -0
  395. data/vendor/libgit2/src/zstream.h +1 -0
  396. metadata +124 -55
  397. data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.c.in +0 -29
  398. data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.cmake +0 -96
  399. data/vendor/libgit2/deps/regex/CMakeLists.txt +0 -2
  400. data/vendor/libgit2/deps/regex/COPYING +0 -502
  401. data/vendor/libgit2/deps/regex/config.h +0 -7
  402. data/vendor/libgit2/deps/regex/regcomp.c +0 -3857
  403. data/vendor/libgit2/deps/regex/regex.c +0 -92
  404. data/vendor/libgit2/deps/regex/regex.h +0 -582
  405. data/vendor/libgit2/deps/regex/regex_internal.c +0 -1744
  406. data/vendor/libgit2/deps/regex/regex_internal.h +0 -819
  407. data/vendor/libgit2/deps/regex/regexec.c +0 -4369
  408. data/vendor/libgit2/include/git2/inttypes.h +0 -309
  409. data/vendor/libgit2/include/git2/sys/time.h +0 -31
  410. data/vendor/libgit2/libgit2.pc.in +0 -13
  411. data/vendor/libgit2/src/fnmatch.c +0 -248
  412. data/vendor/libgit2/src/fnmatch.h +0 -48
  413. data/vendor/libgit2/src/sha1_lookup.c +0 -35
  414. 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;
@@ -410,7 +411,8 @@ int git_index_open(git_index **index_out, const char *index_path)
410
411
  index = git__calloc(1, sizeof(git_index));
411
412
  GIT_ERROR_CHECK_ALLOC(index);
412
413
 
413
- git_pool_init(&index->tree_pool, 1);
414
+ if (git_pool_init(&index->tree_pool, 1) < 0)
415
+ goto fail;
414
416
 
415
417
  if (index_path != NULL) {
416
418
  index->index_file_path = git__strdup(index_path);
@@ -423,10 +425,10 @@ int git_index_open(git_index **index_out, const char *index_path)
423
425
  }
424
426
 
425
427
  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)
428
+ git_idxmap_new(&index->entries_map) < 0 ||
429
+ git_vector_init(&index->names, 8, conflict_name_cmp) < 0 ||
430
+ git_vector_init(&index->reuc, 8, reuc_cmp) < 0 ||
431
+ git_vector_init(&index->deleted, 8, git_index_entry_cmp) < 0)
430
432
  goto fail;
431
433
 
432
434
  index->entries_cmp_path = git__strcmp_cb;
@@ -507,7 +509,7 @@ static int index_remove_entry(git_index *index, size_t pos)
507
509
 
508
510
  if (entry != NULL) {
509
511
  git_tree_cache_invalidate_path(index->tree, entry->path);
510
- DELETE_IN_MAP(index, entry);
512
+ index_map_delete(index->entries_map, entry, index->ignore_case);
511
513
  }
512
514
 
513
515
  error = git_vector_remove(&index->entries, pos);
@@ -538,13 +540,19 @@ int git_index_clear(git_index *index)
538
540
  git_idxmap_clear(index->entries_map);
539
541
  while (!error && index->entries.length > 0)
540
542
  error = index_remove_entry(index, index->entries.length - 1);
543
+
544
+ if (error)
545
+ goto done;
546
+
541
547
  index_free_deleted(index);
542
548
 
543
- git_index_reuc_clear(index);
544
- git_index_name_clear(index);
549
+ if ((error = git_index_name_clear(index)) < 0 ||
550
+ (error = git_index_reuc_clear(index)) < 0)
551
+ goto done;
545
552
 
546
553
  git_futils_filestamp_set(&index->stamp, NULL);
547
554
 
555
+ done:
548
556
  return error;
549
557
  }
550
558
 
@@ -570,11 +578,11 @@ int git_index_set_caps(git_index *index, int caps)
570
578
  return create_index_error(
571
579
  -1, "cannot access repository to set index caps");
572
580
 
573
- if (!git_repository__cvar(&val, repo, GIT_CVAR_IGNORECASE))
581
+ if (!git_repository__configmap_lookup(&val, repo, GIT_CONFIGMAP_IGNORECASE))
574
582
  index->ignore_case = (val != 0);
575
- if (!git_repository__cvar(&val, repo, GIT_CVAR_FILEMODE))
583
+ if (!git_repository__configmap_lookup(&val, repo, GIT_CONFIGMAP_FILEMODE))
576
584
  index->distrust_filemode = (val == 0);
577
- if (!git_repository__cvar(&val, repo, GIT_CVAR_SYMLINKS))
585
+ if (!git_repository__configmap_lookup(&val, repo, GIT_CONFIGMAP_SYMLINKS))
578
586
  index->no_symlinks = (val == 0);
579
587
  }
580
588
  else {
@@ -852,20 +860,24 @@ const git_index_entry *git_index_get_bypath(
852
860
  git_index *index, const char *path, int stage)
853
861
  {
854
862
  git_index_entry key = {{ 0 }};
855
- size_t pos;
863
+ git_index_entry *value;
856
864
 
857
865
  assert(index);
858
866
 
859
867
  key.path = path;
860
868
  GIT_INDEX_ENTRY_STAGE_SET(&key, stage);
861
869
 
862
- LOOKUP_IN_MAP(pos, index, &key);
870
+ if (index->ignore_case)
871
+ value = git_idxmap_icase_get((git_idxmap_icase *) index->entries_map, &key);
872
+ else
873
+ value = git_idxmap_get(index->entries_map, &key);
863
874
 
864
- if (git_idxmap_valid_index(index->entries_map, pos))
865
- return git_idxmap_value_at(index->entries_map, pos);
875
+ if (!value) {
876
+ git_error_set(GIT_ERROR_INDEX, "index does not contain '%s'", path);
877
+ return NULL;
878
+ }
866
879
 
867
- git_error_set(GIT_ERROR_INDEX, "index does not contain '%s'", path);
868
- return NULL;
880
+ return value;
869
881
  }
870
882
 
871
883
  void git_index_entry__init_from_stat(
@@ -1398,10 +1410,9 @@ static int index_insert(
1398
1410
  * at the sorted position. (Since we re-sort after each insert to
1399
1411
  * check for dups, this is actually cheaper in the long run.)
1400
1412
  */
1401
- if ((error = git_vector_insert_sorted(&index->entries, entry, index_no_dups)) < 0)
1413
+ if ((error = git_vector_insert_sorted(&index->entries, entry, index_no_dups)) < 0 ||
1414
+ (error = index_map_set(index->entries_map, entry, index->ignore_case)) < 0)
1402
1415
  goto out;
1403
-
1404
- INSERT_IN_MAP(index, entry, &error);
1405
1416
  }
1406
1417
 
1407
1418
  index->dirty = 1;
@@ -1453,7 +1464,7 @@ GIT_INLINE(bool) valid_filemode(const int filemode)
1453
1464
  return (is_file_or_link(filemode) || filemode == GIT_FILEMODE_COMMIT);
1454
1465
  }
1455
1466
 
1456
- int git_index_add_frombuffer(
1467
+ int git_index_add_from_buffer(
1457
1468
  git_index *index, const git_index_entry *source_entry,
1458
1469
  const void *buffer, size_t len)
1459
1470
  {
@@ -1473,17 +1484,22 @@ int git_index_add_frombuffer(
1473
1484
  return -1;
1474
1485
  }
1475
1486
 
1487
+ if (len > UINT32_MAX) {
1488
+ git_error_set(GIT_ERROR_INDEX, "buffer is too large");
1489
+ return -1;
1490
+ }
1491
+
1476
1492
  if (index_entry_dup(&entry, index, source_entry) < 0)
1477
1493
  return -1;
1478
1494
 
1479
- error = git_blob_create_frombuffer(&id, INDEX_OWNER(index), buffer, len);
1495
+ error = git_blob_create_from_buffer(&id, INDEX_OWNER(index), buffer, len);
1480
1496
  if (error < 0) {
1481
1497
  index_entry_free(entry);
1482
1498
  return error;
1483
1499
  }
1484
1500
 
1485
1501
  git_oid_cpy(&entry->id, &id);
1486
- entry->file_size = len;
1502
+ entry->file_size = (uint32_t)len;
1487
1503
 
1488
1504
  if ((error = index_insert(index, &entry, 1, true, true, true)) < 0)
1489
1505
  return error;
@@ -1610,41 +1626,42 @@ int git_index_remove_bypath(git_index *index, const char *path)
1610
1626
  int git_index__fill(git_index *index, const git_vector *source_entries)
1611
1627
  {
1612
1628
  const git_index_entry *source_entry = NULL;
1629
+ int error = 0;
1613
1630
  size_t i;
1614
- int ret = 0;
1615
1631
 
1616
1632
  assert(index);
1617
1633
 
1618
1634
  if (!source_entries->length)
1619
1635
  return 0;
1620
1636
 
1621
- git_vector_size_hint(&index->entries, source_entries->length);
1622
- git_idxmap_resize(index->entries_map, (size_t)(source_entries->length * 1.3));
1637
+ if (git_vector_size_hint(&index->entries, source_entries->length) < 0 ||
1638
+ index_map_resize(index->entries_map, (size_t)(source_entries->length * 1.3),
1639
+ index->ignore_case) < 0)
1640
+ return -1;
1623
1641
 
1624
1642
  git_vector_foreach(source_entries, i, source_entry) {
1625
1643
  git_index_entry *entry = NULL;
1626
1644
 
1627
- if ((ret = index_entry_dup(&entry, index, source_entry)) < 0)
1645
+ if ((error = index_entry_dup(&entry, index, source_entry)) < 0)
1628
1646
  break;
1629
1647
 
1630
1648
  index_entry_adjust_namemask(entry, ((struct entry_internal *)entry)->pathlen);
1631
1649
  entry->flags_extended |= GIT_INDEX_ENTRY_UPTODATE;
1632
1650
  entry->mode = git_index__create_mode(entry->mode);
1633
1651
 
1634
- if ((ret = git_vector_insert(&index->entries, entry)) < 0)
1652
+ if ((error = git_vector_insert(&index->entries, entry)) < 0)
1635
1653
  break;
1636
1654
 
1637
- INSERT_IN_MAP(index, entry, &ret);
1638
- if (ret < 0)
1655
+ if ((error = index_map_set(index->entries_map, entry, index->ignore_case)) < 0)
1639
1656
  break;
1640
1657
 
1641
1658
  index->dirty = 1;
1642
1659
  }
1643
1660
 
1644
- if (!ret)
1661
+ if (!error)
1645
1662
  git_vector_sort(&index->entries);
1646
1663
 
1647
- return ret;
1664
+ return error;
1648
1665
  }
1649
1666
 
1650
1667
 
@@ -1677,7 +1694,7 @@ int git_index_remove(git_index *index, const char *path, int stage)
1677
1694
  remove_key.path = path;
1678
1695
  GIT_INDEX_ENTRY_STAGE_SET(&remove_key, stage);
1679
1696
 
1680
- DELETE_IN_MAP(index, &remove_key);
1697
+ index_map_delete(index->entries_map, &remove_key, index->ignore_case);
1681
1698
 
1682
1699
  if (index_find(&position, index, path, 0, stage) < 0) {
1683
1700
  git_error_set(
@@ -2126,7 +2143,7 @@ int git_index_name_add(git_index *index,
2126
2143
  return 0;
2127
2144
  }
2128
2145
 
2129
- void git_index_name_clear(git_index *index)
2146
+ int git_index_name_clear(git_index *index)
2130
2147
  {
2131
2148
  size_t i;
2132
2149
  git_index_name_entry *conflict_name;
@@ -2139,6 +2156,8 @@ void git_index_name_clear(git_index *index)
2139
2156
  git_vector_clear(&index->names);
2140
2157
 
2141
2158
  index->dirty = 1;
2159
+
2160
+ return 0;
2142
2161
  }
2143
2162
 
2144
2163
  size_t git_index_reuc_entrycount(git_index *index)
@@ -2235,7 +2254,7 @@ int git_index_reuc_remove(git_index *index, size_t position)
2235
2254
  return error;
2236
2255
  }
2237
2256
 
2238
- void git_index_reuc_clear(git_index *index)
2257
+ int git_index_reuc_clear(git_index *index)
2239
2258
  {
2240
2259
  size_t i;
2241
2260
 
@@ -2247,6 +2266,8 @@ void git_index_reuc_clear(git_index *index)
2247
2266
  git_vector_clear(&index->reuc);
2248
2267
 
2249
2268
  index->dirty = 1;
2269
+
2270
+ return 0;
2250
2271
  }
2251
2272
 
2252
2273
  static int index_error_invalid(const char *message)
@@ -2607,10 +2628,8 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
2607
2628
 
2608
2629
  assert(!index->entries.length);
2609
2630
 
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);
2631
+ if ((error = index_map_resize(index->entries_map, header.entry_count, index->ignore_case)) < 0)
2632
+ return error;
2614
2633
 
2615
2634
  /* Parse all the entries */
2616
2635
  for (i = 0; i < header.entry_count && buffer_size > INDEX_FOOTER_SIZE; ++i) {
@@ -2627,9 +2646,7 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
2627
2646
  goto done;
2628
2647
  }
2629
2648
 
2630
- INSERT_IN_MAP(index, entry, &error);
2631
-
2632
- if (error < 0) {
2649
+ if ((error = index_map_set(index->entries_map, entry, index->ignore_case)) < 0) {
2633
2650
  index_entry_free(entry);
2634
2651
  goto done;
2635
2652
  }
@@ -2728,7 +2745,7 @@ static int write_disk_entry(git_filebuf *file, git_index_entry *entry, const cha
2728
2745
  ++same_len;
2729
2746
  }
2730
2747
  path_len -= same_len;
2731
- varint_len = git_encode_varint(NULL, 0, same_len);
2748
+ varint_len = git_encode_varint(NULL, 0, strlen(last) - same_len);
2732
2749
  }
2733
2750
 
2734
2751
  disk_size = index_entry_size(path_len, varint_len, entry->flags);
@@ -2764,22 +2781,24 @@ static int write_disk_entry(git_filebuf *file, git_index_entry *entry, const cha
2764
2781
  ondisk.flags = htons(entry->flags);
2765
2782
 
2766
2783
  if (entry->flags & GIT_INDEX_ENTRY_EXTENDED) {
2784
+ const size_t path_offset = offsetof(struct entry_long, path);
2767
2785
  struct entry_long ondisk_ext;
2768
2786
  memcpy(&ondisk_ext, &ondisk, sizeof(struct entry_short));
2769
2787
  ondisk_ext.flags_extended = htons(entry->flags_extended &
2770
2788
  GIT_INDEX_ENTRY_EXTENDED_FLAGS);
2771
- memcpy(mem, &ondisk_ext, offsetof(struct entry_long, path));
2772
- path = ((struct entry_long*)mem)->path;
2773
- disk_size -= offsetof(struct entry_long, path);
2789
+ memcpy(mem, &ondisk_ext, path_offset);
2790
+ path = (char *)mem + path_offset;
2791
+ disk_size -= path_offset;
2774
2792
  } else {
2775
- memcpy(mem, &ondisk, offsetof(struct entry_short, path));
2776
- path = ((struct entry_short*)mem)->path;
2777
- disk_size -= offsetof(struct entry_short, path);
2793
+ const size_t path_offset = offsetof(struct entry_short, path);
2794
+ memcpy(mem, &ondisk, path_offset);
2795
+ path = (char *)mem + path_offset;
2796
+ disk_size -= path_offset;
2778
2797
  }
2779
2798
 
2780
2799
  if (last) {
2781
2800
  varint_len = git_encode_varint((unsigned char *) path,
2782
- disk_size, same_len);
2801
+ disk_size, strlen(last) - same_len);
2783
2802
  assert(varint_len > 0);
2784
2803
  path += varint_len;
2785
2804
  disk_size -= varint_len;
@@ -3106,7 +3125,7 @@ int git_index_read_tree(git_index *index, const git_tree *tree)
3106
3125
  size_t i;
3107
3126
  git_index_entry *e;
3108
3127
 
3109
- if (git_idxmap_alloc(&entries_map) < 0)
3128
+ if (git_idxmap_new(&entries_map) < 0)
3110
3129
  return -1;
3111
3130
 
3112
3131
  git_vector_set_cmp(&entries, index->entries._cmp); /* match sort */
@@ -3124,15 +3143,11 @@ int git_index_read_tree(git_index *index, const git_tree *tree)
3124
3143
  if ((error = git_tree_walk(tree, GIT_TREEWALK_POST, read_tree_cb, &data)) < 0)
3125
3144
  goto cleanup;
3126
3145
 
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);
3146
+ if ((error = index_map_resize(entries_map, entries.length, index->ignore_case)) < 0)
3147
+ goto cleanup;
3131
3148
 
3132
3149
  git_vector_foreach(&entries, i, e) {
3133
- INSERT_IN_MAP_EX(index, entries_map, e, &error);
3134
-
3135
- if (error < 0) {
3150
+ if ((error = index_map_set(entries_map, e, index->ignore_case)) < 0) {
3136
3151
  git_error_set(GIT_ERROR_INDEX, "failed to insert entry into map");
3137
3152
  return error;
3138
3153
  }
@@ -3180,14 +3195,13 @@ static int git_index_read_iterator(
3180
3195
  assert((new_iterator->flags & GIT_ITERATOR_DONT_IGNORE_CASE));
3181
3196
 
3182
3197
  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)
3198
+ (error = git_vector_init(&remove_entries, index->entries.length, NULL)) < 0 ||
3199
+ (error = git_idxmap_new(&new_entries_map)) < 0)
3185
3200
  goto done;
3186
3201
 
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);
3202
+ if (new_length_hint && (error = index_map_resize(new_entries_map, new_length_hint,
3203
+ index->ignore_case)) < 0)
3204
+ goto done;
3191
3205
 
3192
3206
  opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE |
3193
3207
  GIT_ITERATOR_INCLUDE_CONFLICTS;
@@ -3251,7 +3265,8 @@ static int git_index_read_iterator(
3251
3265
 
3252
3266
  if (add_entry) {
3253
3267
  if ((error = git_vector_insert(&new_entries, add_entry)) == 0)
3254
- INSERT_IN_MAP_EX(index, new_entries_map, add_entry, &error);
3268
+ error = index_map_set(new_entries_map, add_entry,
3269
+ index->ignore_case);
3255
3270
  }
3256
3271
 
3257
3272
  if (remove_entry && error >= 0)
@@ -3275,8 +3290,9 @@ static int git_index_read_iterator(
3275
3290
  }
3276
3291
  }
3277
3292
 
3278
- git_index_name_clear(index);
3279
- git_index_reuc_clear(index);
3293
+ if ((error = git_index_name_clear(index)) < 0 ||
3294
+ (error = git_index_reuc_clear(index)) < 0)
3295
+ goto done;
3280
3296
 
3281
3297
  git_vector_swap(&new_entries, &index->entries);
3282
3298
  new_entries_map = git__swap(index->entries_map, new_entries_map);
@@ -3700,3 +3716,14 @@ void git_indexwriter_cleanup(git_indexwriter *writer)
3700
3716
  git_index_free(writer->index);
3701
3717
  writer->index = NULL;
3702
3718
  }
3719
+
3720
+ /* Deprecated functions */
3721
+
3722
+ #ifndef GIT_DEPRECATE_HARD
3723
+ int git_index_add_frombuffer(
3724
+ git_index *index, const git_index_entry *source_entry,
3725
+ const void *buffer, size_t len)
3726
+ {
3727
+ return git_index_add_from_buffer(index, source_entry, buffer, len);
3728
+ }
3729
+ #endif