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
@@ -9,6 +9,7 @@
9
9
 
10
10
  #include "common.h"
11
11
  #include "types.h"
12
+ #include "experimental.h"
12
13
 
13
14
  /**
14
15
  * @file git2/oid.h
@@ -19,11 +20,76 @@
19
20
  */
20
21
  GIT_BEGIN_DECL
21
22
 
22
- /** Size (in bytes) of a raw/binary oid */
23
- #define GIT_OID_RAWSZ 20
23
+ /** The type of object id. */
24
+ typedef enum {
24
25
 
25
- /** Size (in bytes) of a hex formatted oid */
26
- #define GIT_OID_HEXSZ (GIT_OID_RAWSZ * 2)
26
+ #ifdef GIT_EXPERIMENTAL_SHA256
27
+ GIT_OID_SHA1 = 1, /**< SHA1 */
28
+ GIT_OID_SHA256 = 2 /**< SHA256 */
29
+ #else
30
+ GIT_OID_SHA1 = 1 /**< SHA1 */
31
+ #endif
32
+
33
+ } git_oid_t;
34
+
35
+ /*
36
+ * SHA1 is currently the only supported object ID type.
37
+ */
38
+
39
+ /** SHA1 is currently libgit2's default oid type. */
40
+ #define GIT_OID_DEFAULT GIT_OID_SHA1
41
+
42
+ /** Size (in bytes) of a raw/binary sha1 oid */
43
+ #define GIT_OID_SHA1_SIZE 20
44
+ /** Size (in bytes) of a hex formatted sha1 oid */
45
+ #define GIT_OID_SHA1_HEXSIZE (GIT_OID_SHA1_SIZE * 2)
46
+
47
+ /**
48
+ * The binary representation of the null sha1 object ID.
49
+ */
50
+ #ifndef GIT_EXPERIMENTAL_SHA256
51
+ # define GIT_OID_SHA1_ZERO { { 0 } }
52
+ #else
53
+ # define GIT_OID_SHA1_ZERO { GIT_OID_SHA1, { 0 } }
54
+ #endif
55
+
56
+ /**
57
+ * The string representation of the null sha1 object ID.
58
+ */
59
+ #define GIT_OID_SHA1_HEXZERO "0000000000000000000000000000000000000000"
60
+
61
+ /*
62
+ * Experimental SHA256 support is a breaking change to the API.
63
+ * This exists for application compatibility testing.
64
+ */
65
+
66
+ #ifdef GIT_EXPERIMENTAL_SHA256
67
+
68
+ /** Size (in bytes) of a raw/binary sha256 oid */
69
+ # define GIT_OID_SHA256_SIZE 32
70
+ /** Size (in bytes) of a hex formatted sha256 oid */
71
+ # define GIT_OID_SHA256_HEXSIZE (GIT_OID_SHA256_SIZE * 2)
72
+
73
+ /**
74
+ * The binary representation of the null sha256 object ID.
75
+ */
76
+ # define GIT_OID_SHA256_ZERO { GIT_OID_SHA256, { 0 } }
77
+
78
+ /**
79
+ * The string representation of the null sha256 object ID.
80
+ */
81
+ # define GIT_OID_SHA256_HEXZERO "0000000000000000000000000000000000000000000000000000000000000000"
82
+
83
+ #endif
84
+
85
+ /* Maximum possible object ID size in raw / hex string format. */
86
+ #ifndef GIT_EXPERIMENTAL_SHA256
87
+ # define GIT_OID_MAX_SIZE GIT_OID_SHA1_SIZE
88
+ # define GIT_OID_MAX_HEXSIZE GIT_OID_SHA1_HEXSIZE
89
+ #else
90
+ # define GIT_OID_MAX_SIZE GIT_OID_SHA256_SIZE
91
+ # define GIT_OID_MAX_HEXSIZE GIT_OID_SHA256_HEXSIZE
92
+ #endif
27
93
 
28
94
  /** Minimum length (in number of hex characters,
29
95
  * i.e. packets of 4 bits) of an oid prefix */
@@ -31,29 +97,50 @@ GIT_BEGIN_DECL
31
97
 
32
98
  /** Unique identity of any object (commit, tree, blob, tag). */
33
99
  typedef struct git_oid {
100
+
101
+ #ifdef GIT_EXPERIMENTAL_SHA256
102
+ /** type of object id */
103
+ unsigned char type;
104
+ #endif
105
+
34
106
  /** raw binary formatted id */
35
- unsigned char id[GIT_OID_RAWSZ];
107
+ unsigned char id[GIT_OID_MAX_SIZE];
36
108
  } git_oid;
37
109
 
38
110
  /**
39
111
  * Parse a hex formatted object id into a git_oid.
40
112
  *
113
+ * The appropriate number of bytes for the given object ID type will
114
+ * be read from the string - 40 bytes for SHA1, 64 bytes for SHA256.
115
+ * The given string need not be NUL terminated.
116
+ *
41
117
  * @param out oid structure the result is written into.
42
118
  * @param str input hex string; must be pointing at the start of
43
119
  * the hex sequence and have at least the number of bytes
44
- * needed for an oid encoded in hex (40 bytes).
120
+ * needed for an oid encoded in hex (40 bytes for sha1,
121
+ * 256 bytes for sha256).
122
+ * @param type the type of object id
45
123
  * @return 0 or an error code
46
124
  */
125
+ #ifdef GIT_EXPERIMENTAL_SHA256
126
+ GIT_EXTERN(int) git_oid_fromstr(git_oid *out, const char *str, git_oid_t type);
127
+ #else
47
128
  GIT_EXTERN(int) git_oid_fromstr(git_oid *out, const char *str);
129
+ #endif
48
130
 
49
131
  /**
50
- * Parse a hex formatted null-terminated string into a git_oid.
132
+ * Parse a hex formatted NUL-terminated string into a git_oid.
51
133
  *
52
134
  * @param out oid structure the result is written into.
53
135
  * @param str input hex string; must be null-terminated.
136
+ * @param type the type of object id
54
137
  * @return 0 or an error code
55
138
  */
139
+ #ifdef GIT_EXPERIMENTAL_SHA256
140
+ GIT_EXTERN(int) git_oid_fromstrp(git_oid *out, const char *str, git_oid_t type);
141
+ #else
56
142
  GIT_EXTERN(int) git_oid_fromstrp(git_oid *out, const char *str);
143
+ #endif
57
144
 
58
145
  /**
59
146
  * Parse N characters of a hex formatted object id into a git_oid.
@@ -64,9 +151,14 @@ GIT_EXTERN(int) git_oid_fromstrp(git_oid *out, const char *str);
64
151
  * @param out oid structure the result is written into.
65
152
  * @param str input hex string of at least size `length`
66
153
  * @param length length of the input string
154
+ * @param type the type of object id
67
155
  * @return 0 or an error code
68
156
  */
157
+ #ifdef GIT_EXPERIMENTAL_SHA256
158
+ GIT_EXTERN(int) git_oid_fromstrn(git_oid *out, const char *str, size_t length, git_oid_t type);
159
+ #else
69
160
  GIT_EXTERN(int) git_oid_fromstrn(git_oid *out, const char *str, size_t length);
161
+ #endif
70
162
 
71
163
  /**
72
164
  * Copy an already raw oid into a git_oid structure.
@@ -75,16 +167,21 @@ GIT_EXTERN(int) git_oid_fromstrn(git_oid *out, const char *str, size_t length);
75
167
  * @param raw the raw input bytes to be copied.
76
168
  * @return 0 on success or error code
77
169
  */
170
+ #ifdef GIT_EXPERIMENTAL_SHA256
171
+ GIT_EXTERN(int) git_oid_fromraw(git_oid *out, const unsigned char *raw, git_oid_t type);
172
+ #else
78
173
  GIT_EXTERN(int) git_oid_fromraw(git_oid *out, const unsigned char *raw);
174
+ #endif
79
175
 
80
176
  /**
81
177
  * Format a git_oid into a hex string.
82
178
  *
83
179
  * @param out output hex string; must be pointing at the start of
84
180
  * the hex sequence and have at least the number of bytes
85
- * needed for an oid encoded in hex (40 bytes). Only the
86
- * oid digits are written; a '\\0' terminator must be added
87
- * by the caller if it is required.
181
+ * needed for an oid encoded in hex (40 bytes for SHA1,
182
+ * 64 bytes for SHA256). Only the oid digits are written;
183
+ * a '\\0' terminator must be added by the caller if it is
184
+ * required.
88
185
  * @param id oid structure to format.
89
186
  * @return 0 on success or error code
90
187
  */
@@ -94,7 +191,7 @@ GIT_EXTERN(int) git_oid_fmt(char *out, const git_oid *id);
94
191
  * Format a git_oid into a partial hex string.
95
192
  *
96
193
  * @param out output hex string; you say how many bytes to write.
97
- * If the number of bytes is > GIT_OID_HEXSZ, extra bytes
194
+ * If the number of bytes is > GIT_OID_SHA1_HEXSIZE, extra bytes
98
195
  * will be zeroed; if not, a '\0' terminator is NOT added.
99
196
  * @param n number of characters to write into out string
100
197
  * @param id oid structure to format.
@@ -110,9 +207,10 @@ GIT_EXTERN(int) git_oid_nfmt(char *out, size_t n, const git_oid *id);
110
207
  *
111
208
  * @param out output hex string; must be pointing at the start of
112
209
  * the hex sequence and have at least the number of bytes
113
- * needed for an oid encoded in hex (41 bytes). Only the
114
- * oid digits are written; a '\\0' terminator must be added
115
- * by the caller if it is required.
210
+ * needed for an oid encoded in hex (41 bytes for SHA1,
211
+ * 65 bytes for SHA256). Only the oid digits are written;
212
+ * a '\\0' terminator must be added by the caller if it
213
+ * is required.
116
214
  * @param id oid structure to format.
117
215
  * @return 0 on success, non-zero callback return value, or error code
118
216
  */
@@ -127,14 +225,16 @@ GIT_EXTERN(int) git_oid_pathfmt(char *out, const git_oid *id);
127
225
  * concurrent calls of the function.
128
226
  *
129
227
  * @param oid The oid structure to format
130
- * @return the c-string
228
+ * @return the c-string or NULL on failure
131
229
  */
132
230
  GIT_EXTERN(char *) git_oid_tostr_s(const git_oid *oid);
133
231
 
134
232
  /**
135
233
  * Format a git_oid into a buffer as a hex format c-string.
136
234
  *
137
- * If the buffer is smaller than GIT_OID_HEXSZ+1, then the resulting
235
+ * If the buffer is smaller than the size of a hex-formatted oid string
236
+ * plus an additional byte (GIT_OID_SHA_HEXSIZE + 1 for SHA1 or
237
+ * GIT_OID_SHA256_HEXSIZE + 1 for SHA256), then the resulting
138
238
  * oid c-string will be truncated to n-1 characters (but will still be
139
239
  * NUL-byte terminated).
140
240
  *
@@ -702,6 +702,15 @@ typedef enum {
702
702
  GIT_REMOTE_DOWNLOAD_TAGS_ALL
703
703
  } git_remote_autotag_option_t;
704
704
 
705
+ /** Constants for fetch depth (shallowness of fetch). */
706
+ typedef enum {
707
+ /** The fetch is "full" (not shallow). This is the default. */
708
+ GIT_FETCH_DEPTH_FULL = 0,
709
+
710
+ /** The fetch should "unshallow" and fetch missing data. */
711
+ GIT_FETCH_DEPTH_UNSHALLOW = 2147483647
712
+ } git_fetch_depth_t;
713
+
705
714
  /**
706
715
  * Fetch options structure.
707
716
  *
@@ -743,6 +752,15 @@ typedef struct {
743
752
  */
744
753
  git_proxy_options proxy_opts;
745
754
 
755
+ /**
756
+ * Depth of the fetch to perform, or `GIT_FETCH_DEPTH_FULL`
757
+ * (or `0`) for full history, or `GIT_FETCH_DEPTH_UNSHALLOW`
758
+ * to "unshallow" a shallow repository.
759
+ *
760
+ * The default is full (`GIT_FETCH_DEPTH_FULL` or `0`).
761
+ */
762
+ int depth;
763
+
746
764
  /**
747
765
  * Whether to allow off-site redirects. If this is not
748
766
  * specified, the `http.followRedirects` configuration setting
@@ -56,9 +56,19 @@ GIT_EXTERN(int) git_repository_open_from_worktree(git_repository **out, git_work
56
56
  *
57
57
  * @param out pointer to the repo
58
58
  * @param odb the object database to wrap
59
+ * @param oid_type the oid type of the object database
59
60
  * @return 0 or an error code
60
61
  */
61
- GIT_EXTERN(int) git_repository_wrap_odb(git_repository **out, git_odb *odb);
62
+ #ifdef GIT_EXPERIMENTAL_SHA256
63
+ GIT_EXTERN(int) git_repository_wrap_odb(
64
+ git_repository **out,
65
+ git_odb *odb,
66
+ git_oid_t oid_type);
67
+ #else
68
+ GIT_EXTERN(int) git_repository_wrap_odb(
69
+ git_repository **out,
70
+ git_odb *odb);
71
+ #endif
62
72
 
63
73
  /**
64
74
  * Look for a git repository and copy its path in the given buffer.
@@ -351,6 +361,15 @@ typedef struct {
351
361
  * pointing to this URL.
352
362
  */
353
363
  const char *origin_url;
364
+
365
+ #ifdef GIT_EXPERIMENTAL_SHA256
366
+ /**
367
+ *
368
+ * Type of object IDs to use for this repository, or 0 for
369
+ * default (currently SHA1).
370
+ */
371
+ git_oid_t oid_type;
372
+ #endif
354
373
  } git_repository_init_options;
355
374
 
356
375
  #define GIT_REPOSITORY_INIT_OPTIONS_VERSION 1
@@ -456,7 +475,9 @@ GIT_EXTERN(int) git_repository_head_unborn(git_repository *repo);
456
475
  * Check if a repository is empty
457
476
  *
458
477
  * An empty repository has just been initialized and contains no references
459
- * apart from HEAD, which must be pointing to the unborn master branch.
478
+ * apart from HEAD, which must be pointing to the unborn master branch,
479
+ * or the branch specified for the repository in the `init.defaultBranch`
480
+ * configuration variable.
460
481
  *
461
482
  * @param repo Repo to test
462
483
  * @return 1 if the repository is empty, 0 if it isn't, error code
@@ -525,7 +546,7 @@ GIT_EXTERN(const char *) git_repository_workdir(const git_repository *repo);
525
546
 
526
547
  /**
527
548
  * Get the path of the shared common directory for this repository.
528
- *
549
+ *
529
550
  * If the repository is bare, it is the root directory for the repository.
530
551
  * If the repository is a worktree, it is the parent repo's gitdir.
531
552
  * Otherwise, it is the gitdir.
@@ -949,6 +970,14 @@ GIT_EXTERN(int) git_repository_ident(const char **name, const char **email, cons
949
970
  */
950
971
  GIT_EXTERN(int) git_repository_set_ident(git_repository *repo, const char *name, const char *email);
951
972
 
973
+ /**
974
+ * Gets the object type used by this repository.
975
+ *
976
+ * @param repo the repository
977
+ * @return the object id type
978
+ */
979
+ GIT_EXTERN(git_oid_t) git_repository_oid_type(git_repository *repo);
980
+
952
981
  /** @} */
953
982
  GIT_END_DECL
954
983
  #endif
@@ -44,7 +44,12 @@ typedef enum {
44
44
  * All ignored files are also stashed and then cleaned up from
45
45
  * the working directory
46
46
  */
47
- GIT_STASH_INCLUDE_IGNORED = (1 << 2)
47
+ GIT_STASH_INCLUDE_IGNORED = (1 << 2),
48
+
49
+ /**
50
+ * All changes in the index and working directory are left intact
51
+ */
52
+ GIT_STASH_KEEP_ALL = (1 << 3)
48
53
  } git_stash_flags;
49
54
 
50
55
  /**
@@ -52,15 +57,10 @@ typedef enum {
52
57
  *
53
58
  * @param out Object id of the commit containing the stashed state.
54
59
  * This commit is also the target of the direct reference refs/stash.
55
- *
56
60
  * @param repo The owning repository.
57
- *
58
61
  * @param stasher The identity of the person performing the stashing.
59
- *
60
62
  * @param message Optional description along with the stashed state.
61
- *
62
63
  * @param flags Flags to control the stashing process. (see GIT_STASH_* above)
63
- *
64
64
  * @return 0 on success, GIT_ENOTFOUND where there's nothing to stash,
65
65
  * or error code.
66
66
  */
@@ -71,6 +71,60 @@ GIT_EXTERN(int) git_stash_save(
71
71
  const char *message,
72
72
  uint32_t flags);
73
73
 
74
+ /**
75
+ * Stash save options structure
76
+ *
77
+ * Initialize with `GIT_STASH_SAVE_OPTIONS_INIT`. Alternatively, you can
78
+ * use `git_stash_save_options_init`.
79
+ *
80
+ */
81
+ typedef struct git_stash_save_options {
82
+ unsigned int version;
83
+
84
+ /** Flags to control the stashing process. (see GIT_STASH_* above) */
85
+ uint32_t flags;
86
+
87
+ /** The identity of the person performing the stashing. */
88
+ const git_signature *stasher;
89
+
90
+ /** Optional description along with the stashed state. */
91
+ const char *message;
92
+
93
+ /** Optional paths that control which files are stashed. */
94
+ git_strarray paths;
95
+ } git_stash_save_options;
96
+
97
+ #define GIT_STASH_SAVE_OPTIONS_VERSION 1
98
+ #define GIT_STASH_SAVE_OPTIONS_INIT { GIT_STASH_SAVE_OPTIONS_VERSION }
99
+
100
+ /**
101
+ * Initialize git_stash_save_options structure
102
+ *
103
+ * Initializes a `git_stash_save_options` with default values. Equivalent to
104
+ * creating an instance with `GIT_STASH_SAVE_OPTIONS_INIT`.
105
+ *
106
+ * @param opts The `git_stash_save_options` struct to initialize.
107
+ * @param version The struct version; pass `GIT_STASH_SAVE_OPTIONS_VERSION`.
108
+ * @return Zero on success; -1 on failure.
109
+ */
110
+ GIT_EXTERN(int) git_stash_save_options_init(
111
+ git_stash_save_options *opts, unsigned int version);
112
+
113
+ /**
114
+ * Save the local modifications to a new stash, with options.
115
+ *
116
+ * @param out Object id of the commit containing the stashed state.
117
+ * This commit is also the target of the direct reference refs/stash.
118
+ * @param repo The owning repository.
119
+ * @param opts The stash options.
120
+ * @return 0 on success, GIT_ENOTFOUND where there's nothing to stash,
121
+ * or error code.
122
+ */
123
+ GIT_EXTERN(int) git_stash_save_with_opts(
124
+ git_oid *out,
125
+ git_repository *repo,
126
+ const git_stash_save_options *opts);
127
+
74
128
  /** Stash application flags. */
75
129
  typedef enum {
76
130
  GIT_STASH_APPLY_DEFAULT = 0,
@@ -36,19 +36,6 @@ typedef struct git_strarray {
36
36
  */
37
37
  GIT_EXTERN(void) git_strarray_dispose(git_strarray *array);
38
38
 
39
- /**
40
- * Copy a string array object from source to target.
41
- *
42
- * Note: target is overwritten and hence should be empty, otherwise its
43
- * contents are leaked. Call git_strarray_free() if necessary.
44
- *
45
- * @param tgt target
46
- * @param src source
47
- * @return 0 on success, < 0 on allocation failure
48
- */
49
- GIT_EXTERN(int) git_strarray_copy(git_strarray *tgt, const git_strarray *src);
50
-
51
-
52
39
  /** @} */
53
40
  GIT_END_DECL
54
41
 
@@ -24,28 +24,6 @@ typedef struct {
24
24
  /** Allocate `n` bytes of memory */
25
25
  void * GIT_CALLBACK(gmalloc)(size_t n, const char *file, int line);
26
26
 
27
- /**
28
- * Allocate memory for an array of `nelem` elements, where each element
29
- * has a size of `elsize`. Returned memory shall be initialized to
30
- * all-zeroes
31
- */
32
- void * GIT_CALLBACK(gcalloc)(size_t nelem, size_t elsize, const char *file, int line);
33
-
34
- /** Allocate memory for the string `str` and duplicate its contents. */
35
- char * GIT_CALLBACK(gstrdup)(const char *str, const char *file, int line);
36
-
37
- /**
38
- * Equivalent to the `gstrdup` function, but only duplicating at most
39
- * `n + 1` bytes
40
- */
41
- char * GIT_CALLBACK(gstrndup)(const char *str, size_t n, const char *file, int line);
42
-
43
- /**
44
- * Equivalent to `gstrndup`, but will always duplicate exactly `n` bytes
45
- * of `str`. Thus, out of bounds reads at `str` may happen.
46
- */
47
- char * GIT_CALLBACK(gsubstrdup)(const char *str, size_t n, const char *file, int line);
48
-
49
27
  /**
50
28
  * This function shall deallocate the old object `ptr` and return a
51
29
  * pointer to a new object that has the size specified by `size`. In
@@ -53,18 +31,6 @@ typedef struct {
53
31
  */
54
32
  void * GIT_CALLBACK(grealloc)(void *ptr, size_t size, const char *file, int line);
55
33
 
56
- /**
57
- * This function shall be equivalent to `grealloc`, but allocating
58
- * `neleme * elsize` bytes.
59
- */
60
- void * GIT_CALLBACK(greallocarray)(void *ptr, size_t nelem, size_t elsize, const char *file, int line);
61
-
62
- /**
63
- * This function shall allocate a new array of `nelem` elements, where
64
- * each element has a size of `elsize` bytes.
65
- */
66
- void * GIT_CALLBACK(gmallocarray)(size_t nelem, size_t elsize, const char *file, int line);
67
-
68
34
  /**
69
35
  * This function shall free the memory pointed to by `ptr`. In case
70
36
  * `ptr` is `NULL`, this shall be a no-op.
@@ -28,7 +28,13 @@ GIT_BEGIN_DECL
28
28
  * @param objects_dir the path to a git objects directory.
29
29
  * @return Zero on success; -1 on failure.
30
30
  */
31
- GIT_EXTERN(int) git_commit_graph_open(git_commit_graph **cgraph_out, const char *objects_dir);
31
+ GIT_EXTERN(int) git_commit_graph_open(
32
+ git_commit_graph **cgraph_out,
33
+ const char *objects_dir
34
+ #ifdef GIT_EXPERIMENTAL_SHA256
35
+ , git_oid_t oid_type
36
+ #endif
37
+ );
32
38
 
33
39
  /**
34
40
  * Frees commit-graph data. This should only be called when memory allocated
@@ -50,7 +56,11 @@ GIT_EXTERN(void) git_commit_graph_free(git_commit_graph *cgraph);
50
56
  */
51
57
  GIT_EXTERN(int) git_commit_graph_writer_new(
52
58
  git_commit_graph_writer **out,
53
- const char *objects_info_dir);
59
+ const char *objects_info_dir
60
+ #ifdef GIT_EXPERIMENTAL_SHA256
61
+ , git_oid_t oid_type
62
+ #endif
63
+ );
54
64
 
55
65
  /**
56
66
  * Free the commit-graph writer and its resources.
@@ -29,7 +29,11 @@ GIT_BEGIN_DECL
29
29
  */
30
30
  GIT_EXTERN(int) git_midx_writer_new(
31
31
  git_midx_writer **out,
32
- const char *pack_dir);
32
+ const char *pack_dir
33
+ #ifdef GIT_EXPERIMENTAL_SHA256
34
+ , git_oid_t oid_type
35
+ #endif
36
+ );
33
37
 
34
38
  /**
35
39
  * Free the multi-pack-index writer and its resources.
@@ -36,7 +36,7 @@ struct git_odb_backend {
36
36
  void **, size_t *, git_object_t *, git_odb_backend *, const git_oid *);
37
37
 
38
38
  /* To find a unique object given a prefix of its oid. The oid given
39
- * must be so that the remaining (GIT_OID_HEXSZ - len)*4 bits are 0s.
39
+ * must be so that the remaining (GIT_OID_SHA1_HEXSIZE - len)*4 bits are 0s.
40
40
  */
41
41
  int GIT_CALLBACK(read_prefix)(
42
42
  git_oid *, void **, size_t *, git_object_t *,
@@ -29,8 +29,22 @@ GIT_BEGIN_DECL
29
29
  typedef struct git_stream {
30
30
  int version;
31
31
 
32
- int encrypted;
33
- int proxy_support;
32
+ int encrypted : 1,
33
+ proxy_support : 1;
34
+
35
+ /**
36
+ * Timeout for read and write operations; can be set to `0` to
37
+ * block indefinitely.
38
+ */
39
+ int timeout;
40
+
41
+ /**
42
+ * Timeout to connect to the remote server; can be set to `0`
43
+ * to use the system defaults. This can be shorter than the
44
+ * system default - often 75 seconds - but cannot be longer.
45
+ */
46
+ int connect_timeout;
47
+
34
48
  int GIT_CALLBACK(connect)(struct git_stream *);
35
49
  int GIT_CALLBACK(certificate)(git_cert **, struct git_stream *);
36
50
  int GIT_CALLBACK(set_proxy)(struct git_stream *, const git_proxy_options *proxy_opts);
@@ -9,6 +9,7 @@
9
9
  #define INCLUDE_sys_git_transport_h
10
10
 
11
11
  #include "git2/net.h"
12
+ #include "git2/oidarray.h"
12
13
  #include "git2/proxy.h"
13
14
  #include "git2/remote.h"
14
15
  #include "git2/strarray.h"
@@ -25,6 +26,14 @@
25
26
 
26
27
  GIT_BEGIN_DECL
27
28
 
29
+ typedef struct {
30
+ const git_remote_head * const *refs;
31
+ size_t refs_len;
32
+ git_oid *shallow_roots;
33
+ size_t shallow_roots_len;
34
+ int depth;
35
+ } git_fetch_negotiation;
36
+
28
37
  struct git_transport {
29
38
  unsigned int version; /**< The struct version */
30
39
 
@@ -57,6 +66,18 @@ struct git_transport {
57
66
  unsigned int *capabilities,
58
67
  git_transport *transport);
59
68
 
69
+ #ifdef GIT_EXPERIMENTAL_SHA256
70
+ /**
71
+ * Gets the object type for the remote repository.
72
+ *
73
+ * This function may be called after a successful call to
74
+ * `connect()`.
75
+ */
76
+ int GIT_CALLBACK(oid_type)(
77
+ git_oid_t *object_type,
78
+ git_transport *transport);
79
+ #endif
80
+
60
81
  /**
61
82
  * Get the list of available references in the remote repository.
62
83
  *
@@ -84,8 +105,17 @@ struct git_transport {
84
105
  int GIT_CALLBACK(negotiate_fetch)(
85
106
  git_transport *transport,
86
107
  git_repository *repo,
87
- const git_remote_head * const *refs,
88
- size_t count);
108
+ const git_fetch_negotiation *fetch_data);
109
+
110
+ /**
111
+ * Return the shallow roots of the remote.
112
+ *
113
+ * This function may be called after a successful call to
114
+ * `negotiate_fetch`.
115
+ */
116
+ int GIT_CALLBACK(shallow_roots)(
117
+ git_oidarray *out,
118
+ git_transport *transport);
89
119
 
90
120
  /**
91
121
  * Start downloading the packfile from the remote repository.
@@ -11,16 +11,16 @@
11
11
  * The version string for libgit2. This string follows semantic
12
12
  * versioning (v2) guidelines.
13
13
  */
14
- #define LIBGIT2_VERSION "1.5.0"
14
+ #define LIBGIT2_VERSION "1.7.1"
15
15
 
16
16
  /** The major version number for this version of libgit2. */
17
17
  #define LIBGIT2_VER_MAJOR 1
18
18
 
19
19
  /** The minor version number for this version of libgit2. */
20
- #define LIBGIT2_VER_MINOR 5
20
+ #define LIBGIT2_VER_MINOR 7
21
21
 
22
22
  /** The revision ("teeny") version number for this version of libgit2. */
23
- #define LIBGIT2_VER_REVISION 0
23
+ #define LIBGIT2_VER_REVISION 1
24
24
 
25
25
  /** The Windows DLL patch number for this version of libgit2. */
26
26
  #define LIBGIT2_VER_PATCH 0
@@ -34,6 +34,6 @@
34
34
  #define LIBGIT2_VER_PRERELEASE NULL
35
35
 
36
36
  /** The library ABI soversion for this version of libgit2. */
37
- #define LIBGIT2_SOVERSION "1.5"
37
+ #define LIBGIT2_SOVERSION "1.7"
38
38
 
39
39
  #endif
@@ -237,7 +237,9 @@ GIT_EXTERN(int) git_worktree_prune_options_init(
237
237
  *
238
238
  * If the worktree is not valid and not locked or if the above
239
239
  * flags have been passed in, this function will return a
240
- * positive value.
240
+ * positive value. If the worktree is not prunable, an error
241
+ * message will be set (visible in `giterr_last`) with details about
242
+ * why.
241
243
  *
242
244
  * @param wt Worktree to check.
243
245
  * @param opts The prunable options.
@@ -28,6 +28,7 @@
28
28
  #include "git2/diff.h"
29
29
  #include "git2/email.h"
30
30
  #include "git2/errors.h"
31
+ #include "git2/experimental.h"
31
32
  #include "git2/filter.h"
32
33
  #include "git2/global.h"
33
34
  #include "git2/graph.h"