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
@@ -55,8 +55,8 @@ extern bool git_reference__enable_symbolic_ref_target_validation;
55
55
  #define GIT_STASH_FILE "stash"
56
56
  #define GIT_REFS_STASH_FILE GIT_REFS_DIR GIT_STASH_FILE
57
57
 
58
- #define GIT_REF_FORMAT__PRECOMPOSE_UNICODE (1u << 16)
59
- #define GIT_REF_FORMAT__VALIDATION_DISABLE (1u << 15)
58
+ #define GIT_REFERENCE_FORMAT__PRECOMPOSE_UNICODE (1u << 16)
59
+ #define GIT_REFERENCE_FORMAT__VALIDATION_DISABLE (1u << 15)
60
60
 
61
61
  #define GIT_REFNAME_MAX 1024
62
62
 
@@ -64,7 +64,7 @@ typedef char git_refname_t[GIT_REFNAME_MAX];
64
64
 
65
65
  struct git_reference {
66
66
  git_refdb *db;
67
- git_ref_t type;
67
+ git_reference_t type;
68
68
 
69
69
  union {
70
70
  git_oid oid;
@@ -136,4 +136,6 @@ int git_reference__update_for_commit(
136
136
  const git_oid *id,
137
137
  const char *operation);
138
138
 
139
+ int git_reference__is_unborn_head(bool *unborn, const git_reference *ref, git_repository *repo);
140
+
139
141
  #endif
@@ -16,7 +16,7 @@
16
16
 
17
17
  int git_refspec__parse(git_refspec *refspec, const char *input, bool is_fetch)
18
18
  {
19
- // Ported from https://github.com/git/git/blob/f06d47e7e0d9db709ee204ed13a8a7486149f494/remote.c#L518-636
19
+ /* Ported from https://github.com/git/git/blob/f06d47e7e0d9db709ee204ed13a8a7486149f494/remote.c#L518-636 */
20
20
 
21
21
  size_t llen;
22
22
  int is_glob = 0;
@@ -43,11 +43,11 @@ int git_refspec__parse(git_refspec *refspec, const char *input, bool is_fetch)
43
43
  if (!is_fetch && rhs == lhs && rhs[1] == '\0') {
44
44
  refspec->matching = 1;
45
45
  refspec->string = git__strdup(input);
46
- GITERR_CHECK_ALLOC(refspec->string);
46
+ GIT_ERROR_CHECK_ALLOC(refspec->string);
47
47
  refspec->src = git__strdup("");
48
- GITERR_CHECK_ALLOC(refspec->src);
48
+ GIT_ERROR_CHECK_ALLOC(refspec->src);
49
49
  refspec->dst = git__strdup("");
50
- GITERR_CHECK_ALLOC(refspec->dst);
50
+ GIT_ERROR_CHECK_ALLOC(refspec->dst);
51
51
  return 0;
52
52
  }
53
53
 
@@ -69,8 +69,9 @@ int git_refspec__parse(git_refspec *refspec, const char *input, bool is_fetch)
69
69
 
70
70
  refspec->pattern = is_glob;
71
71
  refspec->src = git__strndup(lhs, llen);
72
- flags = GIT_REF_FORMAT_ALLOW_ONELEVEL | GIT_REF_FORMAT_REFSPEC_SHORTHAND
73
- | (is_glob ? GIT_REF_FORMAT_REFSPEC_PATTERN : 0);
72
+ flags = GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL |
73
+ GIT_REFERENCE_FORMAT_REFSPEC_SHORTHAND |
74
+ (is_glob ? GIT_REFERENCE_FORMAT_REFSPEC_PATTERN : 0);
74
75
 
75
76
  if (is_fetch) {
76
77
  /*
@@ -131,24 +132,24 @@ int git_refspec__parse(git_refspec *refspec, const char *input, bool is_fetch)
131
132
  /* if the RHS is empty, then it's a copy of the LHS */
132
133
  if (!refspec->dst) {
133
134
  refspec->dst = git__strdup(refspec->src);
134
- GITERR_CHECK_ALLOC(refspec->dst);
135
+ GIT_ERROR_CHECK_ALLOC(refspec->dst);
135
136
  }
136
137
  }
137
138
 
138
139
  refspec->string = git__strdup(input);
139
- GITERR_CHECK_ALLOC(refspec->string);
140
+ GIT_ERROR_CHECK_ALLOC(refspec->string);
140
141
 
141
142
  return 0;
142
143
 
143
144
  invalid:
144
- giterr_set(
145
- GITERR_INVALID,
145
+ git_error_set(
146
+ GIT_ERROR_INVALID,
146
147
  "'%s' is not a valid refspec.", input);
147
- git_refspec__free(refspec);
148
+ git_refspec__dispose(refspec);
148
149
  return -1;
149
150
  }
150
151
 
151
- void git_refspec__free(git_refspec *refspec)
152
+ void git_refspec__dispose(git_refspec *refspec)
152
153
  {
153
154
  if (refspec == NULL)
154
155
  return;
@@ -160,6 +161,31 @@ void git_refspec__free(git_refspec *refspec)
160
161
  memset(refspec, 0x0, sizeof(git_refspec));
161
162
  }
162
163
 
164
+ int git_refspec_parse(git_refspec **out_refspec, const char *input, int is_fetch)
165
+ {
166
+ git_refspec *refspec;
167
+ assert(out_refspec && input);
168
+
169
+ *out_refspec = NULL;
170
+
171
+ refspec = git__malloc(sizeof(git_refspec));
172
+ GIT_ERROR_CHECK_ALLOC(refspec);
173
+
174
+ if (git_refspec__parse(refspec, input, !!is_fetch) != 0) {
175
+ git__free(refspec);
176
+ return -1;
177
+ }
178
+
179
+ *out_refspec = refspec;
180
+ return 0;
181
+ }
182
+
183
+ void git_refspec_free(git_refspec *refspec)
184
+ {
185
+ git_refspec__dispose(refspec);
186
+ git__free(refspec);
187
+ }
188
+
163
189
  const char *git_refspec_src(const git_refspec *refspec)
164
190
  {
165
191
  return refspec == NULL ? NULL : refspec->src;
@@ -247,12 +273,12 @@ int git_refspec_transform(git_buf *out, const git_refspec *spec, const char *nam
247
273
  git_buf_sanitize(out);
248
274
 
249
275
  if (!git_refspec_src_matches(spec, name)) {
250
- giterr_set(GITERR_INVALID, "ref '%s' doesn't match the source", name);
276
+ git_error_set(GIT_ERROR_INVALID, "ref '%s' doesn't match the source", name);
251
277
  return -1;
252
278
  }
253
279
 
254
280
  if (!spec->pattern)
255
- return git_buf_puts(out, spec->dst);
281
+ return git_buf_puts(out, spec->dst ? spec->dst : "");
256
282
 
257
283
  return refspec_transform(out, spec->src, spec->dst, name);
258
284
  }
@@ -263,7 +289,7 @@ int git_refspec_rtransform(git_buf *out, const git_refspec *spec, const char *na
263
289
  git_buf_sanitize(out);
264
290
 
265
291
  if (!git_refspec_dst_matches(spec, name)) {
266
- giterr_set(GITERR_INVALID, "ref '%s' doesn't match the destination", name);
292
+ git_error_set(GIT_ERROR_INVALID, "ref '%s' doesn't match the destination", name);
267
293
  return -1;
268
294
  }
269
295
 
@@ -316,7 +342,7 @@ int git_refspec__dwim_one(git_vector *out, git_refspec *spec, git_vector *refs)
316
342
  assert(out && spec && refs);
317
343
 
318
344
  cur = git__calloc(1, sizeof(git_refspec));
319
- GITERR_CHECK_ALLOC(cur);
345
+ GIT_ERROR_CHECK_ALLOC(cur);
320
346
 
321
347
  cur->force = spec->force;
322
348
  cur->push = spec->push;
@@ -329,7 +355,7 @@ int git_refspec__dwim_one(git_vector *out, git_refspec *spec, git_vector *refs)
329
355
  for (j = 0; formatters[j]; j++) {
330
356
  git_buf_clear(&buf);
331
357
  git_buf_printf(&buf, formatters[j], spec->src);
332
- GITERR_CHECK_ALLOC_BUF(&buf);
358
+ GIT_ERROR_CHECK_ALLOC_BUF(&buf);
333
359
 
334
360
  key.name = (char *) git_buf_cstr(&buf);
335
361
  if (!git_vector_search(&pos, refs, &key)) {
@@ -342,7 +368,7 @@ int git_refspec__dwim_one(git_vector *out, git_refspec *spec, git_vector *refs)
342
368
  /* No shorthands found, copy over the name */
343
369
  if (cur->src == NULL && spec->src != NULL) {
344
370
  cur->src = git__strdup(spec->src);
345
- GITERR_CHECK_ALLOC(cur->src);
371
+ GIT_ERROR_CHECK_ALLOC(cur->src);
346
372
  }
347
373
 
348
374
  if (spec->dst && git__prefixcmp(spec->dst, GIT_REFS_DIR)) {
@@ -354,16 +380,16 @@ int git_refspec__dwim_one(git_vector *out, git_refspec *spec, git_vector *refs)
354
380
  }
355
381
 
356
382
  git_buf_puts(&buf, spec->dst);
357
- GITERR_CHECK_ALLOC_BUF(&buf);
383
+ GIT_ERROR_CHECK_ALLOC_BUF(&buf);
358
384
 
359
385
  cur->dst = git_buf_detach(&buf);
360
386
  }
361
387
 
362
- git_buf_free(&buf);
388
+ git_buf_dispose(&buf);
363
389
 
364
390
  if (cur->dst == NULL && spec->dst != NULL) {
365
391
  cur->dst = git__strdup(spec->dst);
366
- GITERR_CHECK_ALLOC(cur->dst);
392
+ GIT_ERROR_CHECK_ALLOC(cur->dst);
367
393
  }
368
394
 
369
395
  return git_vector_insert(out, cur);
@@ -30,7 +30,7 @@ int git_refspec__parse(
30
30
  const char *str,
31
31
  bool is_fetch);
32
32
 
33
- void git_refspec__free(git_refspec *refspec);
33
+ void git_refspec__dispose(git_refspec *refspec);
34
34
 
35
35
  int git_refspec__serialize(git_buf *out, const git_refspec *refspec);
36
36
 
@@ -35,7 +35,7 @@ static int add_refspec_to(git_vector *vector, const char *string, bool is_fetch)
35
35
  git_refspec *spec;
36
36
 
37
37
  spec = git__calloc(1, sizeof(git_refspec));
38
- GITERR_CHECK_ALLOC(spec);
38
+ GIT_ERROR_CHECK_ALLOC(spec);
39
39
 
40
40
  if (git_refspec__parse(spec, string, is_fetch) < 0) {
41
41
  git__free(spec);
@@ -44,7 +44,7 @@ static int add_refspec_to(git_vector *vector, const char *string, bool is_fetch)
44
44
 
45
45
  spec->push = !is_fetch;
46
46
  if (git_vector_insert(vector, spec) < 0) {
47
- git_refspec__free(spec);
47
+ git_refspec__dispose(spec);
48
48
  git__free(spec);
49
49
  return -1;
50
50
  }
@@ -67,7 +67,7 @@ static int download_tags_value(git_remote *remote, git_config *cfg)
67
67
  return -1;
68
68
 
69
69
  error = git_config__lookup_entry(&ce, cfg, git_buf_cstr(&buf), false);
70
- git_buf_free(&buf);
70
+ git_buf_dispose(&buf);
71
71
 
72
72
  if (!error && ce && ce->value) {
73
73
  if (!strcmp(ce->value, "--no-tags"))
@@ -85,8 +85,8 @@ static int ensure_remote_name_is_valid(const char *name)
85
85
  int error = 0;
86
86
 
87
87
  if (!git_remote_is_valid_name(name)) {
88
- giterr_set(
89
- GITERR_CONFIG,
88
+ git_error_set(
89
+ GIT_ERROR_CONFIG,
90
90
  "'%s' is not a valid remote name.", name ? name : "(null)");
91
91
  error = GIT_EINVALIDSPEC;
92
92
  }
@@ -111,13 +111,13 @@ static int write_add_refspec(git_repository *repo, const char *name, const char
111
111
  return error;
112
112
 
113
113
  if ((error = git_refspec__parse(&spec, refspec, fetch)) < 0) {
114
- if (giterr_last()->klass != GITERR_NOMEMORY)
114
+ if (git_error_last()->klass != GIT_ERROR_NOMEMORY)
115
115
  error = GIT_EINVALIDSPEC;
116
116
 
117
117
  return error;
118
118
  }
119
119
 
120
- git_refspec__free(&spec);
120
+ git_refspec__dispose(&spec);
121
121
 
122
122
  if ((error = git_buf_printf(&var, fmt, name)) < 0)
123
123
  return error;
@@ -132,7 +132,7 @@ static int write_add_refspec(git_repository *repo, const char *name, const char
132
132
  }
133
133
 
134
134
  cleanup:
135
- git_buf_free(&var);
135
+ git_buf_dispose(&var);
136
136
  return 0;
137
137
  }
138
138
 
@@ -168,7 +168,7 @@ static int get_check_cert(int *out, git_repository *repo)
168
168
  static int canonicalize_url(git_buf *out, const char *in)
169
169
  {
170
170
  if (in == NULL || strlen(in) == 0) {
171
- giterr_set(GITERR_INVALID, "cannot set empty URL");
171
+ git_error_set(GIT_ERROR_INVALID, "cannot set empty URL");
172
172
  return GIT_EINVALIDSPEC;
173
173
  }
174
174
 
@@ -189,58 +189,119 @@ static int canonicalize_url(git_buf *out, const char *in)
189
189
  return git_buf_puts(out, in);
190
190
  }
191
191
 
192
- static int create_internal(git_remote **out, git_repository *repo, const char *name, const char *url, const char *fetch)
192
+ static int default_fetchspec_for_name(git_buf *buf, const char *name)
193
193
  {
194
+ if (git_buf_printf(buf, "+refs/heads/*:refs/remotes/%s/*", name) < 0)
195
+ return -1;
196
+
197
+ return 0;
198
+ }
199
+
200
+ static int ensure_remote_doesnot_exist(git_repository *repo, const char *name)
201
+ {
202
+ int error;
194
203
  git_remote *remote;
204
+
205
+ error = git_remote_lookup(&remote, repo, name);
206
+
207
+ if (error == GIT_ENOTFOUND)
208
+ return 0;
209
+
210
+ if (error < 0)
211
+ return error;
212
+
213
+ git_remote_free(remote);
214
+
215
+ git_error_set(GIT_ERROR_CONFIG, "remote '%s' already exists", name);
216
+
217
+ return GIT_EEXISTS;
218
+ }
219
+
220
+ int git_remote_create_init_options(git_remote_create_options *opts, unsigned int version)
221
+ {
222
+ GIT_INIT_STRUCTURE_FROM_TEMPLATE(
223
+ opts, version, git_remote_create_options, GIT_REMOTE_CREATE_OPTIONS_INIT);
224
+ return 0;
225
+ }
226
+
227
+ int git_remote_create_with_opts(git_remote **out, const char *url, const git_remote_create_options *opts)
228
+ {
229
+ git_remote *remote = NULL;
195
230
  git_config *config_ro = NULL, *config_rw;
196
231
  git_buf canonical_url = GIT_BUF_INIT;
197
232
  git_buf var = GIT_BUF_INIT;
233
+ git_buf specbuf = GIT_BUF_INIT;
234
+ const git_remote_create_options dummy_opts = GIT_REMOTE_CREATE_OPTIONS_INIT;
198
235
  int error = -1;
199
236
 
200
- /* repo, name, and fetch are optional */
201
237
  assert(out && url);
202
238
 
203
- if (repo && (error = git_repository_config_snapshot(&config_ro, repo)) < 0)
204
- return error;
239
+ if (!opts) {
240
+ opts = &dummy_opts;
241
+ }
242
+
243
+ GIT_ERROR_CHECK_VERSION(opts, GIT_REMOTE_CREATE_OPTIONS_VERSION, "git_remote_create_options");
244
+
245
+ if (opts->name != NULL) {
246
+ if ((error = ensure_remote_name_is_valid(opts->name)) < 0)
247
+ return error;
248
+
249
+ if (opts->repository &&
250
+ (error = ensure_remote_doesnot_exist(opts->repository, opts->name)) < 0)
251
+ return error;
252
+ }
253
+
254
+ if (opts->repository) {
255
+ if ((error = git_repository_config_snapshot(&config_ro, opts->repository)) < 0)
256
+ goto on_error;
257
+ }
205
258
 
206
259
  remote = git__calloc(1, sizeof(git_remote));
207
- GITERR_CHECK_ALLOC(remote);
260
+ GIT_ERROR_CHECK_ALLOC(remote);
208
261
 
209
- remote->repo = repo;
262
+ remote->repo = opts->repository;
210
263
 
211
- if ((error = git_vector_init(&remote->refs, 32, NULL)) < 0 ||
264
+ if ((error = git_vector_init(&remote->refs, 8, NULL)) < 0 ||
212
265
  (error = canonicalize_url(&canonical_url, url)) < 0)
213
266
  goto on_error;
214
267
 
215
- if (repo) {
268
+ if (opts->repository && !(opts->flags & GIT_REMOTE_CREATE_SKIP_INSTEADOF)) {
216
269
  remote->url = apply_insteadof(config_ro, canonical_url.ptr, GIT_DIRECTION_FETCH);
217
270
  } else {
218
271
  remote->url = git__strdup(canonical_url.ptr);
219
272
  }
220
- GITERR_CHECK_ALLOC(remote->url);
221
-
222
- if (name != NULL) {
223
- remote->name = git__strdup(name);
224
- GITERR_CHECK_ALLOC(remote->name);
273
+ GIT_ERROR_CHECK_ALLOC(remote->url);
225
274
 
226
- if ((error = git_buf_printf(&var, CONFIG_URL_FMT, name)) < 0)
227
- goto on_error;
275
+ if (opts->name != NULL) {
276
+ remote->name = git__strdup(opts->name);
277
+ GIT_ERROR_CHECK_ALLOC(remote->name);
228
278
 
229
- if (repo &&
230
- ((error = git_repository_config__weakptr(&config_rw, repo)) < 0 ||
231
- (error = git_config_set_string(config_rw, var.ptr, canonical_url.ptr)) < 0))
279
+ if (opts->repository &&
280
+ ((error = git_buf_printf(&var, CONFIG_URL_FMT, opts->name)) < 0 ||
281
+ (error = git_repository_config__weakptr(&config_rw, opts->repository)) < 0 ||
282
+ (error = git_config_set_string(config_rw, var.ptr, canonical_url.ptr)) < 0))
232
283
  goto on_error;
233
284
  }
234
285
 
235
- if (fetch != NULL) {
236
- if ((error = add_refspec(remote, fetch, true)) < 0)
237
- goto on_error;
286
+ if (opts->fetchspec != NULL ||
287
+ (opts->name && !(opts->flags & GIT_REMOTE_CREATE_SKIP_DEFAULT_FETCHSPEC))) {
288
+ const char *fetch = NULL;
289
+ if (opts->fetchspec) {
290
+ fetch = opts->fetchspec;
291
+ } else {
292
+ if ((error = default_fetchspec_for_name(&specbuf, opts->name)) < 0)
293
+ goto on_error;
238
294
 
239
- /* only write for non-anonymous remotes */
240
- if (repo && name && (error = write_add_refspec(repo, name, fetch, true)) < 0)
295
+ fetch = git_buf_cstr(&specbuf);
296
+ }
297
+
298
+ if ((error = add_refspec(remote, fetch, true)) < 0)
241
299
  goto on_error;
242
300
 
243
- if (repo && (error = lookup_remote_prune_config(remote, config_ro, name)) < 0)
301
+ /* only write for named remotes with a repository */
302
+ if (opts->repository && opts->name &&
303
+ ((error = write_add_refspec(opts->repository, opts->name, fetch, true)) < 0 ||
304
+ (error = lookup_remote_prune_config(remote, config_ro, opts->name)) < 0))
244
305
  goto on_error;
245
306
 
246
307
  /* Move the data over to where the matching functions can find them */
@@ -249,13 +310,13 @@ static int create_internal(git_remote **out, git_repository *repo, const char *n
249
310
  }
250
311
 
251
312
  /* A remote without a name doesn't download tags */
252
- if (!name)
313
+ if (!opts->name)
253
314
  remote->download_tags = GIT_REMOTE_DOWNLOAD_TAGS_NONE;
254
315
  else
255
316
  remote->download_tags = GIT_REMOTE_DOWNLOAD_TAGS_AUTO;
256
317
 
257
318
 
258
- git_buf_free(&var);
319
+ git_buf_dispose(&var);
259
320
 
260
321
  *out = remote;
261
322
  error = 0;
@@ -265,79 +326,65 @@ on_error:
265
326
  git_remote_free(remote);
266
327
 
267
328
  git_config_free(config_ro);
268
- git_buf_free(&canonical_url);
269
- git_buf_free(&var);
329
+ git_buf_dispose(&specbuf);
330
+ git_buf_dispose(&canonical_url);
331
+ git_buf_dispose(&var);
270
332
  return error;
271
333
  }
272
334
 
273
- static int ensure_remote_doesnot_exist(git_repository *repo, const char *name)
335
+ int git_remote_create(git_remote **out, git_repository *repo, const char *name, const char *url)
274
336
  {
337
+ git_buf buf = GIT_BUF_INIT;
275
338
  int error;
276
- git_remote *remote;
339
+ git_remote_create_options opts = GIT_REMOTE_CREATE_OPTIONS_INIT;
277
340
 
278
- error = git_remote_lookup(&remote, repo, name);
279
-
280
- if (error == GIT_ENOTFOUND)
281
- return 0;
282
-
283
- if (error < 0)
341
+ /* Those 2 tests are duplicated here because of backward-compatibility */
342
+ if ((error = ensure_remote_name_is_valid(name)) < 0)
284
343
  return error;
285
344
 
286
- git_remote_free(remote);
287
-
288
- giterr_set(
289
- GITERR_CONFIG,
290
- "remote '%s' already exists", name);
291
-
292
- return GIT_EEXISTS;
293
- }
345
+ if (canonicalize_url(&buf, url) < 0)
346
+ return GIT_ERROR;
294
347
 
348
+ git_buf_clear(&buf);
295
349
 
296
- int git_remote_create(git_remote **out, git_repository *repo, const char *name, const char *url)
297
- {
298
- git_buf buf = GIT_BUF_INIT;
299
- int error;
350
+ opts.repository = repo;
351
+ opts.name = name;
300
352
 
301
- if (git_buf_printf(&buf, "+refs/heads/*:refs/remotes/%s/*", name) < 0)
302
- return -1;
353
+ error = git_remote_create_with_opts(out, url, &opts);
303
354
 
304
- error = git_remote_create_with_fetchspec(out, repo, name, url, git_buf_cstr(&buf));
305
- git_buf_free(&buf);
355
+ git_buf_dispose(&buf);
306
356
 
307
357
  return error;
308
358
  }
309
359
 
310
360
  int git_remote_create_with_fetchspec(git_remote **out, git_repository *repo, const char *name, const char *url, const char *fetch)
311
361
  {
312
- git_remote *remote = NULL;
313
362
  int error;
363
+ git_remote_create_options opts = GIT_REMOTE_CREATE_OPTIONS_INIT;
314
364
 
315
365
  if ((error = ensure_remote_name_is_valid(name)) < 0)
316
366
  return error;
317
367
 
318
- if ((error = ensure_remote_doesnot_exist(repo, name)) < 0)
319
- return error;
320
-
321
- if (create_internal(&remote, repo, name, url, fetch) < 0)
322
- goto on_error;
323
-
324
- *out = remote;
368
+ opts.repository = repo;
369
+ opts.name = name;
370
+ opts.fetchspec = fetch;
371
+ opts.flags = GIT_REMOTE_CREATE_SKIP_DEFAULT_FETCHSPEC;
325
372
 
326
- return 0;
327
-
328
- on_error:
329
- git_remote_free(remote);
330
- return -1;
373
+ return git_remote_create_with_opts(out, url, &opts);
331
374
  }
332
375
 
333
376
  int git_remote_create_anonymous(git_remote **out, git_repository *repo, const char *url)
334
377
  {
335
- return create_internal(out, repo, NULL, url, NULL);
378
+ git_remote_create_options opts = GIT_REMOTE_CREATE_OPTIONS_INIT;
379
+
380
+ opts.repository = repo;
381
+
382
+ return git_remote_create_with_opts(out, url, &opts);
336
383
  }
337
384
 
338
385
  int git_remote_create_detached(git_remote **out, const char *url)
339
386
  {
340
- return create_internal(out, NULL, NULL, url, NULL);
387
+ return git_remote_create_with_opts(out, url, NULL);
341
388
  }
342
389
 
343
390
  int git_remote_dup(git_remote **dest, git_remote *source)
@@ -346,21 +393,21 @@ int git_remote_dup(git_remote **dest, git_remote *source)
346
393
  int error = 0;
347
394
  git_refspec *spec;
348
395
  git_remote *remote = git__calloc(1, sizeof(git_remote));
349
- GITERR_CHECK_ALLOC(remote);
396
+ GIT_ERROR_CHECK_ALLOC(remote);
350
397
 
351
398
  if (source->name != NULL) {
352
399
  remote->name = git__strdup(source->name);
353
- GITERR_CHECK_ALLOC(remote->name);
400
+ GIT_ERROR_CHECK_ALLOC(remote->name);
354
401
  }
355
402
 
356
403
  if (source->url != NULL) {
357
404
  remote->url = git__strdup(source->url);
358
- GITERR_CHECK_ALLOC(remote->url);
405
+ GIT_ERROR_CHECK_ALLOC(remote->url);
359
406
  }
360
407
 
361
408
  if (source->pushurl != NULL) {
362
409
  remote->pushurl = git__strdup(source->pushurl);
363
- GITERR_CHECK_ALLOC(remote->pushurl);
410
+ GIT_ERROR_CHECK_ALLOC(remote->pushurl);
364
411
  }
365
412
 
366
413
  remote->repo = source->repo;
@@ -419,7 +466,7 @@ static int get_optional_config(
419
466
  *found = !error;
420
467
 
421
468
  if (error == GIT_ENOTFOUND) {
422
- giterr_clear();
469
+ git_error_clear();
423
470
  error = 0;
424
471
  }
425
472
 
@@ -445,10 +492,10 @@ int git_remote_lookup(git_remote **out, git_repository *repo, const char *name)
445
492
  return error;
446
493
 
447
494
  remote = git__calloc(1, sizeof(git_remote));
448
- GITERR_CHECK_ALLOC(remote);
495
+ GIT_ERROR_CHECK_ALLOC(remote);
449
496
 
450
497
  remote->name = git__strdup(name);
451
- GITERR_CHECK_ALLOC(remote->name);
498
+ GIT_ERROR_CHECK_ALLOC(remote->name);
452
499
 
453
500
  if (git_vector_init(&remote->refs, 32, NULL) < 0 ||
454
501
  git_vector_init(&remote->refspecs, 2, NULL) < 0 ||
@@ -471,7 +518,7 @@ int git_remote_lookup(git_remote **out, git_repository *repo, const char *name)
471
518
 
472
519
  if (found && strlen(val) > 0) {
473
520
  remote->url = apply_insteadof(config, val, GIT_DIRECTION_FETCH);
474
- GITERR_CHECK_ALLOC(remote->url);
521
+ GIT_ERROR_CHECK_ALLOC(remote->url);
475
522
  }
476
523
 
477
524
  val = NULL;
@@ -485,13 +532,13 @@ int git_remote_lookup(git_remote **out, git_repository *repo, const char *name)
485
532
 
486
533
  if (!optional_setting_found) {
487
534
  error = GIT_ENOTFOUND;
488
- giterr_set(GITERR_CONFIG, "remote '%s' does not exist", name);
535
+ git_error_set(GIT_ERROR_CONFIG, "remote '%s' does not exist", name);
489
536
  goto cleanup;
490
537
  }
491
538
 
492
539
  if (found && strlen(val) > 0) {
493
540
  remote->pushurl = apply_insteadof(config, val, GIT_DIRECTION_PUSH);
494
- GITERR_CHECK_ALLOC(remote->pushurl);
541
+ GIT_ERROR_CHECK_ALLOC(remote->pushurl);
495
542
  }
496
543
 
497
544
  data.remote = remote;
@@ -524,7 +571,7 @@ int git_remote_lookup(git_remote **out, git_repository *repo, const char *name)
524
571
 
525
572
  cleanup:
526
573
  git_config_free(config);
527
- git_buf_free(&buf);
574
+ git_buf_dispose(&buf);
528
575
 
529
576
  if (error < 0)
530
577
  git_remote_free(remote);
@@ -541,18 +588,18 @@ static int lookup_remote_prune_config(git_remote *remote, git_config *config, co
541
588
 
542
589
  if ((error = git_config_get_bool(&remote->prune_refs, config, git_buf_cstr(&buf))) < 0) {
543
590
  if (error == GIT_ENOTFOUND) {
544
- giterr_clear();
591
+ git_error_clear();
545
592
 
546
593
  if ((error = git_config_get_bool(&remote->prune_refs, config, "fetch.prune")) < 0) {
547
594
  if (error == GIT_ENOTFOUND) {
548
- giterr_clear();
595
+ git_error_clear();
549
596
  error = 0;
550
597
  }
551
598
  }
552
599
  }
553
600
  }
554
601
 
555
- git_buf_free(&buf);
602
+ git_buf_dispose(&buf);
556
603
  return error;
557
604
  }
558
605
 
@@ -601,8 +648,8 @@ static int set_url(git_repository *repo, const char *remote, const char *pattern
601
648
  }
602
649
 
603
650
  cleanup:
604
- git_buf_free(&canonical_url);
605
- git_buf_free(&buf);
651
+ git_buf_dispose(&canonical_url);
652
+ git_buf_dispose(&buf);
606
653
 
607
654
  return error;
608
655
  }
@@ -657,7 +704,7 @@ static int set_transport_custom_headers(git_transport *t, const git_strarray *cu
657
704
  return t->set_custom_headers(t, custom_headers);
658
705
  }
659
706
 
660
- int git_remote_connect(git_remote *remote, git_direction direction, const git_remote_callbacks *callbacks, const git_proxy_options *proxy, const git_strarray *custom_headers)
707
+ int git_remote__connect(git_remote *remote, git_direction direction, const git_remote_callbacks *callbacks, const git_remote_connection_opts *conn)
661
708
  {
662
709
  git_transport *t;
663
710
  const char *url;
@@ -670,20 +717,20 @@ int git_remote_connect(git_remote *remote, git_direction direction, const git_re
670
717
  assert(remote);
671
718
 
672
719
  if (callbacks) {
673
- GITERR_CHECK_VERSION(callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
720
+ GIT_ERROR_CHECK_VERSION(callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
674
721
  credentials = callbacks->credentials;
675
722
  transport = callbacks->transport;
676
723
  payload = callbacks->payload;
677
724
  }
678
725
 
679
- if (proxy)
680
- GITERR_CHECK_VERSION(proxy, GIT_PROXY_OPTIONS_VERSION, "git_proxy_options");
726
+ if (conn->proxy)
727
+ GIT_ERROR_CHECK_VERSION(conn->proxy, GIT_PROXY_OPTIONS_VERSION, "git_proxy_options");
681
728
 
682
729
  t = remote->transport;
683
730
 
684
731
  url = git_remote__urlfordirection(remote, direction);
685
732
  if (url == NULL) {
686
- giterr_set(GITERR_INVALID,
733
+ git_error_set(GIT_ERROR_INVALID,
687
734
  "Malformed remote '%s' - missing %s URL",
688
735
  remote->name ? remote->name : "(anonymous)",
689
736
  direction == GIT_DIRECTION_FETCH ? "fetch" : "push");
@@ -701,11 +748,11 @@ int git_remote_connect(git_remote *remote, git_direction direction, const git_re
701
748
  if (!t && (error = git_transport_new(&t, remote, url)) < 0)
702
749
  return error;
703
750
 
704
- if ((error = set_transport_custom_headers(t, custom_headers)) != 0)
751
+ if ((error = set_transport_custom_headers(t, conn->custom_headers)) != 0)
705
752
  goto on_error;
706
753
 
707
754
  if ((error = set_transport_callbacks(t, callbacks)) < 0 ||
708
- (error = t->connect(t, url, credentials, payload, proxy, direction, flags)) != 0)
755
+ (error = t->connect(t, url, credentials, payload, conn->proxy, direction, flags)) != 0)
709
756
  goto on_error;
710
757
 
711
758
  remote->transport = t;
@@ -721,12 +768,22 @@ on_error:
721
768
  return error;
722
769
  }
723
770
 
771
+ int git_remote_connect(git_remote *remote, git_direction direction, const git_remote_callbacks *callbacks, const git_proxy_options *proxy, const git_strarray *custom_headers)
772
+ {
773
+ git_remote_connection_opts conn;
774
+
775
+ conn.proxy = proxy;
776
+ conn.custom_headers = custom_headers;
777
+
778
+ return git_remote__connect(remote, direction, callbacks, &conn);
779
+ }
780
+
724
781
  int git_remote_ls(const git_remote_head ***out, size_t *size, git_remote *remote)
725
782
  {
726
783
  assert(remote);
727
784
 
728
785
  if (!remote->transport) {
729
- giterr_set(GITERR_NET, "this remote has never connected");
786
+ git_error_set(GIT_ERROR_NET, "this remote has never connected");
730
787
  return -1;
731
788
  }
732
789
 
@@ -761,7 +818,7 @@ int git_remote__get_http_proxy(git_remote *remote, bool use_ssl, char **proxy_ur
761
818
  return error;
762
819
 
763
820
  error = git_config__lookup_entry(&ce, cfg, git_buf_cstr(&buf), false);
764
- git_buf_free(&buf);
821
+ git_buf_dispose(&buf);
765
822
 
766
823
  if (error < 0)
767
824
  return error;
@@ -790,7 +847,7 @@ int git_remote__get_http_proxy(git_remote *remote, bool use_ssl, char **proxy_ur
790
847
 
791
848
  if (error < 0) {
792
849
  if (error == GIT_ENOTFOUND) {
793
- giterr_clear();
850
+ git_error_clear();
794
851
  error = 0;
795
852
  }
796
853
 
@@ -800,7 +857,7 @@ int git_remote__get_http_proxy(git_remote *remote, bool use_ssl, char **proxy_ur
800
857
  *proxy_url = git_buf_detach(&val);
801
858
 
802
859
  found:
803
- GITERR_CHECK_ALLOC(*proxy_url);
860
+ GIT_ERROR_CHECK_ALLOC(*proxy_url);
804
861
  git_config_entry_free(ce);
805
862
 
806
863
  return 0;
@@ -826,7 +883,7 @@ static void free_refspecs(git_vector *vec)
826
883
  git_refspec *spec;
827
884
 
828
885
  git_vector_foreach(vec, i, spec) {
829
- git_refspec__free(spec);
886
+ git_refspec__dispose(spec);
830
887
  git__free(spec);
831
888
  }
832
889
 
@@ -872,15 +929,15 @@ int git_remote_download(git_remote *remote, const git_strarray *refspecs, const
872
929
  assert(remote);
873
930
 
874
931
  if (!remote->repo) {
875
- giterr_set(GITERR_INVALID, "cannot download detached remote");
932
+ git_error_set(GIT_ERROR_INVALID, "cannot download detached remote");
876
933
  return -1;
877
934
  }
878
935
 
879
936
  if (opts) {
880
- GITERR_CHECK_VERSION(&opts->callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
937
+ GIT_ERROR_CHECK_VERSION(&opts->callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
881
938
  cbs = &opts->callbacks;
882
939
  custom_headers = &opts->custom_headers;
883
- GITERR_CHECK_VERSION(&opts->proxy_opts, GIT_PROXY_OPTIONS_VERSION, "git_proxy_options");
940
+ GIT_ERROR_CHECK_VERSION(&opts->proxy_opts, GIT_PROXY_OPTIONS_VERSION, "git_proxy_options");
884
941
  proxy = &opts->proxy_opts;
885
942
  }
886
943
 
@@ -949,21 +1006,20 @@ int git_remote_fetch(
949
1006
  bool prune = false;
950
1007
  git_buf reflog_msg_buf = GIT_BUF_INIT;
951
1008
  const git_remote_callbacks *cbs = NULL;
952
- const git_strarray *custom_headers = NULL;
953
- const git_proxy_options *proxy = NULL;
1009
+ git_remote_connection_opts conn = GIT_REMOTE_CONNECTION_OPTIONS_INIT;
954
1010
 
955
1011
  if (opts) {
956
- GITERR_CHECK_VERSION(&opts->callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
1012
+ GIT_ERROR_CHECK_VERSION(&opts->callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
957
1013
  cbs = &opts->callbacks;
958
- custom_headers = &opts->custom_headers;
1014
+ conn.custom_headers = &opts->custom_headers;
959
1015
  update_fetchhead = opts->update_fetchhead;
960
1016
  tagopt = opts->download_tags;
961
- GITERR_CHECK_VERSION(&opts->proxy_opts, GIT_PROXY_OPTIONS_VERSION, "git_proxy_options");
962
- proxy = &opts->proxy_opts;
1017
+ GIT_ERROR_CHECK_VERSION(&opts->proxy_opts, GIT_PROXY_OPTIONS_VERSION, "git_proxy_options");
1018
+ conn.proxy = &opts->proxy_opts;
963
1019
  }
964
1020
 
965
1021
  /* Connect and download everything */
966
- if ((error = git_remote_connect(remote, GIT_DIRECTION_FETCH, cbs, proxy, custom_headers)) != 0)
1022
+ if ((error = git_remote__connect(remote, GIT_DIRECTION_FETCH, cbs, &conn)) != 0)
967
1023
  return error;
968
1024
 
969
1025
  error = git_remote_download(remote, refspecs, opts);
@@ -985,7 +1041,7 @@ int git_remote_fetch(
985
1041
 
986
1042
  /* Create "remote/foo" branches for all remote branches */
987
1043
  error = git_remote_update_tips(remote, cbs, update_fetchhead, tagopt, git_buf_cstr(&reflog_msg_buf));
988
- git_buf_free(&reflog_msg_buf);
1044
+ git_buf_dispose(&reflog_msg_buf);
989
1045
  if (error < 0)
990
1046
  return error;
991
1047
 
@@ -1041,7 +1097,7 @@ static int ref_to_update(int *update, git_buf *remote_name, git_remote *remote,
1041
1097
  (error = git_refspec_rtransform(remote_name, spec, upstream_name.ptr)) < 0) {
1042
1098
  /* Not an error if there is no upstream */
1043
1099
  if (error == GIT_ENOTFOUND) {
1044
- giterr_clear();
1100
+ git_error_clear();
1045
1101
  error = 0;
1046
1102
  }
1047
1103
 
@@ -1050,8 +1106,8 @@ static int ref_to_update(int *update, git_buf *remote_name, git_remote *remote,
1050
1106
  *update = 1;
1051
1107
  }
1052
1108
 
1053
- git_buf_free(&upstream_remote);
1054
- git_buf_free(&upstream_name);
1109
+ git_buf_dispose(&upstream_remote);
1110
+ git_buf_dispose(&upstream_name);
1055
1111
  return error;
1056
1112
  }
1057
1113
 
@@ -1070,7 +1126,7 @@ static int remote_head_for_ref(git_remote_head **out, git_remote *remote, git_re
1070
1126
  error = git_reference_resolve(&resolved_ref, ref);
1071
1127
 
1072
1128
  /* If we're in an unborn branch, let's pretend nothing happened */
1073
- if (error == GIT_ENOTFOUND && git_reference_type(ref) == GIT_REF_SYMBOLIC) {
1129
+ if (error == GIT_ENOTFOUND && git_reference_type(ref) == GIT_REFERENCE_SYMBOLIC) {
1074
1130
  ref_name = git_reference_symbolic_target(ref);
1075
1131
  error = 0;
1076
1132
  } else {
@@ -1084,7 +1140,7 @@ static int remote_head_for_ref(git_remote_head **out, git_remote *remote, git_re
1084
1140
  error = remote_head_for_fetchspec_src(out, update_heads, git_buf_cstr(&remote_name));
1085
1141
 
1086
1142
  cleanup:
1087
- git_buf_free(&remote_name);
1143
+ git_buf_dispose(&remote_name);
1088
1144
  git_reference_free(resolved_ref);
1089
1145
  git_config_free(config);
1090
1146
  return error;
@@ -1176,7 +1232,7 @@ static int prune_candidates(git_vector *candidates, git_remote *remote)
1176
1232
  continue;
1177
1233
 
1178
1234
  refname_dup = git__strdup(refname);
1179
- GITERR_CHECK_ALLOC(refname_dup);
1235
+ GIT_ERROR_CHECK_ALLOC(refname_dup);
1180
1236
 
1181
1237
  if ((error = git_vector_insert(candidates, refname_dup)) < 0)
1182
1238
  goto out;
@@ -1206,7 +1262,7 @@ int git_remote_prune(git_remote *remote, const git_remote_callbacks *callbacks)
1206
1262
  git_oid zero_id = {{ 0 }};
1207
1263
 
1208
1264
  if (callbacks)
1209
- GITERR_CHECK_VERSION(callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
1265
+ GIT_ERROR_CHECK_VERSION(callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
1210
1266
 
1211
1267
  if ((error = ls_to_vector(&remote_refs, remote)) < 0)
1212
1268
  goto cleanup;
@@ -1235,7 +1291,7 @@ int git_remote_prune(git_remote *remote, const git_remote_callbacks *callbacks)
1235
1291
 
1236
1292
  key.name = (char *) git_buf_cstr(&buf);
1237
1293
  error = git_vector_bsearch(&pos, &remote_refs, &key);
1238
- git_buf_free(&buf);
1294
+ git_buf_dispose(&buf);
1239
1295
 
1240
1296
  if (error < 0 && error != GIT_ENOTFOUND)
1241
1297
  goto cleanup;
@@ -1273,7 +1329,7 @@ int git_remote_prune(git_remote *remote, const git_remote_callbacks *callbacks)
1273
1329
  if (error < 0)
1274
1330
  goto cleanup;
1275
1331
 
1276
- if (git_reference_type(ref) == GIT_REF_SYMBOLIC) {
1332
+ if (git_reference_type(ref) == GIT_REFERENCE_SYMBOLIC) {
1277
1333
  git_reference_free(ref);
1278
1334
  continue;
1279
1335
  }
@@ -1394,7 +1450,7 @@ static int update_tips_for_spec(
1394
1450
  continue;
1395
1451
 
1396
1452
  /* In autotag mode, don't overwrite any locally-existing tags */
1397
- error = git_reference_create(&ref, remote->repo, refname.ptr, &head->oid, !autotag,
1453
+ error = git_reference_create(&ref, remote->repo, refname.ptr, &head->oid, !autotag,
1398
1454
  log_message);
1399
1455
 
1400
1456
  if (error == GIT_EEXISTS)
@@ -1416,14 +1472,14 @@ static int update_tips_for_spec(
1416
1472
  goto on_error;
1417
1473
 
1418
1474
  git_vector_free(&update_heads);
1419
- git_refspec__free(&tagspec);
1420
- git_buf_free(&refname);
1475
+ git_refspec__dispose(&tagspec);
1476
+ git_buf_dispose(&refname);
1421
1477
  return 0;
1422
1478
 
1423
1479
  on_error:
1424
1480
  git_vector_free(&update_heads);
1425
- git_refspec__free(&tagspec);
1426
- git_buf_free(&refname);
1481
+ git_refspec__dispose(&tagspec);
1482
+ git_buf_dispose(&refname);
1427
1483
  return -1;
1428
1484
 
1429
1485
  }
@@ -1537,7 +1593,7 @@ static int opportunistic_updates(const git_remote *remote, const git_remote_call
1537
1593
  error = 0;
1538
1594
 
1539
1595
  cleanup:
1540
- git_buf_free(&refname);
1596
+ git_buf_dispose(&refname);
1541
1597
  return error;
1542
1598
  }
1543
1599
 
@@ -1550,7 +1606,7 @@ static int truncate_fetch_head(const char *gitdir)
1550
1606
  return error;
1551
1607
 
1552
1608
  error = git_futils_truncate(path.ptr, GIT_REFS_FILE_MODE);
1553
- git_buf_free(&path);
1609
+ git_buf_dispose(&path);
1554
1610
 
1555
1611
  return error;
1556
1612
  }
@@ -1607,7 +1663,7 @@ int git_remote_update_tips(
1607
1663
 
1608
1664
  out:
1609
1665
  git_vector_free(&refs);
1610
- git_refspec__free(&tagspec);
1666
+ git_refspec__dispose(&tagspec);
1611
1667
  return error;
1612
1668
  }
1613
1669
 
@@ -1681,7 +1737,7 @@ static int remote_list_cb(const git_config_entry *entry, void *payload)
1681
1737
  remote_name = git__strndup(name, namelen - 4); /* strip ".url" */
1682
1738
  else
1683
1739
  remote_name = git__strndup(name, namelen - 8); /* strip ".pushurl" */
1684
- GITERR_CHECK_ALLOC(remote_name);
1740
+ GIT_ERROR_CHECK_ALLOC(remote_name);
1685
1741
 
1686
1742
  return git_vector_insert(list, remote_name);
1687
1743
  }
@@ -1755,11 +1811,11 @@ int git_remote_set_autotag(git_repository *repo, const char *remote, git_remote_
1755
1811
  error = 0;
1756
1812
  break;
1757
1813
  default:
1758
- giterr_set(GITERR_INVALID, "invalid value for the tagopt setting");
1814
+ git_error_set(GIT_ERROR_INVALID, "invalid value for the tagopt setting");
1759
1815
  error = -1;
1760
1816
  }
1761
1817
 
1762
- git_buf_free(&var);
1818
+ git_buf_dispose(&var);
1763
1819
  return error;
1764
1820
  }
1765
1821
 
@@ -1790,8 +1846,8 @@ static int rename_remote_config_section(
1790
1846
  new_name ? git_buf_cstr(&new_section_name) : NULL);
1791
1847
 
1792
1848
  cleanup:
1793
- git_buf_free(&old_section_name);
1794
- git_buf_free(&new_section_name);
1849
+ git_buf_dispose(&old_section_name);
1850
+ git_buf_dispose(&new_section_name);
1795
1851
 
1796
1852
  return error;
1797
1853
  }
@@ -1863,7 +1919,7 @@ static int rename_one_remote_reference(
1863
1919
  git_buf_cstr(&log_message))) < 0)
1864
1920
  goto cleanup;
1865
1921
 
1866
- if (git_reference_type(ref) != GIT_REF_SYMBOLIC)
1922
+ if (git_reference_type(ref) != GIT_REFERENCE_SYMBOLIC)
1867
1923
  goto cleanup;
1868
1924
 
1869
1925
  /* Handle refs like origin/HEAD -> origin/master */
@@ -1887,10 +1943,10 @@ static int rename_one_remote_reference(
1887
1943
  cleanup:
1888
1944
  git_reference_free(reference_in);
1889
1945
  git_reference_free(ref);
1890
- git_buf_free(&namespace);
1891
- git_buf_free(&old_namespace);
1892
- git_buf_free(&new_name);
1893
- git_buf_free(&log_message);
1946
+ git_buf_dispose(&namespace);
1947
+ git_buf_dispose(&old_namespace);
1948
+ git_buf_dispose(&new_name);
1949
+ git_buf_dispose(&log_message);
1894
1950
  return error;
1895
1951
  }
1896
1952
 
@@ -1908,7 +1964,7 @@ static int rename_remote_references(
1908
1964
  return error;
1909
1965
 
1910
1966
  error = git_reference_iterator_glob_new(&iter, repo, git_buf_cstr(&buf));
1911
- git_buf_free(&buf);
1967
+ git_buf_dispose(&buf);
1912
1968
 
1913
1969
  if (error < 0)
1914
1970
  return error;
@@ -1937,8 +1993,7 @@ static int rename_fetch_refspecs(git_vector *problems, git_remote *remote, const
1937
1993
  if ((error = git_vector_init(problems, 1, NULL)) < 0)
1938
1994
  return error;
1939
1995
 
1940
- if ((error = git_buf_printf(
1941
- &base, "+refs/heads/*:refs/remotes/%s/*", remote->name)) < 0)
1996
+ if ((error = default_fetchspec_for_name(&base, remote->name)) < 0)
1942
1997
  return error;
1943
1998
 
1944
1999
  git_vector_foreach(&remote->refspecs, i, spec) {
@@ -1950,7 +2005,7 @@ static int rename_fetch_refspecs(git_vector *problems, git_remote *remote, const
1950
2005
  char *dup;
1951
2006
 
1952
2007
  dup = git__strdup(spec->string);
1953
- GITERR_CHECK_ALLOC(dup);
2008
+ GIT_ERROR_CHECK_ALLOC(dup);
1954
2009
 
1955
2010
  if ((error = git_vector_insert(problems, dup)) < 0)
1956
2011
  break;
@@ -1963,8 +2018,7 @@ static int rename_fetch_refspecs(git_vector *problems, git_remote *remote, const
1963
2018
  git_buf_clear(&val);
1964
2019
  git_buf_clear(&var);
1965
2020
 
1966
- if (git_buf_printf(
1967
- &val, "+refs/heads/*:refs/remotes/%s/*", new_name) < 0 ||
2021
+ if (default_fetchspec_for_name(&val, new_name) < 0 ||
1968
2022
  git_buf_printf(&var, "remote.%s.fetch", new_name) < 0)
1969
2023
  {
1970
2024
  error = -1;
@@ -1976,9 +2030,9 @@ static int rename_fetch_refspecs(git_vector *problems, git_remote *remote, const
1976
2030
  break;
1977
2031
  }
1978
2032
 
1979
- git_buf_free(&base);
1980
- git_buf_free(&var);
1981
- git_buf_free(&val);
2033
+ git_buf_dispose(&base);
2034
+ git_buf_dispose(&var);
2035
+ git_buf_dispose(&val);
1982
2036
 
1983
2037
  if (error < 0) {
1984
2038
  char *str;
@@ -2044,10 +2098,10 @@ int git_remote_is_valid_name(
2044
2098
  git_buf_printf(&buf, "refs/heads/test:refs/remotes/%s/test", remote_name);
2045
2099
  error = git_refspec__parse(&refspec, git_buf_cstr(&buf), true);
2046
2100
 
2047
- git_buf_free(&buf);
2048
- git_refspec__free(&refspec);
2101
+ git_buf_dispose(&buf);
2102
+ git_refspec__dispose(&refspec);
2049
2103
 
2050
- giterr_clear();
2104
+ git_error_clear();
2051
2105
  return error == 0;
2052
2106
  }
2053
2107
 
@@ -2202,7 +2256,7 @@ static int remove_branch_config_related_entries(
2202
2256
  if ((error = git_config_delete_entry(config, git_buf_cstr(&buf))) < 0) {
2203
2257
  if (error != GIT_ENOTFOUND)
2204
2258
  break;
2205
- giterr_clear();
2259
+ git_error_clear();
2206
2260
  }
2207
2261
 
2208
2262
  git_buf_clear(&buf);
@@ -2212,14 +2266,14 @@ static int remove_branch_config_related_entries(
2212
2266
  if ((error = git_config_delete_entry(config, git_buf_cstr(&buf))) < 0) {
2213
2267
  if (error != GIT_ENOTFOUND)
2214
2268
  break;
2215
- giterr_clear();
2269
+ git_error_clear();
2216
2270
  }
2217
2271
  }
2218
2272
 
2219
2273
  if (error == GIT_ITEROVER)
2220
2274
  error = 0;
2221
2275
 
2222
- git_buf_free(&buf);
2276
+ git_buf_dispose(&buf);
2223
2277
  git_config_iterator_free(iter);
2224
2278
  return error;
2225
2279
  }
@@ -2373,24 +2427,23 @@ int git_remote_upload(git_remote *remote, const git_strarray *refspecs, const gi
2373
2427
  git_push *push;
2374
2428
  git_refspec *spec;
2375
2429
  const git_remote_callbacks *cbs = NULL;
2376
- const git_strarray *custom_headers = NULL;
2377
- const git_proxy_options *proxy = NULL;
2430
+ git_remote_connection_opts conn = GIT_REMOTE_CONNECTION_OPTIONS_INIT;
2378
2431
 
2379
2432
  assert(remote);
2380
2433
 
2381
2434
  if (!remote->repo) {
2382
- giterr_set(GITERR_INVALID, "cannot download detached remote");
2435
+ git_error_set(GIT_ERROR_INVALID, "cannot download detached remote");
2383
2436
  return -1;
2384
2437
  }
2385
2438
 
2386
2439
  if (opts) {
2387
2440
  cbs = &opts->callbacks;
2388
- custom_headers = &opts->custom_headers;
2389
- proxy = &opts->proxy_opts;
2441
+ conn.custom_headers = &opts->custom_headers;
2442
+ conn.proxy = &opts->proxy_opts;
2390
2443
  }
2391
2444
 
2392
2445
  if (!git_remote_connected(remote) &&
2393
- (error = git_remote_connect(remote, GIT_DIRECTION_PUSH, cbs, proxy, custom_headers)) < 0)
2446
+ (error = git_remote__connect(remote, GIT_DIRECTION_PUSH, cbs, &conn)) < 0)
2394
2447
  goto cleanup;
2395
2448
 
2396
2449
  free_refspecs(&remote->active_refspecs);
@@ -2445,15 +2498,15 @@ int git_remote_push(git_remote *remote, const git_strarray *refspecs, const git_
2445
2498
  assert(remote);
2446
2499
 
2447
2500
  if (!remote->repo) {
2448
- giterr_set(GITERR_INVALID, "cannot download detached remote");
2501
+ git_error_set(GIT_ERROR_INVALID, "cannot download detached remote");
2449
2502
  return -1;
2450
2503
  }
2451
2504
 
2452
2505
  if (opts) {
2453
- GITERR_CHECK_VERSION(&opts->callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
2506
+ GIT_ERROR_CHECK_VERSION(&opts->callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
2454
2507
  cbs = &opts->callbacks;
2455
2508
  custom_headers = &opts->custom_headers;
2456
- GITERR_CHECK_VERSION(&opts->proxy_opts, GIT_PROXY_OPTIONS_VERSION, "git_proxy_options");
2509
+ GIT_ERROR_CHECK_VERSION(&opts->proxy_opts, GIT_PROXY_OPTIONS_VERSION, "git_proxy_options");
2457
2510
  proxy = &opts->proxy_opts;
2458
2511
  }
2459
2512