rugged 1.6.5 → 1.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (182) 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 +325 -125
  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/revparse.c +1 -4
  114. data/vendor/libgit2/src/libgit2/revwalk.c +26 -4
  115. data/vendor/libgit2/src/libgit2/stash.c +9 -8
  116. data/vendor/libgit2/src/libgit2/streams/mbedtls.c +0 -1
  117. data/vendor/libgit2/src/libgit2/streams/openssl.c +8 -16
  118. data/vendor/libgit2/src/libgit2/streams/schannel.c +715 -0
  119. data/vendor/libgit2/src/libgit2/streams/schannel.h +28 -0
  120. data/vendor/libgit2/src/libgit2/streams/socket.c +237 -51
  121. data/vendor/libgit2/src/libgit2/streams/socket.h +3 -1
  122. data/vendor/libgit2/src/libgit2/streams/stransport.c +40 -12
  123. data/vendor/libgit2/src/libgit2/streams/tls.c +5 -0
  124. data/vendor/libgit2/src/libgit2/submodule.h +3 -3
  125. data/vendor/libgit2/src/libgit2/threadstate.c +15 -2
  126. data/vendor/libgit2/src/libgit2/threadstate.h +1 -3
  127. data/vendor/libgit2/src/libgit2/transports/auth.h +1 -2
  128. data/vendor/libgit2/src/libgit2/transports/{auth_negotiate.c → auth_gssapi.c} +32 -32
  129. data/vendor/libgit2/src/libgit2/transports/auth_negotiate.h +1 -1
  130. data/vendor/libgit2/src/libgit2/transports/auth_ntlm.h +1 -1
  131. data/vendor/libgit2/src/libgit2/transports/{auth_ntlm.c → auth_ntlmclient.c} +12 -12
  132. data/vendor/libgit2/src/libgit2/transports/auth_sspi.c +341 -0
  133. data/vendor/libgit2/src/libgit2/transports/git.c +7 -8
  134. data/vendor/libgit2/src/libgit2/transports/http.c +7 -2
  135. data/vendor/libgit2/src/libgit2/transports/httpclient.c +5 -0
  136. data/vendor/libgit2/src/libgit2/transports/local.c +13 -4
  137. data/vendor/libgit2/src/libgit2/transports/smart.c +33 -27
  138. data/vendor/libgit2/src/libgit2/transports/smart.h +23 -8
  139. data/vendor/libgit2/src/libgit2/transports/smart_pkt.c +136 -17
  140. data/vendor/libgit2/src/libgit2/transports/smart_protocol.c +154 -47
  141. data/vendor/libgit2/src/libgit2/transports/ssh.c +3 -3
  142. data/vendor/libgit2/src/libgit2/transports/winhttp.c +14 -15
  143. data/vendor/libgit2/src/libgit2/tree-cache.c +26 -16
  144. data/vendor/libgit2/src/libgit2/tree-cache.h +5 -3
  145. data/vendor/libgit2/src/libgit2/tree.c +1 -1
  146. data/vendor/libgit2/src/libgit2/worktree.c +25 -10
  147. data/vendor/libgit2/src/util/alloc.c +65 -6
  148. data/vendor/libgit2/src/util/alloc.h +34 -9
  149. data/vendor/libgit2/src/util/allocators/failalloc.c +0 -60
  150. data/vendor/libgit2/src/util/allocators/failalloc.h +0 -6
  151. data/vendor/libgit2/src/util/allocators/stdalloc.c +2 -105
  152. data/vendor/libgit2/src/util/allocators/win32_leakcheck.c +0 -68
  153. data/vendor/libgit2/src/util/array.h +6 -1
  154. data/vendor/libgit2/src/util/cc-compat.h +2 -0
  155. data/vendor/libgit2/src/util/filebuf.c +6 -1
  156. data/vendor/libgit2/src/util/filebuf.h +19 -6
  157. data/vendor/libgit2/src/util/fs_path.c +1 -1
  158. data/vendor/libgit2/src/util/futils.c +8 -5
  159. data/vendor/libgit2/src/util/git2_features.h.in +9 -3
  160. data/vendor/libgit2/src/util/net.c +308 -157
  161. data/vendor/libgit2/src/util/net.h +25 -0
  162. data/vendor/libgit2/src/util/posix.c +54 -0
  163. data/vendor/libgit2/src/util/posix.h +22 -0
  164. data/vendor/libgit2/src/util/rand.c +6 -4
  165. data/vendor/libgit2/src/util/staticstr.h +66 -0
  166. data/vendor/libgit2/src/util/util.c +15 -10
  167. data/vendor/libgit2/src/util/util.h +24 -16
  168. data/vendor/libgit2/src/util/win32/error.c +1 -1
  169. data/vendor/libgit2/src/util/win32/path_w32.c +8 -8
  170. data/vendor/libgit2/src/util/win32/posix_w32.c +1 -1
  171. data/vendor/libgit2/src/util/win32/utf-conv.c +73 -75
  172. data/vendor/libgit2/src/util/win32/utf-conv.h +81 -14
  173. data/vendor/libgit2/src/util/win32/w32_util.c +1 -1
  174. metadata +29 -23
  175. data/vendor/libgit2/cmake/SelectWinHTTP.cmake +0 -17
  176. data/vendor/libgit2/src/libgit2/netops.c +0 -124
  177. data/vendor/libgit2/src/libgit2/netops.h +0 -68
  178. /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xdiff.h +0 -0
  179. /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xemit.h +0 -0
  180. /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xinclude.h +0 -0
  181. /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xprepare.h +0 -0
  182. /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xtypes.h +0 -0
@@ -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.
@@ -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
 
@@ -96,8 +105,17 @@ struct git_transport {
96
105
  int GIT_CALLBACK(negotiate_fetch)(
97
106
  git_transport *transport,
98
107
  git_repository *repo,
99
- const git_remote_head * const *refs,
100
- 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);
101
119
 
102
120
  /**
103
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.6.5"
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 6
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 5
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.6"
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.
@@ -41,8 +41,8 @@ include(SelectHTTPSBackend)
41
41
  include(SelectHashes)
42
42
  include(SelectHTTPParser)
43
43
  include(SelectRegex)
44
+ include(SelectXdiff)
44
45
  include(SelectSSH)
45
- include(SelectWinHTTP)
46
46
  include(SelectZlib)
47
47
 
48
48
  #
@@ -58,20 +58,43 @@ add_feature_info(futimens GIT_USE_FUTIMENS "futimens support")
58
58
 
59
59
  # qsort
60
60
 
61
- check_prototype_definition(qsort_r
62
- "void qsort_r(void *base, size_t nmemb, size_t size, void *thunk, int (*compar)(void *, const void *, const void *))"
63
- "" "stdlib.h" GIT_QSORT_R_BSD)
61
+ # old-style FreeBSD qsort_r() has the 'context' parameter as the first argument
62
+ # of the comparison function:
63
+ check_prototype_definition_safe(qsort_r
64
+ "void (qsort_r)(void *base, size_t nmemb, size_t size, void *context, int (*compar)(void *, const void *, const void *))"
65
+ "" "stdlib.h" GIT_QSORT_BSD)
66
+
67
+ # GNU or POSIX qsort_r() has the 'context' parameter as the last argument of the
68
+ # comparison function:
69
+ check_prototype_definition_safe(qsort_r
70
+ "void (qsort_r)(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *, void *), void *context)"
71
+ "" "stdlib.h" GIT_QSORT_GNU)
72
+
73
+ # C11 qsort_s() has the 'context' parameter as the last argument of the
74
+ # comparison function, and returns an error status:
75
+ check_prototype_definition_safe(qsort_s
76
+ "errno_t (qsort_s)(void *base, rsize_t nmemb, rsize_t size, int (*compar)(const void *, const void *, void *), void *context)"
77
+ "0" "stdlib.h" GIT_QSORT_C11)
78
+
79
+ # MSC qsort_s() has the 'context' parameter as the first argument of the
80
+ # comparison function, and as the last argument of qsort_s():
81
+ check_prototype_definition_safe(qsort_s
82
+ "void (qsort_s)(void *base, size_t num, size_t width, int (*compare )(void *, const void *, const void *), void *context)"
83
+ "" "stdlib.h" GIT_QSORT_MSC)
64
84
 
65
- check_prototype_definition(qsort_r
66
- "void qsort_r(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *, void *), void *arg)"
67
- "" "stdlib.h" GIT_QSORT_R_GNU)
85
+ # random / entropy data
68
86
 
69
- check_function_exists(qsort_s GIT_QSORT_S)
87
+ check_symbol_exists(getentropy unistd.h GIT_RAND_GETENTROPY)
88
+ check_symbol_exists(getloadavg stdlib.h GIT_RAND_GETLOADAVG)
70
89
 
71
- # random / entropy data
90
+ # poll
72
91
 
73
- check_function_exists(getentropy GIT_RAND_GETENTROPY)
74
- check_function_exists(getloadavg GIT_RAND_GETLOADAVG)
92
+ if(WIN32)
93
+ set(GIT_IO_WSAPOLL 1)
94
+ else()
95
+ check_symbol_exists(poll poll.h GIT_IO_POLL)
96
+ check_symbol_exists(select sys/select.h GIT_IO_SELECT)
97
+ endif()
75
98
 
76
99
  # determine architecture of the machine
77
100
 
@@ -18,7 +18,7 @@
18
18
 
19
19
  #define COMMAND_NAME "clone"
20
20
 
21
- static char *branch, *remote_path, *local_path;
21
+ static char *branch, *remote_path, *local_path, *depth;
22
22
  static int show_help, quiet, checkout = 1, bare;
23
23
  static bool local_path_exists;
24
24
  static cli_progress progress = CLI_PROGRESS_INIT;
@@ -36,6 +36,8 @@ static const cli_opt_spec opts[] = {
36
36
  CLI_OPT_USAGE_DEFAULT, NULL, "don't create a working directory" },
37
37
  { CLI_OPT_TYPE_VALUE, "branch", 'b', &branch, 0,
38
38
  CLI_OPT_USAGE_DEFAULT, "name", "branch to check out" },
39
+ { CLI_OPT_TYPE_VALUE, "depth", 0, &depth, 0,
40
+ CLI_OPT_USAGE_DEFAULT, "depth", "commit depth to check out " },
39
41
  { CLI_OPT_TYPE_LITERAL },
40
42
  { CLI_OPT_TYPE_ARG, "repository", 0, &remote_path, 0,
41
43
  CLI_OPT_USAGE_REQUIRED, "repository", "repository path" },
@@ -71,6 +73,22 @@ static char *compute_local_path(const char *orig_path)
71
73
  return local_path;
72
74
  }
73
75
 
76
+ static int compute_depth(const char *depth)
77
+ {
78
+ int64_t i;
79
+ const char *endptr;
80
+
81
+ if (!depth)
82
+ return 0;
83
+
84
+ if (git__strntol64(&i, depth, strlen(depth), &endptr, 10) < 0 || i < 0 || i > INT_MAX || *endptr) {
85
+ fprintf(stderr, "fatal: depth '%s' is not valid.\n", depth);
86
+ exit(128);
87
+ }
88
+
89
+ return (int)i;
90
+ }
91
+
74
92
  static bool validate_local_path(const char *path)
75
93
  {
76
94
  if (!git_fs_path_exists(path))
@@ -127,11 +145,9 @@ int cmd_clone(int argc, char **argv)
127
145
  goto done;
128
146
  }
129
147
 
130
- if (bare)
131
- clone_opts.bare = 1;
132
-
133
- if (branch)
134
- clone_opts.checkout_branch = branch;
148
+ clone_opts.bare = !!bare;
149
+ clone_opts.checkout_branch = branch;
150
+ clone_opts.fetch_opts.depth = compute_depth(depth);
135
151
 
136
152
  if (!checkout)
137
153
  clone_opts.checkout_opts.checkout_strategy = GIT_CHECKOUT_NONE;
@@ -15,10 +15,10 @@
15
15
  /*
16
16
  * Show updates to the percentage and number of objects received
17
17
  * separately from the throughput to give an accurate progress while
18
- * avoiding too much noise on the screen.
18
+ * avoiding too much noise on the screen. (In milliseconds.)
19
19
  */
20
- #define PROGRESS_UPDATE_TIME 0.10
21
- #define THROUGHPUT_UPDATE_TIME 1.00
20
+ #define PROGRESS_UPDATE_TIME 60
21
+ #define THROUGHPUT_UPDATE_TIME 500
22
22
 
23
23
  #define is_nl(c) ((c) == '\r' || (c) == '\n')
24
24
 
@@ -54,7 +54,7 @@ static int progress_write(cli_progress *progress, bool force, git_str *line)
54
54
  bool has_nl;
55
55
  size_t no_nl = no_nl_len(line->ptr, line->size);
56
56
  size_t nl = nl_len(&has_nl, line->ptr + no_nl, line->size - no_nl);
57
- double now = git__timer();
57
+ uint64_t now = git_time_monotonic();
58
58
  size_t i;
59
59
 
60
60
  /* Avoid spamming the console with progress updates */
@@ -191,20 +191,21 @@ static int fetch_receiving(
191
191
  {
192
192
  char *recv_units[] = { "B", "KiB", "MiB", "GiB", "TiB", NULL };
193
193
  char *rate_units[] = { "B/s", "KiB/s", "MiB/s", "GiB/s", "TiB/s", NULL };
194
+ uint64_t now, elapsed;
194
195
 
195
- double now, recv_len, rate, elapsed;
196
+ double recv_len, rate;
196
197
  size_t recv_unit_idx = 0, rate_unit_idx = 0;
197
198
  bool done = (stats->received_objects == stats->total_objects);
198
199
 
199
200
  if (!progress->action_start)
200
- progress->action_start = git__timer();
201
+ progress->action_start = git_time_monotonic();
201
202
 
202
203
  if (done && progress->action_finish)
203
204
  now = progress->action_finish;
204
205
  else if (done)
205
- progress->action_finish = now = git__timer();
206
+ progress->action_finish = now = git_time_monotonic();
206
207
  else
207
- now = git__timer();
208
+ now = git_time_monotonic();
208
209
 
209
210
  if (progress->throughput_update &&
210
211
  now - progress->throughput_update < THROUGHPUT_UPDATE_TIME) {
@@ -30,11 +30,11 @@ typedef struct {
30
30
  cli_progress_t action;
31
31
 
32
32
  /* Actions may time themselves (eg fetch) but are not required to */
33
- double action_start;
34
- double action_finish;
33
+ uint64_t action_start;
34
+ uint64_t action_finish;
35
35
 
36
36
  /* Last console update, avoid too frequent updates. */
37
- double last_update;
37
+ uint64_t last_update;
38
38
 
39
39
  /* Accumulators for partial output and deferred updates. */
40
40
  git_str sideband;
@@ -42,7 +42,7 @@ typedef struct {
42
42
  git_str deferred;
43
43
 
44
44
  /* Last update about throughput */
45
- double throughput_update;
45
+ uint64_t throughput_update;
46
46
  double throughput_bytes;
47
47
  } cli_progress;
48
48
 
@@ -24,8 +24,7 @@ target_sources(libgit2 PRIVATE ${SRC_H})
24
24
 
25
25
  file(GLOB SRC_GIT2 *.c *.h
26
26
  streams/*.c streams/*.h
27
- transports/*.c transports/*.h
28
- xdiff/*.c xdiff/*.h)
27
+ transports/*.c transports/*.h)
29
28
  list(SORT SRC_GIT2)
30
29
  target_sources(libgit2 PRIVATE ${SRC_GIT2})
31
30
 
@@ -39,23 +38,6 @@ if(APPLE)
39
38
  set_source_files_properties(streams/stransport.c PROPERTIES COMPILE_FLAGS -Wno-deprecated)
40
39
  endif()
41
40
 
42
- # the xdiff dependency is not (yet) warning-free, disable warnings
43
- # as errors for the xdiff sources until we've sorted them out
44
- if(MSVC)
45
- set_source_files_properties(xdiff/xdiffi.c PROPERTIES COMPILE_FLAGS -WX-)
46
- set_source_files_properties(xdiff/xemit.c PROPERTIES COMPILE_FLAGS -WX-)
47
- set_source_files_properties(xdiff/xhistogram.c PROPERTIES COMPILE_FLAGS -WX-)
48
- set_source_files_properties(xdiff/xmerge.c PROPERTIES COMPILE_FLAGS -WX-)
49
- set_source_files_properties(xdiff/xutils.c PROPERTIES COMPILE_FLAGS -WX-)
50
- set_source_files_properties(xdiff/xpatience.c PROPERTIES COMPILE_FLAGS -WX-)
51
- else()
52
- set_source_files_properties(xdiff/xdiffi.c PROPERTIES COMPILE_FLAGS "-Wno-sign-compare -Wno-unused-parameter")
53
- set_source_files_properties(xdiff/xemit.c PROPERTIES COMPILE_FLAGS "-Wno-sign-compare -Wno-unused-parameter")
54
- set_source_files_properties(xdiff/xhistogram.c PROPERTIES COMPILE_FLAGS "-Wno-sign-compare")
55
- set_source_files_properties(xdiff/xutils.c PROPERTIES COMPILE_FLAGS "-Wno-sign-compare")
56
- set_source_files_properties(xdiff/xpatience.c PROPERTIES COMPILE_FLAGS "-Wno-sign-compare")
57
- endif()
58
-
59
41
  ide_split_sources(libgit2)
60
42
  list(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:util> $<TARGET_OBJECTS:libgit2> ${LIBGIT2_DEPENDENCY_OBJECTS})
61
43
  list(APPEND LIBGIT2_INCLUDES ${LIBGIT2_DEPENDENCY_INCLUDES})
@@ -39,8 +39,8 @@ static int annotated_commit_init(
39
39
  if ((error = git_commit_dup(&annotated_commit->commit, commit)) < 0)
40
40
  goto done;
41
41
 
42
- git_oid_fmt(annotated_commit->id_str, git_commit_id(commit));
43
- annotated_commit->id_str[GIT_OID_SHA1_HEXSIZE] = '\0';
42
+ git_oid_tostr(annotated_commit->id_str, GIT_OID_MAX_HEXSIZE + 1,
43
+ git_commit_id(commit));
44
44
 
45
45
  if (!description)
46
46
  description = annotated_commit->id_str;
@@ -41,7 +41,7 @@ struct git_annotated_commit {
41
41
  const char *ref_name;
42
42
  const char *remote_url;
43
43
 
44
- char id_str[GIT_OID_SHA1_HEXSIZE+1];
44
+ char id_str[GIT_OID_MAX_HEXSIZE + 1];
45
45
  };
46
46
 
47
47
  extern int git_annotated_commit_from_head(git_annotated_commit **out,
@@ -19,6 +19,7 @@
19
19
  #include "zstream.h"
20
20
  #include "reader.h"
21
21
  #include "index.h"
22
+ #include "repository.h"
22
23
  #include "apply.h"
23
24
 
24
25
  typedef struct {
@@ -644,7 +645,7 @@ int git_apply_to_tree(
644
645
  * put the current tree into the postimage as-is - the diff will
645
646
  * replace any entries contained therein
646
647
  */
647
- if ((error = git_index_new(&postimage)) < 0 ||
648
+ if ((error = git_index__new(&postimage, repo->oid_type)) < 0 ||
648
649
  (error = git_index_read_tree(postimage, preimage)) < 0 ||
649
650
  (error = git_reader_for_index(&post_reader, repo, postimage)) < 0)
650
651
  goto done;
@@ -851,8 +852,8 @@ int git_apply(
851
852
  * having the full repo index, so we will limit our checkout
852
853
  * to only write these files that were affected by the diff.
853
854
  */
854
- if ((error = git_index_new(&preimage)) < 0 ||
855
- (error = git_index_new(&postimage)) < 0 ||
855
+ if ((error = git_index__new(&preimage, repo->oid_type)) < 0 ||
856
+ (error = git_index__new(&postimage, repo->oid_type)) < 0 ||
856
857
  (error = git_reader_for_index(&post_reader, repo, postimage)) < 0)
857
858
  goto done;
858
859
 
@@ -60,10 +60,11 @@ static bool hunk_starts_at_or_after_line(git_blame_hunk *hunk, size_t line)
60
60
  }
61
61
 
62
62
  static git_blame_hunk *new_hunk(
63
- size_t start,
64
- size_t lines,
65
- size_t orig_start,
66
- const char *path)
63
+ size_t start,
64
+ size_t lines,
65
+ size_t orig_start,
66
+ const char *path,
67
+ git_blame *blame)
67
68
  {
68
69
  git_blame_hunk *hunk = git__calloc(1, sizeof(git_blame_hunk));
69
70
  if (!hunk) return NULL;
@@ -72,8 +73,8 @@ static git_blame_hunk *new_hunk(
72
73
  hunk->final_start_line_number = start;
73
74
  hunk->orig_start_line_number = orig_start;
74
75
  hunk->orig_path = path ? git__strdup(path) : NULL;
75
- git_oid_clear(&hunk->orig_commit_id, GIT_OID_SHA1);
76
- git_oid_clear(&hunk->final_commit_id, GIT_OID_SHA1);
76
+ git_oid_clear(&hunk->orig_commit_id, blame->repository->oid_type);
77
+ git_oid_clear(&hunk->final_commit_id, blame->repository->oid_type);
77
78
 
78
79
  return hunk;
79
80
  }
@@ -86,13 +87,14 @@ static void free_hunk(git_blame_hunk *hunk)
86
87
  git__free(hunk);
87
88
  }
88
89
 
89
- static git_blame_hunk *dup_hunk(git_blame_hunk *hunk)
90
+ static git_blame_hunk *dup_hunk(git_blame_hunk *hunk, git_blame *blame)
90
91
  {
91
92
  git_blame_hunk *newhunk = new_hunk(
92
93
  hunk->final_start_line_number,
93
94
  hunk->lines_in_hunk,
94
95
  hunk->orig_start_line_number,
95
- hunk->orig_path);
96
+ hunk->orig_path,
97
+ blame);
96
98
 
97
99
  if (!newhunk)
98
100
  return NULL;
@@ -237,7 +239,8 @@ static git_blame_hunk *split_hunk_in_vector(
237
239
  git_vector *vec,
238
240
  git_blame_hunk *hunk,
239
241
  size_t rel_line,
240
- bool return_new)
242
+ bool return_new,
243
+ git_blame *blame)
241
244
  {
242
245
  size_t new_line_count;
243
246
  git_blame_hunk *nh;
@@ -250,8 +253,9 @@ static git_blame_hunk *split_hunk_in_vector(
250
253
  }
251
254
 
252
255
  new_line_count = hunk->lines_in_hunk - rel_line;
253
- nh = new_hunk(hunk->final_start_line_number + rel_line, new_line_count,
254
- hunk->orig_start_line_number + rel_line, hunk->orig_path);
256
+ nh = new_hunk(hunk->final_start_line_number + rel_line,
257
+ new_line_count, hunk->orig_start_line_number + rel_line,
258
+ hunk->orig_path, blame);
255
259
 
256
260
  if (!nh)
257
261
  return NULL;
@@ -304,7 +308,8 @@ static int index_blob_lines(git_blame *blame)
304
308
  static git_blame_hunk *hunk_from_entry(git_blame__entry *e, git_blame *blame)
305
309
  {
306
310
  git_blame_hunk *h = new_hunk(
307
- e->lno+1, e->num_lines, e->s_lno+1, e->suspect->path);
311
+ e->lno+1, e->num_lines, e->s_lno+1, e->suspect->path,
312
+ blame);
308
313
 
309
314
  if (!h)
310
315
  return NULL;
@@ -445,14 +450,16 @@ static int buffer_hunk_cb(
445
450
  blame->current_hunk = (git_blame_hunk*)git_blame_get_hunk_byline(blame, wedge_line);
446
451
  if (!blame->current_hunk) {
447
452
  /* Line added at the end of the file */
448
- blame->current_hunk = new_hunk(wedge_line, 0, wedge_line, blame->path);
453
+ blame->current_hunk = new_hunk(wedge_line, 0, wedge_line,
454
+ blame->path, blame);
449
455
  GIT_ERROR_CHECK_ALLOC(blame->current_hunk);
450
456
 
451
457
  git_vector_insert(&blame->hunks, blame->current_hunk);
452
458
  } else if (!hunk_starts_at_or_after_line(blame->current_hunk, wedge_line)){
453
459
  /* If this hunk doesn't start between existing hunks, split a hunk up so it does */
454
460
  blame->current_hunk = split_hunk_in_vector(&blame->hunks, blame->current_hunk,
455
- wedge_line - blame->current_hunk->orig_start_line_number, true);
461
+ wedge_line - blame->current_hunk->orig_start_line_number, true,
462
+ blame);
456
463
  GIT_ERROR_CHECK_ALLOC(blame->current_hunk);
457
464
  }
458
465
 
@@ -481,7 +488,7 @@ static int buffer_line_cb(
481
488
  } else {
482
489
  /* Create a new buffer-blame hunk with this line */
483
490
  shift_hunks_by(&blame->hunks, blame->current_diff_line, 1);
484
- blame->current_hunk = new_hunk(blame->current_diff_line, 1, 0, blame->path);
491
+ blame->current_hunk = new_hunk(blame->current_diff_line, 1, 0, blame->path, blame);
485
492
  GIT_ERROR_CHECK_ALLOC(blame->current_hunk);
486
493
 
487
494
  git_vector_insert_sorted(&blame->hunks, blame->current_hunk, NULL);
@@ -529,7 +536,7 @@ int git_blame_buffer(
529
536
 
530
537
  /* Duplicate all of the hunk structures in the reference blame */
531
538
  git_vector_foreach(&reference->hunks, i, hunk) {
532
- git_blame_hunk *h = dup_hunk(hunk);
539
+ git_blame_hunk *h = dup_hunk(hunk, blame);
533
540
  GIT_ERROR_CHECK_ALLOC(h);
534
541
 
535
542
  git_vector_insert(&blame->hunks, h);
@@ -9,7 +9,6 @@
9
9
 
10
10
  #include "commit.h"
11
11
  #include "blob.h"
12
- #include "xdiff/xinclude.h"
13
12
  #include "diff_xdiff.h"
14
13
 
15
14
  /*
@@ -134,9 +134,9 @@ int git_branch_create(
134
134
  const git_commit *commit,
135
135
  int force)
136
136
  {
137
- char commit_id[GIT_OID_SHA1_HEXSIZE + 1];
137
+ char commit_id[GIT_OID_MAX_HEXSIZE + 1];
138
138
 
139
- git_oid_tostr(commit_id, GIT_OID_SHA1_HEXSIZE + 1, git_commit_id(commit));
139
+ git_oid_tostr(commit_id, GIT_OID_MAX_HEXSIZE + 1, git_commit_id(commit));
140
140
  return create_branch(ref_out, repository, branch_name, commit, commit_id, force);
141
141
  }
142
142
 
@@ -106,10 +106,10 @@ static int cherrypick_state_cleanup(git_repository *repo)
106
106
 
107
107
  static int cherrypick_seterr(git_commit *commit, const char *fmt)
108
108
  {
109
- char commit_oidstr[GIT_OID_SHA1_HEXSIZE + 1];
109
+ char commit_oidstr[GIT_OID_MAX_HEXSIZE + 1];
110
110
 
111
111
  git_error_set(GIT_ERROR_CHERRYPICK, fmt,
112
- git_oid_tostr(commit_oidstr, GIT_OID_SHA1_HEXSIZE + 1, git_commit_id(commit)));
112
+ git_oid_tostr(commit_oidstr, GIT_OID_MAX_HEXSIZE + 1, git_commit_id(commit)));
113
113
 
114
114
  return -1;
115
115
  }
@@ -173,7 +173,7 @@ int git_cherrypick(
173
173
  git_cherrypick_options opts;
174
174
  git_reference *our_ref = NULL;
175
175
  git_commit *our_commit = NULL;
176
- char commit_oidstr[GIT_OID_SHA1_HEXSIZE + 1];
176
+ char commit_oidstr[GIT_OID_MAX_HEXSIZE + 1];
177
177
  const char *commit_msg, *commit_summary;
178
178
  git_str their_label = GIT_STR_INIT;
179
179
  git_index *index = NULL;
@@ -420,7 +420,9 @@ static int clone_into(
420
420
 
421
421
  memcpy(&fetch_opts, opts, sizeof(git_fetch_options));
422
422
  fetch_opts.update_fetchhead = 0;
423
- fetch_opts.download_tags = GIT_REMOTE_DOWNLOAD_TAGS_ALL;
423
+
424
+ if (!opts->depth)
425
+ fetch_opts.download_tags = GIT_REMOTE_DOWNLOAD_TAGS_ALL;
424
426
 
425
427
  if ((error = git_remote_connect_options__from_fetch_opts(&connect_opts, remote, &fetch_opts)) < 0)
426
428
  goto cleanup;
@@ -22,6 +22,7 @@
22
22
  #include "object.h"
23
23
  #include "array.h"
24
24
  #include "oidarray.h"
25
+ #include "grafts.h"
25
26
 
26
27
  void git_commit__free(void *_commit)
27
28
  {
@@ -427,10 +428,6 @@ static int commit_parse(
427
428
  buffer += tree_len;
428
429
  }
429
430
 
430
- /*
431
- * TODO: commit grafts!
432
- */
433
-
434
431
  while (git_object__parse_oid_header(&parent_id,
435
432
  &buffer, buffer_end, "parent ",
436
433
  opts->oid_type) == 0) {
@@ -532,16 +529,41 @@ int git_commit__parse_raw(
532
529
  return commit_parse(commit, data, size, &parse_options);
533
530
  }
534
531
 
532
+ static int assign_commit_parents_from_graft(git_commit *commit, git_commit_graft *graft) {
533
+ size_t idx;
534
+ git_oid *oid;
535
+
536
+ git_array_clear(commit->parent_ids);
537
+ git_array_init_to_size(commit->parent_ids, git_array_size(graft->parents));
538
+ git_array_foreach(graft->parents, idx, oid) {
539
+ git_oid *id = git_array_alloc(commit->parent_ids);
540
+ GIT_ERROR_CHECK_ALLOC(id);
541
+
542
+ git_oid_cpy(id, oid);
543
+ }
544
+
545
+ return 0;
546
+ }
547
+
535
548
  int git_commit__parse_ext(
536
549
  git_commit *commit,
537
550
  git_odb_object *odb_obj,
538
551
  git_commit__parse_options *parse_opts)
539
552
  {
540
- return commit_parse(
541
- commit,
542
- git_odb_object_data(odb_obj),
543
- git_odb_object_size(odb_obj),
544
- parse_opts);
553
+ git_repository *repo = git_object_owner((git_object *)commit);
554
+ git_commit_graft *graft;
555
+ int error;
556
+
557
+ if ((error = commit_parse(commit, git_odb_object_data(odb_obj),
558
+ git_odb_object_size(odb_obj), parse_opts)) < 0)
559
+ return error;
560
+
561
+ /* Perform necessary grafts */
562
+ if (git_grafts_get(&graft, repo->grafts, git_odb_object_id(odb_obj)) != 0 &&
563
+ git_grafts_get(&graft, repo->shallow_grafts, git_odb_object_id(odb_obj)) != 0)
564
+ return 0;
565
+
566
+ return assign_commit_parents_from_graft(commit, graft);
545
567
  }
546
568
 
547
569
  #define GIT_COMMIT_GETTER(_rvalue, _name, _return, _invalid) \