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
@@ -56,7 +56,7 @@ int git_smart__store_refs(transport_smart *t, int flushes)
56
56
  return recvd;
57
57
 
58
58
  if (recvd == 0) {
59
- giterr_set(GITERR_NET, "early EOF");
59
+ git_error_set(GIT_ERROR_NET, "early EOF");
60
60
  return GIT_EEOF;
61
61
  }
62
62
 
@@ -65,7 +65,7 @@ int git_smart__store_refs(transport_smart *t, int flushes)
65
65
 
66
66
  gitno_consume(buf, line_end);
67
67
  if (pkt->type == GIT_PKT_ERR) {
68
- giterr_set(GITERR_NET, "remote error: %s", ((git_pkt_err *)pkt)->error);
68
+ git_error_set(GIT_ERROR_NET, "remote error: %s", ((git_pkt_err *)pkt)->error);
69
69
  git__free(pkt);
70
70
  return -1;
71
71
  }
@@ -103,14 +103,14 @@ static int append_symref(const char **out, git_vector *symrefs, const char *ptr)
103
103
 
104
104
  /* symref mapping has refspec format */
105
105
  mapping = git__calloc(1, sizeof(git_refspec));
106
- GITERR_CHECK_ALLOC(mapping);
106
+ GIT_ERROR_CHECK_ALLOC(mapping);
107
107
 
108
108
  error = git_refspec__parse(mapping, git_buf_cstr(&buf), true);
109
- git_buf_free(&buf);
109
+ git_buf_dispose(&buf);
110
110
 
111
111
  /* if the error isn't OOM, then it's a parse error; let's use a nicer message */
112
112
  if (error < 0) {
113
- if (giterr_last()->klass != GITERR_NOMEMORY)
113
+ if (git_error_last()->klass != GIT_ERROR_NOMEMORY)
114
114
  goto on_invalid;
115
115
 
116
116
  git__free(mapping);
@@ -124,8 +124,8 @@ static int append_symref(const char **out, git_vector *symrefs, const char *ptr)
124
124
  return 0;
125
125
 
126
126
  on_invalid:
127
- giterr_set(GITERR_NET, "remote sent invalid symref");
128
- git_refspec__free(mapping);
127
+ git_error_set(GIT_ERROR_NET, "remote sent invalid symref");
128
+ git_refspec__dispose(mapping);
129
129
  git__free(mapping);
130
130
  return -1;
131
131
  }
@@ -136,7 +136,7 @@ int git_smart__detect_caps(git_pkt_ref *pkt, transport_smart_caps *caps, git_vec
136
136
 
137
137
  /* No refs or capabilites, odd but not a problem */
138
138
  if (pkt == NULL || pkt->capabilities == NULL)
139
- return 0;
139
+ return GIT_ENOTFOUND;
140
140
 
141
141
  ptr = pkt->capabilities;
142
142
  while (ptr != NULL && *ptr != '\0') {
@@ -209,7 +209,7 @@ int git_smart__detect_caps(git_pkt_ref *pkt, transport_smart_caps *caps, git_vec
209
209
  return 0;
210
210
  }
211
211
 
212
- static int recv_pkt(git_pkt **out, git_pkt_type *pkt_type, gitno_buffer *buf)
212
+ static int recv_pkt(git_pkt **out_pkt, git_pkt_type *out_type, gitno_buffer *buf)
213
213
  {
214
214
  const char *ptr = buf->data, *line_end = ptr;
215
215
  git_pkt *pkt = NULL;
@@ -230,16 +230,16 @@ static int recv_pkt(git_pkt **out, git_pkt_type *pkt_type, gitno_buffer *buf)
230
230
  if ((ret = gitno_recv(buf)) < 0) {
231
231
  return ret;
232
232
  } else if (ret == 0) {
233
- giterr_set(GITERR_NET, "early EOF");
233
+ git_error_set(GIT_ERROR_NET, "early EOF");
234
234
  return GIT_EEOF;
235
235
  }
236
236
  } while (error);
237
237
 
238
238
  gitno_consume(buf, line_end);
239
- if (pkt_type)
240
- *pkt_type = pkt->type;
241
- if (out != NULL)
242
- *out = pkt;
239
+ if (out_type != NULL)
240
+ *out_type = pkt->type;
241
+ if (out_pkt != NULL)
242
+ *out_pkt = pkt;
243
243
  else
244
244
  git__free(pkt);
245
245
 
@@ -256,14 +256,15 @@ static int store_common(transport_smart *t)
256
256
  if ((error = recv_pkt(&pkt, NULL, buf)) < 0)
257
257
  return error;
258
258
 
259
- if (pkt->type == GIT_PKT_ACK) {
260
- if (git_vector_insert(&t->common, pkt) < 0)
261
- return -1;
262
- } else {
259
+ if (pkt->type != GIT_PKT_ACK) {
263
260
  git__free(pkt);
264
261
  return 0;
265
262
  }
266
263
 
264
+ if (git_vector_insert(&t->common, pkt) < 0) {
265
+ git__free(pkt);
266
+ return -1;
267
+ }
267
268
  } while (1);
268
269
 
269
270
  return 0;
@@ -296,7 +297,7 @@ static int fetch_setup_walk(git_revwalk **out, git_repository *repo)
296
297
  if ((error = git_reference_lookup(&ref, repo, refs.strings[i])) < 0)
297
298
  goto on_error;
298
299
 
299
- if (git_reference_type(ref) == GIT_REF_SYMBOLIC)
300
+ if (git_reference_type(ref) == GIT_REFERENCE_SYMBOLIC)
300
301
  continue;
301
302
 
302
303
  if ((error = git_revwalk_push(walk, git_reference_target(ref))) < 0)
@@ -316,27 +317,30 @@ on_error:
316
317
  static int wait_while_ack(gitno_buffer *buf)
317
318
  {
318
319
  int error;
319
- git_pkt_ack *pkt = NULL;
320
+ git_pkt *pkt = NULL;
321
+ git_pkt_ack *ack = NULL;
320
322
 
321
323
  while (1) {
322
- git__free(pkt);
324
+ git_pkt_free(pkt);
323
325
 
324
- if ((error = recv_pkt((git_pkt **)&pkt, NULL, buf)) < 0)
326
+ if ((error = recv_pkt(&pkt, NULL, buf)) < 0)
325
327
  return error;
326
328
 
327
329
  if (pkt->type == GIT_PKT_NAK)
328
330
  break;
331
+ if (pkt->type != GIT_PKT_ACK)
332
+ continue;
329
333
 
330
- if (pkt->type == GIT_PKT_ACK &&
331
- (pkt->status != GIT_ACK_CONTINUE &&
332
- pkt->status != GIT_ACK_COMMON &&
333
- pkt->status != GIT_ACK_READY)) {
334
- git__free(pkt);
335
- return 0;
334
+ ack = (git_pkt_ack*)pkt;
335
+
336
+ if (ack->status != GIT_ACK_CONTINUE &&
337
+ ack->status != GIT_ACK_COMMON &&
338
+ ack->status != GIT_ACK_READY) {
339
+ break;
336
340
  }
337
341
  }
338
342
 
339
- git__free(pkt);
343
+ git_pkt_free(pkt);
340
344
  return 0;
341
345
  }
342
346
 
@@ -378,7 +382,7 @@ int git_smart__negotiate_fetch(git_transport *transport, git_repository *repo, c
378
382
  i++;
379
383
  if (i % 20 == 0) {
380
384
  if (t->cancelled.val) {
381
- giterr_set(GITERR_NET, "The fetch was cancelled by the user");
385
+ git_error_set(GIT_ERROR_NET, "The fetch was cancelled by the user");
382
386
  error = GIT_EUSER;
383
387
  goto on_error;
384
388
  }
@@ -397,15 +401,15 @@ int git_smart__negotiate_fetch(git_transport *transport, git_repository *repo, c
397
401
  if ((error = store_common(t)) < 0)
398
402
  goto on_error;
399
403
  } else {
400
- error = recv_pkt(NULL, &pkt_type, buf);
401
- if (error < 0) {
404
+ if ((error = recv_pkt(NULL, &pkt_type, buf)) < 0)
402
405
  goto on_error;
403
- } else if (pkt_type == GIT_PKT_ACK) {
406
+
407
+ if (pkt_type == GIT_PKT_ACK) {
404
408
  break;
405
409
  } else if (pkt_type == GIT_PKT_NAK) {
406
410
  continue;
407
411
  } else {
408
- giterr_set(GITERR_NET, "Unexpected pkt type");
412
+ git_error_set(GIT_ERROR_NET, "Unexpected pkt type");
409
413
  error = -1;
410
414
  goto on_error;
411
415
  }
@@ -457,24 +461,23 @@ int git_smart__negotiate_fetch(git_transport *transport, git_repository *repo, c
457
461
  goto on_error;
458
462
 
459
463
  if (t->cancelled.val) {
460
- giterr_set(GITERR_NET, "The fetch was cancelled by the user");
464
+ git_error_set(GIT_ERROR_NET, "The fetch was cancelled by the user");
461
465
  error = GIT_EUSER;
462
466
  goto on_error;
463
467
  }
464
468
  if ((error = git_smart__negotiation_step(&t->parent, data.ptr, data.size)) < 0)
465
469
  goto on_error;
466
470
 
467
- git_buf_free(&data);
471
+ git_buf_dispose(&data);
468
472
  git_revwalk_free(walk);
469
473
 
470
474
  /* Now let's eat up whatever the server gives us */
471
475
  if (!t->caps.multi_ack && !t->caps.multi_ack_detailed) {
472
- error = recv_pkt(NULL, &pkt_type, buf);
473
-
474
- if (error < 0) {
476
+ if ((error = recv_pkt(NULL, &pkt_type, buf)) < 0)
475
477
  return error;
476
- } else if (pkt_type != GIT_PKT_ACK && pkt_type != GIT_PKT_NAK) {
477
- giterr_set(GITERR_NET, "Unexpected pkt type");
478
+
479
+ if (pkt_type != GIT_PKT_ACK && pkt_type != GIT_PKT_NAK) {
480
+ git_error_set(GIT_ERROR_NET, "Unexpected pkt type");
478
481
  return -1;
479
482
  }
480
483
  } else {
@@ -485,7 +488,7 @@ int git_smart__negotiate_fetch(git_transport *transport, git_repository *repo, c
485
488
 
486
489
  on_error:
487
490
  git_revwalk_free(walk);
488
- git_buf_free(&data);
491
+ git_buf_dispose(&data);
489
492
  return error;
490
493
  }
491
494
 
@@ -495,7 +498,7 @@ static int no_sideband(transport_smart *t, struct git_odb_writepack *writepack,
495
498
 
496
499
  do {
497
500
  if (t->cancelled.val) {
498
- giterr_set(GITERR_NET, "The fetch was cancelled by the user");
501
+ git_error_set(GIT_ERROR_NET, "The fetch was cancelled by the user");
499
502
  return GIT_EUSER;
500
503
  }
501
504
 
@@ -588,7 +591,7 @@ int git_smart__download_pack(
588
591
 
589
592
  /* Check cancellation before network call */
590
593
  if (t->cancelled.val) {
591
- giterr_clear();
594
+ git_error_clear();
592
595
  error = GIT_EUSER;
593
596
  goto done;
594
597
  }
@@ -596,7 +599,7 @@ int git_smart__download_pack(
596
599
  if ((error = recv_pkt(&pkt, NULL, buf)) >= 0) {
597
600
  /* Check cancellation after network call */
598
601
  if (t->cancelled.val) {
599
- giterr_clear();
602
+ git_error_clear();
600
603
  error = GIT_EUSER;
601
604
  } else if (pkt->type == GIT_PKT_PROGRESS) {
602
605
  if (t->progress_cb) {
@@ -615,7 +618,8 @@ int git_smart__download_pack(
615
618
  }
616
619
  }
617
620
 
618
- git__free(pkt);
621
+ git_pkt_free(pkt);
622
+
619
623
  if (error < 0)
620
624
  goto done;
621
625
 
@@ -697,7 +701,7 @@ static int add_push_report_pkt(git_push *push, git_pkt *pkt)
697
701
  switch (pkt->type) {
698
702
  case GIT_PKT_OK:
699
703
  status = git__calloc(1, sizeof(push_status));
700
- GITERR_CHECK_ALLOC(status);
704
+ GIT_ERROR_CHECK_ALLOC(status);
701
705
  status->msg = NULL;
702
706
  status->ref = git__strdup(((git_pkt_ok *)pkt)->ref);
703
707
  if (!status->ref ||
@@ -708,7 +712,7 @@ static int add_push_report_pkt(git_push *push, git_pkt *pkt)
708
712
  break;
709
713
  case GIT_PKT_NG:
710
714
  status = git__calloc(1, sizeof(push_status));
711
- GITERR_CHECK_ALLOC(status);
715
+ GIT_ERROR_CHECK_ALLOC(status);
712
716
  status->ref = git__strdup(((git_pkt_ng *)pkt)->ref);
713
717
  status->msg = git__strdup(((git_pkt_ng *)pkt)->msg);
714
718
  if (!status->ref || !status->msg ||
@@ -723,7 +727,7 @@ static int add_push_report_pkt(git_push *push, git_pkt *pkt)
723
727
  case GIT_PKT_FLUSH:
724
728
  return GIT_ITEROVER;
725
729
  default:
726
- giterr_set(GITERR_NET, "report-status: protocol error");
730
+ git_error_set(GIT_ERROR_NET, "report-status: protocol error");
727
731
  return -1;
728
732
  }
729
733
 
@@ -811,7 +815,7 @@ static int parse_report(transport_smart *transport, git_push *push)
811
815
  }
812
816
 
813
817
  if (recvd == 0) {
814
- giterr_set(GITERR_NET, "early EOF");
818
+ git_error_set(GIT_ERROR_NET, "early EOF");
815
819
  error = GIT_EEOF;
816
820
  goto done;
817
821
  }
@@ -828,7 +832,7 @@ static int parse_report(transport_smart *transport, git_push *push)
828
832
  error = add_push_report_sideband_pkt(push, (git_pkt_data *)pkt, &data_pkt_buf);
829
833
  break;
830
834
  case GIT_PKT_ERR:
831
- giterr_set(GITERR_NET, "report-status: Error reported: %s",
835
+ git_error_set(GIT_ERROR_NET, "report-status: Error reported: %s",
832
836
  ((git_pkt_err *)pkt)->error);
833
837
  error = -1;
834
838
  break;
@@ -851,7 +855,7 @@ static int parse_report(transport_smart *transport, git_push *push)
851
855
  if (data_pkt_buf.size > 0) {
852
856
  /* If there was data remaining in the pack data buffer,
853
857
  * then the server sent a partial pkt-line */
854
- giterr_set(GITERR_NET, "Incomplete pack data pkt-line");
858
+ git_error_set(GIT_ERROR_NET, "Incomplete pack data pkt-line");
855
859
  error = GIT_ERROR;
856
860
  }
857
861
  goto done;
@@ -862,14 +866,14 @@ static int parse_report(transport_smart *transport, git_push *push)
862
866
  }
863
867
  }
864
868
  done:
865
- git_buf_free(&data_pkt_buf);
869
+ git_buf_dispose(&data_pkt_buf);
866
870
  return error;
867
871
  }
868
872
 
869
873
  static int add_ref_from_push_spec(git_vector *refs, push_spec *push_spec)
870
874
  {
871
875
  git_pkt_ref *added = git__calloc(1, sizeof(git_pkt_ref));
872
- GITERR_CHECK_ALLOC(added);
876
+ GIT_ERROR_CHECK_ALLOC(added);
873
877
 
874
878
  added->type = GIT_PKT_REF;
875
879
  git_oid_cpy(&added->head.oid, &push_spec->loid);
@@ -898,7 +902,7 @@ static int update_refs_from_report(
898
902
  /* For each push spec we sent to the server, we should have
899
903
  * gotten back a status packet in the push report */
900
904
  if (push_specs->length != push_report->length) {
901
- giterr_set(GITERR_NET, "report-status: protocol error");
905
+ git_error_set(GIT_ERROR_NET, "report-status: protocol error");
902
906
  return -1;
903
907
  }
904
908
 
@@ -913,7 +917,7 @@ static int update_refs_from_report(
913
917
  /* For each push spec we sent to the server, we should have
914
918
  * gotten back a status packet in the push report which matches */
915
919
  if (strcmp(push_spec->refspec.dst, push_status->ref)) {
916
- giterr_set(GITERR_NET, "report-status: protocol error");
920
+ git_error_set(GIT_ERROR_NET, "report-status: protocol error");
917
921
  return -1;
918
922
  }
919
923
  }
@@ -1085,6 +1089,6 @@ int git_smart__push(git_transport *transport, git_push *push, const git_remote_c
1085
1089
  }
1086
1090
 
1087
1091
  done:
1088
- git_buf_free(&pktline);
1092
+ git_buf_dispose(&pktline);
1089
1093
  return error;
1090
1094
  }
@@ -54,7 +54,7 @@ static void ssh_error(LIBSSH2_SESSION *session, const char *errmsg)
54
54
  char *ssherr;
55
55
  libssh2_session_last_error(session, &ssherr, NULL, 0);
56
56
 
57
- giterr_set(GITERR_SSH, "%s: %s", errmsg, ssherr);
57
+ git_error_set(GIT_ERROR_SSH, "%s: %s", errmsg, ssherr);
58
58
  }
59
59
 
60
60
  /*
@@ -85,7 +85,7 @@ static int gen_proto(git_buf *request, const char *cmd, const char *url)
85
85
 
86
86
  done:
87
87
  if (!repo) {
88
- giterr_set(GITERR_NET, "malformed git protocol URL");
88
+ git_error_set(GIT_ERROR_NET, "malformed git protocol URL");
89
89
  return -1;
90
90
  }
91
91
 
@@ -121,7 +121,7 @@ static int send_command(ssh_stream *s)
121
121
  s->sent_command = 1;
122
122
 
123
123
  cleanup:
124
- git_buf_free(&request);
124
+ git_buf_dispose(&request);
125
125
  return error;
126
126
  }
127
127
 
@@ -151,7 +151,7 @@ static int ssh_stream_read(
151
151
  */
152
152
  if (rc == 0) {
153
153
  if ((rc = libssh2_channel_read_stderr(s->channel, buffer, buf_size)) > 0) {
154
- giterr_set(GITERR_SSH, "%*s", rc, buffer);
154
+ git_error_set(GIT_ERROR_SSH, "%*s", rc, buffer);
155
155
  return GIT_EEOF;
156
156
  } else if (rc < LIBSSH2_ERROR_NONE) {
157
157
  ssh_error(s->session, "SSH could not read stderr");
@@ -238,7 +238,7 @@ static int ssh_stream_alloc(
238
238
  assert(stream);
239
239
 
240
240
  s = git__calloc(sizeof(ssh_stream), 1);
241
- GITERR_CHECK_ALLOC(s);
241
+ GIT_ERROR_CHECK_ALLOC(s);
242
242
 
243
243
  s->parent.subtransport = &t->parent;
244
244
  s->parent.read = ssh_stream_read;
@@ -272,19 +272,19 @@ static int git_ssh_extract_url_parts(
272
272
  if (at) {
273
273
  start = at + 1;
274
274
  *username = git__substrdup(url, at - url);
275
- GITERR_CHECK_ALLOC(*username);
275
+ GIT_ERROR_CHECK_ALLOC(*username);
276
276
  } else {
277
277
  start = url;
278
278
  *username = NULL;
279
279
  }
280
280
 
281
281
  if (colon == NULL || (colon < start)) {
282
- giterr_set(GITERR_NET, "malformed URL");
282
+ git_error_set(GIT_ERROR_NET, "malformed URL");
283
283
  return -1;
284
284
  }
285
285
 
286
286
  *host = git__substrdup(start, colon - start);
287
- GITERR_CHECK_ALLOC(*host);
287
+ GIT_ERROR_CHECK_ALLOC(*host);
288
288
 
289
289
  return 0;
290
290
  }
@@ -350,7 +350,7 @@ static int _git_ssh_authenticate_session(
350
350
  int rc;
351
351
 
352
352
  do {
353
- giterr_clear();
353
+ git_error_clear();
354
354
  switch (cred->credtype) {
355
355
  case GIT_CREDTYPE_USERPASS_PLAINTEXT: {
356
356
  git_cred_userpass_plaintext *c = (git_cred_userpass_plaintext *)cred;
@@ -428,7 +428,7 @@ static int _git_ssh_authenticate_session(
428
428
  return GIT_EAUTH;
429
429
 
430
430
  if (rc != LIBSSH2_ERROR_NONE) {
431
- if (!giterr_last())
431
+ if (!git_error_last())
432
432
  ssh_error(session, "Failed to authenticate SSH session");
433
433
  return -1;
434
434
  }
@@ -447,24 +447,24 @@ static int request_creds(git_cred **out, ssh_subtransport *t, const char *user,
447
447
  error = t->owner->cred_acquire_cb(&cred, t->owner->url, user, auth_methods,
448
448
  t->owner->cred_acquire_payload);
449
449
 
450
- if (error == GIT_PASSTHROUGH)
450
+ if (error == GIT_PASSTHROUGH) {
451
451
  no_callback = 1;
452
- else if (error < 0)
452
+ } else if (error < 0) {
453
453
  return error;
454
- else if (!cred) {
455
- giterr_set(GITERR_SSH, "callback failed to initialize SSH credentials");
454
+ } else if (!cred) {
455
+ git_error_set(GIT_ERROR_SSH, "callback failed to initialize SSH credentials");
456
456
  return -1;
457
457
  }
458
458
  }
459
459
 
460
460
  if (no_callback) {
461
- giterr_set(GITERR_SSH, "authentication required but no callback set");
461
+ git_error_set(GIT_ERROR_SSH, "authentication required but no callback set");
462
462
  return -1;
463
463
  }
464
464
 
465
465
  if (!(cred->credtype & auth_methods)) {
466
466
  cred->free(cred);
467
- giterr_set(GITERR_SSH, "callback returned unsupported credentials type");
467
+ git_error_set(GIT_ERROR_SSH, "callback returned unsupported credentials type");
468
468
  return -1;
469
469
  }
470
470
 
@@ -485,7 +485,7 @@ static int _git_ssh_session_create(
485
485
 
486
486
  s = libssh2_session_init();
487
487
  if (!s) {
488
- giterr_set(GITERR_NET, "failed to initialize SSH session");
488
+ git_error_set(GIT_ERROR_NET, "failed to initialize SSH session");
489
489
  return -1;
490
490
  }
491
491
 
@@ -544,7 +544,7 @@ static int _git_ssh_setup_conn(
544
544
  if ((error = git_ssh_extract_url_parts(&host, &user, url)) < 0)
545
545
  goto done;
546
546
  port = git__strdup(default_port);
547
- GITERR_CHECK_ALLOC(port);
547
+ GIT_ERROR_CHECK_ALLOC(port);
548
548
 
549
549
  post_extract:
550
550
  if ((error = git_socket_stream_new(&s->io, host, port)) < 0 ||
@@ -573,20 +573,21 @@ post_extract:
573
573
  }
574
574
 
575
575
  if (cert.type == 0) {
576
- giterr_set(GITERR_SSH, "unable to get the host key");
576
+ git_error_set(GIT_ERROR_SSH, "unable to get the host key");
577
577
  error = -1;
578
578
  goto done;
579
579
  }
580
580
 
581
581
  /* We don't currently trust any hostkeys */
582
- giterr_clear();
582
+ git_error_clear();
583
583
 
584
584
  cert_ptr = &cert;
585
585
 
586
586
  error = t->owner->certificate_check_cb((git_cert *) cert_ptr, 0, host, t->owner->message_cb_payload);
587
- if (error < 0) {
588
- if (!giterr_last())
589
- giterr_set(GITERR_NET, "user cancelled hostkey check");
587
+
588
+ if (error < 0 && error != GIT_PASSTHROUGH) {
589
+ if (!git_error_last())
590
+ git_error_set(GIT_ERROR_NET, "user cancelled hostkey check");
590
591
 
591
592
  goto done;
592
593
  }
@@ -625,7 +626,7 @@ post_extract:
625
626
  goto done;
626
627
 
627
628
  if (strcmp(user, git_cred__username(cred))) {
628
- giterr_set(GITERR_SSH, "username does not match previous request");
629
+ git_error_set(GIT_ERROR_SSH, "username does not match previous request");
629
630
  error = -1;
630
631
  goto done;
631
632
  }
@@ -692,7 +693,7 @@ static int ssh_uploadpack(
692
693
  return 0;
693
694
  }
694
695
 
695
- giterr_set(GITERR_NET, "must call UPLOADPACK_LS before UPLOADPACK");
696
+ git_error_set(GIT_ERROR_NET, "must call UPLOADPACK_LS before UPLOADPACK");
696
697
  return -1;
697
698
  }
698
699
 
@@ -719,7 +720,7 @@ static int ssh_receivepack(
719
720
  return 0;
720
721
  }
721
722
 
722
- giterr_set(GITERR_NET, "must call RECEIVEPACK_LS before RECEIVEPACK");
723
+ git_error_set(GIT_ERROR_NET, "must call RECEIVEPACK_LS before RECEIVEPACK");
723
724
  return -1;
724
725
  }
725
726
 
@@ -835,7 +836,7 @@ int git_smart_subtransport_ssh(
835
836
  GIT_UNUSED(param);
836
837
 
837
838
  t = git__calloc(sizeof(ssh_subtransport), 1);
838
- GITERR_CHECK_ALLOC(t);
839
+ GIT_ERROR_CHECK_ALLOC(t);
839
840
 
840
841
  t->owner = (transport_smart *)owner;
841
842
  t->parent.action = _ssh_action;
@@ -851,7 +852,7 @@ int git_smart_subtransport_ssh(
851
852
  assert(out);
852
853
  *out = NULL;
853
854
 
854
- giterr_set(GITERR_INVALID, "cannot create SSH transport. Library was built without SSH support");
855
+ git_error_set(GIT_ERROR_INVALID, "cannot create SSH transport. Library was built without SSH support");
855
856
  return -1;
856
857
  #endif
857
858
  }
@@ -871,7 +872,7 @@ int git_transport_ssh_with_paths(git_transport **out, git_remote *owner, void *p
871
872
  };
872
873
 
873
874
  if (paths->count != 2) {
874
- giterr_set(GITERR_SSH, "invalid ssh paths, must be two strings");
875
+ git_error_set(GIT_ERROR_SSH, "invalid ssh paths, must be two strings");
875
876
  return GIT_EINVALIDSPEC;
876
877
  }
877
878
 
@@ -882,9 +883,9 @@ int git_transport_ssh_with_paths(git_transport **out, git_remote *owner, void *p
882
883
  t = (ssh_subtransport *) smart->wrapped;
883
884
 
884
885
  t->cmd_uploadpack = git__strdup(paths->strings[0]);
885
- GITERR_CHECK_ALLOC(t->cmd_uploadpack);
886
+ GIT_ERROR_CHECK_ALLOC(t->cmd_uploadpack);
886
887
  t->cmd_receivepack = git__strdup(paths->strings[1]);
887
- GITERR_CHECK_ALLOC(t->cmd_receivepack);
888
+ GIT_ERROR_CHECK_ALLOC(t->cmd_receivepack);
888
889
 
889
890
  *out = transport;
890
891
  return 0;
@@ -895,7 +896,7 @@ int git_transport_ssh_with_paths(git_transport **out, git_remote *owner, void *p
895
896
  assert(out);
896
897
  *out = NULL;
897
898
 
898
- giterr_set(GITERR_INVALID, "cannot create SSH transport. Library was built without SSH support");
899
+ git_error_set(GIT_ERROR_INVALID, "cannot create SSH transport. Library was built without SSH support");
899
900
  return -1;
900
901
  #endif
901
902
  }
@@ -911,7 +912,7 @@ int git_transport_ssh_global_init(void)
911
912
  {
912
913
  #ifdef GIT_SSH
913
914
  if (libssh2_init(0) < 0) {
914
- giterr_set(GITERR_SSH, "unable to initialize libssh2");
915
+ git_error_set(GIT_ERROR_SSH, "unable to initialize libssh2");
915
916
  return -1;
916
917
  }
917
918