rugged 0.27.10.1 → 0.28.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (297) hide show
  1. checksums.yaml +4 -4
  2. data/ext/rugged/extconf.rb +23 -2
  3. data/ext/rugged/rugged.c +48 -2
  4. data/ext/rugged/rugged.h +5 -0
  5. data/ext/rugged/rugged_allocator.c +89 -0
  6. data/ext/rugged/rugged_blob.c +3 -3
  7. data/ext/rugged/rugged_branch.c +1 -1
  8. data/ext/rugged/rugged_commit.c +8 -8
  9. data/ext/rugged/rugged_config.c +1 -1
  10. data/ext/rugged/rugged_diff.c +24 -4
  11. data/ext/rugged/rugged_note.c +1 -1
  12. data/ext/rugged/rugged_repo.c +10 -10
  13. data/ext/rugged/rugged_settings.c +1 -1
  14. data/lib/rugged/version.rb +1 -1
  15. data/vendor/libgit2/CMakeLists.txt +69 -47
  16. data/vendor/libgit2/cmake/Modules/AddCFlagIfSupported.cmake +15 -1
  17. data/vendor/libgit2/cmake/Modules/EnableWarnings.cmake +5 -8
  18. data/vendor/libgit2/cmake/Modules/FindmbedTLS.cmake +93 -0
  19. data/vendor/libgit2/deps/http-parser/CMakeLists.txt +2 -0
  20. data/vendor/libgit2/deps/http-parser/{LICENSE-MIT → COPYING} +0 -0
  21. data/vendor/libgit2/deps/regex/COPYING +502 -0
  22. data/vendor/libgit2/deps/winhttp/COPYING.GPL +993 -0
  23. data/vendor/libgit2/deps/winhttp/COPYING.LGPL +502 -0
  24. data/vendor/libgit2/deps/zlib/CMakeLists.txt +1 -0
  25. data/vendor/libgit2/deps/zlib/COPYING +27 -0
  26. data/vendor/libgit2/include/git2.h +3 -0
  27. data/vendor/libgit2/include/git2/annotated_commit.h +9 -0
  28. data/vendor/libgit2/include/git2/apply.h +129 -0
  29. data/vendor/libgit2/include/git2/attr.h +19 -8
  30. data/vendor/libgit2/include/git2/blame.h +41 -24
  31. data/vendor/libgit2/include/git2/blob.h +1 -1
  32. data/vendor/libgit2/include/git2/branch.h +1 -1
  33. data/vendor/libgit2/include/git2/buffer.h +2 -2
  34. data/vendor/libgit2/include/git2/checkout.h +20 -19
  35. data/vendor/libgit2/include/git2/cherrypick.h +6 -4
  36. data/vendor/libgit2/include/git2/clone.h +11 -9
  37. data/vendor/libgit2/include/git2/commit.h +30 -2
  38. data/vendor/libgit2/include/git2/common.h +54 -4
  39. data/vendor/libgit2/include/git2/config.h +18 -7
  40. data/vendor/libgit2/include/git2/deprecated.h +253 -0
  41. data/vendor/libgit2/include/git2/describe.h +30 -7
  42. data/vendor/libgit2/include/git2/diff.h +193 -143
  43. data/vendor/libgit2/include/git2/errors.h +54 -46
  44. data/vendor/libgit2/include/git2/ignore.h +2 -2
  45. data/vendor/libgit2/include/git2/index.h +72 -51
  46. data/vendor/libgit2/include/git2/indexer.h +30 -4
  47. data/vendor/libgit2/include/git2/mailmap.h +115 -0
  48. data/vendor/libgit2/include/git2/merge.h +29 -8
  49. data/vendor/libgit2/include/git2/net.h +1 -1
  50. data/vendor/libgit2/include/git2/notes.h +1 -1
  51. data/vendor/libgit2/include/git2/object.h +16 -16
  52. data/vendor/libgit2/include/git2/odb.h +10 -10
  53. data/vendor/libgit2/include/git2/odb_backend.h +7 -7
  54. data/vendor/libgit2/include/git2/oid.h +1 -1
  55. data/vendor/libgit2/include/git2/pack.h +2 -2
  56. data/vendor/libgit2/include/git2/proxy.h +9 -5
  57. data/vendor/libgit2/include/git2/rebase.h +7 -4
  58. data/vendor/libgit2/include/git2/refs.h +14 -15
  59. data/vendor/libgit2/include/git2/refspec.h +17 -0
  60. data/vendor/libgit2/include/git2/remote.h +92 -16
  61. data/vendor/libgit2/include/git2/repository.h +52 -37
  62. data/vendor/libgit2/include/git2/revert.h +5 -3
  63. data/vendor/libgit2/include/git2/revwalk.h +7 -7
  64. data/vendor/libgit2/include/git2/signature.h +2 -2
  65. data/vendor/libgit2/include/git2/stash.h +13 -10
  66. data/vendor/libgit2/include/git2/status.h +8 -4
  67. data/vendor/libgit2/include/git2/submodule.h +11 -10
  68. data/vendor/libgit2/include/git2/sys/alloc.h +101 -0
  69. data/vendor/libgit2/include/git2/sys/commit.h +1 -1
  70. data/vendor/libgit2/include/git2/sys/config.h +13 -13
  71. data/vendor/libgit2/include/git2/sys/filter.h +6 -6
  72. data/vendor/libgit2/include/git2/sys/index.h +3 -0
  73. data/vendor/libgit2/include/git2/sys/mempack.h +35 -35
  74. data/vendor/libgit2/include/git2/sys/merge.h +9 -4
  75. data/vendor/libgit2/include/git2/sys/odb_backend.h +19 -19
  76. data/vendor/libgit2/include/git2/sys/path.h +64 -0
  77. data/vendor/libgit2/include/git2/sys/refdb_backend.h +19 -19
  78. data/vendor/libgit2/include/git2/sys/stream.h +92 -12
  79. data/vendor/libgit2/include/git2/sys/transport.h +127 -81
  80. data/vendor/libgit2/include/git2/tag.h +2 -2
  81. data/vendor/libgit2/include/git2/trace.h +1 -1
  82. data/vendor/libgit2/include/git2/transaction.h +1 -0
  83. data/vendor/libgit2/include/git2/transport.h +47 -18
  84. data/vendor/libgit2/include/git2/tree.h +3 -3
  85. data/vendor/libgit2/include/git2/types.h +35 -28
  86. data/vendor/libgit2/include/git2/version.h +4 -4
  87. data/vendor/libgit2/include/git2/worktree.h +47 -12
  88. data/vendor/libgit2/src/CMakeLists.txt +87 -26
  89. data/vendor/libgit2/src/alloc.c +55 -0
  90. data/vendor/libgit2/src/alloc.h +40 -0
  91. data/vendor/libgit2/src/annotated_commit.c +15 -8
  92. data/vendor/libgit2/src/apply.c +490 -14
  93. data/vendor/libgit2/src/apply.h +3 -1
  94. data/vendor/libgit2/src/array.h +2 -2
  95. data/vendor/libgit2/src/attr.c +11 -11
  96. data/vendor/libgit2/src/attr_file.c +20 -15
  97. data/vendor/libgit2/src/attrcache.c +11 -11
  98. data/vendor/libgit2/src/blame.c +30 -15
  99. data/vendor/libgit2/src/blame.h +1 -0
  100. data/vendor/libgit2/src/blame_git.c +16 -13
  101. data/vendor/libgit2/src/blob.c +50 -28
  102. data/vendor/libgit2/src/blob.h +18 -1
  103. data/vendor/libgit2/src/branch.c +38 -38
  104. data/vendor/libgit2/src/buf_text.c +7 -6
  105. data/vendor/libgit2/src/buffer.c +55 -50
  106. data/vendor/libgit2/src/buffer.h +1 -1
  107. data/vendor/libgit2/src/cache.c +16 -16
  108. data/vendor/libgit2/src/cache.h +2 -2
  109. data/vendor/libgit2/src/cc-compat.h +15 -3
  110. data/vendor/libgit2/src/checkout.c +83 -74
  111. data/vendor/libgit2/src/cherrypick.c +6 -6
  112. data/vendor/libgit2/src/clone.c +20 -20
  113. data/vendor/libgit2/src/commit.c +53 -33
  114. data/vendor/libgit2/src/commit.h +1 -0
  115. data/vendor/libgit2/src/commit_list.c +6 -10
  116. data/vendor/libgit2/src/common.h +32 -30
  117. data/vendor/libgit2/src/config.c +167 -147
  118. data/vendor/libgit2/src/config.h +1 -14
  119. data/vendor/libgit2/src/config_backend.h +84 -0
  120. data/vendor/libgit2/src/config_cache.c +7 -1
  121. data/vendor/libgit2/src/config_entries.c +259 -0
  122. data/vendor/libgit2/src/config_entries.h +23 -0
  123. data/vendor/libgit2/src/config_file.c +167 -439
  124. data/vendor/libgit2/src/config_mem.c +224 -0
  125. data/vendor/libgit2/src/config_parse.c +69 -38
  126. data/vendor/libgit2/src/config_parse.h +4 -4
  127. data/vendor/libgit2/src/crlf.c +215 -186
  128. data/vendor/libgit2/src/delta.c +25 -18
  129. data/vendor/libgit2/src/describe.c +23 -23
  130. data/vendor/libgit2/src/diff.c +12 -12
  131. data/vendor/libgit2/src/diff_driver.c +14 -15
  132. data/vendor/libgit2/src/diff_file.c +10 -10
  133. data/vendor/libgit2/src/diff_generate.c +29 -23
  134. data/vendor/libgit2/src/diff_generate.h +1 -1
  135. data/vendor/libgit2/src/diff_parse.c +3 -3
  136. data/vendor/libgit2/src/diff_print.c +17 -17
  137. data/vendor/libgit2/src/diff_stats.c +22 -7
  138. data/vendor/libgit2/src/diff_tform.c +12 -12
  139. data/vendor/libgit2/src/diff_xdiff.c +15 -3
  140. data/vendor/libgit2/src/errors.c +42 -20
  141. data/vendor/libgit2/src/features.h.in +2 -1
  142. data/vendor/libgit2/src/fetch.c +3 -3
  143. data/vendor/libgit2/src/fetchhead.c +16 -16
  144. data/vendor/libgit2/src/filebuf.c +28 -28
  145. data/vendor/libgit2/src/fileops.c +54 -54
  146. data/vendor/libgit2/src/fileops.h +1 -1
  147. data/vendor/libgit2/src/filter.c +30 -30
  148. data/vendor/libgit2/src/filter.h +0 -10
  149. data/vendor/libgit2/src/global.c +36 -23
  150. data/vendor/libgit2/src/hash.h +4 -1
  151. data/vendor/libgit2/src/hash/hash_collisiondetect.h +6 -2
  152. data/vendor/libgit2/src/hash/hash_common_crypto.h +5 -1
  153. data/vendor/libgit2/src/hash/hash_generic.h +5 -1
  154. data/vendor/libgit2/src/hash/hash_mbedtls.c +38 -0
  155. data/vendor/libgit2/src/hash/hash_mbedtls.h +24 -0
  156. data/vendor/libgit2/src/hash/hash_openssl.h +8 -4
  157. data/vendor/libgit2/src/hash/hash_win32.c +13 -13
  158. data/vendor/libgit2/src/hashsig.c +4 -4
  159. data/vendor/libgit2/src/idxmap.c +25 -5
  160. data/vendor/libgit2/src/idxmap.h +4 -18
  161. data/vendor/libgit2/src/ignore.c +9 -9
  162. data/vendor/libgit2/src/index.c +280 -198
  163. data/vendor/libgit2/src/index.h +16 -0
  164. data/vendor/libgit2/src/indexer.c +311 -139
  165. data/vendor/libgit2/src/integer.h +32 -22
  166. data/vendor/libgit2/src/iterator.c +116 -49
  167. data/vendor/libgit2/src/iterator.h +15 -0
  168. data/vendor/libgit2/src/khash.h +3 -1
  169. data/vendor/libgit2/src/mailmap.c +485 -0
  170. data/vendor/libgit2/src/mailmap.h +35 -0
  171. data/vendor/libgit2/src/merge.c +89 -59
  172. data/vendor/libgit2/src/merge_driver.c +7 -7
  173. data/vendor/libgit2/src/merge_file.c +1 -1
  174. data/vendor/libgit2/src/mwindow.c +8 -8
  175. data/vendor/libgit2/src/netops.c +22 -13
  176. data/vendor/libgit2/src/netops.h +2 -0
  177. data/vendor/libgit2/src/notes.c +15 -10
  178. data/vendor/libgit2/src/object.c +118 -67
  179. data/vendor/libgit2/src/object.h +20 -9
  180. data/vendor/libgit2/src/object_api.c +8 -8
  181. data/vendor/libgit2/src/odb.c +72 -72
  182. data/vendor/libgit2/src/odb.h +7 -7
  183. data/vendor/libgit2/src/odb_loose.c +46 -46
  184. data/vendor/libgit2/src/odb_mempack.c +14 -14
  185. data/vendor/libgit2/src/odb_pack.c +14 -10
  186. data/vendor/libgit2/src/offmap.c +30 -0
  187. data/vendor/libgit2/src/offmap.h +20 -11
  188. data/vendor/libgit2/src/oid.c +6 -6
  189. data/vendor/libgit2/src/oidmap.c +20 -0
  190. data/vendor/libgit2/src/oidmap.h +9 -12
  191. data/vendor/libgit2/src/pack-objects.c +71 -63
  192. data/vendor/libgit2/src/pack-objects.h +1 -7
  193. data/vendor/libgit2/src/pack.c +58 -58
  194. data/vendor/libgit2/src/pack.h +6 -6
  195. data/vendor/libgit2/src/parse.h +1 -1
  196. data/vendor/libgit2/src/patch.c +3 -3
  197. data/vendor/libgit2/src/patch_generate.c +18 -18
  198. data/vendor/libgit2/src/patch_parse.c +13 -13
  199. data/vendor/libgit2/src/path.c +93 -225
  200. data/vendor/libgit2/src/path.h +2 -84
  201. data/vendor/libgit2/src/pathspec.c +6 -6
  202. data/vendor/libgit2/src/posix.c +3 -3
  203. data/vendor/libgit2/src/proxy.c +1 -1
  204. data/vendor/libgit2/src/push.c +27 -26
  205. data/vendor/libgit2/src/push.h +2 -1
  206. data/vendor/libgit2/src/reader.c +265 -0
  207. data/vendor/libgit2/src/reader.h +107 -0
  208. data/vendor/libgit2/src/rebase.c +49 -52
  209. data/vendor/libgit2/src/refdb.c +3 -3
  210. data/vendor/libgit2/src/refdb_fs.c +181 -103
  211. data/vendor/libgit2/src/reflog.c +3 -3
  212. data/vendor/libgit2/src/refs.c +98 -74
  213. data/vendor/libgit2/src/refs.h +5 -3
  214. data/vendor/libgit2/src/refspec.c +47 -21
  215. data/vendor/libgit2/src/refspec.h +1 -1
  216. data/vendor/libgit2/src/remote.c +219 -166
  217. data/vendor/libgit2/src/remote.h +9 -0
  218. data/vendor/libgit2/src/repository.c +173 -133
  219. data/vendor/libgit2/src/repository.h +6 -3
  220. data/vendor/libgit2/src/reset.c +8 -8
  221. data/vendor/libgit2/src/revert.c +6 -6
  222. data/vendor/libgit2/src/revparse.c +30 -30
  223. data/vendor/libgit2/src/revwalk.c +60 -30
  224. data/vendor/libgit2/src/revwalk.h +2 -1
  225. data/vendor/libgit2/src/settings.c +42 -10
  226. data/vendor/libgit2/src/signature.c +11 -11
  227. data/vendor/libgit2/src/sortedcache.c +13 -13
  228. data/vendor/libgit2/src/stash.c +91 -45
  229. data/vendor/libgit2/src/status.c +13 -13
  230. data/vendor/libgit2/src/stdalloc.c +120 -0
  231. data/vendor/libgit2/src/{streams/curl.h → stdalloc.h} +6 -6
  232. data/vendor/libgit2/src/stream.h +17 -2
  233. data/vendor/libgit2/src/streams/mbedtls.c +483 -0
  234. data/vendor/libgit2/src/streams/mbedtls.h +23 -0
  235. data/vendor/libgit2/src/streams/openssl.c +204 -114
  236. data/vendor/libgit2/src/streams/openssl.h +4 -108
  237. data/vendor/libgit2/src/streams/registry.c +118 -0
  238. data/vendor/libgit2/src/streams/registry.h +19 -0
  239. data/vendor/libgit2/src/streams/socket.c +54 -29
  240. data/vendor/libgit2/src/streams/stransport.c +57 -32
  241. data/vendor/libgit2/src/streams/stransport.h +5 -0
  242. data/vendor/libgit2/src/streams/tls.c +50 -19
  243. data/vendor/libgit2/src/streams/tls.h +12 -4
  244. data/vendor/libgit2/src/strmap.c +22 -2
  245. data/vendor/libgit2/src/strmap.h +18 -15
  246. data/vendor/libgit2/src/submodule.c +179 -155
  247. data/vendor/libgit2/src/sysdir.c +18 -18
  248. data/vendor/libgit2/src/tag.c +31 -26
  249. data/vendor/libgit2/src/tag.h +2 -1
  250. data/vendor/libgit2/src/trace.c +1 -1
  251. data/vendor/libgit2/src/trace.h +1 -1
  252. data/vendor/libgit2/src/trailer.c +6 -6
  253. data/vendor/libgit2/src/transaction.c +23 -23
  254. data/vendor/libgit2/src/transport.c +5 -5
  255. data/vendor/libgit2/src/transports/auth.c +7 -4
  256. data/vendor/libgit2/src/transports/auth.h +1 -1
  257. data/vendor/libgit2/src/transports/auth_negotiate.c +12 -11
  258. data/vendor/libgit2/src/transports/cred.c +18 -18
  259. data/vendor/libgit2/src/transports/git.c +15 -15
  260. data/vendor/libgit2/src/transports/http.c +606 -216
  261. data/vendor/libgit2/src/transports/http.h +2 -0
  262. data/vendor/libgit2/src/transports/local.c +26 -26
  263. data/vendor/libgit2/src/transports/smart.c +54 -31
  264. data/vendor/libgit2/src/transports/smart.h +1 -2
  265. data/vendor/libgit2/src/transports/smart_pkt.c +43 -40
  266. data/vendor/libgit2/src/transports/smart_protocol.c +61 -57
  267. data/vendor/libgit2/src/transports/ssh.c +34 -33
  268. data/vendor/libgit2/src/transports/winhttp.c +99 -119
  269. data/vendor/libgit2/src/tree-cache.c +5 -5
  270. data/vendor/libgit2/src/tree.c +96 -121
  271. data/vendor/libgit2/src/tree.h +1 -12
  272. data/vendor/libgit2/src/unix/map.c +2 -2
  273. data/vendor/libgit2/src/util.c +22 -6
  274. data/vendor/libgit2/src/util.h +12 -135
  275. data/vendor/libgit2/src/vector.c +4 -4
  276. data/vendor/libgit2/src/win32/dir.c +3 -3
  277. data/vendor/libgit2/src/win32/findfile.c +3 -3
  278. data/vendor/libgit2/src/win32/map.c +6 -6
  279. data/vendor/libgit2/src/win32/msvc-compat.h +6 -0
  280. data/vendor/libgit2/src/win32/path_w32.c +101 -7
  281. data/vendor/libgit2/src/win32/path_w32.h +18 -0
  282. data/vendor/libgit2/src/win32/posix_w32.c +24 -43
  283. data/vendor/libgit2/src/win32/w32_buffer.c +2 -2
  284. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +96 -2
  285. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +28 -75
  286. data/vendor/libgit2/src/win32/w32_stack.c +2 -2
  287. data/vendor/libgit2/src/win32/w32_util.c +1 -69
  288. data/vendor/libgit2/src/win32/w32_util.h +1 -19
  289. data/vendor/libgit2/src/worktree.c +75 -54
  290. data/vendor/libgit2/src/worktree.h +2 -0
  291. data/vendor/libgit2/src/xdiff/xdiffi.c +7 -5
  292. data/vendor/libgit2/src/xdiff/xhistogram.c +1 -1
  293. data/vendor/libgit2/src/xdiff/xmerge.c +15 -15
  294. data/vendor/libgit2/src/zstream.c +4 -4
  295. metadata +33 -7
  296. data/vendor/libgit2/src/config_file.h +0 -73
  297. data/vendor/libgit2/src/streams/curl.c +0 -385
@@ -37,7 +37,7 @@ static int write_cherrypick_head(
37
37
  if (error < 0)
38
38
  git_filebuf_cleanup(&file);
39
39
 
40
- git_buf_free(&file_path);
40
+ git_buf_dispose(&file_path);
41
41
 
42
42
  return error;
43
43
  }
@@ -61,7 +61,7 @@ cleanup:
61
61
  if (error < 0)
62
62
  git_filebuf_cleanup(&file);
63
63
 
64
- git_buf_free(&file_path);
64
+ git_buf_dispose(&file_path);
65
65
 
66
66
  return error;
67
67
  }
@@ -108,7 +108,7 @@ static int cherrypick_seterr(git_commit *commit, const char *fmt)
108
108
  {
109
109
  char commit_oidstr[GIT_OID_HEXSZ + 1];
110
110
 
111
- giterr_set(GITERR_CHERRYPICK, fmt,
111
+ git_error_set(GIT_ERROR_CHERRYPICK, fmt,
112
112
  git_oid_tostr(commit_oidstr, GIT_OID_HEXSZ + 1, git_commit_id(commit)));
113
113
 
114
114
  return -1;
@@ -179,7 +179,7 @@ int git_cherrypick(
179
179
 
180
180
  assert(repo && commit);
181
181
 
182
- GITERR_CHECK_VERSION(given_opts, GIT_CHERRYPICK_OPTIONS_VERSION, "git_cherrypick_options");
182
+ GIT_ERROR_CHECK_VERSION(given_opts, GIT_CHERRYPICK_OPTIONS_VERSION, "git_cherrypick_options");
183
183
 
184
184
  if ((error = git_repository__ensure_not_bare(repo, "cherry-pick")) < 0)
185
185
  return error;
@@ -198,7 +198,7 @@ int git_cherrypick(
198
198
  (error = git_indexwriter_init_for_operation(&indexwriter, repo, &opts.checkout_opts.checkout_strategy)) < 0 ||
199
199
  (error = write_cherrypick_head(repo, commit_oidstr)) < 0 ||
200
200
  (error = git_repository_head(&our_ref, repo)) < 0 ||
201
- (error = git_reference_peel((git_object **)&our_commit, our_ref, GIT_OBJ_COMMIT)) < 0 ||
201
+ (error = git_reference_peel((git_object **)&our_commit, our_ref, GIT_OBJECT_COMMIT)) < 0 ||
202
202
  (error = git_cherrypick_commit(&index, repo, commit, our_commit, opts.mainline, &opts.merge_opts)) < 0 ||
203
203
  (error = git_merge__check_result(repo, index)) < 0 ||
204
204
  (error = git_merge__append_conflicts_to_merge_msg(repo, index)) < 0 ||
@@ -216,7 +216,7 @@ done:
216
216
  git_index_free(index);
217
217
  git_commit_free(our_commit);
218
218
  git_reference_free(our_ref);
219
- git_buf_free(&their_label);
219
+ git_buf_dispose(&their_label);
220
220
 
221
221
  return error;
222
222
  }
@@ -48,7 +48,7 @@ static int create_branch(
48
48
  return error;
49
49
 
50
50
  error = git_reference_create(&branch_ref, repo, git_buf_cstr(&refname), target, 0, log_message);
51
- git_buf_free(&refname);
51
+ git_buf_dispose(&refname);
52
52
  git_commit_free(head_obj);
53
53
 
54
54
  if (!error)
@@ -87,8 +87,8 @@ static int setup_tracking_config(
87
87
  error = 0;
88
88
 
89
89
  cleanup:
90
- git_buf_free(&remote_key);
91
- git_buf_free(&merge_key);
90
+ git_buf_dispose(&remote_key);
91
+ git_buf_dispose(&merge_key);
92
92
  return error;
93
93
  }
94
94
 
@@ -176,7 +176,7 @@ static int update_head_to_remote(
176
176
  refspec = git_remote__matching_refspec(remote, git_buf_cstr(&branch));
177
177
 
178
178
  if (refspec == NULL) {
179
- giterr_set(GITERR_NET, "the remote's default branch does not fit the refspec configuration");
179
+ git_error_set(GIT_ERROR_NET, "the remote's default branch does not fit the refspec configuration");
180
180
  error = GIT_EINVALIDSPEC;
181
181
  goto cleanup;
182
182
  }
@@ -195,8 +195,8 @@ static int update_head_to_remote(
195
195
  reflog_message);
196
196
 
197
197
  cleanup:
198
- git_buf_free(&remote_master_name);
199
- git_buf_free(&branch);
198
+ git_buf_dispose(&remote_master_name);
199
+ git_buf_dispose(&branch);
200
200
 
201
201
  return error;
202
202
  }
@@ -225,7 +225,7 @@ static int update_head_to_branch(
225
225
 
226
226
  cleanup:
227
227
  git_reference_free(remote_ref);
228
- git_buf_free(&remote_branch_name);
228
+ git_buf_dispose(&remote_branch_name);
229
229
  return retcode;
230
230
  }
231
231
 
@@ -332,7 +332,7 @@ static int clone_into(git_repository *repo, git_remote *_remote, const git_fetch
332
332
  assert(repo && _remote);
333
333
 
334
334
  if (!git_repository_is_empty(repo)) {
335
- giterr_set(GITERR_INVALID, "the repository is not empty");
335
+ git_error_set(GIT_ERROR_INVALID, "the repository is not empty");
336
336
  return -1;
337
337
  }
338
338
 
@@ -351,7 +351,7 @@ static int clone_into(git_repository *repo, git_remote *_remote, const git_fetch
351
351
 
352
352
  cleanup:
353
353
  git_remote_free(remote);
354
- git_buf_free(&reflog_message);
354
+ git_buf_dispose(&reflog_message);
355
355
 
356
356
  return error;
357
357
  }
@@ -378,7 +378,7 @@ int git_clone__should_clone_local(const char *url_or_path, git_clone_local_t loc
378
378
  git_path_isdir(path);
379
379
 
380
380
  done:
381
- git_buf_free(&fromurl);
381
+ git_buf_dispose(&fromurl);
382
382
  return is_local;
383
383
  }
384
384
 
@@ -400,11 +400,11 @@ int git_clone(
400
400
  if (_options)
401
401
  memcpy(&options, _options, sizeof(git_clone_options));
402
402
 
403
- GITERR_CHECK_VERSION(&options, GIT_CLONE_OPTIONS_VERSION, "git_clone_options");
403
+ GIT_ERROR_CHECK_VERSION(&options, GIT_CLONE_OPTIONS_VERSION, "git_clone_options");
404
404
 
405
405
  /* Only clone to a new directory or an empty directory */
406
406
  if (git_path_exists(local_path) && !git_path_is_empty_dir(local_path)) {
407
- giterr_set(GITERR_INVALID,
407
+ git_error_set(GIT_ERROR_INVALID,
408
408
  "'%s' exists and is not an empty directory", local_path);
409
409
  return GIT_EEXISTS;
410
410
  }
@@ -441,14 +441,14 @@ int git_clone(
441
441
 
442
442
  if (error != 0) {
443
443
  git_error_state last_error = {0};
444
- giterr_state_capture(&last_error, error);
444
+ git_error_state_capture(&last_error, error);
445
445
 
446
446
  git_repository_free(repo);
447
447
  repo = NULL;
448
448
 
449
449
  (void)git_futils_rmdir_r(local_path, NULL, rmdir_flags);
450
450
 
451
- giterr_state_restore(&last_error);
451
+ git_error_state_restore(&last_error);
452
452
  }
453
453
 
454
454
  *out = repo;
@@ -496,7 +496,7 @@ static int clone_local_into(git_repository *repo, git_remote *remote, const git_
496
496
  assert(repo && remote);
497
497
 
498
498
  if (!git_repository_is_empty(repo)) {
499
- giterr_set(GITERR_INVALID, "the repository is not empty");
499
+ git_error_set(GIT_ERROR_INVALID, "the repository is not empty");
500
500
  return -1;
501
501
  }
502
502
 
@@ -510,7 +510,7 @@ static int clone_local_into(git_repository *repo, git_remote *remote, const git_
510
510
 
511
511
  /* Copy .git/objects/ from the source to the target */
512
512
  if ((error = git_repository_open(&src, git_buf_cstr(&src_path))) < 0) {
513
- git_buf_free(&src_path);
513
+ git_buf_dispose(&src_path);
514
514
  return error;
515
515
  }
516
516
 
@@ -549,10 +549,10 @@ static int clone_local_into(git_repository *repo, git_remote *remote, const git_
549
549
  error = checkout_branch(repo, remote, co_opts, branch, git_buf_cstr(&reflog_message));
550
550
 
551
551
  cleanup:
552
- git_buf_free(&reflog_message);
553
- git_buf_free(&src_path);
554
- git_buf_free(&src_odb);
555
- git_buf_free(&dst_odb);
552
+ git_buf_dispose(&reflog_message);
553
+ git_buf_dispose(&src_path);
554
+ git_buf_dispose(&src_odb);
555
+ git_buf_dispose(&dst_odb);
556
556
  git_repository_free(src);
557
557
  return error;
558
558
  }
@@ -11,6 +11,7 @@
11
11
  #include "git2/object.h"
12
12
  #include "git2/repository.h"
13
13
  #include "git2/signature.h"
14
+ #include "git2/mailmap.h"
14
15
  #include "git2/sys/commit.h"
15
16
 
16
17
  #include "odb.h"
@@ -74,7 +75,7 @@ static int git_commit__create_buffer_internal(
74
75
  return 0;
75
76
 
76
77
  on_error:
77
- git_buf_free(out);
78
+ git_buf_dispose(out);
78
79
  return -1;
79
80
  }
80
81
 
@@ -87,25 +88,25 @@ static int validate_tree_and_parents(git_array_oid_t *parents, git_repository *r
87
88
  git_oid *parent_cpy;
88
89
  const git_oid *parent;
89
90
 
90
- if (validate && !git_object__is_valid(repo, tree, GIT_OBJ_TREE))
91
+ if (validate && !git_object__is_valid(repo, tree, GIT_OBJECT_TREE))
91
92
  return -1;
92
93
 
93
94
  i = 0;
94
95
  while ((parent = parent_cb(i, parent_payload)) != NULL) {
95
- if (validate && !git_object__is_valid(repo, parent, GIT_OBJ_COMMIT)) {
96
+ if (validate && !git_object__is_valid(repo, parent, GIT_OBJECT_COMMIT)) {
96
97
  error = -1;
97
98
  goto on_error;
98
99
  }
99
100
 
100
101
  parent_cpy = git_array_alloc(*parents);
101
- GITERR_CHECK_ALLOC(parent_cpy);
102
+ GIT_ERROR_CHECK_ALLOC(parent_cpy);
102
103
 
103
104
  git_oid_cpy(parent_cpy, parent);
104
105
  i++;
105
106
  }
106
107
 
107
108
  if (current_id && (parents->size == 0 || git_oid_cmp(current_id, git_array_get(*parents, 0)))) {
108
- giterr_set(GITERR_OBJECT, "failed to create commit: current tip is not the first parent");
109
+ git_error_set(GIT_ERROR_OBJECT, "failed to create commit: current tip is not the first parent");
109
110
  error = GIT_EMODIFIED;
110
111
  goto on_error;
111
112
  }
@@ -142,7 +143,7 @@ static int git_commit__create_internal(
142
143
  if (error < 0 && error != GIT_ENOTFOUND)
143
144
  return error;
144
145
  }
145
- giterr_clear();
146
+ git_error_clear();
146
147
 
147
148
  if (ref)
148
149
  current_id = git_reference_target(ref);
@@ -163,7 +164,7 @@ static int git_commit__create_internal(
163
164
  if (git_odb__freshen(odb, tree) < 0)
164
165
  goto cleanup;
165
166
 
166
- if (git_odb_write(id, odb, buf.ptr, buf.size, GIT_OBJ_COMMIT) < 0)
167
+ if (git_odb_write(id, odb, buf.ptr, buf.size, GIT_OBJECT_COMMIT) < 0)
167
168
  goto cleanup;
168
169
 
169
170
 
@@ -176,7 +177,7 @@ static int git_commit__create_internal(
176
177
  cleanup:
177
178
  git_array_clear(parents);
178
179
  git_reference_free(ref);
179
- git_buf_free(&buf);
180
+ git_buf_dispose(&buf);
180
181
  return error;
181
182
  }
182
183
 
@@ -350,7 +351,7 @@ int git_commit_amend(
350
351
 
351
352
  if (!tree) {
352
353
  git_tree *old_tree;
353
- GITERR_CHECK_ERROR( git_commit_tree(&old_tree, commit_to_amend) );
354
+ GIT_ERROR_CHECK_ERROR( git_commit_tree(&old_tree, commit_to_amend) );
354
355
  git_oid_cpy(&tree_id, git_tree_id(old_tree));
355
356
  git_tree_free(old_tree);
356
357
  } else {
@@ -364,7 +365,7 @@ int git_commit_amend(
364
365
 
365
366
  if (git_oid_cmp(git_commit_id(commit_to_amend), git_reference_target(ref))) {
366
367
  git_reference_free(ref);
367
- giterr_set(GITERR_REFERENCE, "commit to amend is not the tip of the given branch");
368
+ git_error_set(GIT_ERROR_REFERENCE, "commit to amend is not the tip of the given branch");
368
369
  return -1;
369
370
  }
370
371
  }
@@ -382,11 +383,11 @@ int git_commit_amend(
382
383
  return error;
383
384
  }
384
385
 
385
- int git_commit__parse(void *_commit, git_odb_object *odb_obj)
386
+ int git_commit__parse_raw(void *_commit, const char *data, size_t size)
386
387
  {
387
388
  git_commit *commit = _commit;
388
- const char *buffer_start = git_odb_object_data(odb_obj), *buffer;
389
- const char *buffer_end = buffer_start + git_odb_object_size(odb_obj);
389
+ const char *buffer_start = data, *buffer;
390
+ const char *buffer_end = buffer_start + size;
390
391
  git_oid parent_id;
391
392
  size_t header_len;
392
393
  git_signature dummy_sig;
@@ -395,7 +396,7 @@ int git_commit__parse(void *_commit, git_odb_object *odb_obj)
395
396
 
396
397
  /* Allocate for one, which will allow not to realloc 90% of the time */
397
398
  git_array_init_to_size(commit->parent_ids, 1);
398
- GITERR_CHECK_ARRAY(commit->parent_ids);
399
+ GIT_ERROR_CHECK_ARRAY(commit->parent_ids);
399
400
 
400
401
  /* The tree is always the first field */
401
402
  if (git_oid__parse(&commit->tree_id, &buffer, buffer_end, "tree ") < 0)
@@ -407,13 +408,13 @@ int git_commit__parse(void *_commit, git_odb_object *odb_obj)
407
408
 
408
409
  while (git_oid__parse(&parent_id, &buffer, buffer_end, "parent ") == 0) {
409
410
  git_oid *new_id = git_array_alloc(commit->parent_ids);
410
- GITERR_CHECK_ALLOC(new_id);
411
+ GIT_ERROR_CHECK_ALLOC(new_id);
411
412
 
412
413
  git_oid_cpy(new_id, &parent_id);
413
414
  }
414
415
 
415
416
  commit->author = git__malloc(sizeof(git_signature));
416
- GITERR_CHECK_ALLOC(commit->author);
417
+ GIT_ERROR_CHECK_ALLOC(commit->author);
417
418
 
418
419
  if (git_signature__parse(commit->author, &buffer, buffer_end, "author ", '\n') < 0)
419
420
  return -1;
@@ -429,7 +430,7 @@ int git_commit__parse(void *_commit, git_odb_object *odb_obj)
429
430
 
430
431
  /* Always parse the committer; we need the commit time */
431
432
  commit->committer = git__malloc(sizeof(git_signature));
432
- GITERR_CHECK_ALLOC(commit->committer);
433
+ GIT_ERROR_CHECK_ALLOC(commit->committer);
433
434
 
434
435
  if (git_signature__parse(commit->committer, &buffer, buffer_end, "committer ", '\n') < 0)
435
436
  return -1;
@@ -447,7 +448,7 @@ int git_commit__parse(void *_commit, git_odb_object *odb_obj)
447
448
  buffer += strlen("encoding ");
448
449
 
449
450
  commit->message_encoding = git__strndup(buffer, eoln - buffer);
450
- GITERR_CHECK_ALLOC(commit->message_encoding);
451
+ GIT_ERROR_CHECK_ALLOC(commit->message_encoding);
451
452
  }
452
453
 
453
454
  if (eoln < buffer_end && *eoln == '\n')
@@ -457,7 +458,7 @@ int git_commit__parse(void *_commit, git_odb_object *odb_obj)
457
458
 
458
459
  header_len = buffer - buffer_start;
459
460
  commit->raw_header = git__strndup(buffer_start, header_len);
460
- GITERR_CHECK_ALLOC(commit->raw_header);
461
+ GIT_ERROR_CHECK_ALLOC(commit->raw_header);
461
462
 
462
463
  /* point "buffer" to data after header, +1 for the final LF */
463
464
  buffer = buffer_start + header_len + 1;
@@ -467,15 +468,22 @@ int git_commit__parse(void *_commit, git_odb_object *odb_obj)
467
468
  commit->raw_message = git__strndup(buffer, buffer_end - buffer);
468
469
  else
469
470
  commit->raw_message = git__strdup("");
470
- GITERR_CHECK_ALLOC(commit->raw_message);
471
+ GIT_ERROR_CHECK_ALLOC(commit->raw_message);
471
472
 
472
473
  return 0;
473
474
 
474
475
  bad_buffer:
475
- giterr_set(GITERR_OBJECT, "failed to parse bad commit object");
476
+ git_error_set(GIT_ERROR_OBJECT, "failed to parse bad commit object");
476
477
  return -1;
477
478
  }
478
479
 
480
+ int git_commit__parse(void *_commit, git_odb_object *odb_obj)
481
+ {
482
+ return git_commit__parse_raw(_commit,
483
+ git_odb_object_data(odb_obj),
484
+ git_odb_object_size(odb_obj));
485
+ }
486
+
479
487
  #define GIT_COMMIT_GETTER(_rvalue, _name, _return) \
480
488
  _rvalue git_commit_##_name(const git_commit *commit) \
481
489
  {\
@@ -602,7 +610,7 @@ int git_commit_parent(
602
610
 
603
611
  parent_id = git_commit_parent_id(commit, n);
604
612
  if (parent_id == NULL) {
605
- giterr_set(GITERR_INVALID, "parent %u does not exist", n);
613
+ git_error_set(GIT_ERROR_INVALID, "parent %u does not exist", n);
606
614
  return GIT_ENOTFOUND;
607
615
  }
608
616
 
@@ -691,14 +699,14 @@ int git_commit_header_field(git_buf *out, const git_commit *commit, const char *
691
699
  return 0;
692
700
  }
693
701
 
694
- giterr_set(GITERR_OBJECT, "no such field '%s'", field);
702
+ git_error_set(GIT_ERROR_OBJECT, "no such field '%s'", field);
695
703
  return GIT_ENOTFOUND;
696
704
 
697
705
  malformed:
698
- giterr_set(GITERR_OBJECT, "malformed header");
706
+ git_error_set(GIT_ERROR_OBJECT, "malformed header");
699
707
  return -1;
700
708
  oom:
701
- giterr_set_oom();
709
+ git_error_set_oom();
702
710
  return -1;
703
711
  }
704
712
 
@@ -722,8 +730,8 @@ int git_commit_extract_signature(git_buf *signature, git_buf *signed_data, git_r
722
730
  if ((error = git_odb_read(&obj, odb, commit_id)) < 0)
723
731
  return error;
724
732
 
725
- if (obj->cached.type != GIT_OBJ_COMMIT) {
726
- giterr_set(GITERR_INVALID, "the requested type does not match the type in ODB");
733
+ if (obj->cached.type != GIT_OBJECT_COMMIT) {
734
+ git_error_set(GIT_ERROR_INVALID, "the requested type does not match the type in ODB");
727
735
  error = GIT_ENOTFOUND;
728
736
  goto cleanup;
729
737
  }
@@ -775,16 +783,16 @@ int git_commit_extract_signature(git_buf *signature, git_buf *signed_data, git_r
775
783
  return error;
776
784
  }
777
785
 
778
- giterr_set(GITERR_OBJECT, "this commit is not signed");
786
+ git_error_set(GIT_ERROR_OBJECT, "this commit is not signed");
779
787
  error = GIT_ENOTFOUND;
780
788
  goto cleanup;
781
789
 
782
790
  malformed:
783
- giterr_set(GITERR_OBJECT, "malformed header");
791
+ git_error_set(GIT_ERROR_OBJECT, "malformed header");
784
792
  error = -1;
785
793
  goto cleanup;
786
794
  oom:
787
- giterr_set_oom();
795
+ git_error_set_oom();
788
796
  error = -1;
789
797
  goto cleanup;
790
798
 
@@ -864,7 +872,7 @@ int git_commit_create_with_signature(
864
872
  /* We start by identifying the end of the commit header */
865
873
  header_end = strstr(commit_content, "\n\n");
866
874
  if (!header_end) {
867
- giterr_set(GITERR_INVALID, "malformed commit contents");
875
+ git_error_set(GIT_ERROR_INVALID, "malformed commit contents");
868
876
  return -1;
869
877
  }
870
878
 
@@ -882,10 +890,22 @@ int git_commit_create_with_signature(
882
890
  if ((error = git_repository_odb__weakptr(&odb, repo)) < 0)
883
891
  goto cleanup;
884
892
 
885
- if ((error = git_odb_write(out, odb, commit.ptr, commit.size, GIT_OBJ_COMMIT)) < 0)
893
+ if ((error = git_odb_write(out, odb, commit.ptr, commit.size, GIT_OBJECT_COMMIT)) < 0)
886
894
  goto cleanup;
887
895
 
888
896
  cleanup:
889
- git_buf_free(&commit);
897
+ git_buf_dispose(&commit);
890
898
  return error;
891
899
  }
900
+
901
+ int git_commit_committer_with_mailmap(
902
+ git_signature **out, const git_commit *commit, const git_mailmap *mailmap)
903
+ {
904
+ return git_mailmap_resolve_signature(out, mailmap, commit->committer);
905
+ }
906
+
907
+ int git_commit_author_with_mailmap(
908
+ git_signature **out, const git_commit *commit, const git_mailmap *mailmap)
909
+ {
910
+ return git_mailmap_resolve_signature(out, mailmap, commit->author);
911
+ }