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
@@ -8,7 +8,6 @@
8
8
  #include "common.h"
9
9
 
10
10
  #include "git2/describe.h"
11
- #include "git2/strarray.h"
12
11
  #include "git2/diff.h"
13
12
  #include "git2/status.h"
14
13
 
@@ -19,6 +18,7 @@
19
18
  #include "refs.h"
20
19
  #include "repository.h"
21
20
  #include "revwalk.h"
21
+ #include "strarray.h"
22
22
  #include "tag.h"
23
23
  #include "vector.h"
24
24
  #include "wildmatch.h"
@@ -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_HEXSZ) {
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_HEXSZ;
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_HEXSZ];
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_HEXSZ + 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_HEXSZ + 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_HEXSZ + 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_HEXSZ + 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_RAWSZ; 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,9 +387,13 @@ 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
 
393
+ #ifdef GIT_EXPERIMENTAL_SHA256
394
+ args.result.type = diff->opts.oid_type;
395
+ #endif
396
+
384
397
  git_oid_cpy(out, &args.result);
385
398
 
386
399
  out:
@@ -30,15 +30,15 @@ typedef enum {
30
30
  } git_diff_origin_t;
31
31
 
32
32
  struct git_diff {
33
- git_refcount rc;
33
+ git_refcount rc;
34
34
  git_repository *repo;
35
- git_attr_session attrsession;
35
+ git_attr_session attrsession;
36
36
  git_diff_origin_t type;
37
- git_diff_options opts;
38
- git_vector deltas; /* vector of git_diff_delta */
37
+ git_diff_options opts;
38
+ git_vector deltas; /* vector of git_diff_delta */
39
39
  git_pool pool;
40
- git_iterator_t old_src;
41
- git_iterator_t new_src;
40
+ git_iterator_t old_src;
41
+ git_iterator_t new_src;
42
42
  git_diff_perfdata perf;
43
43
 
44
44
  int (*strcomp)(const char *, const char *);
@@ -112,7 +112,7 @@ int git_diff_file_content__init_from_diff(
112
112
  case GIT_DELTA_DELETED:
113
113
  has_data = use_old; break;
114
114
  case GIT_DELTA_UNTRACKED:
115
- has_data = !use_old &&
115
+ has_data = (use_old == (diff->opts.flags & GIT_DIFF_REVERSE)) &&
116
116
  (diff->opts.flags & GIT_DIFF_SHOW_UNTRACKED_CONTENT) != 0;
117
117
  break;
118
118
  case GIT_DELTA_UNREADABLE:
@@ -144,6 +144,7 @@ int git_diff_file_content__init_from_src(
144
144
 
145
145
  if (!src->blob && !src->buf) {
146
146
  fc->flags |= GIT_DIFF_FLAG__NO_DATA;
147
+ git_oid_clear(&fc->file->id, opts->oid_type);
147
148
  } else {
148
149
  fc->flags |= GIT_DIFF_FLAG__LOADED;
149
150
  fc->file->flags |= GIT_DIFF_FLAG_VALID_ID;
@@ -153,7 +154,7 @@ int git_diff_file_content__init_from_src(
153
154
  git_blob_dup((git_blob **)&fc->blob, (git_blob *) src->blob);
154
155
  fc->file->size = git_blob_rawsize(src->blob);
155
156
  git_oid_cpy(&fc->file->id, git_blob_id(src->blob));
156
- fc->file->id_abbrev = GIT_OID_HEXSZ;
157
+ fc->file->id_abbrev = (uint16_t)git_oid_hexsize(repo->oid_type);
157
158
 
158
159
  fc->map.len = (size_t)fc->file->size;
159
160
  fc->map.data = (char *)git_blob_rawcontent(src->blob);
@@ -161,10 +162,10 @@ int git_diff_file_content__init_from_src(
161
162
  fc->flags |= GIT_DIFF_FLAG__FREE_BLOB;
162
163
  } else {
163
164
  int error;
164
- if ((error = git_odb_hash(&fc->file->id, src->buf, src->buflen, GIT_OBJECT_BLOB)) < 0)
165
+ if ((error = git_odb__hash(&fc->file->id, src->buf, src->buflen, GIT_OBJECT_BLOB, opts->oid_type)) < 0)
165
166
  return error;
166
167
  fc->file->size = src->buflen;
167
- fc->file->id_abbrev = GIT_OID_HEXSZ;
168
+ fc->file->id_abbrev = (uint16_t)git_oid_hexsize(opts->oid_type);
168
169
 
169
170
  fc->map.len = src->buflen;
170
171
  fc->map.data = (char *)src->buf;
@@ -177,7 +178,7 @@ int git_diff_file_content__init_from_src(
177
178
  static int diff_file_content_commit_to_str(
178
179
  git_diff_file_content *fc, bool check_status)
179
180
  {
180
- char oid[GIT_OID_HEXSZ+1];
181
+ char oid[GIT_OID_MAX_HEXSIZE+1];
181
182
  git_str content = GIT_STR_INIT;
182
183
  const char *status = "";
183
184
 
@@ -347,6 +348,13 @@ static int diff_file_content_load_workdir_file(
347
348
  goto cleanup;
348
349
  }
349
350
 
351
+ /* if file is empty, don't attempt to mmap or readbuffer */
352
+ if (fc->file->size == 0) {
353
+ fc->map.len = 0;
354
+ fc->map.data = git_str__initstr;
355
+ goto cleanup;
356
+ }
357
+
350
358
  if ((diff_opts->flags & GIT_DIFF_SHOW_BINARY) == 0 &&
351
359
  diff_file_content_binary_by_size(fc))
352
360
  goto cleanup;
@@ -410,8 +418,9 @@ static int diff_file_content_load_workdir(
410
418
 
411
419
  /* once data is loaded, update OID if we didn't have it previously */
412
420
  if (!error && (fc->file->flags & GIT_DIFF_FLAG_VALID_ID) == 0) {
413
- error = git_odb_hash(
414
- &fc->file->id, fc->map.data, fc->map.len, GIT_OBJECT_BLOB);
421
+ error = git_odb__hash(
422
+ &fc->file->id, fc->map.data, fc->map.len,
423
+ GIT_OBJECT_BLOB, diff_opts->oid_type);
415
424
  fc->file->flags |= GIT_DIFF_FLAG_VALID_ID;
416
425
  }
417
426
 
@@ -61,6 +61,9 @@ static git_diff_delta *diff_delta__alloc(
61
61
  }
62
62
  delta->status = status;
63
63
 
64
+ git_oid_clear(&delta->old_file.id, diff->base.opts.oid_type);
65
+ git_oid_clear(&delta->new_file.id, diff->base.opts.oid_type);
66
+
64
67
  return delta;
65
68
  }
66
69
 
@@ -146,10 +149,13 @@ static int diff_delta__from_one(
146
149
  const git_index_entry *entry = nitem;
147
150
  bool has_old = false;
148
151
  git_diff_delta *delta;
152
+ git_oid_t oid_type;
149
153
  const char *matched_pathspec;
150
154
 
151
155
  GIT_ASSERT_ARG((oitem != NULL) ^ (nitem != NULL));
152
156
 
157
+ oid_type = diff->base.opts.oid_type;
158
+
153
159
  if (oitem) {
154
160
  entry = oitem;
155
161
  has_old = true;
@@ -183,18 +189,23 @@ static int diff_delta__from_one(
183
189
  GIT_ASSERT(status != GIT_DELTA_MODIFIED);
184
190
  delta->nfiles = 1;
185
191
 
192
+ git_oid_clear(&delta->old_file.id, diff->base.opts.oid_type);
193
+ git_oid_clear(&delta->new_file.id, diff->base.opts.oid_type);
194
+
186
195
  if (has_old) {
187
196
  delta->old_file.mode = entry->mode;
188
197
  delta->old_file.size = entry->file_size;
189
198
  delta->old_file.flags |= GIT_DIFF_FLAG_EXISTS;
190
199
  git_oid_cpy(&delta->old_file.id, &entry->id);
191
- delta->old_file.id_abbrev = GIT_OID_HEXSZ;
200
+ git_oid_clear(&delta->new_file.id, oid_type);
201
+ delta->old_file.id_abbrev = (uint16_t)git_oid_hexsize(oid_type);
192
202
  } else /* ADDED, IGNORED, UNTRACKED */ {
193
203
  delta->new_file.mode = entry->mode;
194
204
  delta->new_file.size = entry->file_size;
195
205
  delta->new_file.flags |= GIT_DIFF_FLAG_EXISTS;
206
+ git_oid_clear(&delta->old_file.id, oid_type);
196
207
  git_oid_cpy(&delta->new_file.id, &entry->id);
197
- delta->new_file.id_abbrev = GIT_OID_HEXSZ;
208
+ delta->new_file.id_abbrev = (uint16_t)git_oid_hexsize(oid_type);
198
209
  }
199
210
 
200
211
  delta->old_file.flags |= GIT_DIFF_FLAG_VALID_ID;
@@ -220,6 +231,9 @@ static int diff_delta__from_two(
220
231
  const git_oid *old_id = &old_entry->id;
221
232
  git_diff_delta *delta;
222
233
  const char *canonical_path = old_entry->path;
234
+ git_oid_t oid_type;
235
+
236
+ oid_type = diff->base.opts.oid_type;
223
237
 
224
238
  if (status == GIT_DELTA_UNMODIFIED &&
225
239
  DIFF_FLAG_ISNT_SET(diff, GIT_DIFF_INCLUDE_UNMODIFIED))
@@ -249,14 +263,14 @@ static int diff_delta__from_two(
249
263
  delta->old_file.size = old_entry->file_size;
250
264
  delta->old_file.mode = old_mode;
251
265
  git_oid_cpy(&delta->old_file.id, old_id);
252
- delta->old_file.id_abbrev = GIT_OID_HEXSZ;
266
+ delta->old_file.id_abbrev = (uint16_t)git_oid_hexsize(oid_type);
253
267
  delta->old_file.flags |= GIT_DIFF_FLAG_VALID_ID |
254
268
  GIT_DIFF_FLAG_EXISTS;
255
269
  }
256
270
 
257
271
  if (!git_index_entry_is_conflict(new_entry)) {
258
272
  git_oid_cpy(&delta->new_file.id, new_id);
259
- delta->new_file.id_abbrev = GIT_OID_HEXSZ;
273
+ delta->new_file.id_abbrev = (uint16_t)git_oid_hexsize(oid_type);
260
274
  delta->new_file.size = new_entry->file_size;
261
275
  delta->new_file.mode = new_mode;
262
276
  delta->old_file.flags |= GIT_DIFF_FLAG_EXISTS;
@@ -485,6 +499,14 @@ static int diff_generated_apply_options(
485
499
  return -1;
486
500
  }
487
501
 
502
+ if (!diff->base.opts.oid_type) {
503
+ diff->base.opts.oid_type = repo->oid_type;
504
+ } else if (diff->base.opts.oid_type != repo->oid_type) {
505
+ git_error_set(GIT_ERROR_INVALID,
506
+ "specified object ID type does not match repository object ID type");
507
+ return -1;
508
+ }
509
+
488
510
  /* flag INCLUDE_TYPECHANGE_TREES implies INCLUDE_TYPECHANGE */
489
511
  if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_INCLUDE_TYPECHANGE_TREES))
490
512
  diff->base.opts.flags |= GIT_DIFF_INCLUDE_TYPECHANGE;
@@ -598,6 +620,7 @@ int git_diff__oid_for_file(
598
620
  entry.mode = mode;
599
621
  entry.file_size = (uint32_t)size;
600
622
  entry.path = (char *)path;
623
+ git_oid_clear(&entry.id, diff->opts.oid_type);
601
624
 
602
625
  return git_diff__oid_for_entry(out, diff, &entry, mode, NULL);
603
626
  }
@@ -618,7 +641,7 @@ int git_diff__oid_for_entry(
618
641
  GIT_ASSERT(d->type == GIT_DIFF_TYPE_GENERATED);
619
642
  diff = (git_diff_generated *)d;
620
643
 
621
- memset(out, 0, sizeof(*out));
644
+ git_oid_clear(out, diff->base.opts.oid_type);
622
645
 
623
646
  if (git_repository_workdir_path(&full_path, diff->base.repo, entry.path) < 0)
624
647
  return -1;
@@ -654,7 +677,8 @@ int git_diff__oid_for_entry(
654
677
  git_error_clear();
655
678
  }
656
679
  } else if (S_ISLNK(mode)) {
657
- error = git_odb__hashlink(out, full_path.ptr);
680
+ error = git_odb__hashlink(out, full_path.ptr,
681
+ diff->base.opts.oid_type);
658
682
  diff->base.perf.oid_calculations++;
659
683
  } else if (!git__is_sizet(entry.file_size)) {
660
684
  git_error_set(GIT_ERROR_NOMEMORY, "file size overflow (for 32-bits) on '%s'",
@@ -669,7 +693,9 @@ int git_diff__oid_for_entry(
669
693
  error = fd;
670
694
  else {
671
695
  error = git_odb__hashfd_filtered(
672
- out, fd, (size_t)entry.file_size, GIT_OBJECT_BLOB, fl);
696
+ out, fd, (size_t)entry.file_size,
697
+ GIT_OBJECT_BLOB, diff->base.opts.oid_type,
698
+ fl);
673
699
  p_close(fd);
674
700
  diff->base.perf.oid_calculations++;
675
701
  }
@@ -789,11 +815,11 @@ static int maybe_modified(
789
815
  const char *matched_pathspec;
790
816
  int error = 0;
791
817
 
818
+ git_oid_clear(&noid, diff->base.opts.oid_type);
819
+
792
820
  if (!diff_pathspec_match(&matched_pathspec, diff, oitem))
793
821
  return 0;
794
822
 
795
- memset(&noid, 0, sizeof(noid));
796
-
797
823
  /* on platforms with no symlinks, preserve mode of existing symlinks */
798
824
  if (S_ISLNK(omode) && S_ISREG(nmode) && new_is_workdir &&
799
825
  !(diff->diffcaps & GIT_DIFFCAPS_HAS_SYMLINKS))
@@ -1695,11 +1721,11 @@ int git_diff__commit(
1695
1721
  *out = NULL;
1696
1722
 
1697
1723
  if ((parents = git_commit_parentcount(commit)) > 1) {
1698
- char commit_oidstr[GIT_OID_HEXSZ + 1];
1724
+ char commit_oidstr[GIT_OID_MAX_HEXSIZE + 1];
1699
1725
 
1700
1726
  error = -1;
1701
1727
  git_error_set(GIT_ERROR_INVALID, "commit %s is a merge commit",
1702
- git_oid_tostr(commit_oidstr, GIT_OID_HEXSZ + 1, git_commit_id(commit)));
1728
+ git_oid_tostr(commit_oidstr, GIT_OID_MAX_HEXSIZE + 1, git_commit_id(commit)));
1703
1729
  goto on_error;
1704
1730
  }
1705
1731
 
@@ -29,7 +29,7 @@ static void diff_parsed_free(git_diff *d)
29
29
  git__free(diff);
30
30
  }
31
31
 
32
- static git_diff_parsed *diff_parsed_alloc(void)
32
+ static git_diff_parsed *diff_parsed_alloc(git_oid_t oid_type)
33
33
  {
34
34
  git_diff_parsed *diff;
35
35
 
@@ -51,6 +51,7 @@ static git_diff_parsed *diff_parsed_alloc(void)
51
51
  }
52
52
 
53
53
  diff->base.opts.flags &= ~GIT_DIFF_IGNORE_CASE;
54
+ diff->base.opts.oid_type = oid_type;
54
55
 
55
56
  if (git_pool_init(&diff->base.pool, 1) < 0 ||
56
57
  git_vector_init(&diff->patches, 0, NULL) < 0 ||
@@ -67,19 +68,34 @@ static git_diff_parsed *diff_parsed_alloc(void)
67
68
  int git_diff_from_buffer(
68
69
  git_diff **out,
69
70
  const char *content,
70
- size_t content_len)
71
+ size_t content_len
72
+ #ifdef GIT_EXPERIMENTAL_SHA256
73
+ , git_diff_parse_options *opts
74
+ #endif
75
+ )
71
76
  {
72
77
  git_diff_parsed *diff;
73
78
  git_patch *patch;
74
79
  git_patch_parse_ctx *ctx = NULL;
80
+ git_patch_options patch_opts = GIT_PATCH_OPTIONS_INIT;
81
+ git_oid_t oid_type;
75
82
  int error = 0;
76
83
 
77
84
  *out = NULL;
78
85
 
79
- diff = diff_parsed_alloc();
86
+ #ifdef GIT_EXPERIMENTAL_SHA256
87
+ oid_type = (opts && opts->oid_type) ? opts->oid_type :
88
+ GIT_OID_DEFAULT;
89
+ #else
90
+ oid_type = GIT_OID_DEFAULT;
91
+ #endif
92
+
93
+ patch_opts.oid_type = oid_type;
94
+
95
+ diff = diff_parsed_alloc(oid_type);
80
96
  GIT_ERROR_CHECK_ALLOC(diff);
81
97
 
82
- ctx = git_patch_parse_ctx_init(content, content_len, NULL);
98
+ ctx = git_patch_parse_ctx_init(content, content_len, &patch_opts);
83
99
  GIT_ERROR_CHECK_ALLOC(ctx);
84
100
 
85
101
  while (ctx->parse_ctx.remain_len) {
@@ -29,6 +29,7 @@ typedef struct {
29
29
  const char *new_prefix;
30
30
  uint32_t flags;
31
31
  int id_strlen;
32
+ git_oid_t oid_type;
32
33
 
33
34
  int (*strcomp)(const char *, const char *);
34
35
  } diff_print_info;
@@ -46,6 +47,8 @@ static int diff_print_info_init__common(
46
47
  pi->payload = payload;
47
48
  pi->buf = out;
48
49
 
50
+ GIT_ASSERT(pi->oid_type);
51
+
49
52
  if (!pi->id_strlen) {
50
53
  if (!repo)
51
54
  pi->id_strlen = GIT_ABBREV_DEFAULT;
@@ -53,8 +56,9 @@ static int diff_print_info_init__common(
53
56
  return -1;
54
57
  }
55
58
 
56
- if (pi->id_strlen > GIT_OID_HEXSZ)
57
- pi->id_strlen = GIT_OID_HEXSZ;
59
+ if (pi->id_strlen > 0 &&
60
+ (size_t)pi->id_strlen > git_oid_hexsize(pi->oid_type))
61
+ pi->id_strlen = (int)git_oid_hexsize(pi->oid_type);
58
62
 
59
63
  memset(&pi->line, 0, sizeof(pi->line));
60
64
  pi->line.old_lineno = -1;
@@ -78,6 +82,7 @@ static int diff_print_info_init_fromdiff(
78
82
 
79
83
  if (diff) {
80
84
  pi->flags = diff->opts.flags;
85
+ pi->oid_type = diff->opts.oid_type;
81
86
  pi->id_strlen = diff->opts.id_abbrev;
82
87
  pi->old_prefix = diff->opts.old_prefix;
83
88
  pi->new_prefix = diff->opts.new_prefix;
@@ -101,6 +106,7 @@ static int diff_print_info_init_frompatch(
101
106
  memset(pi, 0, sizeof(diff_print_info));
102
107
 
103
108
  pi->flags = patch->diff_opts.flags;
109
+ pi->oid_type = patch->diff_opts.oid_type;
104
110
  pi->id_strlen = patch->diff_opts.id_abbrev;
105
111
  pi->old_prefix = patch->diff_opts.old_prefix;
106
112
  pi->new_prefix = patch->diff_opts.new_prefix;
@@ -212,7 +218,10 @@ static int diff_print_one_raw(
212
218
  git_str *out = pi->buf;
213
219
  int id_abbrev;
214
220
  char code = git_diff_status_char(delta->status);
215
- char start_oid[GIT_OID_HEXSZ+1], end_oid[GIT_OID_HEXSZ+1];
221
+ char start_oid[GIT_OID_MAX_HEXSIZE + 1],
222
+ end_oid[GIT_OID_MAX_HEXSIZE + 1];
223
+ size_t oid_hexsize;
224
+ bool id_is_abbrev;
216
225
 
217
226
  GIT_UNUSED(progress);
218
227
 
@@ -231,12 +240,21 @@ static int diff_print_one_raw(
231
240
  return -1;
232
241
  }
233
242
 
243
+ #ifdef GIT_EXPERIMENTAL_SHA256
244
+ GIT_ASSERT(delta->old_file.id.type == delta->new_file.id.type);
245
+ oid_hexsize = git_oid_hexsize(delta->old_file.id.type);
246
+ #else
247
+ oid_hexsize = GIT_OID_SHA1_HEXSIZE;
248
+ #endif
249
+
250
+ id_is_abbrev = (pi->id_strlen > 0 &&
251
+ (size_t)pi->id_strlen <= oid_hexsize);
252
+
234
253
  git_oid_tostr(start_oid, pi->id_strlen + 1, &delta->old_file.id);
235
254
  git_oid_tostr(end_oid, pi->id_strlen + 1, &delta->new_file.id);
236
255
 
237
- git_str_printf(
238
- out, (pi->id_strlen <= GIT_OID_HEXSZ) ?
239
- ":%06o %06o %s... %s... %c" : ":%06o %06o %s %s %c",
256
+ git_str_printf(out,
257
+ id_is_abbrev ? ":%06o %06o %s... %s... %c" : ":%06o %06o %s %s %c",
240
258
  delta->old_file.mode, delta->new_file.mode, start_oid, end_oid, code);
241
259
 
242
260
  if (delta->similarity > 0)
@@ -273,7 +291,8 @@ static int diff_print_oid_range(
273
291
  git_str *out, const git_diff_delta *delta, int id_strlen,
274
292
  bool print_index)
275
293
  {
276
- char start_oid[GIT_OID_HEXSZ+1], end_oid[GIT_OID_HEXSZ+1];
294
+ char start_oid[GIT_OID_MAX_HEXSIZE + 1],
295
+ end_oid[GIT_OID_MAX_HEXSIZE + 1];
277
296
 
278
297
  if (delta->old_file.mode &&
279
298
  id_strlen > delta->old_file.id_abbrev) {
@@ -364,6 +364,7 @@ static int insert_delete_side_of_split(
364
364
  memset(&deleted->new_file, 0, sizeof(deleted->new_file));
365
365
  deleted->new_file.path = deleted->old_file.path;
366
366
  deleted->new_file.flags |= GIT_DIFF_FLAG_VALID_ID;
367
+ git_oid_clear(&deleted->new_file.id, diff->opts.oid_type);
367
368
 
368
369
  return git_vector_insert(onto, deleted);
369
370
  }
@@ -397,6 +398,7 @@ static int apply_splits_and_deletes(
397
398
  memset(&delta->old_file, 0, sizeof(delta->old_file));
398
399
  delta->old_file.path = delta->new_file.path;
399
400
  delta->old_file.flags |= GIT_DIFF_FLAG_VALID_ID;
401
+ git_oid_clear(&delta->old_file.id, diff->opts.oid_type);
400
402
  }
401
403
 
402
404
  /* clean up delta before inserting into new list */
@@ -995,6 +997,7 @@ find_best_matches:
995
997
  memset(&src->new_file, 0, sizeof(src->new_file));
996
998
  src->new_file.path = src->old_file.path;
997
999
  src->new_file.flags |= GIT_DIFF_FLAG_VALID_ID;
1000
+ git_oid_clear(&src->new_file.id, diff->opts.oid_type);
998
1001
 
999
1002
  num_updates++;
1000
1003
 
@@ -1020,6 +1023,7 @@ find_best_matches:
1020
1023
  memset(&src->old_file, 0, sizeof(src->old_file));
1021
1024
  src->old_file.path = src->new_file.path;
1022
1025
  src->old_file.flags |= GIT_DIFF_FLAG_VALID_ID;
1026
+ git_oid_clear(&src->old_file.id, diff->opts.oid_type);
1023
1027
 
1024
1028
  src->flags &= ~GIT_DIFF_FLAG__TO_SPLIT;
1025
1029
  num_rewrites--;
@@ -10,7 +10,7 @@
10
10
  #include "common.h"
11
11
 
12
12
  #include "diff.h"
13
- #include "xdiff/xdiff.h"
13
+ #include "xdiff.h"
14
14
  #include "patch_generate.h"
15
15
 
16
16
  /* xdiff cannot cope with large files. these files should not be passed to
@@ -130,11 +130,12 @@ static int append_header(
130
130
  const git_signature *author,
131
131
  git_email_create_options *opts)
132
132
  {
133
- char id[GIT_OID_HEXSZ];
133
+ char id[GIT_OID_MAX_HEXSIZE + 1];
134
134
  int error;
135
135
 
136
- if ((error = git_oid_fmt(id, commit_id)) < 0 ||
137
- (error = git_str_printf(out, "From %.*s %s\n", GIT_OID_HEXSZ, id, EMAIL_TIMESTAMP)) < 0 ||
136
+ git_oid_tostr(id, GIT_OID_MAX_HEXSIZE + 1, commit_id);
137
+
138
+ if ((error = git_str_printf(out, "From %s %s\n", id, EMAIL_TIMESTAMP)) < 0 ||
138
139
  (error = git_str_printf(out, "From: %s <%s>\n", author->name, author->email)) < 0 ||
139
140
  (error = append_date(out, &author->when)) < 0 ||
140
141
  (error = append_subject(out, patch_idx, patch_count, summary, opts)) < 0)