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
@@ -50,7 +50,7 @@ int git_parse_advance_expected(
50
50
  int git_parse_advance_ws(git_parse_ctx *ctx);
51
51
  int git_parse_advance_nl(git_parse_ctx *ctx);
52
52
  int git_parse_advance_digit(int64_t *out, git_parse_ctx *ctx, int base);
53
- int git_parse_advance_oid(git_oid *out, git_parse_ctx *ctx);
53
+ int git_parse_advance_oid(git_oid *out, git_parse_ctx *ctx, git_oid_t oid_type);
54
54
 
55
55
  enum GIT_PARSE_PEEK_FLAGS {
56
56
  GIT_PARSE_PEEK_SKIP_WHITESPACE = (1 << 0)
@@ -59,9 +59,15 @@ typedef struct {
59
59
  * This prefix will be removed when looking for files. The default is 1.
60
60
  */
61
61
  uint32_t prefix_len;
62
+
63
+ /**
64
+ * The type of object IDs in the patch file. The default is
65
+ * `GIT_OID_DEFAULT`.
66
+ */
67
+ git_oid_t oid_type;
62
68
  } git_patch_options;
63
69
 
64
- #define GIT_PATCH_OPTIONS_INIT { 1 }
70
+ #define GIT_PATCH_OPTIONS_INIT { 1, GIT_OID_DEFAULT }
65
71
 
66
72
  extern int git_patch__to_buf(git_str *out, git_patch *patch);
67
73
  extern void git_patch_free(git_patch *patch);
@@ -81,7 +81,8 @@ static void patch_generated_init_common(git_patch_generated *patch)
81
81
 
82
82
  static int patch_generated_normalize_options(
83
83
  git_diff_options *out,
84
- const git_diff_options *opts)
84
+ const git_diff_options *opts,
85
+ git_repository *repo)
85
86
  {
86
87
  if (opts) {
87
88
  GIT_ERROR_CHECK_VERSION(opts, GIT_DIFF_OPTIONS_VERSION, "git_diff_options");
@@ -91,6 +92,23 @@ static int patch_generated_normalize_options(
91
92
  memcpy(out, &default_opts, sizeof(git_diff_options));
92
93
  }
93
94
 
95
+ if (repo && opts && opts->oid_type && repo->oid_type != opts->oid_type) {
96
+ /*
97
+ * This limitation feels unnecessary - we should consider
98
+ * allowing users to generate diffs with a different object
99
+ * ID format than the repository.
100
+ */
101
+ git_error_set(GIT_ERROR_INVALID,
102
+ "specified object ID type does not match repository object ID type");
103
+ return -1;
104
+ } else if (repo) {
105
+ out->oid_type = repo->oid_type;
106
+ } else if (opts && opts->oid_type) {
107
+ out->oid_type = opts->oid_type;
108
+ } else {
109
+ out->oid_type = GIT_OID_DEFAULT;
110
+ }
111
+
94
112
  out->old_prefix = opts && opts->old_prefix ?
95
113
  git__strdup(opts->old_prefix) :
96
114
  git__strdup(DIFF_OLD_PREFIX_DEFAULT);
@@ -118,7 +136,7 @@ static int patch_generated_init(
118
136
  patch->delta_index = delta_index;
119
137
 
120
138
  if ((error = patch_generated_normalize_options(
121
- &patch->base.diff_opts, &diff->opts)) < 0 ||
139
+ &patch->base.diff_opts, &diff->opts, diff->repo)) < 0 ||
122
140
  (error = git_diff_file_content__init_from_diff(
123
141
  &patch->ofile, diff, patch->base.delta, true)) < 0 ||
124
142
  (error = git_diff_file_content__init_from_diff(
@@ -449,7 +467,7 @@ static int patch_generated_from_sources(
449
467
  git_xdiff_output *xo,
450
468
  git_diff_file_content_src *oldsrc,
451
469
  git_diff_file_content_src *newsrc,
452
- const git_diff_options *opts)
470
+ const git_diff_options *given_opts)
453
471
  {
454
472
  int error = 0;
455
473
  git_repository *repo =
@@ -457,11 +475,12 @@ static int patch_generated_from_sources(
457
475
  newsrc->blob ? git_blob_owner(newsrc->blob) : NULL;
458
476
  git_diff_file *lfile = &pd->delta.old_file, *rfile = &pd->delta.new_file;
459
477
  git_diff_file_content *ldata = &pd->patch.ofile, *rdata = &pd->patch.nfile;
478
+ git_diff_options *opts = &pd->patch.base.diff_opts;
460
479
 
461
- if ((error = patch_generated_normalize_options(&pd->patch.base.diff_opts, opts)) < 0)
480
+ if ((error = patch_generated_normalize_options(opts, given_opts, repo)) < 0)
462
481
  return error;
463
482
 
464
- if (opts && (opts->flags & GIT_DIFF_REVERSE) != 0) {
483
+ if ((opts->flags & GIT_DIFF_REVERSE) != 0) {
465
484
  void *tmp = lfile; lfile = rfile; rfile = tmp;
466
485
  tmp = ldata; ldata = rdata; rdata = tmp;
467
486
  }
@@ -166,15 +166,19 @@ static int parse_header_oid(
166
166
  uint16_t *oid_len,
167
167
  git_patch_parse_ctx *ctx)
168
168
  {
169
- size_t len;
169
+ size_t hexsize, len;
170
+
171
+ hexsize = git_oid_hexsize(ctx->opts.oid_type);
170
172
 
171
- for (len = 0; len < ctx->parse_ctx.line_len && len < GIT_OID_HEXSZ; len++) {
173
+ for (len = 0;
174
+ len < ctx->parse_ctx.line_len && len < hexsize;
175
+ len++) {
172
176
  if (!git__isxdigit(ctx->parse_ctx.line[len]))
173
177
  break;
174
178
  }
175
179
 
176
- if (len < GIT_OID_MINPREFIXLEN || len > GIT_OID_HEXSZ ||
177
- git_oid_fromstrn(oid, ctx->parse_ctx.line, len) < 0)
180
+ if (len < GIT_OID_MINPREFIXLEN || len > hexsize ||
181
+ git_oid__fromstrn(oid, ctx->parse_ctx.line, len, ctx->opts.oid_type) < 0)
178
182
  return git_parse_err("invalid hex formatted object id at line %"PRIuZ,
179
183
  ctx->parse_ctx.line_num);
180
184
 
@@ -1065,12 +1069,14 @@ static int check_patch(git_patch_parsed *patch)
1065
1069
  return git_parse_err("patch with no hunks");
1066
1070
 
1067
1071
  if (delta->status == GIT_DELTA_ADDED) {
1068
- memset(&delta->old_file.id, 0x0, sizeof(git_oid));
1072
+ git_oid_clear(&delta->old_file.id,
1073
+ patch->base.diff_opts.oid_type);
1069
1074
  delta->old_file.id_abbrev = 0;
1070
1075
  }
1071
1076
 
1072
1077
  if (delta->status == GIT_DELTA_DELETED) {
1073
- memset(&delta->new_file.id, 0x0, sizeof(git_oid));
1078
+ git_oid_clear(&delta->new_file.id,
1079
+ patch->base.diff_opts.oid_type);
1074
1080
  delta->new_file.id_abbrev = 0;
1075
1081
  }
1076
1082
 
@@ -1187,11 +1193,13 @@ int git_patch_parse(
1187
1193
  patch->base.delta->status = GIT_DELTA_MODIFIED;
1188
1194
  patch->base.delta->nfiles = 2;
1189
1195
 
1196
+ patch->base.diff_opts.oid_type = ctx->opts.oid_type;
1197
+
1190
1198
  start = ctx->parse_ctx.remain_len;
1191
1199
 
1192
1200
  if ((error = parse_patch_header(patch, ctx)) < 0 ||
1193
- (error = parse_patch_body(patch, ctx)) < 0 ||
1194
- (error = check_patch(patch)) < 0)
1201
+ (error = parse_patch_body(patch, ctx)) < 0 ||
1202
+ (error = check_patch(patch)) < 0)
1195
1203
  goto done;
1196
1204
 
1197
1205
  used = start - ctx->parse_ctx.remain_len;
@@ -118,6 +118,9 @@ static int parse_refspec(git_push *push, push_spec **spec, const char *str)
118
118
  s = git__calloc(1, sizeof(*s));
119
119
  GIT_ERROR_CHECK_ALLOC(s);
120
120
 
121
+ git_oid_clear(&s->loid, push->repo->oid_type);
122
+ git_oid_clear(&s->roid, push->repo->oid_type);
123
+
121
124
  if (git_refspec__parse(&s->refspec, str, false) < 0) {
122
125
  git_error_set(GIT_ERROR_INVALID, "invalid refspec %s", str);
123
126
  goto on_error;
@@ -382,11 +385,18 @@ static int calculate_work(git_push *push)
382
385
  git_vector_foreach(&push->specs, i, spec) {
383
386
  if (spec->refspec.src && spec->refspec.src[0]!= '\0') {
384
387
  /* This is a create or update. Local ref must exist. */
385
- if (git_reference_name_to_id(
386
- &spec->loid, push->repo, spec->refspec.src) < 0) {
387
- git_error_set(GIT_ERROR_REFERENCE, "no such reference '%s'", spec->refspec.src);
388
+
389
+ git_object *obj;
390
+ int error = git_revparse_single(&obj, push->repo, spec->refspec.src);
391
+
392
+ if (error < 0) {
393
+ git_object_free(obj);
394
+ git_error_set(GIT_ERROR_REFERENCE, "src refspec %s does not match any", spec->refspec.src);
388
395
  return -1;
389
396
  }
397
+
398
+ git_oid_cpy(&spec->loid, git_object_id(obj));
399
+ git_object_free(obj);
390
400
  }
391
401
 
392
402
  /* Remote ref may or may not (e.g. during create) already exist. */
@@ -125,7 +125,7 @@ static int workdir_reader_read(
125
125
  goto done;
126
126
 
127
127
  if (out_id || reader->index) {
128
- if ((error = git_odb_hash(&id, out->ptr, out->size, GIT_OBJECT_BLOB)) < 0)
128
+ if ((error = git_odb__hash(&id, out->ptr, out->size, GIT_OBJECT_BLOB, reader->repo->oid_type)) < 0)
129
129
  goto done;
130
130
  }
131
131
 
@@ -65,6 +65,9 @@ struct git_rebase {
65
65
  git_rebase_t type;
66
66
  char *state_path;
67
67
 
68
+ /* Temporary buffer for paths within the state path. */
69
+ git_str state_filename;
70
+
68
71
  unsigned int head_detached:1,
69
72
  inmemory:1,
70
73
  quiet:1,
@@ -134,33 +137,42 @@ done:
134
137
 
135
138
  GIT_INLINE(int) rebase_readfile(
136
139
  git_str *out,
137
- git_str *state_path,
140
+ git_rebase *rebase,
138
141
  const char *filename)
139
142
  {
140
- size_t state_path_len = state_path->size;
143
+ /*
144
+ * `rebase->state_filename` is a temporary buffer to avoid
145
+ * unnecessary allocations and copies of `rebase->state_path`.
146
+ * At the start and end of this function it always contains the
147
+ * contents of `rebase->state_path` itself.
148
+ */
149
+ size_t state_path_len = rebase->state_filename.size;
141
150
  int error;
142
151
 
143
152
  git_str_clear(out);
144
153
 
145
- if ((error = git_str_joinpath(state_path, state_path->ptr, filename)) < 0 ||
146
- (error = git_futils_readbuffer(out, state_path->ptr)) < 0)
154
+ if ((error = git_str_joinpath(&rebase->state_filename, rebase->state_filename.ptr, filename)) < 0 ||
155
+ (error = git_futils_readbuffer(out, rebase->state_filename.ptr)) < 0)
147
156
  goto done;
148
157
 
149
158
  git_str_rtrim(out);
150
159
 
151
160
  done:
152
- git_str_truncate(state_path, state_path_len);
161
+ git_str_truncate(&rebase->state_filename, state_path_len);
153
162
  return error;
154
163
  }
155
164
 
156
165
  GIT_INLINE(int) rebase_readint(
157
- size_t *out, git_str *asc_out, git_str *state_path, const char *filename)
166
+ size_t *out,
167
+ git_str *asc_out,
168
+ git_rebase *rebase,
169
+ const char *filename)
158
170
  {
159
171
  int32_t num;
160
172
  const char *eol;
161
173
  int error = 0;
162
174
 
163
- if ((error = rebase_readfile(asc_out, state_path, filename)) < 0)
175
+ if ((error = rebase_readfile(asc_out, rebase, filename)) < 0)
164
176
  return error;
165
177
 
166
178
  if (git__strntol32(&num, asc_out->ptr, asc_out->size, &eol, 10) < 0 || num < 0 || *eol) {
@@ -174,14 +186,18 @@ GIT_INLINE(int) rebase_readint(
174
186
  }
175
187
 
176
188
  GIT_INLINE(int) rebase_readoid(
177
- git_oid *out, git_str *str_out, git_str *state_path, const char *filename)
189
+ git_oid *out,
190
+ git_str *str_out,
191
+ git_rebase *rebase,
192
+ const char *filename)
178
193
  {
179
194
  int error;
180
195
 
181
- if ((error = rebase_readfile(str_out, state_path, filename)) < 0)
196
+ if ((error = rebase_readfile(str_out, rebase, filename)) < 0)
182
197
  return error;
183
198
 
184
- if (str_out->size != GIT_OID_HEXSZ || git_oid_fromstr(out, str_out->ptr) < 0) {
199
+ if (str_out->size != git_oid_hexsize(rebase->repo->oid_type) ||
200
+ git_oid__fromstr(out, str_out->ptr, rebase->repo->oid_type) < 0) {
185
201
  git_error_set(GIT_ERROR_REBASE, "the file '%s' contains an invalid object ID", filename);
186
202
  return -1;
187
203
  }
@@ -212,17 +228,14 @@ static git_rebase_operation *rebase_operation_alloc(
212
228
 
213
229
  static int rebase_open_merge(git_rebase *rebase)
214
230
  {
215
- git_str state_path = GIT_STR_INIT, buf = GIT_STR_INIT, cmt = GIT_STR_INIT;
231
+ git_str buf = GIT_STR_INIT, cmt = GIT_STR_INIT;
216
232
  git_oid id;
217
233
  git_rebase_operation *operation;
218
234
  size_t i, msgnum = 0, end;
219
235
  int error;
220
236
 
221
- if ((error = git_str_puts(&state_path, rebase->state_path)) < 0)
222
- goto done;
223
-
224
237
  /* Read 'msgnum' if it exists (otherwise, let msgnum = 0) */
225
- if ((error = rebase_readint(&msgnum, &buf, &state_path, MSGNUM_FILE)) < 0 &&
238
+ if ((error = rebase_readint(&msgnum, &buf, rebase, MSGNUM_FILE)) < 0 &&
226
239
  error != GIT_ENOTFOUND)
227
240
  goto done;
228
241
 
@@ -232,11 +245,11 @@ static int rebase_open_merge(git_rebase *rebase)
232
245
  }
233
246
 
234
247
  /* Read 'end' */
235
- if ((error = rebase_readint(&end, &buf, &state_path, END_FILE)) < 0)
248
+ if ((error = rebase_readint(&end, &buf, rebase, END_FILE)) < 0)
236
249
  goto done;
237
250
 
238
251
  /* Read 'current' if it exists */
239
- if ((error = rebase_readoid(&id, &buf, &state_path, CURRENT_FILE)) < 0 &&
252
+ if ((error = rebase_readoid(&id, &buf, rebase, CURRENT_FILE)) < 0 &&
240
253
  error != GIT_ENOTFOUND)
241
254
  goto done;
242
255
 
@@ -248,7 +261,7 @@ static int rebase_open_merge(git_rebase *rebase)
248
261
  git_str_clear(&cmt);
249
262
 
250
263
  if ((error = git_str_printf(&cmt, "cmt.%" PRIuZ, (i+1))) < 0 ||
251
- (error = rebase_readoid(&id, &buf, &state_path, cmt.ptr)) < 0)
264
+ (error = rebase_readoid(&id, &buf, rebase, cmt.ptr)) < 0)
252
265
  goto done;
253
266
 
254
267
  operation = rebase_operation_alloc(rebase, GIT_REBASE_OPERATION_PICK, &id, NULL);
@@ -256,14 +269,13 @@ static int rebase_open_merge(git_rebase *rebase)
256
269
  }
257
270
 
258
271
  /* Read 'onto_name' */
259
- if ((error = rebase_readfile(&buf, &state_path, ONTO_NAME_FILE)) < 0)
272
+ if ((error = rebase_readfile(&buf, rebase, ONTO_NAME_FILE)) < 0)
260
273
  goto done;
261
274
 
262
275
  rebase->onto_name = git_str_detach(&buf);
263
276
 
264
277
  done:
265
278
  git_str_dispose(&cmt);
266
- git_str_dispose(&state_path);
267
279
  git_str_dispose(&buf);
268
280
 
269
281
  return error;
@@ -307,9 +319,9 @@ int git_rebase_open(
307
319
  const git_rebase_options *given_opts)
308
320
  {
309
321
  git_rebase *rebase;
310
- git_str path = GIT_STR_INIT, orig_head_name = GIT_STR_INIT,
311
- orig_head_id = GIT_STR_INIT, onto_id = GIT_STR_INIT;
312
- size_t state_path_len;
322
+ git_str orig_head_name = GIT_STR_INIT,
323
+ orig_head_id = GIT_STR_INIT,
324
+ onto_id = GIT_STR_INIT;
313
325
  int error;
314
326
 
315
327
  GIT_ASSERT_ARG(repo);
@@ -331,13 +343,10 @@ int git_rebase_open(
331
343
  goto done;
332
344
  }
333
345
 
334
- if ((error = git_str_puts(&path, rebase->state_path)) < 0)
346
+ if ((error = git_str_puts(&rebase->state_filename, rebase->state_path)) < 0)
335
347
  goto done;
336
348
 
337
- state_path_len = git_str_len(&path);
338
-
339
- if ((error = git_str_joinpath(&path, path.ptr, HEAD_NAME_FILE)) < 0 ||
340
- (error = git_futils_readbuffer(&orig_head_name, path.ptr)) < 0)
349
+ if ((error = rebase_readfile(&orig_head_name, rebase, HEAD_NAME_FILE)) < 0)
341
350
  goto done;
342
351
 
343
352
  git_str_rtrim(&orig_head_name);
@@ -345,36 +354,16 @@ int git_rebase_open(
345
354
  if (strcmp(ORIG_DETACHED_HEAD, orig_head_name.ptr) == 0)
346
355
  rebase->head_detached = 1;
347
356
 
348
- git_str_truncate(&path, state_path_len);
349
-
350
- if ((error = git_str_joinpath(&path, path.ptr, ORIG_HEAD_FILE)) < 0)
351
- goto done;
352
-
353
- if (!git_fs_path_isfile(path.ptr)) {
357
+ if ((error = rebase_readoid(&rebase->orig_head_id, &orig_head_id, rebase, ORIG_HEAD_FILE)) < 0) {
354
358
  /* Previous versions of git.git used 'head' here; support that. */
355
- git_str_truncate(&path, state_path_len);
359
+ if (error == GIT_ENOTFOUND)
360
+ error = rebase_readoid(&rebase->orig_head_id, &orig_head_id, rebase, HEAD_FILE);
356
361
 
357
- if ((error = git_str_joinpath(&path, path.ptr, HEAD_FILE)) < 0)
362
+ if (error < 0)
358
363
  goto done;
359
364
  }
360
365
 
361
- if ((error = git_futils_readbuffer(&orig_head_id, path.ptr)) < 0)
362
- goto done;
363
-
364
- git_str_rtrim(&orig_head_id);
365
-
366
- if ((error = git_oid_fromstr(&rebase->orig_head_id, orig_head_id.ptr)) < 0)
367
- goto done;
368
-
369
- git_str_truncate(&path, state_path_len);
370
-
371
- if ((error = git_str_joinpath(&path, path.ptr, ONTO_FILE)) < 0 ||
372
- (error = git_futils_readbuffer(&onto_id, path.ptr)) < 0)
373
- goto done;
374
-
375
- git_str_rtrim(&onto_id);
376
-
377
- if ((error = git_oid_fromstr(&rebase->onto_id, onto_id.ptr)) < 0)
366
+ if ((error = rebase_readoid(&rebase->onto_id, &onto_id, rebase, ONTO_FILE)) < 0)
378
367
  goto done;
379
368
 
380
369
  if (!rebase->head_detached)
@@ -402,7 +391,6 @@ done:
402
391
  else
403
392
  git_rebase_free(rebase);
404
393
 
405
- git_str_dispose(&path);
406
394
  git_str_dispose(&orig_head_name);
407
395
  git_str_dispose(&orig_head_id);
408
396
  git_str_dispose(&onto_id);
@@ -452,13 +440,13 @@ static const char *rebase_onto_name(const git_annotated_commit *onto)
452
440
  static int rebase_setupfiles_merge(git_rebase *rebase)
453
441
  {
454
442
  git_str commit_filename = GIT_STR_INIT;
455
- char id_str[GIT_OID_HEXSZ];
443
+ char id_str[GIT_OID_MAX_HEXSIZE + 1];
456
444
  git_rebase_operation *operation;
457
445
  size_t i;
458
446
  int error = 0;
459
447
 
460
448
  if ((error = rebase_setupfile(rebase, END_FILE, 0, "%" PRIuZ "\n", git_array_size(rebase->operations))) < 0 ||
461
- (error = rebase_setupfile(rebase, ONTO_NAME_FILE, 0, "%s\n", rebase->onto_name)) < 0)
449
+ (error = rebase_setupfile(rebase, ONTO_NAME_FILE, 0, "%s\n", rebase->onto_name)) < 0)
462
450
  goto done;
463
451
 
464
452
  for (i = 0; i < git_array_size(rebase->operations); i++) {
@@ -467,10 +455,9 @@ static int rebase_setupfiles_merge(git_rebase *rebase)
467
455
  git_str_clear(&commit_filename);
468
456
  git_str_printf(&commit_filename, CMT_FILE_FMT, i+1);
469
457
 
470
- git_oid_fmt(id_str, &operation->id);
458
+ git_oid_tostr(id_str, GIT_OID_MAX_HEXSIZE + 1, &operation->id);
471
459
 
472
- if ((error = rebase_setupfile(rebase, commit_filename.ptr, 0,
473
- "%.*s\n", GIT_OID_HEXSZ, id_str)) < 0)
460
+ if ((error = rebase_setupfile(rebase, commit_filename.ptr, 0, "%s\n", id_str)) < 0)
474
461
  goto done;
475
462
  }
476
463
 
@@ -481,11 +468,11 @@ done:
481
468
 
482
469
  static int rebase_setupfiles(git_rebase *rebase)
483
470
  {
484
- char onto[GIT_OID_HEXSZ], orig_head[GIT_OID_HEXSZ];
471
+ char onto[GIT_OID_MAX_HEXSIZE + 1], orig_head[GIT_OID_MAX_HEXSIZE + 1];
485
472
  const char *orig_head_name;
486
473
 
487
- git_oid_fmt(onto, &rebase->onto_id);
488
- git_oid_fmt(orig_head, &rebase->orig_head_id);
474
+ git_oid_tostr(onto, GIT_OID_MAX_HEXSIZE + 1, &rebase->onto_id);
475
+ git_oid_tostr(orig_head, GIT_OID_MAX_HEXSIZE + 1, &rebase->orig_head_id);
489
476
 
490
477
  if (p_mkdir(rebase->state_path, REBASE_DIR_MODE) < 0) {
491
478
  git_error_set(GIT_ERROR_OS, "failed to create rebase directory '%s'", rebase->state_path);
@@ -497,8 +484,8 @@ static int rebase_setupfiles(git_rebase *rebase)
497
484
 
498
485
  if (git_repository__set_orig_head(rebase->repo, &rebase->orig_head_id) < 0 ||
499
486
  rebase_setupfile(rebase, HEAD_NAME_FILE, 0, "%s\n", orig_head_name) < 0 ||
500
- rebase_setupfile(rebase, ONTO_FILE, 0, "%.*s\n", GIT_OID_HEXSZ, onto) < 0 ||
501
- rebase_setupfile(rebase, ORIG_HEAD_FILE, 0, "%.*s\n", GIT_OID_HEXSZ, orig_head) < 0 ||
487
+ rebase_setupfile(rebase, ONTO_FILE, 0, "%s\n", onto) < 0 ||
488
+ rebase_setupfile(rebase, ORIG_HEAD_FILE, 0, "%s\n", orig_head) < 0 ||
502
489
  rebase_setupfile(rebase, QUIET_FILE, 0, rebase->quiet ? "t\n" : "\n") < 0)
503
490
  return -1;
504
491
 
@@ -643,7 +630,8 @@ static int rebase_init_merge(
643
630
 
644
631
  GIT_UNUSED(upstream);
645
632
 
646
- if ((error = git_str_joinpath(&state_path, repo->gitdir, REBASE_MERGE_DIR)) < 0)
633
+ if ((error = git_str_joinpath(&state_path, repo->gitdir, REBASE_MERGE_DIR)) < 0 ||
634
+ (error = git_str_put(&rebase->state_filename, state_path.ptr, state_path.size)) < 0)
647
635
  goto done;
648
636
 
649
637
  rebase->state_path = git_str_detach(&state_path);
@@ -813,7 +801,7 @@ static int rebase_next_merge(
813
801
  git_indexwriter indexwriter = GIT_INDEXWRITER_INIT;
814
802
  git_rebase_operation *operation;
815
803
  git_checkout_options checkout_opts;
816
- char current_idstr[GIT_OID_HEXSZ];
804
+ char current_idstr[GIT_OID_MAX_HEXSIZE + 1];
817
805
  unsigned int parent_count;
818
806
  int error;
819
807
 
@@ -836,13 +824,13 @@ static int rebase_next_merge(
836
824
  goto done;
837
825
  }
838
826
 
839
- git_oid_fmt(current_idstr, &operation->id);
827
+ git_oid_tostr(current_idstr, GIT_OID_MAX_HEXSIZE + 1, &operation->id);
840
828
 
841
829
  normalize_checkout_options_for_apply(&checkout_opts, rebase, current_commit);
842
830
 
843
831
  if ((error = git_indexwriter_init_for_operation(&indexwriter, rebase->repo, &checkout_opts.checkout_strategy)) < 0 ||
844
832
  (error = rebase_setupfile(rebase, MSGNUM_FILE, 0, "%" PRIuZ "\n", rebase->current+1)) < 0 ||
845
- (error = rebase_setupfile(rebase, CURRENT_FILE, 0, "%.*s\n", GIT_OID_HEXSZ, current_idstr)) < 0 ||
833
+ (error = rebase_setupfile(rebase, CURRENT_FILE, 0, "%s\n", current_idstr)) < 0 ||
846
834
  (error = git_merge_trees(&index, rebase->repo, parent_tree, head_tree, current_tree, &rebase->options.merge_options)) < 0 ||
847
835
  (error = git_merge__check_result(rebase->repo, index)) < 0 ||
848
836
  (error = git_checkout_index(rebase->repo, index, &checkout_opts)) < 0 ||
@@ -1102,7 +1090,7 @@ static int rebase_commit_merge(
1102
1090
  git_reference *head = NULL;
1103
1091
  git_commit *head_commit = NULL, *commit = NULL;
1104
1092
  git_index *index = NULL;
1105
- char old_idstr[GIT_OID_HEXSZ], new_idstr[GIT_OID_HEXSZ];
1093
+ char old_idstr[GIT_OID_MAX_HEXSIZE + 1], new_idstr[GIT_OID_MAX_HEXSIZE + 1];
1106
1094
  int error;
1107
1095
 
1108
1096
  operation = git_array_get(rebase->operations, rebase->current);
@@ -1118,11 +1106,11 @@ static int rebase_commit_merge(
1118
1106
  rebase->repo, NULL, "HEAD", git_commit_id(commit), "rebase")) < 0)
1119
1107
  goto done;
1120
1108
 
1121
- git_oid_fmt(old_idstr, &operation->id);
1122
- git_oid_fmt(new_idstr, git_commit_id(commit));
1109
+ git_oid_tostr(old_idstr, GIT_OID_MAX_HEXSIZE + 1, &operation->id);
1110
+ git_oid_tostr(new_idstr, GIT_OID_MAX_HEXSIZE + 1, git_commit_id(commit));
1123
1111
 
1124
1112
  if ((error = rebase_setupfile(rebase, REWRITTEN_FILE, O_CREAT|O_WRONLY|O_APPEND,
1125
- "%.*s %.*s\n", GIT_OID_HEXSZ, old_idstr, GIT_OID_HEXSZ, new_idstr)) < 0)
1113
+ "%s %s\n", old_idstr, new_idstr)) < 0)
1126
1114
  goto done;
1127
1115
 
1128
1116
  git_oid_cpy(commit_id, git_commit_id(commit));
@@ -1305,7 +1293,9 @@ static int rebase_copy_notes(
1305
1293
  git_rebase *rebase,
1306
1294
  const git_signature *committer)
1307
1295
  {
1308
- git_str path = GIT_STR_INIT, rewritten = GIT_STR_INIT, notes_ref = GIT_STR_INIT;
1296
+ git_str path = GIT_STR_INIT,
1297
+ rewritten = GIT_STR_INIT,
1298
+ notes_ref = GIT_STR_INIT;
1309
1299
  char *pair_list, *fromstr, *tostr, *end;
1310
1300
  git_oid from, to;
1311
1301
  unsigned int linenum = 1;
@@ -1341,10 +1331,10 @@ static int rebase_copy_notes(
1341
1331
  tostr = end+1;
1342
1332
  *end = '\0';
1343
1333
 
1344
- if (strlen(fromstr) != GIT_OID_HEXSZ ||
1345
- strlen(tostr) != GIT_OID_HEXSZ ||
1346
- git_oid_fromstr(&from, fromstr) < 0 ||
1347
- git_oid_fromstr(&to, tostr) < 0)
1334
+ if (strlen(fromstr) != git_oid_hexsize(rebase->repo->oid_type) ||
1335
+ strlen(tostr) != git_oid_hexsize(rebase->repo->oid_type) ||
1336
+ git_oid__fromstr(&from, fromstr, rebase->repo->oid_type) < 0 ||
1337
+ git_oid__fromstr(&to, tostr, rebase->repo->oid_type) < 0)
1348
1338
  goto on_error;
1349
1339
 
1350
1340
  if ((error = rebase_copy_note(rebase, notes_ref.ptr, &from, &to, committer)) < 0)
@@ -1372,17 +1362,15 @@ static int return_to_orig_head(git_rebase *rebase)
1372
1362
  git_reference *terminal_ref = NULL, *branch_ref = NULL, *head_ref = NULL;
1373
1363
  git_commit *terminal_commit = NULL;
1374
1364
  git_str branch_msg = GIT_STR_INIT, head_msg = GIT_STR_INIT;
1375
- char onto[GIT_OID_HEXSZ];
1365
+ char onto[GIT_OID_MAX_HEXSIZE + 1];
1376
1366
  int error = 0;
1377
1367
 
1378
- git_oid_fmt(onto, &rebase->onto_id);
1368
+ git_oid_tostr(onto, GIT_OID_MAX_HEXSIZE + 1, &rebase->onto_id);
1379
1369
 
1380
1370
  if ((error = git_str_printf(&branch_msg,
1381
- "rebase finished: %s onto %.*s",
1382
- rebase->orig_head_name, GIT_OID_HEXSZ, onto)) == 0 &&
1371
+ "rebase finished: %s onto %s", rebase->orig_head_name, onto)) == 0 &&
1383
1372
  (error = git_str_printf(&head_msg,
1384
- "rebase finished: returning to %s",
1385
- rebase->orig_head_name)) == 0 &&
1373
+ "rebase finished: returning to %s", rebase->orig_head_name)) == 0 &&
1386
1374
  (error = git_repository_head(&terminal_ref, rebase->repo)) == 0 &&
1387
1375
  (error = git_reference_peel((git_object **)&terminal_commit,
1388
1376
  terminal_ref, GIT_OBJECT_COMMIT)) == 0 &&
@@ -1474,6 +1462,7 @@ void git_rebase_free(git_rebase *rebase)
1474
1462
  git__free(rebase->onto_name);
1475
1463
  git__free(rebase->orig_head_name);
1476
1464
  git__free(rebase->state_path);
1465
+ git_str_dispose(&rebase->state_filename);
1477
1466
  git_array_clear(rebase->operations);
1478
1467
  git__free((char *)rebase->options.rewrite_notes_ref);
1479
1468
  git__free(rebase);