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
@@ -134,9 +134,9 @@ int git_branch_create(
134
134
  const git_commit *commit,
135
135
  int force)
136
136
  {
137
- char commit_id[GIT_OID_HEXSZ + 1];
137
+ char commit_id[GIT_OID_MAX_HEXSIZE + 1];
138
138
 
139
- git_oid_tostr(commit_id, GIT_OID_HEXSZ + 1, git_commit_id(commit));
139
+ git_oid_tostr(commit_id, GIT_OID_MAX_HEXSIZE + 1, git_commit_id(commit));
140
140
  return create_branch(ref_out, repository, branch_name, commit, commit_id, force);
141
141
  }
142
142
 
@@ -106,10 +106,10 @@ static int cherrypick_state_cleanup(git_repository *repo)
106
106
 
107
107
  static int cherrypick_seterr(git_commit *commit, const char *fmt)
108
108
  {
109
- char commit_oidstr[GIT_OID_HEXSZ + 1];
109
+ char commit_oidstr[GIT_OID_MAX_HEXSIZE + 1];
110
110
 
111
111
  git_error_set(GIT_ERROR_CHERRYPICK, fmt,
112
- git_oid_tostr(commit_oidstr, GIT_OID_HEXSZ + 1, git_commit_id(commit)));
112
+ git_oid_tostr(commit_oidstr, GIT_OID_MAX_HEXSIZE + 1, git_commit_id(commit)));
113
113
 
114
114
  return -1;
115
115
  }
@@ -173,7 +173,7 @@ int git_cherrypick(
173
173
  git_cherrypick_options opts;
174
174
  git_reference *our_ref = NULL;
175
175
  git_commit *our_commit = NULL;
176
- char commit_oidstr[GIT_OID_HEXSZ + 1];
176
+ char commit_oidstr[GIT_OID_MAX_HEXSIZE + 1];
177
177
  const char *commit_msg, *commit_summary;
178
178
  git_str their_label = GIT_STR_INIT;
179
179
  git_index *index = NULL;
@@ -282,7 +282,11 @@ static int update_head_to_branch(
282
282
  reflog_message)) < 0)
283
283
  goto cleanup;
284
284
 
285
- if ((retcode = git_remote__default_branch(&default_branch, remote)) < 0)
285
+ retcode = git_remote__default_branch(&default_branch, remote);
286
+
287
+ if (retcode == GIT_ENOTFOUND)
288
+ retcode = 0;
289
+ else if (retcode)
286
290
  goto cleanup;
287
291
 
288
292
  if (!git_remote__matching_refspec(remote, git_str_cstr(&default_branch)))
@@ -389,12 +393,19 @@ static int checkout_branch(git_repository *repo, git_remote *remote, const git_c
389
393
  return error;
390
394
  }
391
395
 
392
- static int clone_into(git_repository *repo, git_remote *_remote, const git_fetch_options *opts, const git_checkout_options *co_opts, const char *branch)
396
+ static int clone_into(
397
+ git_repository *repo,
398
+ git_remote *_remote,
399
+ const git_fetch_options *opts,
400
+ const git_checkout_options *co_opts,
401
+ const char *branch)
393
402
  {
394
403
  int error;
395
404
  git_str reflog_message = GIT_STR_INIT;
405
+ git_remote_connect_options connect_opts = GIT_REMOTE_CONNECT_OPTIONS_INIT;
396
406
  git_fetch_options fetch_opts;
397
407
  git_remote *remote;
408
+ git_oid_t oid_type;
398
409
 
399
410
  GIT_ASSERT_ARG(repo);
400
411
  GIT_ASSERT_ARG(_remote);
@@ -409,9 +420,28 @@ static int clone_into(git_repository *repo, git_remote *_remote, const git_fetch
409
420
 
410
421
  memcpy(&fetch_opts, opts, sizeof(git_fetch_options));
411
422
  fetch_opts.update_fetchhead = 0;
412
- fetch_opts.download_tags = GIT_REMOTE_DOWNLOAD_TAGS_ALL;
423
+
424
+ if (!opts->depth)
425
+ fetch_opts.download_tags = GIT_REMOTE_DOWNLOAD_TAGS_ALL;
426
+
427
+ if ((error = git_remote_connect_options__from_fetch_opts(&connect_opts, remote, &fetch_opts)) < 0)
428
+ goto cleanup;
429
+
413
430
  git_str_printf(&reflog_message, "clone: from %s", git_remote_url(remote));
414
431
 
432
+ /*
433
+ * Connect to the server so that we can identify the remote
434
+ * object format.
435
+ */
436
+
437
+ if ((error = git_remote_connect_ext(remote, GIT_DIRECTION_FETCH,
438
+ &connect_opts)) < 0)
439
+ goto cleanup;
440
+
441
+ if ((error = git_remote_oid_type(&oid_type, remote)) < 0 ||
442
+ (error = git_repository__set_objectformat(repo, oid_type)) < 0)
443
+ goto cleanup;
444
+
415
445
  if ((error = git_remote_fetch(remote, NULL, &fetch_opts, git_str_cstr(&reflog_message))) != 0)
416
446
  goto cleanup;
417
447
 
@@ -419,6 +449,7 @@ static int clone_into(git_repository *repo, git_remote *_remote, const git_fetch
419
449
 
420
450
  cleanup:
421
451
  git_remote_free(remote);
452
+ git_remote_connect_options_dispose(&connect_opts);
422
453
  git_str_dispose(&reflog_message);
423
454
 
424
455
  return error;
@@ -22,6 +22,7 @@
22
22
  #include "object.h"
23
23
  #include "array.h"
24
24
  #include "oidarray.h"
25
+ #include "grafts.h"
25
26
 
26
27
  void git_commit__free(void *_commit)
27
28
  {
@@ -56,11 +57,13 @@ static int git_commit__create_buffer_internal(
56
57
  GIT_ASSERT_ARG(out);
57
58
  GIT_ASSERT_ARG(tree);
58
59
 
59
- git_oid__writebuf(out, "tree ", tree);
60
+ if (git_object__write_oid_header(out, "tree ", tree) < 0)
61
+ goto on_error;
60
62
 
61
63
  for (i = 0; i < git_array_size(*parents); i++) {
62
64
  parent = git_array_get(*parents, i);
63
- git_oid__writebuf(out, "parent ", parent);
65
+ if (git_object__write_oid_header(out, "parent ", parent) < 0)
66
+ goto on_error;
64
67
  }
65
68
 
66
69
  git_signature__writebuf(out, "author ", author);
@@ -388,7 +391,11 @@ int git_commit_amend(
388
391
  return error;
389
392
  }
390
393
 
391
- static int commit_parse(git_commit *commit, const char *data, size_t size, unsigned int flags)
394
+ static int commit_parse(
395
+ git_commit *commit,
396
+ const char *data,
397
+ size_t size,
398
+ git_commit__parse_options *opts)
392
399
  {
393
400
  const char *buffer_start = data, *buffer;
394
401
  const char *buffer_end = buffer_start + size;
@@ -399,6 +406,7 @@ static int commit_parse(git_commit *commit, const char *data, size_t size, unsig
399
406
 
400
407
  GIT_ASSERT_ARG(commit);
401
408
  GIT_ASSERT_ARG(data);
409
+ GIT_ASSERT_ARG(opts);
402
410
 
403
411
  buffer = buffer_start;
404
412
 
@@ -407,28 +415,29 @@ static int commit_parse(git_commit *commit, const char *data, size_t size, unsig
407
415
  GIT_ERROR_CHECK_ARRAY(commit->parent_ids);
408
416
 
409
417
  /* The tree is always the first field */
410
- if (!(flags & GIT_COMMIT_PARSE_QUICK)) {
411
- if (git_oid__parse(&commit->tree_id, &buffer, buffer_end, "tree ") < 0)
418
+ if (!(opts->flags & GIT_COMMIT_PARSE_QUICK)) {
419
+ if (git_object__parse_oid_header(&commit->tree_id,
420
+ &buffer, buffer_end, "tree ",
421
+ opts->oid_type) < 0)
412
422
  goto bad_buffer;
413
423
  } else {
414
- size_t tree_len = strlen("tree ") + GIT_OID_HEXSZ + 1;
424
+ size_t tree_len = strlen("tree ") + git_oid_hexsize(opts->oid_type) + 1;
425
+
415
426
  if (buffer + tree_len > buffer_end)
416
427
  goto bad_buffer;
417
428
  buffer += tree_len;
418
429
  }
419
430
 
420
- /*
421
- * TODO: commit grafts!
422
- */
423
-
424
- while (git_oid__parse(&parent_id, &buffer, buffer_end, "parent ") == 0) {
431
+ while (git_object__parse_oid_header(&parent_id,
432
+ &buffer, buffer_end, "parent ",
433
+ opts->oid_type) == 0) {
425
434
  git_oid *new_id = git_array_alloc(commit->parent_ids);
426
435
  GIT_ERROR_CHECK_ALLOC(new_id);
427
436
 
428
437
  git_oid_cpy(new_id, &parent_id);
429
438
  }
430
439
 
431
- if (!(flags & GIT_COMMIT_PARSE_QUICK)) {
440
+ if (!opts || !(opts->flags & GIT_COMMIT_PARSE_QUICK)) {
432
441
  commit->author = git__malloc(sizeof(git_signature));
433
442
  GIT_ERROR_CHECK_ALLOC(commit->author);
434
443
 
@@ -452,7 +461,7 @@ static int commit_parse(git_commit *commit, const char *data, size_t size, unsig
452
461
  if ((error = git_signature__parse(commit->committer, &buffer, buffer_end, "committer ", '\n')) < 0)
453
462
  return error;
454
463
 
455
- if (flags & GIT_COMMIT_PARSE_QUICK)
464
+ if (opts && opts->flags & GIT_COMMIT_PARSE_QUICK)
456
465
  return 0;
457
466
 
458
467
  /* Parse add'l header entries */
@@ -497,19 +506,64 @@ bad_buffer:
497
506
  return GIT_EINVALID;
498
507
  }
499
508
 
500
- int git_commit__parse_raw(void *commit, const char *data, size_t size)
509
+ int git_commit__parse(
510
+ void *commit,
511
+ git_odb_object *odb_obj,
512
+ git_oid_t oid_type)
501
513
  {
502
- return commit_parse(commit, data, size, 0);
514
+ git_commit__parse_options parse_options = {0};
515
+ parse_options.oid_type = oid_type;
516
+
517
+ return git_commit__parse_ext(commit, odb_obj, &parse_options);
503
518
  }
504
519
 
505
- int git_commit__parse_ext(git_commit *commit, git_odb_object *odb_obj, unsigned int flags)
520
+ int git_commit__parse_raw(
521
+ void *commit,
522
+ const char *data,
523
+ size_t size,
524
+ git_oid_t oid_type)
506
525
  {
507
- return commit_parse(commit, git_odb_object_data(odb_obj), git_odb_object_size(odb_obj), flags);
526
+ git_commit__parse_options parse_options = {0};
527
+ parse_options.oid_type = oid_type;
528
+
529
+ return commit_parse(commit, data, size, &parse_options);
508
530
  }
509
531
 
510
- int git_commit__parse(void *_commit, git_odb_object *odb_obj)
532
+ static int assign_commit_parents_from_graft(git_commit *commit, git_commit_graft *graft) {
533
+ size_t idx;
534
+ git_oid *oid;
535
+
536
+ git_array_clear(commit->parent_ids);
537
+ git_array_init_to_size(commit->parent_ids, git_array_size(graft->parents));
538
+ git_array_foreach(graft->parents, idx, oid) {
539
+ git_oid *id = git_array_alloc(commit->parent_ids);
540
+ GIT_ERROR_CHECK_ALLOC(id);
541
+
542
+ git_oid_cpy(id, oid);
543
+ }
544
+
545
+ return 0;
546
+ }
547
+
548
+ int git_commit__parse_ext(
549
+ git_commit *commit,
550
+ git_odb_object *odb_obj,
551
+ git_commit__parse_options *parse_opts)
511
552
  {
512
- return git_commit__parse_ext(_commit, odb_obj, 0);
553
+ git_repository *repo = git_object_owner((git_object *)commit);
554
+ git_commit_graft *graft;
555
+ int error;
556
+
557
+ if ((error = commit_parse(commit, git_odb_object_data(odb_obj),
558
+ git_odb_object_size(odb_obj), parse_opts)) < 0)
559
+ return error;
560
+
561
+ /* Perform necessary grafts */
562
+ if (git_grafts_get(&graft, repo->grafts, git_odb_object_id(odb_obj)) != 0 &&
563
+ git_grafts_get(&graft, repo->shallow_grafts, git_odb_object_id(odb_obj)) != 0)
564
+ return 0;
565
+
566
+ return assign_commit_parents_from_graft(commit, graft);
513
567
  }
514
568
 
515
569
  #define GIT_COMMIT_GETTER(_rvalue, _name, _return, _invalid) \
@@ -566,7 +620,7 @@ const char *git_commit_summary(git_commit *commit)
566
620
  while (*next && git__isspace_nonlf(*next)) {
567
621
  ++next;
568
622
  }
569
- if (!*next || *next == '\n')
623
+ if (!*next || *next == '\n')
570
624
  break;
571
625
  }
572
626
  /* record the beginning of contiguous whitespace runs */
@@ -979,11 +1033,14 @@ int git_commit_create_with_signature(
979
1033
  git_str commit = GIT_STR_INIT;
980
1034
  git_commit *parsed;
981
1035
  git_array_oid_t parents = GIT_ARRAY_INIT;
1036
+ git_commit__parse_options parse_opts = {0};
1037
+
1038
+ parse_opts.oid_type = repo->oid_type;
982
1039
 
983
1040
  /* The first step is to verify that all the tree and parents exist */
984
1041
  parsed = git__calloc(1, sizeof(git_commit));
985
1042
  GIT_ERROR_CHECK_ALLOC(parsed);
986
- if (commit_parse(parsed, commit_content, strlen(commit_content), 0) < 0) {
1043
+ if (commit_parse(parsed, commit_content, strlen(commit_content), &parse_opts) < 0) {
987
1044
  error = -1;
988
1045
  goto cleanup;
989
1046
  }
@@ -33,6 +33,16 @@ struct git_commit {
33
33
  char *body;
34
34
  };
35
35
 
36
+ typedef struct {
37
+ git_oid_t oid_type;
38
+ unsigned int flags;
39
+ } git_commit__parse_options;
40
+
41
+ typedef enum {
42
+ /** Only parse parents and committer info */
43
+ GIT_COMMIT_PARSE_QUICK = (1 << 0)
44
+ } git_commit__parse_flags;
45
+
36
46
  int git_commit__header_field(
37
47
  git_str *out,
38
48
  const git_commit *commit,
@@ -56,14 +66,22 @@ int git_commit__create_buffer(
56
66
  size_t parent_count,
57
67
  const git_commit *parents[]);
58
68
 
59
- void git_commit__free(void *commit);
60
- int git_commit__parse(void *commit, git_odb_object *obj);
61
- int git_commit__parse_raw(void *commit, const char *data, size_t size);
69
+ int git_commit__parse(
70
+ void *commit,
71
+ git_odb_object *obj,
72
+ git_oid_t oid_type);
62
73
 
63
- typedef enum {
64
- GIT_COMMIT_PARSE_QUICK = (1 << 0) /**< Only parse parents and committer info */
65
- } git_commit__parse_flags;
74
+ int git_commit__parse_raw(
75
+ void *commit,
76
+ const char *data,
77
+ size_t size,
78
+ git_oid_t oid_type);
66
79
 
67
- int git_commit__parse_ext(git_commit *commit, git_odb_object *odb_obj, unsigned int flags);
80
+ int git_commit__parse_ext(
81
+ git_commit *commit,
82
+ git_odb_object *odb_obj,
83
+ git_commit__parse_options *parse_opts);
84
+
85
+ void git_commit__free(void *commit);
68
86
 
69
87
  #endif