rugged 1.5.0.1 → 1.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (250) hide show
  1. checksums.yaml +4 -4
  2. data/ext/rugged/extconf.rb +2 -2
  3. data/ext/rugged/rugged_allocator.c +0 -54
  4. data/ext/rugged/rugged_blame.c +2 -0
  5. data/ext/rugged/rugged_blob.c +3 -0
  6. data/ext/rugged/rugged_commit.c +1 -0
  7. data/ext/rugged/rugged_config.c +2 -0
  8. data/ext/rugged/rugged_diff.c +1 -0
  9. data/ext/rugged/rugged_index.c +2 -0
  10. data/ext/rugged/rugged_patch.c +1 -0
  11. data/ext/rugged/rugged_rebase.c +1 -0
  12. data/ext/rugged/rugged_reference.c +1 -0
  13. data/ext/rugged/rugged_remote.c +1 -0
  14. data/ext/rugged/rugged_repo.c +5 -2
  15. data/ext/rugged/rugged_revwalk.c +5 -1
  16. data/ext/rugged/rugged_submodule.c +1 -0
  17. data/ext/rugged/rugged_tag.c +1 -0
  18. data/ext/rugged/rugged_tree.c +4 -0
  19. data/lib/rugged/index.rb +1 -1
  20. data/lib/rugged/tree.rb +1 -1
  21. data/lib/rugged/version.rb +1 -1
  22. data/vendor/libgit2/CMakeLists.txt +7 -8
  23. data/vendor/libgit2/COPYING +30 -0
  24. data/vendor/libgit2/cmake/CheckPrototypeDefinitionSafe.cmake +16 -0
  25. data/vendor/libgit2/cmake/ExperimentalFeatures.cmake +23 -0
  26. data/vendor/libgit2/cmake/SelectGSSAPI.cmake +3 -3
  27. data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +21 -2
  28. data/vendor/libgit2/cmake/SelectHashes.cmake +4 -0
  29. data/vendor/libgit2/cmake/SelectXdiff.cmake +9 -0
  30. data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +2 -0
  31. data/vendor/libgit2/deps/pcre/LICENCE +5 -5
  32. data/vendor/libgit2/deps/pcre/pcre.h +2 -2
  33. data/vendor/libgit2/deps/pcre/pcre_compile.c +6 -3
  34. data/vendor/libgit2/deps/pcre/pcre_exec.c +2 -2
  35. data/vendor/libgit2/deps/xdiff/CMakeLists.txt +28 -0
  36. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/git-xdiff.h +4 -1
  37. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xdiffi.c +19 -18
  38. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xdiffi.h +2 -4
  39. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xemit.c +3 -3
  40. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xhistogram.c +7 -18
  41. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xmacros.h +18 -1
  42. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xmerge.c +24 -22
  43. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xpatience.c +21 -30
  44. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xprepare.c +13 -30
  45. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xutils.c +18 -1
  46. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xutils.h +2 -1
  47. data/vendor/libgit2/include/git2/common.h +38 -6
  48. data/vendor/libgit2/include/git2/deprecated.h +6 -0
  49. data/vendor/libgit2/include/git2/diff.h +42 -4
  50. data/vendor/libgit2/include/git2/errors.h +4 -2
  51. data/vendor/libgit2/include/git2/experimental.h +20 -0
  52. data/vendor/libgit2/include/git2/index.h +9 -0
  53. data/vendor/libgit2/include/git2/indexer.h +29 -0
  54. data/vendor/libgit2/include/git2/object.h +28 -2
  55. data/vendor/libgit2/include/git2/odb.h +58 -7
  56. data/vendor/libgit2/include/git2/odb_backend.h +106 -18
  57. data/vendor/libgit2/include/git2/oid.h +116 -16
  58. data/vendor/libgit2/include/git2/remote.h +18 -0
  59. data/vendor/libgit2/include/git2/repository.h +32 -3
  60. data/vendor/libgit2/include/git2/stash.h +60 -6
  61. data/vendor/libgit2/include/git2/strarray.h +0 -13
  62. data/vendor/libgit2/include/git2/sys/alloc.h +0 -34
  63. data/vendor/libgit2/include/git2/sys/commit_graph.h +12 -2
  64. data/vendor/libgit2/include/git2/sys/midx.h +5 -1
  65. data/vendor/libgit2/include/git2/sys/odb_backend.h +1 -1
  66. data/vendor/libgit2/include/git2/sys/stream.h +16 -2
  67. data/vendor/libgit2/include/git2/sys/transport.h +32 -2
  68. data/vendor/libgit2/include/git2/version.h +4 -4
  69. data/vendor/libgit2/include/git2/worktree.h +3 -1
  70. data/vendor/libgit2/include/git2.h +1 -0
  71. data/vendor/libgit2/src/CMakeLists.txt +34 -17
  72. data/vendor/libgit2/src/cli/CMakeLists.txt +5 -2
  73. data/vendor/libgit2/src/cli/cmd_clone.c +22 -6
  74. data/vendor/libgit2/src/cli/cmd_hash_object.c +27 -8
  75. data/vendor/libgit2/src/cli/opt.c +1 -1
  76. data/vendor/libgit2/src/cli/progress.c +9 -8
  77. data/vendor/libgit2/src/cli/progress.h +4 -4
  78. data/vendor/libgit2/src/libgit2/CMakeLists.txt +25 -34
  79. data/vendor/libgit2/src/libgit2/annotated_commit.c +2 -2
  80. data/vendor/libgit2/src/libgit2/annotated_commit.h +1 -1
  81. data/vendor/libgit2/src/libgit2/apply.c +4 -3
  82. data/vendor/libgit2/src/libgit2/attr_file.c +1 -1
  83. data/vendor/libgit2/src/libgit2/attrcache.c +1 -1
  84. data/vendor/libgit2/src/libgit2/blame.c +23 -14
  85. data/vendor/libgit2/src/libgit2/blame_git.c +0 -1
  86. data/vendor/libgit2/src/libgit2/blob.c +4 -2
  87. data/vendor/libgit2/src/libgit2/blob.h +2 -2
  88. data/vendor/libgit2/src/libgit2/branch.c +2 -2
  89. data/vendor/libgit2/src/libgit2/cherrypick.c +3 -3
  90. data/vendor/libgit2/src/libgit2/clone.c +34 -3
  91. data/vendor/libgit2/src/libgit2/commit.c +78 -21
  92. data/vendor/libgit2/src/libgit2/commit.h +25 -7
  93. data/vendor/libgit2/src/libgit2/commit_graph.c +129 -47
  94. data/vendor/libgit2/src/libgit2/commit_graph.h +23 -4
  95. data/vendor/libgit2/src/libgit2/commit_list.c +16 -5
  96. data/vendor/libgit2/src/libgit2/commit_list.h +1 -0
  97. data/vendor/libgit2/src/libgit2/config.c +6 -3
  98. data/vendor/libgit2/src/libgit2/config_file.c +16 -10
  99. data/vendor/libgit2/src/libgit2/describe.c +11 -8
  100. data/vendor/libgit2/src/libgit2/diff.c +19 -6
  101. data/vendor/libgit2/src/libgit2/diff.h +6 -6
  102. data/vendor/libgit2/src/libgit2/diff_file.c +16 -7
  103. data/vendor/libgit2/src/libgit2/diff_generate.c +37 -11
  104. data/vendor/libgit2/src/libgit2/diff_parse.c +20 -4
  105. data/vendor/libgit2/src/libgit2/diff_print.c +26 -7
  106. data/vendor/libgit2/src/libgit2/diff_tform.c +4 -0
  107. data/vendor/libgit2/src/libgit2/diff_xdiff.h +1 -1
  108. data/vendor/libgit2/src/libgit2/email.c +4 -3
  109. data/vendor/libgit2/src/libgit2/errors.c +73 -18
  110. data/vendor/libgit2/src/libgit2/experimental.h.in +13 -0
  111. data/vendor/libgit2/src/libgit2/fetch.c +38 -13
  112. data/vendor/libgit2/src/libgit2/fetch.h +0 -2
  113. data/vendor/libgit2/src/libgit2/fetchhead.c +11 -9
  114. data/vendor/libgit2/src/libgit2/grafts.c +272 -0
  115. data/vendor/libgit2/src/libgit2/grafts.h +36 -0
  116. data/vendor/libgit2/src/libgit2/ident.c +3 -3
  117. data/vendor/libgit2/src/libgit2/index.c +327 -123
  118. data/vendor/libgit2/src/libgit2/index.h +14 -1
  119. data/vendor/libgit2/src/libgit2/indexer.c +116 -46
  120. data/vendor/libgit2/src/libgit2/iterator.c +21 -4
  121. data/vendor/libgit2/src/libgit2/iterator.h +3 -0
  122. data/vendor/libgit2/src/libgit2/libgit2.c +58 -0
  123. data/vendor/libgit2/src/libgit2/merge.c +14 -9
  124. data/vendor/libgit2/src/libgit2/merge_file.c +0 -2
  125. data/vendor/libgit2/src/libgit2/midx.c +68 -38
  126. data/vendor/libgit2/src/libgit2/midx.h +13 -3
  127. data/vendor/libgit2/src/libgit2/mwindow.c +5 -2
  128. data/vendor/libgit2/src/libgit2/mwindow.h +4 -1
  129. data/vendor/libgit2/src/libgit2/notes.c +9 -8
  130. data/vendor/libgit2/src/libgit2/object.c +118 -29
  131. data/vendor/libgit2/src/libgit2/object.h +17 -2
  132. data/vendor/libgit2/src/libgit2/odb.c +224 -55
  133. data/vendor/libgit2/src/libgit2/odb.h +43 -4
  134. data/vendor/libgit2/src/libgit2/odb_loose.c +128 -70
  135. data/vendor/libgit2/src/libgit2/odb_pack.c +111 -46
  136. data/vendor/libgit2/src/libgit2/oid.c +141 -77
  137. data/vendor/libgit2/src/libgit2/oid.h +183 -9
  138. data/vendor/libgit2/src/libgit2/oidarray.c +49 -3
  139. data/vendor/libgit2/src/libgit2/oidarray.h +5 -1
  140. data/vendor/libgit2/src/libgit2/pack-objects.c +31 -13
  141. data/vendor/libgit2/src/libgit2/pack-objects.h +5 -2
  142. data/vendor/libgit2/src/libgit2/pack.c +93 -70
  143. data/vendor/libgit2/src/libgit2/pack.h +29 -15
  144. data/vendor/libgit2/src/libgit2/parse.c +8 -4
  145. data/vendor/libgit2/src/libgit2/parse.h +1 -1
  146. data/vendor/libgit2/src/libgit2/patch.h +7 -1
  147. data/vendor/libgit2/src/libgit2/patch_generate.c +24 -5
  148. data/vendor/libgit2/src/libgit2/patch_parse.c +16 -8
  149. data/vendor/libgit2/src/libgit2/push.c +13 -3
  150. data/vendor/libgit2/src/libgit2/reader.c +1 -1
  151. data/vendor/libgit2/src/libgit2/rebase.c +72 -83
  152. data/vendor/libgit2/src/libgit2/refdb_fs.c +92 -52
  153. data/vendor/libgit2/src/libgit2/reflog.c +7 -5
  154. data/vendor/libgit2/src/libgit2/reflog.h +1 -2
  155. data/vendor/libgit2/src/libgit2/refs.c +9 -0
  156. data/vendor/libgit2/src/libgit2/remote.c +47 -37
  157. data/vendor/libgit2/src/libgit2/remote.h +41 -0
  158. data/vendor/libgit2/src/libgit2/repository.c +784 -329
  159. data/vendor/libgit2/src/libgit2/repository.h +26 -2
  160. data/vendor/libgit2/src/libgit2/reset.c +2 -2
  161. data/vendor/libgit2/src/libgit2/revert.c +8 -11
  162. data/vendor/libgit2/src/libgit2/revparse.c +23 -7
  163. data/vendor/libgit2/src/libgit2/revwalk.c +31 -5
  164. data/vendor/libgit2/src/libgit2/stash.c +209 -33
  165. data/vendor/libgit2/src/libgit2/strarray.c +1 -0
  166. data/vendor/libgit2/src/libgit2/strarray.h +25 -0
  167. data/vendor/libgit2/src/libgit2/streams/mbedtls.c +0 -1
  168. data/vendor/libgit2/src/libgit2/streams/openssl.c +9 -17
  169. data/vendor/libgit2/src/libgit2/streams/openssl_dynamic.c +7 -3
  170. data/vendor/libgit2/src/libgit2/streams/schannel.c +715 -0
  171. data/vendor/libgit2/src/libgit2/streams/schannel.h +28 -0
  172. data/vendor/libgit2/src/libgit2/streams/socket.c +240 -51
  173. data/vendor/libgit2/src/libgit2/streams/socket.h +3 -1
  174. data/vendor/libgit2/src/libgit2/streams/stransport.c +40 -12
  175. data/vendor/libgit2/src/libgit2/streams/tls.c +5 -0
  176. data/vendor/libgit2/src/libgit2/submodule.c +6 -2
  177. data/vendor/libgit2/src/libgit2/submodule.h +3 -3
  178. data/vendor/libgit2/src/libgit2/sysdir.c +294 -7
  179. data/vendor/libgit2/src/libgit2/sysdir.h +41 -9
  180. data/vendor/libgit2/src/libgit2/tag.c +29 -10
  181. data/vendor/libgit2/src/libgit2/tag.h +2 -2
  182. data/vendor/libgit2/src/libgit2/threadstate.c +15 -2
  183. data/vendor/libgit2/src/libgit2/threadstate.h +1 -3
  184. data/vendor/libgit2/src/libgit2/transports/auth.h +1 -2
  185. data/vendor/libgit2/src/libgit2/transports/{auth_negotiate.c → auth_gssapi.c} +32 -32
  186. data/vendor/libgit2/src/libgit2/transports/auth_negotiate.h +1 -1
  187. data/vendor/libgit2/src/libgit2/transports/auth_ntlm.h +1 -1
  188. data/vendor/libgit2/src/libgit2/transports/{auth_ntlm.c → auth_ntlmclient.c} +12 -12
  189. data/vendor/libgit2/src/libgit2/transports/auth_sspi.c +341 -0
  190. data/vendor/libgit2/src/libgit2/transports/git.c +7 -8
  191. data/vendor/libgit2/src/libgit2/transports/http.c +15 -9
  192. data/vendor/libgit2/src/libgit2/transports/httpclient.c +14 -0
  193. data/vendor/libgit2/src/libgit2/transports/httpclient.h +10 -0
  194. data/vendor/libgit2/src/libgit2/transports/local.c +27 -4
  195. data/vendor/libgit2/src/libgit2/transports/smart.c +68 -27
  196. data/vendor/libgit2/src/libgit2/transports/smart.h +33 -9
  197. data/vendor/libgit2/src/libgit2/transports/smart_pkt.c +281 -49
  198. data/vendor/libgit2/src/libgit2/transports/smart_protocol.c +192 -55
  199. data/vendor/libgit2/src/libgit2/transports/ssh.c +334 -102
  200. data/vendor/libgit2/src/libgit2/transports/winhttp.c +22 -18
  201. data/vendor/libgit2/src/libgit2/tree-cache.c +26 -16
  202. data/vendor/libgit2/src/libgit2/tree-cache.h +5 -3
  203. data/vendor/libgit2/src/libgit2/tree.c +23 -17
  204. data/vendor/libgit2/src/libgit2/tree.h +2 -2
  205. data/vendor/libgit2/src/libgit2/worktree.c +30 -10
  206. data/vendor/libgit2/src/util/CMakeLists.txt +6 -1
  207. data/vendor/libgit2/src/util/alloc.c +65 -6
  208. data/vendor/libgit2/src/util/alloc.h +34 -9
  209. data/vendor/libgit2/src/util/allocators/failalloc.c +0 -60
  210. data/vendor/libgit2/src/util/allocators/failalloc.h +0 -6
  211. data/vendor/libgit2/src/util/allocators/stdalloc.c +2 -105
  212. data/vendor/libgit2/src/util/allocators/win32_leakcheck.c +0 -68
  213. data/vendor/libgit2/src/util/array.h +6 -1
  214. data/vendor/libgit2/src/util/cc-compat.h +2 -0
  215. data/vendor/libgit2/src/util/filebuf.c +6 -1
  216. data/vendor/libgit2/src/util/filebuf.h +19 -6
  217. data/vendor/libgit2/src/util/fs_path.c +2 -2
  218. data/vendor/libgit2/src/util/futils.c +8 -8
  219. data/vendor/libgit2/src/{features.h.in → util/git2_features.h.in} +9 -3
  220. data/vendor/libgit2/src/util/git2_util.h +2 -2
  221. data/vendor/libgit2/src/util/hash/openssl.c +4 -3
  222. data/vendor/libgit2/src/util/hash/rfc6234/sha.h +0 -112
  223. data/vendor/libgit2/src/util/hash.h +13 -0
  224. data/vendor/libgit2/src/util/net.c +492 -87
  225. data/vendor/libgit2/src/util/net.h +32 -0
  226. data/vendor/libgit2/src/util/posix.c +54 -0
  227. data/vendor/libgit2/src/util/posix.h +24 -0
  228. data/vendor/libgit2/src/util/rand.c +10 -4
  229. data/vendor/libgit2/src/util/regexp.c +3 -3
  230. data/vendor/libgit2/src/util/staticstr.h +66 -0
  231. data/vendor/libgit2/src/util/thread.h +20 -19
  232. data/vendor/libgit2/src/util/util.c +15 -10
  233. data/vendor/libgit2/src/util/util.h +25 -16
  234. data/vendor/libgit2/src/util/win32/error.c +1 -1
  235. data/vendor/libgit2/src/util/win32/path_w32.c +8 -8
  236. data/vendor/libgit2/src/util/win32/posix_w32.c +1 -1
  237. data/vendor/libgit2/src/util/win32/utf-conv.c +73 -75
  238. data/vendor/libgit2/src/util/win32/utf-conv.h +81 -14
  239. data/vendor/libgit2/src/util/win32/w32_util.c +1 -1
  240. metadata +34 -26
  241. data/vendor/libgit2/cmake/SelectWinHTTP.cmake +0 -17
  242. data/vendor/libgit2/src/libgit2/netops.c +0 -124
  243. data/vendor/libgit2/src/libgit2/netops.h +0 -68
  244. data/vendor/libgit2/src/util/win32/findfile.c +0 -286
  245. data/vendor/libgit2/src/util/win32/findfile.h +0 -22
  246. /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xdiff.h +0 -0
  247. /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xemit.h +0 -0
  248. /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xinclude.h +0 -0
  249. /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xprepare.h +0 -0
  250. /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xtypes.h +0 -0
@@ -60,15 +60,17 @@ typedef struct refdb_fs_backend {
60
60
  /* path to common objects' directory */
61
61
  char *commonpath;
62
62
 
63
- git_sortedcache *refcache;
63
+ git_oid_t oid_type;
64
+
65
+ int fsync : 1,
66
+ sorted : 1;
64
67
  int peeling_mode;
65
68
  git_iterator_flag_t iterator_flags;
66
69
  uint32_t direach_flags;
67
- int fsync;
70
+ git_sortedcache *refcache;
68
71
  git_map packed_refs_map;
69
72
  git_mutex prlock; /* protect packed_refs_map */
70
73
  git_futils_filestamp packed_refs_stamp;
71
- bool sorted;
72
74
  } refdb_fs_backend;
73
75
 
74
76
  static int refdb_reflog_fs__delete(git_refdb_backend *_backend, const char *name);
@@ -113,6 +115,7 @@ static int packed_reload(refdb_fs_backend *backend)
113
115
  {
114
116
  int error;
115
117
  git_str packedrefs = GIT_STR_INIT;
118
+ size_t oid_hexsize = git_oid_hexsize(backend->oid_type);
116
119
  char *scan, *eof, *eol;
117
120
 
118
121
  if (!backend->gitpath)
@@ -158,9 +161,9 @@ static int packed_reload(refdb_fs_backend *backend)
158
161
 
159
162
  /* parse "<OID> <refname>\n" */
160
163
 
161
- if (git_oid_fromstr(&oid, scan) < 0)
164
+ if (git_oid__fromstr(&oid, scan, backend->oid_type) < 0)
162
165
  goto parse_failed;
163
- scan += GIT_OID_HEXSZ;
166
+ scan += oid_hexsize;
164
167
 
165
168
  if (*scan++ != ' ')
166
169
  goto parse_failed;
@@ -179,9 +182,9 @@ static int packed_reload(refdb_fs_backend *backend)
179
182
  /* look for optional "^<OID>\n" */
180
183
 
181
184
  if (*scan == '^') {
182
- if (git_oid_fromstr(&oid, scan + 1) < 0)
185
+ if (git_oid__fromstr(&oid, scan + 1, backend->oid_type) < 0)
183
186
  goto parse_failed;
184
- scan += GIT_OID_HEXSZ + 1;
187
+ scan += oid_hexsize + 1;
185
188
 
186
189
  if (scan < eof) {
187
190
  if (!(eol = strchr(scan, '\n')))
@@ -214,19 +217,23 @@ parse_failed:
214
217
  }
215
218
 
216
219
  static int loose_parse_oid(
217
- git_oid *oid, const char *filename, git_str *file_content)
220
+ git_oid *oid,
221
+ const char *filename,
222
+ git_str *file_content,
223
+ git_oid_t oid_type)
218
224
  {
219
225
  const char *str = git_str_cstr(file_content);
226
+ size_t oid_hexsize = git_oid_hexsize(oid_type);
220
227
 
221
- if (git_str_len(file_content) < GIT_OID_HEXSZ)
228
+ if (git_str_len(file_content) < oid_hexsize)
222
229
  goto corrupted;
223
230
 
224
231
  /* we need to get 40 OID characters from the file */
225
- if (git_oid_fromstr(oid, str) < 0)
232
+ if (git_oid__fromstr(oid, str, oid_type) < 0)
226
233
  goto corrupted;
227
234
 
228
235
  /* If the file is longer than 40 chars, the 41st must be a space */
229
- str += GIT_OID_HEXSZ;
236
+ str += oid_hexsize;
230
237
  if (*str == '\0' || git__isspace(*str))
231
238
  return 0;
232
239
 
@@ -266,7 +273,7 @@ static int loose_lookup_to_packfile(refdb_fs_backend *backend, const char *name)
266
273
  goto done;
267
274
 
268
275
  /* parse OID from file */
269
- if ((error = loose_parse_oid(&oid, name, &ref_file)) < 0)
276
+ if ((error = loose_parse_oid(&oid, name, &ref_file, backend->oid_type)) < 0)
270
277
  goto done;
271
278
 
272
279
  if ((error = git_sortedcache_wlock(backend->refcache)) < 0)
@@ -437,7 +444,7 @@ static int loose_lookup(
437
444
  } else {
438
445
  git_oid oid;
439
446
 
440
- if (!(error = loose_parse_oid(&oid, ref_name, &ref_file)) &&
447
+ if (!(error = loose_parse_oid(&oid, ref_name, &ref_file, backend->oid_type)) &&
441
448
  out != NULL)
442
449
  *out = git_reference__alloc(ref_name, &oid, NULL);
443
450
  }
@@ -615,19 +622,24 @@ static const char *end_of_record(const char *p, const char *end)
615
622
  return p;
616
623
  }
617
624
 
618
- static int
619
- cmp_record_to_refname(const char *rec, size_t data_end, const char *ref_name)
625
+ static int cmp_record_to_refname(
626
+ const char *rec,
627
+ size_t data_end,
628
+ const char *ref_name,
629
+ git_oid_t oid_type)
620
630
  {
621
631
  const size_t ref_len = strlen(ref_name);
622
632
  int cmp_val;
623
633
  const char *end;
634
+ size_t oid_hexsize = git_oid_hexsize(oid_type);
624
635
 
625
- rec += GIT_OID_HEXSZ + 1; /* <oid> + space */
626
- if (data_end < GIT_OID_HEXSZ + 3) {
627
- /* an incomplete (corrupt) record is treated as less than ref_name */
636
+ rec += oid_hexsize + 1; /* <oid> + space */
637
+
638
+ /* an incomplete (corrupt) record is treated as less than ref_name */
639
+ if (data_end < oid_hexsize + 3)
628
640
  return -1;
629
- }
630
- data_end -= GIT_OID_HEXSZ + 1;
641
+
642
+ data_end -= oid_hexsize + 1;
631
643
 
632
644
  end = memchr(rec, '\n', data_end);
633
645
  if (end)
@@ -675,6 +687,7 @@ static int packed_lookup(
675
687
  {
676
688
  int error = 0;
677
689
  const char *left, *right, *data_end;
690
+ size_t oid_hexsize = git_oid_hexsize(backend->oid_type);
678
691
 
679
692
  if ((error = packed_map_check(backend)) < 0)
680
693
  return error;
@@ -698,7 +711,7 @@ static int packed_lookup(
698
711
 
699
712
  mid = left + (right - left) / 2;
700
713
  rec = start_of_record(left, mid);
701
- compare = cmp_record_to_refname(rec, data_end - rec, ref_name);
714
+ compare = cmp_record_to_refname(rec, data_end - rec, ref_name, backend->oid_type);
702
715
 
703
716
  if (compare < 0) {
704
717
  left = end_of_record(mid, right);
@@ -708,11 +721,11 @@ static int packed_lookup(
708
721
  const char *eol;
709
722
  git_oid oid, peel, *peel_ptr = NULL;
710
723
 
711
- if (data_end - rec < GIT_OID_HEXSZ ||
712
- git_oid_fromstr(&oid, rec) < 0) {
724
+ if (data_end - rec < (long)oid_hexsize ||
725
+ git_oid__fromstr(&oid, rec, backend->oid_type) < 0) {
713
726
  goto parse_failed;
714
727
  }
715
- rec += GIT_OID_HEXSZ + 1;
728
+ rec += oid_hexsize + 1;
716
729
  if (!(eol = memchr(rec, '\n', data_end - rec))) {
717
730
  goto parse_failed;
718
731
  }
@@ -724,8 +737,8 @@ static int packed_lookup(
724
737
 
725
738
  if (*rec == '^') {
726
739
  rec++;
727
- if (data_end - rec < GIT_OID_HEXSZ ||
728
- git_oid_fromstr(&peel, rec) < 0) {
740
+ if (data_end - rec < (long)oid_hexsize ||
741
+ git_oid__fromstr(&peel, rec, backend->oid_type) < 0) {
729
742
  goto parse_failed;
730
743
  }
731
744
  peel_ptr = &peel;
@@ -792,7 +805,9 @@ static void refdb_fs_backend__iterator_free(git_reference_iterator *_iter)
792
805
  git__free(iter);
793
806
  }
794
807
 
795
- static int iter_load_loose_paths(refdb_fs_backend *backend, refdb_fs_iter *iter)
808
+ static int iter_load_loose_paths(
809
+ refdb_fs_backend *backend,
810
+ refdb_fs_iter *iter)
796
811
  {
797
812
  int error = 0;
798
813
  git_str path = GIT_STR_INIT;
@@ -806,6 +821,7 @@ static int iter_load_loose_paths(refdb_fs_backend *backend, refdb_fs_iter *iter)
806
821
  return 0;
807
822
 
808
823
  fsit_opts.flags = backend->iterator_flags;
824
+ fsit_opts.oid_type = backend->oid_type;
809
825
 
810
826
  if (iter->glob) {
811
827
  const char *last_sep = NULL;
@@ -1108,7 +1124,7 @@ static int loose_commit(git_filebuf *file, const git_reference *ref)
1108
1124
  GIT_ASSERT_ARG(ref);
1109
1125
 
1110
1126
  if (ref->type == GIT_REFERENCE_DIRECT) {
1111
- char oid[GIT_OID_HEXSZ + 1];
1127
+ char oid[GIT_OID_MAX_HEXSIZE + 1];
1112
1128
  git_oid_nfmt(oid, sizeof(oid), &ref->target.oid);
1113
1129
 
1114
1130
  git_filebuf_printf(file, "%s\n", oid);
@@ -1224,7 +1240,7 @@ static int packed_find_peel(refdb_fs_backend *backend, struct packref *ref)
1224
1240
  */
1225
1241
  static int packed_write_ref(struct packref *ref, git_filebuf *file)
1226
1242
  {
1227
- char oid[GIT_OID_HEXSZ + 1];
1243
+ char oid[GIT_OID_MAX_HEXSIZE + 1];
1228
1244
  git_oid_nfmt(oid, sizeof(oid), &ref->oid);
1229
1245
 
1230
1246
  /*
@@ -1238,7 +1254,7 @@ static int packed_write_ref(struct packref *ref, git_filebuf *file)
1238
1254
  * The required peels have already been loaded into `ref->peel_target`.
1239
1255
  */
1240
1256
  if (ref->flags & PACKREF_HAS_PEEL) {
1241
- char peel[GIT_OID_HEXSZ + 1];
1257
+ char peel[GIT_OID_MAX_HEXSIZE + 1];
1242
1258
  git_oid_nfmt(peel, sizeof(peel), &ref->peel);
1243
1259
 
1244
1260
  if (git_filebuf_printf(file, "%s %s\n^%s\n", oid, ref->name, peel) < 0)
@@ -1302,7 +1318,7 @@ static int packed_remove_loose(refdb_fs_backend *backend)
1302
1318
  continue;
1303
1319
 
1304
1320
  /* Figure out the current id; if we find a bad ref file, skip it so we can do the rest */
1305
- if (loose_parse_oid(&current_id, lock.path_original, &ref_content) < 0)
1321
+ if (loose_parse_oid(&current_id, lock.path_original, &ref_content, backend->oid_type) < 0)
1306
1322
  continue;
1307
1323
 
1308
1324
  /* If the ref moved since we packed it, we must not delete it */
@@ -1769,7 +1785,7 @@ static int refdb_fs_backend__rename(
1769
1785
  (error = refdb_fs_backend__lookup(&old, _backend, old_name)) < 0)
1770
1786
  return error;
1771
1787
 
1772
- if ((error = refdb_fs_backend__delete(_backend, old_name, NULL, NULL)) < 0) {
1788
+ if ((error = loose_lock(&file, backend, old->name)) < 0) {
1773
1789
  git_reference_free(old);
1774
1790
  return error;
1775
1791
  }
@@ -1777,32 +1793,33 @@ static int refdb_fs_backend__rename(
1777
1793
  new = git_reference__realloc(&old, new_name);
1778
1794
  if (!new) {
1779
1795
  git_reference_free(old);
1796
+ git_filebuf_cleanup(&file);
1780
1797
  return -1;
1781
1798
  }
1782
1799
 
1783
- if ((error = loose_lock(&file, backend, new->name)) < 0) {
1800
+ if ((error = refdb_fs_backend__delete_tail(_backend, &file, old_name, NULL, NULL)) < 0) {
1784
1801
  git_reference_free(new);
1802
+ git_filebuf_cleanup(&file);
1785
1803
  return error;
1786
1804
  }
1787
1805
 
1788
- /* Try to rename the refog; it's ok if the old doesn't exist */
1789
- error = refdb_reflog_fs__rename(_backend, old_name, new_name);
1790
- if (((error == 0) || (error == GIT_ENOTFOUND)) &&
1791
- ((error = reflog_append(backend, new, git_reference_target(new), NULL, who, message)) < 0)) {
1806
+ if ((error = loose_lock(&file, backend, new_name)) < 0) {
1792
1807
  git_reference_free(new);
1793
- git_filebuf_cleanup(&file);
1794
1808
  return error;
1795
1809
  }
1796
1810
 
1797
- if (error < 0) {
1811
+ /* Try to rename the refog; it's ok if the old doesn't exist */
1812
+ error = refdb_reflog_fs__rename(_backend, old_name, new_name);
1813
+ if (((error == 0) || (error == GIT_ENOTFOUND)) &&
1814
+ ((error = reflog_append(backend, new, git_reference_target(new), NULL, who, message)) < 0)) {
1798
1815
  git_reference_free(new);
1799
1816
  git_filebuf_cleanup(&file);
1800
1817
  return error;
1801
1818
  }
1802
1819
 
1803
-
1804
1820
  if ((error = loose_commit(&file, new)) < 0 || out == NULL) {
1805
1821
  git_reference_free(new);
1822
+ git_filebuf_cleanup(&file);
1806
1823
  return error;
1807
1824
  }
1808
1825
 
@@ -1891,7 +1908,10 @@ done:
1891
1908
  return out;
1892
1909
  }
1893
1910
 
1894
- static int reflog_alloc(git_reflog **reflog, const char *name)
1911
+ static int reflog_alloc(
1912
+ git_reflog **reflog,
1913
+ const char *name,
1914
+ git_oid_t oid_type)
1895
1915
  {
1896
1916
  git_reflog *log;
1897
1917
 
@@ -1903,6 +1923,8 @@ static int reflog_alloc(git_reflog **reflog, const char *name)
1903
1923
  log->ref_name = git__strdup(name);
1904
1924
  GIT_ERROR_CHECK_ALLOC(log->ref_name);
1905
1925
 
1926
+ log->oid_type = oid_type;
1927
+
1906
1928
  if (git_vector_init(&log->entries, 0, NULL) < 0) {
1907
1929
  git__free(log->ref_name);
1908
1930
  git__free(log);
@@ -1931,9 +1953,9 @@ static int reflog_parse(git_reflog *log, const char *buf, size_t buf_size)
1931
1953
  entry->committer = git__calloc(1, sizeof(*entry->committer));
1932
1954
  GIT_ERROR_CHECK_ALLOC(entry->committer);
1933
1955
 
1934
- if (git_parse_advance_oid(&entry->oid_old, &parser) < 0 ||
1956
+ if (git_parse_advance_oid(&entry->oid_old, &parser, log->oid_type) < 0 ||
1935
1957
  git_parse_advance_expected(&parser, " ", 1) < 0 ||
1936
- git_parse_advance_oid(&entry->oid_cur, &parser) < 0)
1958
+ git_parse_advance_oid(&entry->oid_cur, &parser, log->oid_type) < 0)
1937
1959
  goto next;
1938
1960
 
1939
1961
  sig = parser.line;
@@ -2032,7 +2054,10 @@ static int refdb_reflog_fs__has_log(git_refdb_backend *_backend, const char *nam
2032
2054
  return has_reflog(backend->repo, name);
2033
2055
  }
2034
2056
 
2035
- static int refdb_reflog_fs__read(git_reflog **out, git_refdb_backend *_backend, const char *name)
2057
+ static int refdb_reflog_fs__read(
2058
+ git_reflog **out,
2059
+ git_refdb_backend *_backend,
2060
+ const char *name)
2036
2061
  {
2037
2062
  int error = -1;
2038
2063
  git_str log_path = GIT_STR_INIT;
@@ -2048,7 +2073,7 @@ static int refdb_reflog_fs__read(git_reflog **out, git_refdb_backend *_backend,
2048
2073
  backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
2049
2074
  repo = backend->repo;
2050
2075
 
2051
- if (reflog_alloc(&log, name) < 0)
2076
+ if (reflog_alloc(&log, name, backend->oid_type) < 0)
2052
2077
  return -1;
2053
2078
 
2054
2079
  if (reflog_path(&log_path, repo, name) < 0)
@@ -2086,11 +2111,11 @@ static int serialize_reflog_entry(
2086
2111
  const git_signature *committer,
2087
2112
  const char *msg)
2088
2113
  {
2089
- char raw_old[GIT_OID_HEXSZ+1];
2090
- char raw_new[GIT_OID_HEXSZ+1];
2114
+ char raw_old[GIT_OID_MAX_HEXSIZE + 1];
2115
+ char raw_new[GIT_OID_MAX_HEXSIZE + 1];
2091
2116
 
2092
- git_oid_tostr(raw_old, GIT_OID_HEXSZ+1, oid_old);
2093
- git_oid_tostr(raw_new, GIT_OID_HEXSZ+1, oid_new);
2117
+ git_oid_tostr(raw_old, GIT_OID_MAX_HEXSIZE + 1, oid_old);
2118
+ git_oid_tostr(raw_new, GIT_OID_MAX_HEXSIZE + 1, oid_new);
2094
2119
 
2095
2120
  git_str_clear(buf);
2096
2121
 
@@ -2189,10 +2214,16 @@ success:
2189
2214
  }
2190
2215
 
2191
2216
  /* Append to the reflog, must be called under reference lock */
2192
- static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, const git_oid *old, const git_oid *new, const git_signature *who, const char *message)
2217
+ static int reflog_append(
2218
+ refdb_fs_backend *backend,
2219
+ const git_reference *ref,
2220
+ const git_oid *old,
2221
+ const git_oid *new,
2222
+ const git_signature *who,
2223
+ const char *message)
2193
2224
  {
2194
2225
  int error, is_symbolic, open_flags;
2195
- git_oid old_id = {{0}}, new_id = {{0}};
2226
+ git_oid old_id, new_id;
2196
2227
  git_str buf = GIT_STR_INIT, path = GIT_STR_INIT;
2197
2228
  git_repository *repo = backend->repo;
2198
2229
 
@@ -2206,6 +2237,9 @@ static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, co
2206
2237
 
2207
2238
  /* From here on is_symbolic also means that it's HEAD */
2208
2239
 
2240
+ git_oid_clear(&old_id, backend->oid_type);
2241
+ git_oid_clear(&new_id, backend->oid_type);
2242
+
2209
2243
  if (old) {
2210
2244
  git_oid_cpy(&old_id, old);
2211
2245
  } else {
@@ -2368,7 +2402,12 @@ static int refdb_reflog_fs__delete(git_refdb_backend *_backend, const char *name
2368
2402
  if ((error = reflog_path(&path, backend->repo, name)) < 0)
2369
2403
  goto out;
2370
2404
 
2371
- if (!git_fs_path_exists(path.ptr))
2405
+ /*
2406
+ * If a reference was moved downwards, eg refs/heads/br2 -> refs/heads/br2/new-name,
2407
+ * refs/heads/br2 does exist but it's a directory. That's a valid situation.
2408
+ * Proceed only if it's a file.
2409
+ */
2410
+ if (!git_fs_path_isfile(path.ptr))
2372
2411
  goto out;
2373
2412
 
2374
2413
  if ((error = p_unlink(path.ptr)) < 0)
@@ -2402,6 +2441,7 @@ int git_refdb_backend_fs(
2402
2441
  goto fail;
2403
2442
 
2404
2443
  backend->repo = repository;
2444
+ backend->oid_type = repository->oid_type;
2405
2445
 
2406
2446
  if (repository->gitdir) {
2407
2447
  backend->gitpath = setup_namespace(repository, repository->gitdir);
@@ -71,7 +71,11 @@ int git_reflog_write(git_reflog *reflog)
71
71
  return db->backend->reflog_write(db->backend, reflog);
72
72
  }
73
73
 
74
- int git_reflog_append(git_reflog *reflog, const git_oid *new_oid, const git_signature *committer, const char *msg)
74
+ int git_reflog_append(
75
+ git_reflog *reflog,
76
+ const git_oid *new_oid,
77
+ const git_signature *committer,
78
+ const char *msg)
75
79
  {
76
80
  const git_reflog_entry *previous;
77
81
  git_reflog_entry *entry;
@@ -104,7 +108,7 @@ int git_reflog_append(git_reflog *reflog, const git_oid *new_oid, const git_sign
104
108
  previous = git_reflog_entry_byindex(reflog, 0);
105
109
 
106
110
  if (previous == NULL)
107
- git_oid_fromstr(&entry->oid_old, GIT_OID_HEX_ZERO);
111
+ git_oid_clear(&entry->oid_old, reflog->oid_type);
108
112
  else
109
113
  git_oid_cpy(&entry->oid_old, &previous->oid_cur);
110
114
 
@@ -219,9 +223,7 @@ int git_reflog_drop(git_reflog *reflog, size_t idx, int rewrite_previous_entry)
219
223
  /* If the oldest entry has just been removed... */
220
224
  if (idx == entrycount - 1) {
221
225
  /* ...clear the oid_old member of the "new" oldest entry */
222
- if (git_oid_fromstr(&entry->oid_old, GIT_OID_HEX_ZERO) < 0)
223
- return -1;
224
-
226
+ git_oid_clear(&entry->oid_old, reflog->oid_type);
225
227
  return 0;
226
228
  }
227
229
 
@@ -16,8 +16,6 @@
16
16
  #define GIT_REFLOG_DIR_MODE 0777
17
17
  #define GIT_REFLOG_FILE_MODE 0666
18
18
 
19
- #define GIT_REFLOG_SIZE_MIN (2*GIT_OID_HEXSZ+2+17)
20
-
21
19
  struct git_reflog_entry {
22
20
  git_oid oid_old;
23
21
  git_oid oid_cur;
@@ -30,6 +28,7 @@ struct git_reflog_entry {
30
28
  struct git_reflog {
31
29
  git_refdb *db;
32
30
  char *ref_name;
31
+ git_oid_t oid_type;
33
32
  git_vector entries;
34
33
  };
35
34
 
@@ -72,6 +72,7 @@ git_reference *git_reference__alloc(
72
72
  const git_oid *oid,
73
73
  const git_oid *peel)
74
74
  {
75
+ git_oid_t oid_type;
75
76
  git_reference *ref;
76
77
 
77
78
  GIT_ASSERT_ARG_WITH_RETVAL(name, NULL);
@@ -84,8 +85,16 @@ git_reference *git_reference__alloc(
84
85
  ref->type = GIT_REFERENCE_DIRECT;
85
86
  git_oid_cpy(&ref->target.oid, oid);
86
87
 
88
+ #ifdef GIT_EXPERIMENTAL_SHA256
89
+ oid_type = oid->type;
90
+ #else
91
+ oid_type = GIT_OID_SHA1;
92
+ #endif
93
+
87
94
  if (peel != NULL)
88
95
  git_oid_cpy(&ref->peel, peel);
96
+ else
97
+ git_oid_clear(&ref->peel, oid_type);
89
98
 
90
99
  return ref;
91
100
  }
@@ -17,11 +17,13 @@
17
17
  #include "fetchhead.h"
18
18
  #include "push.h"
19
19
  #include "proxy.h"
20
+ #include "strarray.h"
20
21
 
21
22
  #include "git2/config.h"
22
23
  #include "git2/types.h"
23
24
  #include "git2/oid.h"
24
25
  #include "git2/net.h"
26
+ #include "transports/smart.h"
25
27
 
26
28
  #define CONFIG_URL_FMT "remote.%s.url"
27
29
  #define CONFIG_PUSHURL_FMT "remote.%s.pushurl"
@@ -1026,6 +1028,24 @@ int git_remote_capabilities(unsigned int *out, git_remote *remote)
1026
1028
  return remote->transport->capabilities(out, remote->transport);
1027
1029
  }
1028
1030
 
1031
+ int git_remote_oid_type(git_oid_t *out, git_remote *remote)
1032
+ {
1033
+ GIT_ASSERT_ARG(remote);
1034
+
1035
+ if (!remote->transport) {
1036
+ git_error_set(GIT_ERROR_NET, "this remote has never connected");
1037
+ *out = 0;
1038
+ return -1;
1039
+ }
1040
+
1041
+ #ifdef GIT_EXPERIMENTAL_SHA256
1042
+ return remote->transport->oid_type(out, remote->transport);
1043
+ #else
1044
+ *out = GIT_OID_SHA1;
1045
+ return 0;
1046
+ #endif
1047
+ }
1048
+
1029
1049
  static int lookup_config(char **out, git_config *cfg, const char *name)
1030
1050
  {
1031
1051
  git_config_entry *ce = NULL;
@@ -1225,24 +1245,6 @@ static int ls_to_vector(git_vector *out, git_remote *remote)
1225
1245
  return 0;
1226
1246
  }
1227
1247
 
1228
- #define copy_opts(out, in) \
1229
- if (in) { \
1230
- (out)->callbacks = (in)->callbacks; \
1231
- (out)->proxy_opts = (in)->proxy_opts; \
1232
- (out)->custom_headers = (in)->custom_headers; \
1233
- (out)->follow_redirects = (in)->follow_redirects; \
1234
- }
1235
-
1236
- GIT_INLINE(int) connect_opts_from_fetch_opts(
1237
- git_remote_connect_options *out,
1238
- git_remote *remote,
1239
- const git_fetch_options *fetch_opts)
1240
- {
1241
- git_remote_connect_options tmp = GIT_REMOTE_CONNECT_OPTIONS_INIT;
1242
- copy_opts(&tmp, fetch_opts);
1243
- return git_remote_connect_options_normalize(out, remote->repo, &tmp);
1244
- }
1245
-
1246
1248
  static int connect_or_reset_options(
1247
1249
  git_remote *remote,
1248
1250
  int direction,
@@ -1330,7 +1332,8 @@ int git_remote_download(
1330
1332
  return -1;
1331
1333
  }
1332
1334
 
1333
- if (connect_opts_from_fetch_opts(&connect_opts, remote, opts) < 0)
1335
+ if (git_remote_connect_options__from_fetch_opts(&connect_opts,
1336
+ remote, opts) < 0)
1334
1337
  return -1;
1335
1338
 
1336
1339
  if ((error = connect_or_reset_options(remote, GIT_DIRECTION_FETCH, &connect_opts)) < 0)
@@ -1350,6 +1353,8 @@ int git_remote_fetch(
1350
1353
  bool prune = false;
1351
1354
  git_str reflog_msg_buf = GIT_STR_INIT;
1352
1355
  git_remote_connect_options connect_opts = GIT_REMOTE_CONNECT_OPTIONS_INIT;
1356
+ unsigned int capabilities;
1357
+ git_oid_t oid_type;
1353
1358
 
1354
1359
  GIT_ASSERT_ARG(remote);
1355
1360
 
@@ -1358,7 +1363,8 @@ int git_remote_fetch(
1358
1363
  return -1;
1359
1364
  }
1360
1365
 
1361
- if (connect_opts_from_fetch_opts(&connect_opts, remote, opts) < 0)
1366
+ if (git_remote_connect_options__from_fetch_opts(&connect_opts,
1367
+ remote, opts) < 0)
1362
1368
  return -1;
1363
1369
 
1364
1370
  if ((error = connect_or_reset_options(remote, GIT_DIRECTION_FETCH, &connect_opts)) < 0)
@@ -1369,6 +1375,10 @@ int git_remote_fetch(
1369
1375
  tagopt = opts->download_tags;
1370
1376
  }
1371
1377
 
1378
+ if ((error = git_remote_capabilities(&capabilities, remote)) < 0 ||
1379
+ (error = git_remote_oid_type(&oid_type, remote)) < 0)
1380
+ return error;
1381
+
1372
1382
  /* Connect and download everything */
1373
1383
  error = git_remote__download(remote, refspecs, opts);
1374
1384
 
@@ -1622,7 +1632,10 @@ int git_remote_prune(git_remote *remote, const git_remote_callbacks *callbacks)
1622
1632
  const git_refspec *spec;
1623
1633
  const char *refname;
1624
1634
  int error;
1625
- git_oid zero_id = {{ 0 }};
1635
+ git_oid zero_id;
1636
+
1637
+ GIT_ASSERT(remote && remote->repo);
1638
+ git_oid_clear(&zero_id, remote->repo->oid_type);
1626
1639
 
1627
1640
  if (callbacks)
1628
1641
  GIT_ERROR_CHECK_VERSION(callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
@@ -1727,6 +1740,9 @@ static int update_ref(
1727
1740
  git_oid old_id;
1728
1741
  int error;
1729
1742
 
1743
+ GIT_ASSERT(remote && remote->repo);
1744
+ git_oid_clear(&old_id, remote->repo->oid_type);
1745
+
1730
1746
  error = git_reference_name_to_id(&old_id, remote->repo, ref_name);
1731
1747
 
1732
1748
  if (error < 0 && error != GIT_ENOTFOUND)
@@ -1770,6 +1786,8 @@ static int update_one_tip(
1770
1786
  int valid;
1771
1787
  int error;
1772
1788
 
1789
+ GIT_ASSERT(remote && remote->repo);
1790
+
1773
1791
  if ((error = git_repository_odb__weakptr(&odb, remote->repo)) < 0)
1774
1792
  goto done;
1775
1793
 
@@ -1830,7 +1848,7 @@ static int update_one_tip(
1830
1848
  }
1831
1849
 
1832
1850
  if (error == GIT_ENOTFOUND) {
1833
- memset(&old, 0, sizeof(git_oid));
1851
+ git_oid_clear(&old, remote->repo->oid_type);
1834
1852
  error = 0;
1835
1853
 
1836
1854
  if (autotag && (error = git_vector_insert(update_heads, head)) < 0)
@@ -1876,7 +1894,7 @@ static int update_tips_for_spec(
1876
1894
  int error = 0;
1877
1895
  size_t i;
1878
1896
 
1879
- GIT_ASSERT_ARG(remote);
1897
+ GIT_ASSERT_ARG(remote && remote->repo);
1880
1898
 
1881
1899
  if (git_refspec__parse(&tagspec, GIT_REFSPEC_TAGS, true) < 0)
1882
1900
  return -1;
@@ -1892,10 +1910,10 @@ static int update_tips_for_spec(
1892
1910
  }
1893
1911
 
1894
1912
  /* Handle specified oid sources */
1895
- if (git_oid__is_hexstr(spec->src)) {
1913
+ if (git_oid__is_hexstr(spec->src, remote->repo->oid_type)) {
1896
1914
  git_oid id;
1897
1915
 
1898
- if ((error = git_oid_fromstr(&id, spec->src)) < 0)
1916
+ if ((error = git_oid__fromstr(&id, spec->src, remote->repo->oid_type)) < 0)
1899
1917
  goto on_error;
1900
1918
 
1901
1919
  if (spec->dst &&
@@ -2896,16 +2914,6 @@ done:
2896
2914
  return error;
2897
2915
  }
2898
2916
 
2899
- GIT_INLINE(int) connect_opts_from_push_opts(
2900
- git_remote_connect_options *out,
2901
- git_remote *remote,
2902
- const git_push_options *push_opts)
2903
- {
2904
- git_remote_connect_options tmp = GIT_REMOTE_CONNECT_OPTIONS_INIT;
2905
- copy_opts(&tmp, push_opts);
2906
- return git_remote_connect_options_normalize(out, remote->repo, &tmp);
2907
- }
2908
-
2909
2917
  int git_remote_upload(
2910
2918
  git_remote *remote,
2911
2919
  const git_strarray *refspecs,
@@ -2924,7 +2932,8 @@ int git_remote_upload(
2924
2932
  return -1;
2925
2933
  }
2926
2934
 
2927
- if ((error = connect_opts_from_push_opts(&connect_opts, remote, opts)) < 0)
2935
+ if ((error = git_remote_connect_options__from_push_opts(
2936
+ &connect_opts, remote, opts)) < 0)
2928
2937
  goto cleanup;
2929
2938
 
2930
2939
  if ((error = connect_or_reset_options(remote, GIT_DIRECTION_PUSH, &connect_opts)) < 0)
@@ -2985,7 +2994,8 @@ int git_remote_push(
2985
2994
  return -1;
2986
2995
  }
2987
2996
 
2988
- if (connect_opts_from_push_opts(&connect_opts, remote, opts) < 0)
2997
+ if (git_remote_connect_options__from_push_opts(&connect_opts,
2998
+ remote, opts) < 0)
2989
2999
  return -1;
2990
3000
 
2991
3001
  if ((error = git_remote_upload(remote, refspecs, opts)) < 0)