rugged 1.6.5 → 1.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (181) hide show
  1. checksums.yaml +4 -4
  2. data/ext/rugged/rugged_allocator.c +0 -54
  3. data/lib/rugged/version.rb +1 -1
  4. data/vendor/libgit2/CMakeLists.txt +3 -8
  5. data/vendor/libgit2/cmake/CheckPrototypeDefinitionSafe.cmake +16 -0
  6. data/vendor/libgit2/cmake/SelectGSSAPI.cmake +3 -3
  7. data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +21 -2
  8. data/vendor/libgit2/cmake/SelectHashes.cmake +4 -0
  9. data/vendor/libgit2/cmake/SelectXdiff.cmake +9 -0
  10. data/vendor/libgit2/deps/pcre/LICENCE +5 -5
  11. data/vendor/libgit2/deps/pcre/pcre.h +2 -2
  12. data/vendor/libgit2/deps/pcre/pcre_compile.c +6 -3
  13. data/vendor/libgit2/deps/pcre/pcre_exec.c +2 -2
  14. data/vendor/libgit2/deps/xdiff/CMakeLists.txt +28 -0
  15. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/git-xdiff.h +4 -1
  16. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xdiffi.c +19 -18
  17. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xdiffi.h +2 -4
  18. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xemit.c +3 -3
  19. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xhistogram.c +7 -18
  20. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xmacros.h +18 -1
  21. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xmerge.c +24 -22
  22. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xpatience.c +21 -30
  23. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xprepare.c +13 -30
  24. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xutils.c +18 -1
  25. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xutils.h +2 -1
  26. data/vendor/libgit2/include/git2/common.h +26 -1
  27. data/vendor/libgit2/include/git2/diff.h +41 -3
  28. data/vendor/libgit2/include/git2/errors.h +4 -2
  29. data/vendor/libgit2/include/git2/index.h +9 -0
  30. data/vendor/libgit2/include/git2/oid.h +1 -1
  31. data/vendor/libgit2/include/git2/remote.h +18 -0
  32. data/vendor/libgit2/include/git2/repository.h +12 -2
  33. data/vendor/libgit2/include/git2/sys/alloc.h +0 -34
  34. data/vendor/libgit2/include/git2/sys/commit_graph.h +12 -2
  35. data/vendor/libgit2/include/git2/sys/midx.h +5 -1
  36. data/vendor/libgit2/include/git2/sys/stream.h +16 -2
  37. data/vendor/libgit2/include/git2/sys/transport.h +20 -2
  38. data/vendor/libgit2/include/git2/version.h +4 -4
  39. data/vendor/libgit2/include/git2/worktree.h +3 -1
  40. data/vendor/libgit2/src/CMakeLists.txt +34 -11
  41. data/vendor/libgit2/src/cli/cmd_clone.c +22 -6
  42. data/vendor/libgit2/src/cli/progress.c +9 -8
  43. data/vendor/libgit2/src/cli/progress.h +4 -4
  44. data/vendor/libgit2/src/libgit2/CMakeLists.txt +1 -19
  45. data/vendor/libgit2/src/libgit2/annotated_commit.c +2 -2
  46. data/vendor/libgit2/src/libgit2/annotated_commit.h +1 -1
  47. data/vendor/libgit2/src/libgit2/apply.c +4 -3
  48. data/vendor/libgit2/src/libgit2/blame.c +23 -16
  49. data/vendor/libgit2/src/libgit2/blame_git.c +0 -1
  50. data/vendor/libgit2/src/libgit2/branch.c +2 -2
  51. data/vendor/libgit2/src/libgit2/cherrypick.c +3 -3
  52. data/vendor/libgit2/src/libgit2/clone.c +3 -1
  53. data/vendor/libgit2/src/libgit2/commit.c +31 -9
  54. data/vendor/libgit2/src/libgit2/commit_graph.c +110 -43
  55. data/vendor/libgit2/src/libgit2/commit_graph.h +20 -4
  56. data/vendor/libgit2/src/libgit2/commit_list.c +12 -5
  57. data/vendor/libgit2/src/libgit2/commit_list.h +1 -0
  58. data/vendor/libgit2/src/libgit2/config_file.c +14 -8
  59. data/vendor/libgit2/src/libgit2/describe.c +10 -7
  60. data/vendor/libgit2/src/libgit2/diff.c +16 -7
  61. data/vendor/libgit2/src/libgit2/diff.h +6 -6
  62. data/vendor/libgit2/src/libgit2/diff_file.c +7 -7
  63. data/vendor/libgit2/src/libgit2/diff_generate.c +36 -15
  64. data/vendor/libgit2/src/libgit2/diff_parse.c +20 -4
  65. data/vendor/libgit2/src/libgit2/diff_print.c +26 -7
  66. data/vendor/libgit2/src/libgit2/diff_tform.c +4 -4
  67. data/vendor/libgit2/src/libgit2/diff_xdiff.h +1 -1
  68. data/vendor/libgit2/src/libgit2/email.c +4 -3
  69. data/vendor/libgit2/src/libgit2/errors.c +73 -18
  70. data/vendor/libgit2/src/libgit2/fetch.c +37 -9
  71. data/vendor/libgit2/src/libgit2/fetch.h +0 -2
  72. data/vendor/libgit2/src/libgit2/fetchhead.c +11 -9
  73. data/vendor/libgit2/src/libgit2/grafts.c +272 -0
  74. data/vendor/libgit2/src/libgit2/grafts.h +36 -0
  75. data/vendor/libgit2/src/libgit2/ident.c +3 -3
  76. data/vendor/libgit2/src/libgit2/index.c +323 -120
  77. data/vendor/libgit2/src/libgit2/index.h +14 -1
  78. data/vendor/libgit2/src/libgit2/indexer.c +10 -3
  79. data/vendor/libgit2/src/libgit2/iterator.c +20 -5
  80. data/vendor/libgit2/src/libgit2/iterator.h +3 -0
  81. data/vendor/libgit2/src/libgit2/libgit2.c +39 -0
  82. data/vendor/libgit2/src/libgit2/merge.c +14 -9
  83. data/vendor/libgit2/src/libgit2/merge_file.c +0 -2
  84. data/vendor/libgit2/src/libgit2/midx.c +66 -37
  85. data/vendor/libgit2/src/libgit2/midx.h +13 -3
  86. data/vendor/libgit2/src/libgit2/notes.c +9 -8
  87. data/vendor/libgit2/src/libgit2/object.c +40 -15
  88. data/vendor/libgit2/src/libgit2/object.h +6 -0
  89. data/vendor/libgit2/src/libgit2/odb.c +11 -5
  90. data/vendor/libgit2/src/libgit2/odb_pack.c +16 -3
  91. data/vendor/libgit2/src/libgit2/oid.c +7 -1
  92. data/vendor/libgit2/src/libgit2/oidarray.c +49 -3
  93. data/vendor/libgit2/src/libgit2/oidarray.h +5 -1
  94. data/vendor/libgit2/src/libgit2/pack-objects.c +19 -12
  95. data/vendor/libgit2/src/libgit2/pack-objects.h +5 -2
  96. data/vendor/libgit2/src/libgit2/pack.c +3 -3
  97. data/vendor/libgit2/src/libgit2/parse.c +7 -4
  98. data/vendor/libgit2/src/libgit2/parse.h +1 -1
  99. data/vendor/libgit2/src/libgit2/patch.h +7 -1
  100. data/vendor/libgit2/src/libgit2/patch_generate.c +24 -5
  101. data/vendor/libgit2/src/libgit2/patch_parse.c +16 -8
  102. data/vendor/libgit2/src/libgit2/push.c +2 -2
  103. data/vendor/libgit2/src/libgit2/reader.c +1 -1
  104. data/vendor/libgit2/src/libgit2/rebase.c +72 -84
  105. data/vendor/libgit2/src/libgit2/refdb_fs.c +22 -13
  106. data/vendor/libgit2/src/libgit2/refs.c +8 -1
  107. data/vendor/libgit2/src/libgit2/remote.c +15 -6
  108. data/vendor/libgit2/src/libgit2/remote.h +1 -0
  109. data/vendor/libgit2/src/libgit2/repository.c +580 -301
  110. data/vendor/libgit2/src/libgit2/repository.h +17 -2
  111. data/vendor/libgit2/src/libgit2/reset.c +2 -2
  112. data/vendor/libgit2/src/libgit2/revert.c +8 -11
  113. data/vendor/libgit2/src/libgit2/revwalk.c +26 -4
  114. data/vendor/libgit2/src/libgit2/stash.c +9 -8
  115. data/vendor/libgit2/src/libgit2/streams/mbedtls.c +0 -1
  116. data/vendor/libgit2/src/libgit2/streams/openssl.c +8 -16
  117. data/vendor/libgit2/src/libgit2/streams/schannel.c +715 -0
  118. data/vendor/libgit2/src/libgit2/streams/schannel.h +28 -0
  119. data/vendor/libgit2/src/libgit2/streams/socket.c +237 -51
  120. data/vendor/libgit2/src/libgit2/streams/socket.h +3 -1
  121. data/vendor/libgit2/src/libgit2/streams/stransport.c +40 -12
  122. data/vendor/libgit2/src/libgit2/streams/tls.c +5 -0
  123. data/vendor/libgit2/src/libgit2/submodule.h +3 -3
  124. data/vendor/libgit2/src/libgit2/threadstate.c +15 -2
  125. data/vendor/libgit2/src/libgit2/threadstate.h +1 -3
  126. data/vendor/libgit2/src/libgit2/transports/auth.h +1 -2
  127. data/vendor/libgit2/src/libgit2/transports/{auth_negotiate.c → auth_gssapi.c} +32 -32
  128. data/vendor/libgit2/src/libgit2/transports/auth_negotiate.h +1 -1
  129. data/vendor/libgit2/src/libgit2/transports/auth_ntlm.h +1 -1
  130. data/vendor/libgit2/src/libgit2/transports/{auth_ntlm.c → auth_ntlmclient.c} +12 -12
  131. data/vendor/libgit2/src/libgit2/transports/auth_sspi.c +341 -0
  132. data/vendor/libgit2/src/libgit2/transports/git.c +7 -8
  133. data/vendor/libgit2/src/libgit2/transports/http.c +7 -2
  134. data/vendor/libgit2/src/libgit2/transports/httpclient.c +5 -0
  135. data/vendor/libgit2/src/libgit2/transports/local.c +13 -4
  136. data/vendor/libgit2/src/libgit2/transports/smart.c +33 -27
  137. data/vendor/libgit2/src/libgit2/transports/smart.h +23 -8
  138. data/vendor/libgit2/src/libgit2/transports/smart_pkt.c +135 -15
  139. data/vendor/libgit2/src/libgit2/transports/smart_protocol.c +154 -47
  140. data/vendor/libgit2/src/libgit2/transports/ssh.c +3 -3
  141. data/vendor/libgit2/src/libgit2/transports/winhttp.c +14 -15
  142. data/vendor/libgit2/src/libgit2/tree-cache.c +26 -16
  143. data/vendor/libgit2/src/libgit2/tree-cache.h +5 -3
  144. data/vendor/libgit2/src/libgit2/tree.c +1 -1
  145. data/vendor/libgit2/src/libgit2/worktree.c +25 -10
  146. data/vendor/libgit2/src/util/alloc.c +65 -6
  147. data/vendor/libgit2/src/util/alloc.h +34 -9
  148. data/vendor/libgit2/src/util/allocators/failalloc.c +0 -60
  149. data/vendor/libgit2/src/util/allocators/failalloc.h +0 -6
  150. data/vendor/libgit2/src/util/allocators/stdalloc.c +2 -105
  151. data/vendor/libgit2/src/util/allocators/win32_leakcheck.c +0 -68
  152. data/vendor/libgit2/src/util/array.h +6 -1
  153. data/vendor/libgit2/src/util/cc-compat.h +2 -0
  154. data/vendor/libgit2/src/util/filebuf.c +6 -1
  155. data/vendor/libgit2/src/util/filebuf.h +19 -6
  156. data/vendor/libgit2/src/util/fs_path.c +1 -1
  157. data/vendor/libgit2/src/util/futils.c +8 -5
  158. data/vendor/libgit2/src/util/git2_features.h.in +9 -3
  159. data/vendor/libgit2/src/util/net.c +308 -157
  160. data/vendor/libgit2/src/util/net.h +25 -0
  161. data/vendor/libgit2/src/util/posix.c +54 -0
  162. data/vendor/libgit2/src/util/posix.h +22 -0
  163. data/vendor/libgit2/src/util/rand.c +6 -4
  164. data/vendor/libgit2/src/util/staticstr.h +66 -0
  165. data/vendor/libgit2/src/util/util.c +15 -10
  166. data/vendor/libgit2/src/util/util.h +24 -16
  167. data/vendor/libgit2/src/util/win32/error.c +1 -1
  168. data/vendor/libgit2/src/util/win32/path_w32.c +8 -8
  169. data/vendor/libgit2/src/util/win32/posix_w32.c +1 -1
  170. data/vendor/libgit2/src/util/win32/utf-conv.c +73 -75
  171. data/vendor/libgit2/src/util/win32/utf-conv.h +81 -14
  172. data/vendor/libgit2/src/util/win32/w32_util.c +1 -1
  173. metadata +28 -22
  174. data/vendor/libgit2/cmake/SelectWinHTTP.cmake +0 -17
  175. data/vendor/libgit2/src/libgit2/netops.c +0 -124
  176. data/vendor/libgit2/src/libgit2/netops.h +0 -68
  177. /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xdiff.h +0 -0
  178. /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xemit.h +0 -0
  179. /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xinclude.h +0 -0
  180. /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xprepare.h +0 -0
  181. /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xtypes.h +0 -0
@@ -138,19 +138,22 @@ static int commit_graph_parse_oid_lookup(
138
138
  struct git_commit_graph_chunk *chunk_oid_lookup)
139
139
  {
140
140
  uint32_t i;
141
- unsigned char *oid, *prev_oid, zero_oid[GIT_OID_SHA1_SIZE] = {0};
141
+ unsigned char *oid, *prev_oid, zero_oid[GIT_OID_MAX_SIZE] = {0};
142
+ size_t oid_size;
143
+
144
+ oid_size = git_oid_size(file->oid_type);
142
145
 
143
146
  if (chunk_oid_lookup->offset == 0)
144
147
  return commit_graph_error("missing OID Lookup chunk");
145
148
  if (chunk_oid_lookup->length == 0)
146
149
  return commit_graph_error("empty OID Lookup chunk");
147
- if (chunk_oid_lookup->length != file->num_commits * GIT_OID_SHA1_SIZE)
150
+ if (chunk_oid_lookup->length != file->num_commits * oid_size)
148
151
  return commit_graph_error("OID Lookup chunk has wrong length");
149
152
 
150
153
  file->oid_lookup = oid = (unsigned char *)(data + chunk_oid_lookup->offset);
151
154
  prev_oid = zero_oid;
152
- for (i = 0; i < file->num_commits; ++i, oid += GIT_OID_SHA1_SIZE) {
153
- if (git_oid_raw_cmp(prev_oid, oid, GIT_OID_SHA1_SIZE) >= 0)
155
+ for (i = 0; i < file->num_commits; ++i, oid += oid_size) {
156
+ if (git_oid_raw_cmp(prev_oid, oid, oid_size) >= 0)
154
157
  return commit_graph_error("OID Lookup index is non-monotonic");
155
158
  prev_oid = oid;
156
159
  }
@@ -163,11 +166,13 @@ static int commit_graph_parse_commit_data(
163
166
  const unsigned char *data,
164
167
  struct git_commit_graph_chunk *chunk_commit_data)
165
168
  {
169
+ size_t oid_size = git_oid_size(file->oid_type);
170
+
166
171
  if (chunk_commit_data->offset == 0)
167
172
  return commit_graph_error("missing Commit Data chunk");
168
173
  if (chunk_commit_data->length == 0)
169
174
  return commit_graph_error("empty Commit Data chunk");
170
- if (chunk_commit_data->length != file->num_commits * (GIT_OID_SHA1_SIZE + 16))
175
+ if (chunk_commit_data->length != file->num_commits * (oid_size + 16))
171
176
  return commit_graph_error("Commit Data chunk has wrong length");
172
177
 
173
178
  file->commit_data = data + chunk_commit_data->offset;
@@ -209,7 +214,9 @@ int git_commit_graph_file_parse(
209
214
 
210
215
  GIT_ASSERT_ARG(file);
211
216
 
212
- if (size < sizeof(struct git_commit_graph_header) + GIT_OID_SHA1_SIZE)
217
+ checksum_size = git_oid_size(file->oid_type);
218
+
219
+ if (size < sizeof(struct git_commit_graph_header) + checksum_size)
213
220
  return commit_graph_error("commit-graph is too short");
214
221
 
215
222
  hdr = ((struct git_commit_graph_header *)data);
@@ -226,8 +233,7 @@ int git_commit_graph_file_parse(
226
233
  * headers, and a special zero chunk.
227
234
  */
228
235
  last_chunk_offset = sizeof(struct git_commit_graph_header) + (1 + hdr->chunks) * 12;
229
- trailer_offset = size - GIT_OID_SHA1_SIZE;
230
- checksum_size = GIT_HASH_SHA1_SIZE;
236
+ trailer_offset = size - checksum_size;
231
237
 
232
238
  if (trailer_offset < last_chunk_offset)
233
239
  return commit_graph_error("wrong commit-graph size");
@@ -295,25 +301,35 @@ int git_commit_graph_file_parse(
295
301
  return 0;
296
302
  }
297
303
 
298
- int git_commit_graph_new(git_commit_graph **cgraph_out, const char *objects_dir, bool open_file)
304
+ int git_commit_graph_new(
305
+ git_commit_graph **cgraph_out,
306
+ const char *objects_dir,
307
+ bool open_file,
308
+ git_oid_t oid_type)
299
309
  {
300
310
  git_commit_graph *cgraph = NULL;
301
311
  int error = 0;
302
312
 
303
313
  GIT_ASSERT_ARG(cgraph_out);
304
314
  GIT_ASSERT_ARG(objects_dir);
315
+ GIT_ASSERT_ARG(oid_type);
305
316
 
306
317
  cgraph = git__calloc(1, sizeof(git_commit_graph));
307
318
  GIT_ERROR_CHECK_ALLOC(cgraph);
308
319
 
320
+ cgraph->oid_type = oid_type;
321
+
309
322
  error = git_str_joinpath(&cgraph->filename, objects_dir, "info/commit-graph");
310
323
  if (error < 0)
311
324
  goto error;
312
325
 
313
326
  if (open_file) {
314
- error = git_commit_graph_file_open(&cgraph->file, git_str_cstr(&cgraph->filename));
327
+ error = git_commit_graph_file_open(&cgraph->file,
328
+ git_str_cstr(&cgraph->filename), oid_type);
329
+
315
330
  if (error < 0)
316
331
  goto error;
332
+
317
333
  cgraph->checked = 1;
318
334
  }
319
335
 
@@ -326,14 +342,18 @@ error:
326
342
  }
327
343
 
328
344
  int git_commit_graph_validate(git_commit_graph *cgraph) {
329
- unsigned char checksum[GIT_HASH_SHA1_SIZE];
330
- size_t checksum_size = GIT_HASH_SHA1_SIZE;
331
- size_t trailer_offset = cgraph->file->graph_map.len - checksum_size;
345
+ unsigned char checksum[GIT_HASH_MAX_SIZE];
346
+ git_hash_algorithm_t checksum_type;
347
+ size_t checksum_size, trailer_offset;
348
+
349
+ checksum_type = git_oid_algorithm(cgraph->oid_type);
350
+ checksum_size = git_hash_size(checksum_type);
351
+ trailer_offset = cgraph->file->graph_map.len - checksum_size;
332
352
 
333
353
  if (cgraph->file->graph_map.len < checksum_size)
334
354
  return commit_graph_error("map length too small");
335
355
 
336
- if (git_hash_buf(checksum, cgraph->file->graph_map.data, trailer_offset, GIT_HASH_ALGORITHM_SHA1) < 0)
356
+ if (git_hash_buf(checksum, cgraph->file->graph_map.data, trailer_offset, checksum_type) < 0)
337
357
  return commit_graph_error("could not calculate signature");
338
358
  if (memcmp(checksum, cgraph->file->checksum, checksum_size) != 0)
339
359
  return commit_graph_error("index signature mismatch");
@@ -341,16 +361,32 @@ int git_commit_graph_validate(git_commit_graph *cgraph) {
341
361
  return 0;
342
362
  }
343
363
 
344
- int git_commit_graph_open(git_commit_graph **cgraph_out, const char *objects_dir)
364
+ int git_commit_graph_open(
365
+ git_commit_graph **cgraph_out,
366
+ const char *objects_dir
367
+ #ifdef GIT_EXPERIMENTAL_SHA256
368
+ , git_oid_t oid_type
369
+ #endif
370
+ )
345
371
  {
346
- int error = git_commit_graph_new(cgraph_out, objects_dir, true);
347
- if (!error) {
372
+ #ifndef GIT_EXPERIMENTAL_SHA256
373
+ git_oid_t oid_type = GIT_OID_SHA1;
374
+ #endif
375
+ int error;
376
+
377
+ error = git_commit_graph_new(cgraph_out, objects_dir, true,
378
+ oid_type);
379
+
380
+ if (!error)
348
381
  return git_commit_graph_validate(*cgraph_out);
349
- }
382
+
350
383
  return error;
351
384
  }
352
385
 
353
- int git_commit_graph_file_open(git_commit_graph_file **file_out, const char *path)
386
+ int git_commit_graph_file_open(
387
+ git_commit_graph_file **file_out,
388
+ const char *path,
389
+ git_oid_t oid_type)
354
390
  {
355
391
  git_commit_graph_file *file;
356
392
  git_file fd = -1;
@@ -379,6 +415,8 @@ int git_commit_graph_file_open(git_commit_graph_file **file_out, const char *pat
379
415
  file = git__calloc(1, sizeof(git_commit_graph_file));
380
416
  GIT_ERROR_CHECK_ALLOC(file);
381
417
 
418
+ file->oid_type = oid_type;
419
+
382
420
  error = git_futils_mmap_ro(&file->graph_map, fd, 0, cgraph_size);
383
421
  p_close(fd);
384
422
  if (error < 0) {
@@ -395,7 +433,9 @@ int git_commit_graph_file_open(git_commit_graph_file **file_out, const char *pat
395
433
  return 0;
396
434
  }
397
435
 
398
- int git_commit_graph_get_file(git_commit_graph_file **file_out, git_commit_graph *cgraph)
436
+ int git_commit_graph_get_file(
437
+ git_commit_graph_file **file_out,
438
+ git_commit_graph *cgraph)
399
439
  {
400
440
  if (!cgraph->checked) {
401
441
  int error = 0;
@@ -405,7 +445,8 @@ int git_commit_graph_get_file(git_commit_graph_file **file_out, git_commit_graph
405
445
  cgraph->checked = 1;
406
446
 
407
447
  /* Best effort */
408
- error = git_commit_graph_file_open(&result, git_str_cstr(&cgraph->filename));
448
+ error = git_commit_graph_file_open(&result,
449
+ git_str_cstr(&cgraph->filename), cgraph->oid_type);
409
450
 
410
451
  if (error < 0)
411
452
  return error;
@@ -441,6 +482,7 @@ static int git_commit_graph_entry_get_byindex(
441
482
  size_t pos)
442
483
  {
443
484
  const unsigned char *commit_data;
485
+ size_t oid_size = git_oid_size(file->oid_type);
444
486
 
445
487
  GIT_ASSERT_ARG(e);
446
488
  GIT_ASSERT_ARG(file);
@@ -450,15 +492,15 @@ static int git_commit_graph_entry_get_byindex(
450
492
  return GIT_ENOTFOUND;
451
493
  }
452
494
 
453
- commit_data = file->commit_data + pos * (GIT_OID_SHA1_SIZE + 4 * sizeof(uint32_t));
454
- git_oid__fromraw(&e->tree_oid, commit_data, GIT_OID_SHA1);
455
- e->parent_indices[0] = ntohl(*((uint32_t *)(commit_data + GIT_OID_SHA1_SIZE)));
495
+ commit_data = file->commit_data + pos * (oid_size + 4 * sizeof(uint32_t));
496
+ git_oid__fromraw(&e->tree_oid, commit_data, file->oid_type);
497
+ e->parent_indices[0] = ntohl(*((uint32_t *)(commit_data + oid_size)));
456
498
  e->parent_indices[1] = ntohl(
457
- *((uint32_t *)(commit_data + GIT_OID_SHA1_SIZE + sizeof(uint32_t))));
499
+ *((uint32_t *)(commit_data + oid_size + sizeof(uint32_t))));
458
500
  e->parent_count = (e->parent_indices[0] != GIT_COMMIT_GRAPH_MISSING_PARENT)
459
501
  + (e->parent_indices[1] != GIT_COMMIT_GRAPH_MISSING_PARENT);
460
- e->generation = ntohl(*((uint32_t *)(commit_data + GIT_OID_SHA1_SIZE + 2 * sizeof(uint32_t))));
461
- e->commit_time = ntohl(*((uint32_t *)(commit_data + GIT_OID_SHA1_SIZE + 3 * sizeof(uint32_t))));
502
+ e->generation = ntohl(*((uint32_t *)(commit_data + oid_size + 2 * sizeof(uint32_t))));
503
+ e->commit_time = ntohl(*((uint32_t *)(commit_data + oid_size + 3 * sizeof(uint32_t))));
462
504
 
463
505
  e->commit_time |= (e->generation & UINT64_C(0x3)) << UINT64_C(32);
464
506
  e->generation >>= 2u;
@@ -485,7 +527,7 @@ static int git_commit_graph_entry_get_byindex(
485
527
  }
486
528
  }
487
529
 
488
- git_oid__fromraw(&e->sha1, &file->oid_lookup[pos * GIT_OID_SHA1_SIZE], GIT_OID_SHA1);
530
+ git_oid__fromraw(&e->sha1, &file->oid_lookup[pos * oid_size], file->oid_type);
489
531
  return 0;
490
532
  }
491
533
 
@@ -494,8 +536,8 @@ bool git_commit_graph_file_needs_refresh(const git_commit_graph_file *file, cons
494
536
  git_file fd = -1;
495
537
  struct stat st;
496
538
  ssize_t bytes_read;
497
- unsigned char checksum[GIT_HASH_SHA1_SIZE];
498
- size_t checksum_size = GIT_HASH_SHA1_SIZE;
539
+ unsigned char checksum[GIT_HASH_MAX_SIZE];
540
+ size_t checksum_size = git_oid_size(file->oid_type);
499
541
 
500
542
  /* TODO: properly open the file without access time using O_NOATIME */
501
543
  fd = git_futils_open_ro(path);
@@ -530,35 +572,40 @@ int git_commit_graph_entry_find(
530
572
  int pos, found = 0;
531
573
  uint32_t hi, lo;
532
574
  const unsigned char *current = NULL;
575
+ size_t oid_size, oid_hexsize;
533
576
 
534
577
  GIT_ASSERT_ARG(e);
535
578
  GIT_ASSERT_ARG(file);
536
579
  GIT_ASSERT_ARG(short_oid);
537
580
 
581
+ oid_size = git_oid_size(file->oid_type);
582
+ oid_hexsize = git_oid_hexsize(file->oid_type);
583
+
538
584
  hi = ntohl(file->oid_fanout[(int)short_oid->id[0]]);
539
585
  lo = ((short_oid->id[0] == 0x0) ? 0 : ntohl(file->oid_fanout[(int)short_oid->id[0] - 1]));
540
586
 
541
- pos = git_pack__lookup_id(file->oid_lookup, GIT_OID_SHA1_SIZE, lo, hi, short_oid->id, GIT_OID_SHA1);
587
+ pos = git_pack__lookup_id(file->oid_lookup, oid_size, lo, hi,
588
+ short_oid->id, file->oid_type);
542
589
 
543
590
  if (pos >= 0) {
544
591
  /* An object matching exactly the oid was found */
545
592
  found = 1;
546
- current = file->oid_lookup + (pos * GIT_OID_SHA1_SIZE);
593
+ current = file->oid_lookup + (pos * oid_size);
547
594
  } else {
548
595
  /* No object was found */
549
596
  /* pos refers to the object with the "closest" oid to short_oid */
550
597
  pos = -1 - pos;
551
598
  if (pos < (int)file->num_commits) {
552
- current = file->oid_lookup + (pos * GIT_OID_SHA1_SIZE);
599
+ current = file->oid_lookup + (pos * oid_size);
553
600
 
554
601
  if (!git_oid_raw_ncmp(short_oid->id, current, len))
555
602
  found = 1;
556
603
  }
557
604
  }
558
605
 
559
- if (found && len != GIT_OID_SHA1_HEXSIZE && pos + 1 < (int)file->num_commits) {
606
+ if (found && len != oid_hexsize && pos + 1 < (int)file->num_commits) {
560
607
  /* Check for ambiguousity */
561
- const unsigned char *next = current + GIT_OID_SHA1_SIZE;
608
+ const unsigned char *next = current + oid_size;
562
609
 
563
610
  if (!git_oid_raw_ncmp(short_oid->id, next, len))
564
611
  found = 2;
@@ -637,11 +684,27 @@ static int packed_commit__cmp(const void *a_, const void *b_)
637
684
  return git_oid_cmp(&a->sha1, &b->sha1);
638
685
  }
639
686
 
640
- int git_commit_graph_writer_new(git_commit_graph_writer **out, const char *objects_info_dir)
687
+ int git_commit_graph_writer_new(
688
+ git_commit_graph_writer **out,
689
+ const char *objects_info_dir
690
+ #ifdef GIT_EXPERIMENTAL_SHA256
691
+ , git_oid_t oid_type
692
+ #endif
693
+ )
641
694
  {
642
- git_commit_graph_writer *w = git__calloc(1, sizeof(git_commit_graph_writer));
695
+ git_commit_graph_writer *w;
696
+
697
+ #ifndef GIT_EXPERIMENTAL_SHA256
698
+ git_oid_t oid_type = GIT_OID_SHA1;
699
+ #endif
700
+
701
+ GIT_ASSERT_ARG(out && objects_info_dir && oid_type);
702
+
703
+ w = git__calloc(1, sizeof(git_commit_graph_writer));
643
704
  GIT_ERROR_CHECK_ALLOC(w);
644
705
 
706
+ w->oid_type = oid_type;
707
+
645
708
  if (git_str_sets(&w->objects_info_dir, objects_info_dir) < 0) {
646
709
  git__free(w);
647
710
  return -1;
@@ -993,8 +1056,9 @@ static int commit_graph_write(
993
1056
  off64_t offset;
994
1057
  git_str oid_lookup = GIT_STR_INIT, commit_data = GIT_STR_INIT,
995
1058
  extra_edge_list = GIT_STR_INIT;
996
- unsigned char checksum[GIT_HASH_SHA1_SIZE];
997
- size_t checksum_size;
1059
+ unsigned char checksum[GIT_HASH_MAX_SIZE];
1060
+ git_hash_algorithm_t checksum_type;
1061
+ size_t checksum_size, oid_size;
998
1062
  git_hash_ctx ctx;
999
1063
  struct commit_graph_write_hash_context hash_cb_data = {0};
1000
1064
 
@@ -1007,8 +1071,11 @@ static int commit_graph_write(
1007
1071
  hash_cb_data.cb_data = cb_data;
1008
1072
  hash_cb_data.ctx = &ctx;
1009
1073
 
1010
- checksum_size = GIT_HASH_SHA1_SIZE;
1011
- error = git_hash_ctx_init(&ctx, GIT_HASH_ALGORITHM_SHA1);
1074
+ oid_size = git_oid_size(w->oid_type);
1075
+ checksum_type = git_oid_algorithm(w->oid_type);
1076
+ checksum_size = git_hash_size(checksum_type);
1077
+
1078
+ error = git_hash_ctx_init(&ctx, checksum_type);
1012
1079
  if (error < 0)
1013
1080
  return error;
1014
1081
  cb_data = &hash_cb_data;
@@ -1035,7 +1102,7 @@ static int commit_graph_write(
1035
1102
  git_vector_foreach (&w->commits, i, packed_commit) {
1036
1103
  error = git_str_put(&oid_lookup,
1037
1104
  (const char *)&packed_commit->sha1.id,
1038
- GIT_OID_SHA1_SIZE);
1105
+ oid_size);
1039
1106
 
1040
1107
  if (error < 0)
1041
1108
  goto cleanup;
@@ -1052,7 +1119,7 @@ static int commit_graph_write(
1052
1119
 
1053
1120
  error = git_str_put(&commit_data,
1054
1121
  (const char *)&packed_commit->tree_oid.id,
1055
- GIT_OID_SHA1_SIZE);
1122
+ oid_size);
1056
1123
 
1057
1124
  if (error < 0)
1058
1125
  goto cleanup;
@@ -30,6 +30,9 @@
30
30
  typedef struct git_commit_graph_file {
31
31
  git_map graph_map;
32
32
 
33
+ /* The type of object IDs in the commit graph file. */
34
+ git_oid_t oid_type;
35
+
33
36
  /* The OID Fanout table. */
34
37
  const uint32_t *oid_fanout;
35
38
  /* The total number of commits in the graph. */
@@ -84,10 +87,10 @@ typedef struct git_commit_graph_entry {
84
87
  /* The index within the Extra Edge List of any parent after the first two. */
85
88
  size_t extra_parents_index;
86
89
 
87
- /* The SHA-1 hash of the root tree of the commit. */
90
+ /* The object ID of the root tree of the commit. */
88
91
  git_oid tree_oid;
89
92
 
90
- /* The SHA-1 hash of the requested commit. */
93
+ /* The object ID hash of the requested commit. */
91
94
  git_oid sha1;
92
95
  } git_commit_graph_entry;
93
96
 
@@ -99,18 +102,28 @@ struct git_commit_graph {
99
102
  /* The underlying commit-graph file. */
100
103
  git_commit_graph_file *file;
101
104
 
105
+ /* The object ID types in the commit graph. */
106
+ git_oid_t oid_type;
107
+
102
108
  /* Whether the commit-graph file was already checked for validity. */
103
109
  bool checked;
104
110
  };
105
111
 
106
112
  /** Create a new commit-graph, optionally opening the underlying file. */
107
- int git_commit_graph_new(git_commit_graph **cgraph_out, const char *objects_dir, bool open_file);
113
+ int git_commit_graph_new(
114
+ git_commit_graph **cgraph_out,
115
+ const char *objects_dir,
116
+ bool open_file,
117
+ git_oid_t oid_type);
108
118
 
109
119
  /** Validate the checksum of a commit graph */
110
120
  int git_commit_graph_validate(git_commit_graph *cgraph);
111
121
 
112
122
  /** Open and validate a commit-graph file. */
113
- int git_commit_graph_file_open(git_commit_graph_file **file_out, const char *path);
123
+ int git_commit_graph_file_open(
124
+ git_commit_graph_file **file_out,
125
+ const char *path,
126
+ git_oid_t oid_type);
114
127
 
115
128
  /*
116
129
  * Attempt to get the git_commit_graph's commit-graph file. This object is
@@ -134,6 +147,9 @@ struct git_commit_graph_writer {
134
147
  */
135
148
  git_str objects_info_dir;
136
149
 
150
+ /* The object ID type of the commit graph. */
151
+ git_oid_t oid_type;
152
+
137
153
  /* The list of packed commits. */
138
154
  git_vector commits;
139
155
  };
@@ -43,13 +43,18 @@ int git_commit_list_time_cmp(const void *a, const void *b)
43
43
  return 0;
44
44
  }
45
45
 
46
- git_commit_list *git_commit_list_insert(git_commit_list_node *item, git_commit_list **list_p)
47
- {
46
+ git_commit_list *git_commit_list_create(git_commit_list_node *item, git_commit_list *next) {
48
47
  git_commit_list *new_list = git__malloc(sizeof(git_commit_list));
49
48
  if (new_list != NULL) {
50
49
  new_list->item = item;
51
- new_list->next = *list_p;
50
+ new_list->next = next;
52
51
  }
52
+ return new_list;
53
+ }
54
+
55
+ git_commit_list *git_commit_list_insert(git_commit_list_node *item, git_commit_list **list_p)
56
+ {
57
+ git_commit_list *new_list = git_commit_list_create(item, *list_p);
53
58
  *list_p = new_list;
54
59
  return new_list;
55
60
  }
@@ -125,7 +130,7 @@ static int commit_quick_parse(
125
130
  git_oid *parent_oid;
126
131
  git_commit *commit;
127
132
  git_commit__parse_options parse_opts = {
128
- GIT_OID_SHA1,
133
+ walk->repo->oid_type,
129
134
  GIT_COMMIT_PARSE_QUICK
130
135
  };
131
136
  size_t i;
@@ -176,7 +181,9 @@ int git_commit_list_parse(git_revwalk *walk, git_commit_list_node *commit)
176
181
  if (cgraph_file) {
177
182
  git_commit_graph_entry e;
178
183
 
179
- error = git_commit_graph_entry_find(&e, cgraph_file, &commit->oid, GIT_OID_SHA1_SIZE);
184
+ error = git_commit_graph_entry_find(&e, cgraph_file,
185
+ &commit->oid, git_oid_size(walk->repo->oid_type));
186
+
180
187
  if (error == 0 && git__is_uint16(e.parent_count)) {
181
188
  size_t i;
182
189
  commit->generation = (uint32_t)e.generation;
@@ -49,6 +49,7 @@ git_commit_list_node *git_commit_list_alloc_node(git_revwalk *walk);
49
49
  int git_commit_list_generation_cmp(const void *a, const void *b);
50
50
  int git_commit_list_time_cmp(const void *a, const void *b);
51
51
  void git_commit_list_free(git_commit_list **list_p);
52
+ git_commit_list *git_commit_list_create(git_commit_list_node *item, git_commit_list *next);
52
53
  git_commit_list *git_commit_list_insert(git_commit_list_node *item, git_commit_list **list_p);
53
54
  git_commit_list *git_commit_list_insert_by_date(git_commit_list_node *item, git_commit_list **list_p);
54
55
  int git_commit_list_parse(git_revwalk *walk, git_commit_list_node *commit);
@@ -26,7 +26,7 @@
26
26
 
27
27
  typedef struct config_file {
28
28
  git_futils_filestamp stamp;
29
- unsigned char checksum[GIT_HASH_SHA1_SIZE];
29
+ unsigned char checksum[GIT_HASH_SHA256_SIZE];
30
30
  char *path;
31
31
  git_array_t(struct config_file) includes;
32
32
  } config_file;
@@ -133,7 +133,7 @@ static int config_file_is_modified(int *modified, config_file *file)
133
133
  {
134
134
  config_file *include;
135
135
  git_str buf = GIT_STR_INIT;
136
- unsigned char checksum[GIT_HASH_SHA1_SIZE];
136
+ unsigned char checksum[GIT_HASH_SHA256_SIZE];
137
137
  uint32_t i;
138
138
  int error = 0;
139
139
 
@@ -145,10 +145,10 @@ static int config_file_is_modified(int *modified, config_file *file)
145
145
  if ((error = git_futils_readbuffer(&buf, file->path)) < 0)
146
146
  goto out;
147
147
 
148
- if ((error = git_hash_buf(checksum, buf.ptr, buf.size, GIT_HASH_ALGORITHM_SHA1)) < 0)
148
+ if ((error = git_hash_buf(checksum, buf.ptr, buf.size, GIT_HASH_ALGORITHM_SHA256)) < 0)
149
149
  goto out;
150
150
 
151
- if (memcmp(checksum, file->checksum, GIT_HASH_SHA1_SIZE) != 0) {
151
+ if (memcmp(checksum, file->checksum, GIT_HASH_SHA256_SIZE) != 0) {
152
152
  *modified = 1;
153
153
  goto out;
154
154
  }
@@ -881,7 +881,7 @@ static int config_file_read(
881
881
  goto out;
882
882
 
883
883
  git_futils_filestamp_set_from_stat(&file->stamp, &st);
884
- if ((error = git_hash_buf(file->checksum, contents.ptr, contents.size, GIT_HASH_ALGORITHM_SHA1)) < 0)
884
+ if ((error = git_hash_buf(file->checksum, contents.ptr, contents.size, GIT_HASH_ALGORITHM_SHA256)) < 0)
885
885
  goto out;
886
886
 
887
887
  if ((error = config_file_read_buffer(entries, repo, file, level, depth,
@@ -1116,7 +1116,12 @@ static int write_on_eof(
1116
1116
  /*
1117
1117
  * This is pretty much the parsing, except we write out anything we don't have
1118
1118
  */
1119
- static int config_file_write(config_file_backend *cfg, const char *orig_key, const char *key, const git_regexp *preg, const char *value)
1119
+ static int config_file_write(
1120
+ config_file_backend *cfg,
1121
+ const char *orig_key,
1122
+ const char *key,
1123
+ const git_regexp *preg,
1124
+ const char *value)
1120
1125
 
1121
1126
  {
1122
1127
  char *orig_section = NULL, *section = NULL, *orig_name, *name, *ldot;
@@ -1131,8 +1136,9 @@ static int config_file_write(config_file_backend *cfg, const char *orig_key, con
1131
1136
  if (cfg->locked) {
1132
1137
  error = git_str_puts(&contents, git_str_cstr(&cfg->locked_content) == NULL ? "" : git_str_cstr(&cfg->locked_content));
1133
1138
  } else {
1134
- if ((error = git_filebuf_open(&file, cfg->file.path, GIT_FILEBUF_HASH_CONTENTS,
1135
- GIT_CONFIG_FILE_MODE)) < 0)
1139
+ if ((error = git_filebuf_open(&file, cfg->file.path,
1140
+ GIT_FILEBUF_HASH_SHA256,
1141
+ GIT_CONFIG_FILE_MODE)) < 0)
1136
1142
  goto done;
1137
1143
 
1138
1144
  /* We need to read in our own config file */
@@ -363,12 +363,15 @@ static int find_unique_abbrev_size(
363
363
  size_t size = abbreviated_size;
364
364
  git_odb *odb;
365
365
  git_oid dummy;
366
+ size_t hexsize;
366
367
  int error;
367
368
 
368
369
  if ((error = git_repository_odb__weakptr(&odb, repo)) < 0)
369
370
  return error;
370
371
 
371
- while (size < GIT_OID_SHA1_HEXSIZE) {
372
+ hexsize = git_oid_hexsize(repo->oid_type);
373
+
374
+ while (size < hexsize) {
372
375
  if ((error = git_odb_exists_prefix(&dummy, odb, oid_in, size)) == 0) {
373
376
  *out = (int) size;
374
377
  return 0;
@@ -383,7 +386,7 @@ static int find_unique_abbrev_size(
383
386
  }
384
387
 
385
388
  /* If we didn't find any shorter prefix, we have to do the whole thing */
386
- *out = GIT_OID_SHA1_HEXSIZE;
389
+ *out = (int)hexsize;
387
390
 
388
391
  return 0;
389
392
  }
@@ -397,7 +400,7 @@ static int show_suffix(
397
400
  {
398
401
  int error, size = 0;
399
402
 
400
- char hex_oid[GIT_OID_SHA1_HEXSIZE];
403
+ char hex_oid[GIT_OID_MAX_HEXSIZE];
401
404
 
402
405
  if ((error = find_unique_abbrev_size(&size, repo, id, abbrev_size)) < 0)
403
406
  return error;
@@ -414,7 +417,7 @@ static int show_suffix(
414
417
  #define MAX_CANDIDATES_TAGS FLAG_BITS - 1
415
418
 
416
419
  static int describe_not_found(const git_oid *oid, const char *message_format) {
417
- char oid_str[GIT_OID_SHA1_HEXSIZE + 1];
420
+ char oid_str[GIT_OID_MAX_HEXSIZE + 1];
418
421
  git_oid_tostr(oid_str, sizeof(oid_str), oid);
419
422
 
420
423
  git_error_set(GIT_ERROR_DESCRIBE, message_format, oid_str);
@@ -525,7 +528,7 @@ static int describe(
525
528
  if (annotated_cnt && (git_pqueue_size(&list) == 0)) {
526
529
  /*
527
530
  if (debug) {
528
- char oid_str[GIT_OID_SHA1_HEXSIZE + 1];
531
+ char oid_str[GIT_OID_MAX_HEXSIZE + 1];
529
532
  git_oid_tostr(oid_str, sizeof(oid_str), &c->oid);
530
533
 
531
534
  fprintf(stderr, "finished search at %s\n", oid_str);
@@ -592,7 +595,7 @@ static int describe(
592
595
  "head", "lightweight", "annotated",
593
596
  };
594
597
 
595
- char oid_str[GIT_OID_SHA1_HEXSIZE + 1];
598
+ char oid_str[GIT_OID_MAX_HEXSIZE + 1];
596
599
 
597
600
  if (debug) {
598
601
  for (cur_match = 0; cur_match < match_cnt; cur_match++) {
@@ -816,7 +819,7 @@ static int git_describe__format(
816
819
 
817
820
  /* If we didn't find *any* tags, we fall back to the commit's id */
818
821
  if (result->fallback_to_id) {
819
- char hex_oid[GIT_OID_SHA1_HEXSIZE + 1] = {0};
822
+ char hex_oid[GIT_OID_MAX_HEXSIZE + 1] = {0};
820
823
  int size = 0;
821
824
 
822
825
  if ((error = find_unique_abbrev_size(
@@ -19,8 +19,10 @@
19
19
  #include "git2/email.h"
20
20
 
21
21
  struct patch_id_args {
22
+ git_diff *diff;
22
23
  git_hash_ctx ctx;
23
24
  git_oid result;
25
+ git_oid_t oid_type;
24
26
  int first_file;
25
27
  };
26
28
 
@@ -280,17 +282,19 @@ int git_diff_find_options_init(
280
282
  return 0;
281
283
  }
282
284
 
283
- static int flush_hunk(git_oid *result, git_hash_ctx *ctx)
285
+ static int flush_hunk(git_oid *result, struct patch_id_args *args)
284
286
  {
287
+ git_hash_ctx *ctx = &args->ctx;
285
288
  git_oid hash;
286
289
  unsigned short carry = 0;
287
- int error, i;
290
+ size_t i;
291
+ int error;
288
292
 
289
293
  if ((error = git_hash_final(hash.id, ctx)) < 0 ||
290
294
  (error = git_hash_init(ctx)) < 0)
291
295
  return error;
292
296
 
293
- for (i = 0; i < GIT_OID_SHA1_SIZE; i++) {
297
+ for (i = 0; i < git_oid_size(args->oid_type); i++) {
294
298
  carry += result->id[i] + hash.id[i];
295
299
  result->id[i] = (unsigned char)carry;
296
300
  carry >>= 8;
@@ -338,7 +342,7 @@ static int diff_patchid_print_callback_to_buf(
338
342
 
339
343
  if (line->origin == GIT_DIFF_LINE_FILE_HDR &&
340
344
  !args->first_file &&
341
- (error = flush_hunk(&args->result, &args->ctx) < 0))
345
+ (error = flush_hunk(&args->result, args) < 0))
342
346
  goto out;
343
347
 
344
348
  if ((error = git_hash_update(&args->ctx, buf.ptr, buf.size)) < 0)
@@ -362,14 +366,19 @@ int git_diff_patchid_options_init(git_diff_patchid_options *opts, unsigned int v
362
366
  int git_diff_patchid(git_oid *out, git_diff *diff, git_diff_patchid_options *opts)
363
367
  {
364
368
  struct patch_id_args args;
369
+ git_hash_algorithm_t algorithm;
365
370
  int error;
366
371
 
367
372
  GIT_ERROR_CHECK_VERSION(
368
373
  opts, GIT_DIFF_PATCHID_OPTIONS_VERSION, "git_diff_patchid_options");
369
374
 
375
+ algorithm = git_oid_algorithm(diff->opts.oid_type);
376
+
370
377
  memset(&args, 0, sizeof(args));
378
+ args.diff = diff;
371
379
  args.first_file = 1;
372
- if ((error = git_hash_ctx_init(&args.ctx, GIT_HASH_ALGORITHM_SHA1)) < 0)
380
+ args.oid_type = diff->opts.oid_type;
381
+ if ((error = git_hash_ctx_init(&args.ctx, algorithm)) < 0)
373
382
  goto out;
374
383
 
375
384
  if ((error = git_diff_print(diff,
@@ -378,11 +387,11 @@ int git_diff_patchid(git_oid *out, git_diff *diff, git_diff_patchid_options *opt
378
387
  &args)) < 0)
379
388
  goto out;
380
389
 
381
- if ((error = (flush_hunk(&args.result, &args.ctx))) < 0)
390
+ if ((error = (flush_hunk(&args.result, &args))) < 0)
382
391
  goto out;
383
392
 
384
393
  #ifdef GIT_EXPERIMENTAL_SHA256
385
- args.result.type = GIT_OID_SHA1;
394
+ args.result.type = diff->opts.oid_type;
386
395
  #endif
387
396
 
388
397
  git_oid_cpy(out, &args.result);