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
@@ -161,7 +161,7 @@ int git_diff_file_content__init_from_src(
161
161
  fc->flags |= GIT_DIFF_FLAG__FREE_BLOB;
162
162
  } else {
163
163
  fc->file->size = src->buflen;
164
- git_odb_hash(&fc->file->id, src->buf, src->buflen, GIT_OBJ_BLOB);
164
+ git_odb_hash(&fc->file->id, src->buf, src->buflen, GIT_OBJECT_BLOB);
165
165
  fc->file->id_abbrev = GIT_OID_HEXSZ;
166
166
 
167
167
  fc->map.len = src->buflen;
@@ -188,7 +188,7 @@ static int diff_file_content_commit_to_str(
188
188
  if ((error = git_submodule_lookup(&sm, fc->repo, fc->file->path)) < 0) {
189
189
  /* GIT_EEXISTS means a "submodule" that has not been git added */
190
190
  if (error == GIT_EEXISTS) {
191
- giterr_clear();
191
+ git_error_clear();
192
192
  error = 0;
193
193
  }
194
194
  return error;
@@ -251,7 +251,7 @@ static int diff_file_content_load_blob(
251
251
 
252
252
  if (odb_obj != NULL) {
253
253
  error = git_object__from_odb_object(
254
- (git_object **)&fc->blob, fc->repo, odb_obj, GIT_OBJ_BLOB);
254
+ (git_object **)&fc->blob, fc->repo, odb_obj, GIT_OBJECT_BLOB);
255
255
  git_odb_object_free(odb_obj);
256
256
  } else {
257
257
  error = git_blob_lookup(
@@ -280,7 +280,7 @@ static int diff_file_content_load_workdir_symlink_fake(
280
280
  fc->map.data = git_buf_detach(&target);
281
281
  fc->flags |= GIT_DIFF_FLAG__FREE_DATA;
282
282
 
283
- git_buf_free(&target);
283
+ git_buf_dispose(&target);
284
284
  return error;
285
285
  }
286
286
 
@@ -303,13 +303,13 @@ static int diff_file_content_load_workdir_symlink(
303
303
  alloc_len = (ssize_t)(fc->file->size * 2) + 1;
304
304
 
305
305
  fc->map.data = git__calloc(alloc_len, sizeof(char));
306
- GITERR_CHECK_ALLOC(fc->map.data);
306
+ GIT_ERROR_CHECK_ALLOC(fc->map.data);
307
307
 
308
308
  fc->flags |= GIT_DIFF_FLAG__FREE_DATA;
309
309
 
310
310
  read_len = p_readlink(git_buf_cstr(path), fc->map.data, alloc_len);
311
311
  if (read_len < 0) {
312
- giterr_set(GITERR_OS, "failed to read symlink '%s'", fc->file->path);
312
+ git_error_set(GIT_ERROR_OS, "failed to read symlink '%s'", fc->file->path);
313
313
  return -1;
314
314
  }
315
315
 
@@ -352,7 +352,7 @@ static int diff_file_content_load_workdir_file(
352
352
  }
353
353
 
354
354
  /* if mmap failed, fall through to try readbuffer below */
355
- giterr_clear();
355
+ git_error_clear();
356
356
  }
357
357
 
358
358
  if (!(error = git_futils_readbuffer_fd(&raw, fd, (size_t)fc->file->size))) {
@@ -361,7 +361,7 @@ static int diff_file_content_load_workdir_file(
361
361
  error = git_filter_list_apply_to_data(&out, fl, &raw);
362
362
 
363
363
  if (out.ptr != raw.ptr)
364
- git_buf_free(&raw);
364
+ git_buf_dispose(&raw);
365
365
 
366
366
  if (!error) {
367
367
  fc->map.len = out.size;
@@ -402,11 +402,11 @@ static int diff_file_content_load_workdir(
402
402
  /* once data is loaded, update OID if we didn't have it previously */
403
403
  if (!error && (fc->file->flags & GIT_DIFF_FLAG_VALID_ID) == 0) {
404
404
  error = git_odb_hash(
405
- &fc->file->id, fc->map.data, fc->map.len, GIT_OBJ_BLOB);
405
+ &fc->file->id, fc->map.data, fc->map.len, GIT_OBJECT_BLOB);
406
406
  fc->file->flags |= GIT_DIFF_FLAG_VALID_ID;
407
407
  }
408
408
 
409
- git_buf_free(&path);
409
+ git_buf_dispose(&path);
410
410
  return error;
411
411
  }
412
412
 
@@ -81,7 +81,7 @@ static int diff_insert_delta(
81
81
  if (error > 0) /* positive value means to skip this delta */
82
82
  return 0;
83
83
  else /* negative value means to cancel diff */
84
- return giterr_set_after_callback_function(error, "git_diff");
84
+ return git_error_set_after_callback_function(error, "git_diff");
85
85
  }
86
86
  }
87
87
 
@@ -138,7 +138,7 @@ static int diff_delta__from_one(
138
138
  if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_REVERSE))
139
139
  has_old = !has_old;
140
140
 
141
- if ((entry->flags & GIT_IDXENTRY_VALID) != 0)
141
+ if ((entry->flags & GIT_INDEX_ENTRY_VALID) != 0)
142
142
  return 0;
143
143
 
144
144
  if (status == GIT_DELTA_IGNORED &&
@@ -157,7 +157,7 @@ static int diff_delta__from_one(
157
157
  return 0;
158
158
 
159
159
  delta = diff_delta__alloc(diff, status, entry->path);
160
- GITERR_CHECK_ALLOC(delta);
160
+ GIT_ERROR_CHECK_ALLOC(delta);
161
161
 
162
162
  /* This fn is just for single-sided diffs */
163
163
  assert(status != GIT_DELTA_MODIFIED);
@@ -220,7 +220,7 @@ static int diff_delta__from_two(
220
220
  }
221
221
 
222
222
  delta = diff_delta__alloc(diff, status, canonical_path);
223
- GITERR_CHECK_ALLOC(delta);
223
+ GIT_ERROR_CHECK_ALLOC(delta);
224
224
  delta->nfiles = 2;
225
225
 
226
226
  if (!git_index_entry_is_conflict(old_entry)) {
@@ -273,7 +273,8 @@ static git_diff_delta *diff_delta__last_for_item(
273
273
  break;
274
274
  case GIT_DELTA_MODIFIED:
275
275
  if (git_oid__cmp(&delta->old_file.id, &item->id) == 0 ||
276
- git_oid__cmp(&delta->new_file.id, &item->id) == 0)
276
+ (delta->new_file.mode == item->mode &&
277
+ git_oid__cmp(&delta->new_file.id, &item->id) == 0))
277
278
  return delta;
278
279
  break;
279
280
  default:
@@ -516,7 +517,7 @@ static int diff_generated_apply_options(
516
517
 
517
518
  if (entry && git_submodule_parse_ignore(
518
519
  &diff->base.opts.ignore_submodules, entry->value) < 0)
519
- giterr_clear();
520
+ git_error_clear();
520
521
  git_config_entry_free(entry);
521
522
  }
522
523
 
@@ -563,9 +564,14 @@ int git_diff__oid_for_file(
563
564
  {
564
565
  git_index_entry entry;
565
566
 
567
+ if (size < 0 || size > UINT32_MAX) {
568
+ git_error_set(GIT_ERROR_NOMEMORY, "file size overflow (for 32-bits) on '%s'", path);
569
+ return -1;
570
+ }
571
+
566
572
  memset(&entry, 0, sizeof(entry));
567
573
  entry.mode = mode;
568
- entry.file_size = size;
574
+ entry.file_size = (uint32_t)size;
569
575
  entry.path = (char *)path;
570
576
 
571
577
  return git_diff__oid_for_entry(out, diff, &entry, mode, NULL);
@@ -600,7 +606,7 @@ int git_diff__oid_for_entry(
600
606
 
601
607
  if (p_stat(full_path.ptr, &st) < 0) {
602
608
  error = git_path_set_error(errno, entry.path, "stat");
603
- git_buf_free(&full_path);
609
+ git_buf_dispose(&full_path);
604
610
  return error;
605
611
  }
606
612
 
@@ -621,13 +627,13 @@ int git_diff__oid_for_entry(
621
627
  /* if submodule lookup failed probably just in an intermediate
622
628
  * state where some init hasn't happened, so ignore the error
623
629
  */
624
- giterr_clear();
630
+ git_error_clear();
625
631
  }
626
632
  } else if (S_ISLNK(mode)) {
627
633
  error = git_odb__hashlink(out, full_path.ptr);
628
634
  diff->base.perf.oid_calculations++;
629
635
  } else if (!git__is_sizet(entry.file_size)) {
630
- giterr_set(GITERR_OS, "file size overflow (for 32-bits) on '%s'",
636
+ git_error_set(GIT_ERROR_NOMEMORY, "file size overflow (for 32-bits) on '%s'",
631
637
  entry.path);
632
638
  error = -1;
633
639
  } else if (!(error = git_filter_list_load(&fl,
@@ -639,7 +645,7 @@ int git_diff__oid_for_entry(
639
645
  error = fd;
640
646
  else {
641
647
  error = git_odb__hashfd_filtered(
642
- out, fd, (size_t)entry.file_size, GIT_OBJ_BLOB, fl);
648
+ out, fd, (size_t)entry.file_size, GIT_OBJECT_BLOB, fl);
643
649
  p_close(fd);
644
650
  diff->base.perf.oid_calculations++;
645
651
  }
@@ -663,7 +669,7 @@ int git_diff__oid_for_entry(
663
669
  }
664
670
  }
665
671
 
666
- git_buf_free(&full_path);
672
+ git_buf_dispose(&full_path);
667
673
  return error;
668
674
  }
669
675
 
@@ -699,7 +705,7 @@ static int maybe_modified_submodule(
699
705
 
700
706
  /* GIT_EEXISTS means dir with .git in it was found - ignore it */
701
707
  if (error == GIT_EEXISTS) {
702
- giterr_clear();
708
+ git_error_clear();
703
709
  error = 0;
704
710
  }
705
711
  return error;
@@ -763,11 +769,11 @@ static int maybe_modified(
763
769
  status = GIT_DELTA_CONFLICTED;
764
770
 
765
771
  /* support "assume unchanged" (poorly, b/c we still stat everything) */
766
- } else if ((oitem->flags & GIT_IDXENTRY_VALID) != 0) {
772
+ } else if ((oitem->flags & GIT_INDEX_ENTRY_VALID) != 0) {
767
773
  status = GIT_DELTA_UNMODIFIED;
768
774
 
769
775
  /* support "skip worktree" index bit */
770
- } else if ((oitem->flags_extended & GIT_IDXENTRY_SKIP_WORKTREE) != 0) {
776
+ } else if ((oitem->flags_extended & GIT_INDEX_ENTRY_SKIP_WORKTREE) != 0) {
771
777
  status = GIT_DELTA_UNMODIFIED;
772
778
 
773
779
  /* if basic type of file changed, then split into delete and add */
@@ -1059,7 +1065,7 @@ static int handle_unmatched_new_item(
1059
1065
 
1060
1066
  /* if directory is empty, can't advance into it, so skip it */
1061
1067
  if (error == GIT_ENOTFOUND) {
1062
- giterr_clear();
1068
+ git_error_clear();
1063
1069
  error = iterator_advance(&info->nitem, info->new_iter);
1064
1070
  }
1065
1071
 
@@ -1081,7 +1087,7 @@ static int handle_unmatched_new_item(
1081
1087
  else if (nitem->mode == GIT_FILEMODE_COMMIT) {
1082
1088
  /* ignore things that are not actual submodules */
1083
1089
  if (git_submodule_lookup(NULL, info->repo, nitem->path) != 0) {
1084
- giterr_clear();
1090
+ git_error_clear();
1085
1091
  delta_type = GIT_DELTA_IGNORED;
1086
1092
 
1087
1093
  /* if this contains a tracked item, treat as normal TREE */
@@ -1090,7 +1096,7 @@ static int handle_unmatched_new_item(
1090
1096
  if (error != GIT_ENOTFOUND)
1091
1097
  return error;
1092
1098
 
1093
- giterr_clear();
1099
+ git_error_clear();
1094
1100
  return iterator_advance(&info->nitem, info->new_iter);
1095
1101
  }
1096
1102
  }
@@ -1191,7 +1197,7 @@ int git_diff__from_iterators(
1191
1197
  *out = NULL;
1192
1198
 
1193
1199
  diff = diff_generated_alloc(repo, old_iter, new_iter);
1194
- GITERR_CHECK_ALLOC(diff);
1200
+ GIT_ERROR_CHECK_ALLOC(diff);
1195
1201
 
1196
1202
  info.repo = repo;
1197
1203
  info.old_iter = old_iter;
@@ -1268,7 +1274,7 @@ cleanup:
1268
1274
  b_opts.flags = FLAGS_SECOND; \
1269
1275
  b_opts.start = pfx; \
1270
1276
  b_opts.end = pfx; \
1271
- GITERR_CHECK_VERSION(opts, GIT_DIFF_OPTIONS_VERSION, "git_diff_options"); \
1277
+ GIT_ERROR_CHECK_VERSION(opts, GIT_DIFF_OPTIONS_VERSION, "git_diff_options"); \
1272
1278
  if (opts && (opts->flags & GIT_DIFF_DISABLE_PATHSPEC_MATCH)) { \
1273
1279
  a_opts.pathlist.strings = opts->pathspec.strings; \
1274
1280
  a_opts.pathlist.count = opts->pathspec.count; \
@@ -1319,7 +1325,7 @@ static int diff_load_index(git_index **index, git_repository *repo)
1319
1325
 
1320
1326
  /* reload the repository index when user did not pass one in */
1321
1327
  if (!error && git_index_read(*index, false) < 0)
1322
- giterr_clear();
1328
+ git_error_clear();
1323
1329
 
1324
1330
  return error;
1325
1331
  }
@@ -1551,7 +1557,7 @@ int git_diff__paired_foreach(
1551
1557
  }
1552
1558
 
1553
1559
  if ((error = cb(h2i, i2w, payload)) != 0) {
1554
- giterr_set_after_callback(error);
1560
+ git_error_set_after_callback(error);
1555
1561
  break;
1556
1562
  }
1557
1563
  }
@@ -1590,7 +1596,7 @@ int git_diff__commit(
1590
1596
  char commit_oidstr[GIT_OID_HEXSZ + 1];
1591
1597
 
1592
1598
  error = -1;
1593
- giterr_set(GITERR_INVALID, "commit %s is a merge commit",
1599
+ git_error_set(GIT_ERROR_INVALID, "commit %s is a merge commit",
1594
1600
  git_oid_tostr(commit_oidstr, GIT_OID_HEXSZ + 1, git_commit_id(commit)));
1595
1601
  goto on_error;
1596
1602
  }
@@ -109,7 +109,7 @@ GIT_INLINE(int) git_diff_file__resolve_zero_size(
109
109
  int error;
110
110
  git_odb *odb;
111
111
  size_t len;
112
- git_otype type;
112
+ git_object_t type;
113
113
 
114
114
  if ((error = git_repository_odb(&odb, repo)) < 0)
115
115
  return error;
@@ -78,10 +78,10 @@ int git_diff_from_buffer(
78
78
  *out = NULL;
79
79
 
80
80
  diff = diff_parsed_alloc();
81
- GITERR_CHECK_ALLOC(diff);
81
+ GIT_ERROR_CHECK_ALLOC(diff);
82
82
 
83
83
  ctx = git_patch_parse_ctx_init(content, content_len, NULL);
84
- GITERR_CHECK_ALLOC(ctx);
84
+ GIT_ERROR_CHECK_ALLOC(ctx);
85
85
 
86
86
  while (ctx->parse_ctx.remain_len) {
87
87
  if ((error = git_patch_parse(&patch, ctx)) < 0)
@@ -92,7 +92,7 @@ int git_diff_from_buffer(
92
92
  }
93
93
 
94
94
  if (error == GIT_ENOTFOUND && git_vector_length(&diff->patches) > 0) {
95
- giterr_clear();
95
+ git_error_clear();
96
96
  error = 0;
97
97
  }
98
98
 
@@ -224,7 +224,7 @@ static int diff_print_one_raw(
224
224
  delta->new_file.id_abbrev;
225
225
 
226
226
  if (pi->id_strlen > id_abbrev) {
227
- giterr_set(GITERR_PATCH,
227
+ git_error_set(GIT_ERROR_PATCH,
228
228
  "the patch input contains %d id characters (cannot print %d)",
229
229
  id_abbrev, pi->id_strlen);
230
230
  return -1;
@@ -275,7 +275,7 @@ static int diff_print_oid_range(
275
275
 
276
276
  if (delta->old_file.mode &&
277
277
  id_strlen > delta->old_file.id_abbrev) {
278
- giterr_set(GITERR_PATCH,
278
+ git_error_set(GIT_ERROR_PATCH,
279
279
  "the patch input contains %d id characters (cannot print %d)",
280
280
  delta->old_file.id_abbrev, id_strlen);
281
281
  return -1;
@@ -283,7 +283,7 @@ static int diff_print_oid_range(
283
283
 
284
284
  if ((delta->new_file.mode &&
285
285
  id_strlen > delta->new_file.id_abbrev)) {
286
- giterr_set(GITERR_PATCH,
286
+ git_error_set(GIT_ERROR_PATCH,
287
287
  "the patch input contains %d id characters (cannot print %d)",
288
288
  delta->new_file.id_abbrev, id_strlen);
289
289
  return -1;
@@ -343,7 +343,7 @@ int diff_delta_format_similarity_header(
343
343
  int error = 0;
344
344
 
345
345
  if (delta->similarity > 100) {
346
- giterr_set(GITERR_PATCH, "invalid similarity %d", delta->similarity);
346
+ git_error_set(GIT_ERROR_PATCH, "invalid similarity %d", delta->similarity);
347
347
  error = -1;
348
348
  goto done;
349
349
  }
@@ -373,8 +373,8 @@ int diff_delta_format_similarity_header(
373
373
  error = -1;
374
374
 
375
375
  done:
376
- git_buf_free(&old_path);
377
- git_buf_free(&new_path);
376
+ git_buf_dispose(&old_path);
377
+ git_buf_dispose(&new_path);
378
378
 
379
379
  return error;
380
380
  }
@@ -446,8 +446,8 @@ int git_diff_delta__format_file_header(
446
446
  error = -1;
447
447
 
448
448
  done:
449
- git_buf_free(&old_path);
450
- git_buf_free(&new_path);
449
+ git_buf_dispose(&old_path);
450
+ git_buf_dispose(&new_path);
451
451
 
452
452
  return error;
453
453
  }
@@ -509,8 +509,8 @@ static int diff_print_patch_file_binary_noshow(
509
509
  old_path.ptr, new_path.ptr);
510
510
 
511
511
  done:
512
- git_buf_free(&old_path);
513
- git_buf_free(&new_path);
512
+ git_buf_dispose(&old_path);
513
+ git_buf_dispose(&new_path);
514
514
 
515
515
  return error;
516
516
  }
@@ -540,7 +540,7 @@ static int diff_print_patch_file_binary(
540
540
  binary->old_file.datalen, binary->old_file.inflatedlen)) < 0) {
541
541
 
542
542
  if (error == GIT_EBUFS) {
543
- giterr_clear();
543
+ git_error_clear();
544
544
  git_buf_truncate(pi->buf, pre_binary_size);
545
545
 
546
546
  return diff_print_patch_file_binary_noshow(
@@ -683,7 +683,7 @@ int git_diff_print(
683
683
  print_file = diff_print_one_name_status;
684
684
  break;
685
685
  default:
686
- giterr_set(GITERR_INVALID, "unknown diff output format (%d)", format);
686
+ git_error_set(GIT_ERROR_INVALID, "unknown diff output format (%d)", format);
687
687
  return -1;
688
688
  }
689
689
 
@@ -693,10 +693,10 @@ int git_diff_print(
693
693
  diff, print_file, print_binary, print_hunk, print_line, &pi);
694
694
 
695
695
  if (error) /* make sure error message is set */
696
- giterr_set_after_callback_function(error, "git_diff_print");
696
+ git_error_set_after_callback_function(error, "git_diff_print");
697
697
  }
698
698
 
699
- git_buf_free(&buf);
699
+ git_buf_dispose(&buf);
700
700
 
701
701
  return error;
702
702
  }
@@ -711,7 +711,7 @@ int git_diff_print_callback__to_buf(
711
711
  GIT_UNUSED(delta); GIT_UNUSED(hunk);
712
712
 
713
713
  if (!output) {
714
- giterr_set(GITERR_INVALID, "buffer pointer must be provided");
714
+ git_error_set(GIT_ERROR_INVALID, "buffer pointer must be provided");
715
715
  return -1;
716
716
  }
717
717
 
@@ -773,10 +773,10 @@ int git_patch_print(
773
773
  &pi);
774
774
 
775
775
  if (error) /* make sure error message is set */
776
- giterr_set_after_callback_function(error, "git_patch_print");
776
+ git_error_set_after_callback_function(error, "git_patch_print");
777
777
  }
778
778
 
779
- git_buf_free(&temp);
779
+ git_buf_dispose(&temp);
780
780
 
781
781
  return error;
782
782
  }
@@ -54,22 +54,37 @@ int git_diff_file_stats__full_to_buf(
54
54
  size_t width)
55
55
  {
56
56
  const char *old_path = NULL, *new_path = NULL;
57
- size_t padding, old_size, new_size;
57
+ size_t padding;
58
+ git_off_t old_size, new_size;
58
59
 
59
60
  old_path = delta->old_file.path;
60
61
  new_path = delta->new_file.path;
61
62
  old_size = delta->old_file.size;
62
63
  new_size = delta->new_file.size;
63
64
 
64
- if (git_buf_printf(out, " %s", old_path) < 0)
65
- goto on_error;
66
-
67
65
  if (strcmp(old_path, new_path) != 0) {
66
+ size_t common_dirlen;
67
+ int error;
68
+
68
69
  padding = stats->max_name - strlen(old_path) - strlen(new_path);
69
70
 
70
- if (git_buf_printf(out, DIFF_RENAME_FILE_SEPARATOR "%s", new_path) < 0)
71
+ if ((common_dirlen = git_path_common_dirlen(old_path, new_path)) &&
72
+ common_dirlen <= INT_MAX) {
73
+ error = git_buf_printf(out, " %.*s{%s"DIFF_RENAME_FILE_SEPARATOR"%s}",
74
+ (int) common_dirlen, old_path,
75
+ old_path + common_dirlen,
76
+ new_path + common_dirlen);
77
+ } else {
78
+ error = git_buf_printf(out, " %s" DIFF_RENAME_FILE_SEPARATOR "%s",
79
+ old_path, new_path);
80
+ }
81
+
82
+ if (error < 0)
71
83
  goto on_error;
72
84
  } else {
85
+ if (git_buf_printf(out, " %s", old_path) < 0)
86
+ goto on_error;
87
+
73
88
  padding = stats->max_name - strlen(old_path);
74
89
 
75
90
  if (stats->renames > 0)
@@ -82,7 +97,7 @@ int git_diff_file_stats__full_to_buf(
82
97
 
83
98
  if (delta->flags & GIT_DIFF_FLAG_BINARY) {
84
99
  if (git_buf_printf(out,
85
- "Bin %" PRIuZ " -> %" PRIuZ " bytes", old_size, new_size) < 0)
100
+ "Bin %" PRId64 " -> %" PRId64 " bytes", old_size, new_size) < 0)
86
101
  goto on_error;
87
102
  }
88
103
  else {
@@ -170,7 +185,7 @@ int git_diff_get_stats(
170
185
  assert(out && diff);
171
186
 
172
187
  stats = git__calloc(1, sizeof(git_diff_stats));
173
- GITERR_CHECK_ALLOC(stats);
188
+ GIT_ERROR_CHECK_ALLOC(stats);
174
189
 
175
190
  deltas = git_diff_num_deltas(diff);
176
191