rugged 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (277) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -0
  3. data/README.md +1 -1
  4. data/ext/rugged/rugged.c +7 -4
  5. data/ext/rugged/rugged_object.c +1 -1
  6. data/ext/rugged/rugged_repo.c +3 -3
  7. data/lib/rugged/repository.rb +2 -2
  8. data/lib/rugged/version.rb +1 -1
  9. data/vendor/libgit2/CMakeLists.txt +11 -6
  10. data/vendor/libgit2/COPYING +109 -1
  11. data/vendor/libgit2/cmake/Findfutimens.cmake +14 -0
  12. data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +4 -0
  13. data/vendor/libgit2/cmake/SelectHashes.cmake +1 -0
  14. data/vendor/libgit2/deps/chromium-zlib/CMakeLists.txt +101 -0
  15. data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +17 -5
  16. data/vendor/libgit2/deps/ntlmclient/crypt.h +14 -9
  17. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +20 -20
  18. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +3 -3
  19. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +37 -36
  20. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +4 -3
  21. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +178 -51
  22. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +74 -5
  23. data/vendor/libgit2/deps/ntlmclient/ntlm.c +150 -118
  24. data/vendor/libgit2/deps/ntlmclient/ntlm.h +13 -9
  25. data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +16 -3
  26. data/vendor/libgit2/deps/ntlmclient/unicode.h +10 -4
  27. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +16 -27
  28. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.h +20 -0
  29. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +28 -52
  30. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.h +22 -0
  31. data/vendor/libgit2/include/git2/attr.h +89 -0
  32. data/vendor/libgit2/include/git2/blame.h +93 -42
  33. data/vendor/libgit2/include/git2/blob.h +14 -2
  34. data/vendor/libgit2/include/git2/branch.h +25 -0
  35. data/vendor/libgit2/include/git2/cert.h +42 -5
  36. data/vendor/libgit2/include/git2/checkout.h +28 -12
  37. data/vendor/libgit2/include/git2/commit.h +35 -19
  38. data/vendor/libgit2/include/git2/common.h +14 -4
  39. data/vendor/libgit2/include/git2/deprecated.h +206 -6
  40. data/vendor/libgit2/include/git2/diff.h +34 -19
  41. data/vendor/libgit2/include/git2/errors.h +6 -6
  42. data/vendor/libgit2/include/git2/filter.h +57 -17
  43. data/vendor/libgit2/include/git2/graph.h +20 -2
  44. data/vendor/libgit2/include/git2/index.h +2 -2
  45. data/vendor/libgit2/include/git2/odb.h +29 -0
  46. data/vendor/libgit2/include/git2/patch.h +8 -0
  47. data/vendor/libgit2/include/git2/rebase.h +25 -1
  48. data/vendor/libgit2/include/git2/refs.h +6 -2
  49. data/vendor/libgit2/include/git2/remote.h +59 -6
  50. data/vendor/libgit2/include/git2/revparse.h +5 -5
  51. data/vendor/libgit2/include/git2/status.h +115 -59
  52. data/vendor/libgit2/include/git2/submodule.h +9 -0
  53. data/vendor/libgit2/include/git2/sys/commit_graph.h +174 -0
  54. data/vendor/libgit2/include/git2/sys/filter.h +49 -28
  55. data/vendor/libgit2/include/git2/sys/midx.h +74 -0
  56. data/vendor/libgit2/include/git2/sys/odb_backend.h +7 -0
  57. data/vendor/libgit2/include/git2/sys/transport.h +1 -0
  58. data/vendor/libgit2/include/git2/tag.h +12 -0
  59. data/vendor/libgit2/include/git2/tree.h +0 -14
  60. data/vendor/libgit2/include/git2/types.h +9 -0
  61. data/vendor/libgit2/include/git2/version.h +4 -4
  62. data/vendor/libgit2/include/git2/worktree.h +1 -0
  63. data/vendor/libgit2/src/CMakeLists.txt +25 -4
  64. data/vendor/libgit2/src/alloc.c +21 -8
  65. data/vendor/libgit2/src/allocators/failalloc.c +92 -0
  66. data/vendor/libgit2/src/allocators/failalloc.h +23 -0
  67. data/vendor/libgit2/src/allocators/stdalloc.c +41 -10
  68. data/vendor/libgit2/src/allocators/win32_leakcheck.c +118 -0
  69. data/vendor/libgit2/src/allocators/{win32_crtdbg.h → win32_leakcheck.h} +3 -3
  70. data/vendor/libgit2/src/annotated_commit.c +21 -9
  71. data/vendor/libgit2/src/apply.c +16 -7
  72. data/vendor/libgit2/src/array.h +11 -11
  73. data/vendor/libgit2/src/attr.c +181 -74
  74. data/vendor/libgit2/src/attr_file.c +84 -39
  75. data/vendor/libgit2/src/attr_file.h +32 -11
  76. data/vendor/libgit2/src/attrcache.c +42 -37
  77. data/vendor/libgit2/src/attrcache.h +4 -5
  78. data/vendor/libgit2/src/blame.c +11 -5
  79. data/vendor/libgit2/src/blob.c +35 -24
  80. data/vendor/libgit2/src/branch.c +69 -17
  81. data/vendor/libgit2/src/buffer.c +334 -25
  82. data/vendor/libgit2/src/buffer.h +153 -2
  83. data/vendor/libgit2/src/cache.c +2 -2
  84. data/vendor/libgit2/src/cache.h +7 -7
  85. data/vendor/libgit2/src/cc-compat.h +10 -2
  86. data/vendor/libgit2/src/checkout.c +48 -26
  87. data/vendor/libgit2/src/cherrypick.c +6 -2
  88. data/vendor/libgit2/src/clone.c +41 -47
  89. data/vendor/libgit2/src/commit.c +41 -28
  90. data/vendor/libgit2/src/commit_graph.c +1209 -0
  91. data/vendor/libgit2/src/commit_graph.h +162 -0
  92. data/vendor/libgit2/src/commit_list.c +46 -0
  93. data/vendor/libgit2/src/commit_list.h +2 -0
  94. data/vendor/libgit2/src/common.h +25 -2
  95. data/vendor/libgit2/src/config.c +37 -15
  96. data/vendor/libgit2/src/config_cache.c +5 -3
  97. data/vendor/libgit2/src/config_file.c +16 -8
  98. data/vendor/libgit2/src/config_parse.c +4 -6
  99. data/vendor/libgit2/src/crlf.c +16 -6
  100. data/vendor/libgit2/src/date.c +4 -3
  101. data/vendor/libgit2/src/delta.c +1 -1
  102. data/vendor/libgit2/src/describe.c +6 -3
  103. data/vendor/libgit2/src/diff.c +11 -8
  104. data/vendor/libgit2/src/diff_driver.c +21 -17
  105. data/vendor/libgit2/src/diff_file.c +2 -6
  106. data/vendor/libgit2/src/diff_generate.c +46 -17
  107. data/vendor/libgit2/src/diff_print.c +19 -6
  108. data/vendor/libgit2/src/diff_stats.c +7 -5
  109. data/vendor/libgit2/src/diff_tform.c +9 -8
  110. data/vendor/libgit2/src/diff_xdiff.c +4 -2
  111. data/vendor/libgit2/src/diff_xdiff.h +1 -1
  112. data/vendor/libgit2/src/errors.c +24 -19
  113. data/vendor/libgit2/src/features.h.in +5 -1
  114. data/vendor/libgit2/src/fetch.c +5 -2
  115. data/vendor/libgit2/src/fetchhead.c +8 -4
  116. data/vendor/libgit2/src/filebuf.c +9 -7
  117. data/vendor/libgit2/src/filter.c +206 -110
  118. data/vendor/libgit2/src/filter.h +24 -5
  119. data/vendor/libgit2/src/futils.c +5 -5
  120. data/vendor/libgit2/src/futils.h +1 -1
  121. data/vendor/libgit2/src/graph.c +64 -9
  122. data/vendor/libgit2/src/hash/sha1/collisiondetect.c +3 -3
  123. data/vendor/libgit2/src/hash/sha1/common_crypto.c +3 -3
  124. data/vendor/libgit2/src/hash/sha1/generic.h +1 -1
  125. data/vendor/libgit2/src/hash/sha1/mbedtls.c +12 -12
  126. data/vendor/libgit2/src/hash/sha1/openssl.c +3 -3
  127. data/vendor/libgit2/src/hash/sha1/sha1dc/sha1.c +0 -2
  128. data/vendor/libgit2/src/hash/sha1/win32.c +15 -11
  129. data/vendor/libgit2/src/hash.c +16 -13
  130. data/vendor/libgit2/src/hash.h +1 -1
  131. data/vendor/libgit2/src/hashsig.c +23 -10
  132. data/vendor/libgit2/src/ident.c +13 -3
  133. data/vendor/libgit2/src/ignore.c +35 -19
  134. data/vendor/libgit2/src/index.c +106 -70
  135. data/vendor/libgit2/src/index.h +1 -1
  136. data/vendor/libgit2/src/indexer.c +31 -29
  137. data/vendor/libgit2/src/integer.h +64 -2
  138. data/vendor/libgit2/src/iterator.c +36 -24
  139. data/vendor/libgit2/src/iterator.h +1 -1
  140. data/vendor/libgit2/src/khash.h +2 -11
  141. data/vendor/libgit2/src/{settings.c → libgit2.c} +117 -50
  142. data/vendor/libgit2/src/libgit2.h +15 -0
  143. data/vendor/libgit2/src/mailmap.c +23 -10
  144. data/vendor/libgit2/src/map.h +3 -3
  145. data/vendor/libgit2/src/merge.c +70 -30
  146. data/vendor/libgit2/src/merge.h +2 -1
  147. data/vendor/libgit2/src/merge_driver.c +19 -13
  148. data/vendor/libgit2/src/merge_file.c +11 -3
  149. data/vendor/libgit2/src/message.c +3 -1
  150. data/vendor/libgit2/src/midx.c +471 -10
  151. data/vendor/libgit2/src/midx.h +28 -1
  152. data/vendor/libgit2/src/mwindow.c +103 -59
  153. data/vendor/libgit2/src/mwindow.h +3 -3
  154. data/vendor/libgit2/src/net.c +127 -3
  155. data/vendor/libgit2/src/net.h +16 -2
  156. data/vendor/libgit2/src/netops.c +6 -4
  157. data/vendor/libgit2/src/netops.h +2 -2
  158. data/vendor/libgit2/src/notes.c +10 -10
  159. data/vendor/libgit2/src/object.c +22 -14
  160. data/vendor/libgit2/src/odb.c +285 -48
  161. data/vendor/libgit2/src/odb.h +16 -2
  162. data/vendor/libgit2/src/odb_loose.c +28 -18
  163. data/vendor/libgit2/src/odb_mempack.c +1 -1
  164. data/vendor/libgit2/src/odb_pack.c +391 -114
  165. data/vendor/libgit2/src/oid.c +5 -4
  166. data/vendor/libgit2/src/pack-objects.c +54 -48
  167. data/vendor/libgit2/src/pack.c +329 -119
  168. data/vendor/libgit2/src/pack.h +25 -7
  169. data/vendor/libgit2/src/patch.c +14 -7
  170. data/vendor/libgit2/src/patch_generate.c +2 -2
  171. data/vendor/libgit2/src/patch_parse.c +2 -1
  172. data/vendor/libgit2/src/path.c +98 -53
  173. data/vendor/libgit2/src/path.h +79 -6
  174. data/vendor/libgit2/src/pathspec.c +8 -8
  175. data/vendor/libgit2/src/pool.c +13 -7
  176. data/vendor/libgit2/src/posix.c +11 -3
  177. data/vendor/libgit2/src/reader.c +10 -6
  178. data/vendor/libgit2/src/rebase.c +93 -49
  179. data/vendor/libgit2/src/refdb.c +30 -13
  180. data/vendor/libgit2/src/refdb_fs.c +121 -69
  181. data/vendor/libgit2/src/reflog.c +19 -14
  182. data/vendor/libgit2/src/refs.c +76 -41
  183. data/vendor/libgit2/src/refspec.c +32 -12
  184. data/vendor/libgit2/src/remote.c +272 -102
  185. data/vendor/libgit2/src/remote.h +2 -1
  186. data/vendor/libgit2/src/repository.c +176 -103
  187. data/vendor/libgit2/src/repository.h +12 -1
  188. data/vendor/libgit2/src/reset.c +7 -6
  189. data/vendor/libgit2/src/revert.c +6 -2
  190. data/vendor/libgit2/src/revparse.c +14 -9
  191. data/vendor/libgit2/src/revwalk.c +32 -15
  192. data/vendor/libgit2/src/runtime.c +162 -0
  193. data/vendor/libgit2/src/runtime.h +62 -0
  194. data/vendor/libgit2/src/settings.h +11 -0
  195. data/vendor/libgit2/src/signature.c +6 -5
  196. data/vendor/libgit2/src/sortedcache.h +10 -8
  197. data/vendor/libgit2/src/stash.c +3 -1
  198. data/vendor/libgit2/src/status.c +7 -4
  199. data/vendor/libgit2/src/strarray.c +2 -1
  200. data/vendor/libgit2/src/streams/mbedtls.c +14 -17
  201. data/vendor/libgit2/src/streams/mbedtls.h +1 -1
  202. data/vendor/libgit2/src/streams/openssl.c +101 -201
  203. data/vendor/libgit2/src/streams/openssl.h +9 -1
  204. data/vendor/libgit2/src/streams/openssl_dynamic.c +309 -0
  205. data/vendor/libgit2/src/streams/openssl_dynamic.h +348 -0
  206. data/vendor/libgit2/src/streams/openssl_legacy.c +203 -0
  207. data/vendor/libgit2/src/streams/openssl_legacy.h +63 -0
  208. data/vendor/libgit2/src/streams/registry.c +5 -6
  209. data/vendor/libgit2/src/streams/socket.c +6 -2
  210. data/vendor/libgit2/src/streams/stransport.c +6 -3
  211. data/vendor/libgit2/src/streams/tls.c +5 -3
  212. data/vendor/libgit2/src/submodule.c +128 -62
  213. data/vendor/libgit2/src/submodule.h +9 -9
  214. data/vendor/libgit2/src/sysdir.c +4 -6
  215. data/vendor/libgit2/src/tag.c +47 -11
  216. data/vendor/libgit2/src/thread.c +140 -0
  217. data/vendor/libgit2/src/thread.h +479 -0
  218. data/vendor/libgit2/src/threadstate.c +83 -0
  219. data/vendor/libgit2/src/threadstate.h +24 -0
  220. data/vendor/libgit2/src/trace.c +2 -2
  221. data/vendor/libgit2/src/trace.h +17 -13
  222. data/vendor/libgit2/src/transaction.c +19 -8
  223. data/vendor/libgit2/src/transport.c +3 -3
  224. data/vendor/libgit2/src/transports/auth.c +1 -1
  225. data/vendor/libgit2/src/transports/auth_negotiate.c +11 -4
  226. data/vendor/libgit2/src/transports/auth_ntlm.c +10 -6
  227. data/vendor/libgit2/src/transports/credential.c +15 -7
  228. data/vendor/libgit2/src/transports/git.c +1 -3
  229. data/vendor/libgit2/src/transports/http.c +19 -17
  230. data/vendor/libgit2/src/transports/http.h +1 -0
  231. data/vendor/libgit2/src/transports/httpclient.c +53 -26
  232. data/vendor/libgit2/src/transports/httpclient.h +1 -1
  233. data/vendor/libgit2/src/transports/local.c +3 -3
  234. data/vendor/libgit2/src/transports/smart.c +12 -7
  235. data/vendor/libgit2/src/transports/smart.h +1 -1
  236. data/vendor/libgit2/src/transports/smart_protocol.c +11 -5
  237. data/vendor/libgit2/src/transports/ssh.c +51 -17
  238. data/vendor/libgit2/src/transports/winhttp.c +41 -31
  239. data/vendor/libgit2/src/tree.c +100 -77
  240. data/vendor/libgit2/src/tree.h +1 -0
  241. data/vendor/libgit2/src/tsort.c +0 -2
  242. data/vendor/libgit2/src/unix/map.c +3 -1
  243. data/vendor/libgit2/src/unix/pthread.h +2 -1
  244. data/vendor/libgit2/src/utf8.c +150 -0
  245. data/vendor/libgit2/src/utf8.h +52 -0
  246. data/vendor/libgit2/src/util.c +53 -129
  247. data/vendor/libgit2/src/util.h +33 -39
  248. data/vendor/libgit2/src/vector.c +23 -19
  249. data/vendor/libgit2/src/vector.h +4 -2
  250. data/vendor/libgit2/src/win32/findfile.c +4 -2
  251. data/vendor/libgit2/src/win32/map.c +1 -1
  252. data/vendor/libgit2/src/win32/msvc-compat.h +9 -1
  253. data/vendor/libgit2/src/win32/path_w32.c +22 -24
  254. data/vendor/libgit2/src/win32/path_w32.h +0 -1
  255. data/vendor/libgit2/src/win32/posix_w32.c +7 -1
  256. data/vendor/libgit2/src/win32/precompiled.h +0 -1
  257. data/vendor/libgit2/src/win32/reparse.h +4 -4
  258. data/vendor/libgit2/src/win32/thread.c +24 -15
  259. data/vendor/libgit2/src/win32/thread.h +1 -1
  260. data/vendor/libgit2/src/win32/w32_buffer.c +3 -3
  261. data/vendor/libgit2/src/win32/w32_common.h +18 -9
  262. data/vendor/libgit2/src/win32/{w32_crtdbg_stacktrace.c → w32_leakcheck.c} +269 -33
  263. data/vendor/libgit2/src/win32/w32_leakcheck.h +222 -0
  264. data/vendor/libgit2/src/win32/w32_util.h +6 -6
  265. data/vendor/libgit2/src/worktree.c +27 -16
  266. data/vendor/libgit2/src/zstream.c +1 -1
  267. metadata +32 -16
  268. data/vendor/libgit2/src/allocators/win32_crtdbg.c +0 -118
  269. data/vendor/libgit2/src/buf_text.c +0 -316
  270. data/vendor/libgit2/src/buf_text.h +0 -122
  271. data/vendor/libgit2/src/global.c +0 -363
  272. data/vendor/libgit2/src/global.h +0 -41
  273. data/vendor/libgit2/src/thread-utils.c +0 -58
  274. data/vendor/libgit2/src/thread-utils.h +0 -369
  275. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +0 -127
  276. data/vendor/libgit2/src/win32/w32_stack.c +0 -188
  277. data/vendor/libgit2/src/win32/w32_stack.h +0 -140
@@ -18,11 +18,11 @@
18
18
  #include "buffer.h"
19
19
  #include "common.h"
20
20
  #include "strnlen.h"
21
- #include "thread-utils.h"
21
+ #include "thread.h"
22
22
 
23
23
  #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
24
24
  #define bitsizeof(x) (CHAR_BIT * sizeof(x))
25
- #define MSB(x, bits) ((x) & (~0ULL << (bitsizeof(x) - (bits))))
25
+ #define MSB(x, bits) ((x) & (~UINT64_C(0) << (bitsizeof(x) - (bits))))
26
26
  #ifndef min
27
27
  # define min(a,b) ((a) < (b) ? (a) : (b))
28
28
  #endif
@@ -168,30 +168,41 @@ extern int git__strncasecmp(const char *a, const char *b, size_t sz);
168
168
 
169
169
  extern int git__strcasesort_cmp(const char *a, const char *b);
170
170
 
171
+ /*
172
+ * Compare some NUL-terminated `a` to a possibly non-NUL terminated
173
+ * `b` of length `b_len`; like `strncmp` but ensuring that
174
+ * `strlen(a) == b_len` as well.
175
+ */
176
+ GIT_INLINE(int) git__strlcmp(const char *a, const char *b, size_t b_len)
177
+ {
178
+ int cmp = strncmp(a, b, b_len);
179
+ return cmp ? cmp : (int)a[b_len];
180
+ }
181
+
171
182
  typedef struct {
172
- git_atomic refcount;
183
+ git_atomic32 refcount;
173
184
  void *owner;
174
185
  } git_refcount;
175
186
 
176
187
  typedef void (*git_refcount_freeptr)(void *r);
177
188
 
178
189
  #define GIT_REFCOUNT_INC(r) { \
179
- git_atomic_inc(&(r)->rc.refcount); \
190
+ git_atomic32_inc(&(r)->rc.refcount); \
180
191
  }
181
192
 
182
193
  #define GIT_REFCOUNT_DEC(_r, do_free) { \
183
194
  git_refcount *r = &(_r)->rc; \
184
- int val = git_atomic_dec(&r->refcount); \
195
+ int val = git_atomic32_dec(&r->refcount); \
185
196
  if (val <= 0 && r->owner == NULL) { do_free(_r); } \
186
197
  }
187
198
 
188
199
  #define GIT_REFCOUNT_OWN(r, o) { \
189
- (void)git__swap((r)->rc.owner, o); \
200
+ (void)git_atomic_swap((r)->rc.owner, o); \
190
201
  }
191
202
 
192
- #define GIT_REFCOUNT_OWNER(r) git__load((r)->rc.owner)
203
+ #define GIT_REFCOUNT_OWNER(r) git_atomic_load((r)->rc.owner)
193
204
 
194
- #define GIT_REFCOUNT_VAL(r) git_atomic_get((r)->rc.refcount)
205
+ #define GIT_REFCOUNT_VAL(r) git_atomic32_get((r)->rc.refcount)
195
206
 
196
207
 
197
208
  static signed char from_hex[] = {
@@ -316,27 +327,6 @@ extern int git__date_rfc2822_fmt(char *out, size_t len, const git_time *date);
316
327
  */
317
328
  extern size_t git__unescape(char *str);
318
329
 
319
- /*
320
- * Iterate through an UTF-8 string, yielding one
321
- * codepoint at a time.
322
- *
323
- * @param str current position in the string
324
- * @param str_len size left in the string; -1 if the string is NULL-terminated
325
- * @param dst pointer where to store the current codepoint
326
- * @return length in bytes of the read codepoint; -1 if the codepoint was invalid
327
- */
328
- extern int git__utf8_iterate(const uint8_t *str, int str_len, int32_t *dst);
329
-
330
- /*
331
- * Iterate through an UTF-8 string and stops after finding any invalid UTF-8
332
- * codepoints.
333
- *
334
- * @param str string to scan
335
- * @param str_len size of the string
336
- * @return length in bytes of the string that contains valid data
337
- */
338
- extern size_t git__utf8_valid_buf_length(const uint8_t *str, size_t str_len);
339
-
340
330
  /*
341
331
  * Safely zero-out memory, making sure that the compiler
342
332
  * doesn't optimize away the operation.
@@ -380,7 +370,7 @@ GIT_INLINE(double) git__timer(void)
380
370
  return (double)time * scaling_factor / 1.0E9;
381
371
  }
382
372
 
383
- #elif defined(AMIGA)
373
+ #elif defined(__amigaos4__)
384
374
 
385
375
  #include <proto/timer.h>
386
376
 
@@ -397,23 +387,27 @@ GIT_INLINE(double) git__timer(void)
397
387
 
398
388
  GIT_INLINE(double) git__timer(void)
399
389
  {
400
- struct timespec tp;
390
+ struct timeval tv;
401
391
 
402
- if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0) {
392
+ #ifdef CLOCK_MONOTONIC
393
+ struct timespec tp;
394
+ if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
403
395
  return (double) tp.tv_sec + (double) tp.tv_nsec / 1.0E9;
404
- } else {
405
- /* Fall back to using gettimeofday */
406
- struct timeval tv;
407
- struct timezone tz;
408
- gettimeofday(&tv, &tz);
409
- return (double)tv.tv_sec + (double)tv.tv_usec / 1.0E6;
410
- }
396
+ #endif
397
+
398
+ /* Fall back to using gettimeofday */
399
+ gettimeofday(&tv, NULL);
400
+ return (double)tv.tv_sec + (double)tv.tv_usec / 1.0E6;
411
401
  }
412
402
 
413
403
  #endif
414
404
 
415
405
  extern int git__getenv(git_buf *out, const char *name);
416
406
 
407
+ extern int git__online_cpus(void);
408
+
409
+ GIT_INLINE(int) git__noop(void) { return 0; }
410
+
417
411
  #include "alloc.h"
418
412
 
419
413
  #endif
@@ -53,7 +53,8 @@ int git_vector_size_hint(git_vector *v, size_t size_hint)
53
53
 
54
54
  int git_vector_dup(git_vector *v, const git_vector *src, git_vector_cmp cmp)
55
55
  {
56
- assert(v && src);
56
+ GIT_ASSERT_ARG(v);
57
+ GIT_ASSERT_ARG(src);
57
58
 
58
59
  v->_alloc_size = 0;
59
60
  v->contents = NULL;
@@ -77,7 +78,8 @@ int git_vector_dup(git_vector *v, const git_vector *src, git_vector_cmp cmp)
77
78
 
78
79
  void git_vector_free(git_vector *v)
79
80
  {
80
- assert(v);
81
+ if (!v)
82
+ return;
81
83
 
82
84
  git__free(v->contents);
83
85
  v->contents = NULL;
@@ -90,7 +92,8 @@ void git_vector_free_deep(git_vector *v)
90
92
  {
91
93
  size_t i;
92
94
 
93
- assert(v);
95
+ if (!v)
96
+ return;
94
97
 
95
98
  for (i = 0; i < v->length; ++i) {
96
99
  git__free(v->contents[i]);
@@ -102,7 +105,7 @@ void git_vector_free_deep(git_vector *v)
102
105
 
103
106
  int git_vector_init(git_vector *v, size_t initial_size, git_vector_cmp cmp)
104
107
  {
105
- assert(v);
108
+ GIT_ASSERT_ARG(v);
106
109
 
107
110
  v->_alloc_size = 0;
108
111
  v->_cmp = cmp;
@@ -131,7 +134,7 @@ void **git_vector_detach(size_t *size, size_t *asize, git_vector *v)
131
134
 
132
135
  int git_vector_insert(git_vector *v, void *element)
133
136
  {
134
- assert(v);
137
+ GIT_ASSERT_ARG(v);
135
138
 
136
139
  if (v->length >= v->_alloc_size &&
137
140
  resize_vector(v, compute_new_size(v)) < 0)
@@ -150,7 +153,8 @@ int git_vector_insert_sorted(
150
153
  int result;
151
154
  size_t pos;
152
155
 
153
- assert(v && v->_cmp);
156
+ GIT_ASSERT_ARG(v);
157
+ GIT_ASSERT(v->_cmp);
154
158
 
155
159
  if (!git_vector_is_sorted(v))
156
160
  git_vector_sort(v);
@@ -180,8 +184,6 @@ int git_vector_insert_sorted(
180
184
 
181
185
  void git_vector_sort(git_vector *v)
182
186
  {
183
- assert(v);
184
-
185
187
  if (git_vector_is_sorted(v) || !v->_cmp)
186
188
  return;
187
189
 
@@ -196,7 +198,9 @@ int git_vector_bsearch2(
196
198
  git_vector_cmp key_lookup,
197
199
  const void *key)
198
200
  {
199
- assert(v && key && key_lookup);
201
+ GIT_ASSERT_ARG(v);
202
+ GIT_ASSERT_ARG(key);
203
+ GIT_ASSERT(key_lookup);
200
204
 
201
205
  /* need comparison function to sort the vector */
202
206
  if (!v->_cmp)
@@ -212,7 +216,9 @@ int git_vector_search2(
212
216
  {
213
217
  size_t i;
214
218
 
215
- assert(v && key && key_lookup);
219
+ GIT_ASSERT_ARG(v);
220
+ GIT_ASSERT_ARG(key);
221
+ GIT_ASSERT(key_lookup);
216
222
 
217
223
  for (i = 0; i < v->length; ++i) {
218
224
  if (key_lookup(key, v->contents[i]) == 0) {
@@ -240,7 +246,7 @@ int git_vector_remove(git_vector *v, size_t idx)
240
246
  {
241
247
  size_t shift_count;
242
248
 
243
- assert(v);
249
+ GIT_ASSERT_ARG(v);
244
250
 
245
251
  if (idx >= v->length)
246
252
  return GIT_ENOTFOUND;
@@ -303,7 +309,6 @@ void git_vector_remove_matching(
303
309
 
304
310
  void git_vector_clear(git_vector *v)
305
311
  {
306
- assert(v);
307
312
  v->length = 0;
308
313
  git_vector_set_sorted(v, 1);
309
314
  }
@@ -312,8 +317,6 @@ void git_vector_swap(git_vector *a, git_vector *b)
312
317
  {
313
318
  git_vector t;
314
319
 
315
- assert(a && b);
316
-
317
320
  if (a != b) {
318
321
  memcpy(&t, a, sizeof(t));
319
322
  memcpy(a, b, sizeof(t));
@@ -340,7 +343,8 @@ int git_vector_insert_null(git_vector *v, size_t idx, size_t insert_len)
340
343
  {
341
344
  size_t new_length;
342
345
 
343
- assert(insert_len > 0 && idx <= v->length);
346
+ GIT_ASSERT_ARG(insert_len > 0);
347
+ GIT_ASSERT_ARG(idx <= v->length);
344
348
 
345
349
  GIT_ERROR_CHECK_ALLOC_ADD(&new_length, v->length, insert_len);
346
350
 
@@ -359,13 +363,13 @@ int git_vector_remove_range(git_vector *v, size_t idx, size_t remove_len)
359
363
  {
360
364
  size_t new_length = v->length - remove_len;
361
365
  size_t end_idx = 0;
362
-
363
- assert(remove_len > 0);
366
+
367
+ GIT_ASSERT_ARG(remove_len > 0);
364
368
 
365
369
  if (git__add_sizet_overflow(&end_idx, idx, remove_len))
366
- assert(0);
370
+ GIT_ASSERT(0);
367
371
 
368
- assert(end_idx <= v->length);
372
+ GIT_ASSERT(end_idx <= v->length);
369
373
 
370
374
  if (end_idx < v->length)
371
375
  memmove(&v->contents[idx], &v->contents[end_idx],
@@ -26,11 +26,13 @@ typedef struct git_vector {
26
26
 
27
27
  #define GIT_VECTOR_INIT {0}
28
28
 
29
- int git_vector_init(git_vector *v, size_t initial_size, git_vector_cmp cmp);
29
+ GIT_WARN_UNUSED_RESULT int git_vector_init(
30
+ git_vector *v, size_t initial_size, git_vector_cmp cmp);
30
31
  void git_vector_free(git_vector *v);
31
32
  void git_vector_free_deep(git_vector *v); /* free each entry and self */
32
33
  void git_vector_clear(git_vector *v);
33
- int git_vector_dup(git_vector *v, const git_vector *src, git_vector_cmp cmp);
34
+ GIT_WARN_UNUSED_RESULT int git_vector_dup(
35
+ git_vector *v, const git_vector *src, git_vector_cmp cmp);
34
36
  void git_vector_swap(git_vector *a, git_vector *b);
35
37
  int git_vector_size_hint(git_vector *v, size_t size_hint);
36
38
 
@@ -53,7 +53,9 @@ static wchar_t* win32_walkpath(wchar_t *path, wchar_t *buf, size_t buflen)
53
53
  {
54
54
  wchar_t term, *base = path;
55
55
 
56
- assert(path && buf && buflen);
56
+ GIT_ASSERT_ARG_WITH_RETVAL(path, NULL);
57
+ GIT_ASSERT_ARG_WITH_RETVAL(buf, NULL);
58
+ GIT_ASSERT_ARG_WITH_RETVAL(buflen, NULL);
57
59
 
58
60
  term = (*path == L'"') ? *path++ : L';';
59
61
 
@@ -109,7 +111,7 @@ static int win32_find_git_in_registry(
109
111
  HKEY hKey;
110
112
  int error = GIT_ENOTFOUND;
111
113
 
112
- assert(buf);
114
+ GIT_ASSERT_ARG(buf);
113
115
 
114
116
  if (!RegOpenKeyExW(hive, key, 0, KEY_READ, &hKey)) {
115
117
  DWORD dwType, cbData;
@@ -117,7 +117,7 @@ int p_munmap(git_map *map)
117
117
  {
118
118
  int error = 0;
119
119
 
120
- assert(map != NULL);
120
+ GIT_ASSERT_ARG(map);
121
121
 
122
122
  if (map->data) {
123
123
  if (!UnmapViewOfFile(map->data)) {
@@ -23,6 +23,14 @@ typedef SSIZE_T ssize_t;
23
23
 
24
24
  #endif
25
25
 
26
- #define GIT_STDLIB_CALL __cdecl
26
+ /*
27
+ * Offer GIT_LIBGIT2_CALL for our calling conventions (__cdecl, always).
28
+ * This is useful for providing callbacks to userspace code.
29
+ *
30
+ * Offer GIT_SYSTEM_CALL for the system calling conventions (__stdcall on
31
+ * Win32). Useful for providing callbacks to system libraries.
32
+ */
33
+ #define GIT_LIBGIT2_CALL __cdecl
34
+ #define GIT_SYSTEM_CALL NTAPI
27
35
 
28
36
  #endif
@@ -170,7 +170,7 @@ static int win32_path_cwd(wchar_t *out, size_t len)
170
170
  * '\'s, but we we add a 'UNC' specifier to the path, plus
171
171
  * a trailing directory separator, plus a NUL.
172
172
  */
173
- if (cwd_len > MAX_PATH - 4) {
173
+ if (cwd_len > GIT_WIN_PATH_MAX - 4) {
174
174
  errno = ENAMETOOLONG;
175
175
  return -1;
176
176
  }
@@ -187,7 +187,7 @@ static int win32_path_cwd(wchar_t *out, size_t len)
187
187
  * working directory. (One character for the directory separator,
188
188
  * one for the null.
189
189
  */
190
- else if (cwd_len > MAX_PATH - 2) {
190
+ else if (cwd_len > GIT_WIN_PATH_MAX - 2) {
191
191
  errno = ENAMETOOLONG;
192
192
  return -1;
193
193
  }
@@ -205,13 +205,13 @@ int git_win32_path_from_utf8(git_win32_path out, const char *src)
205
205
 
206
206
  /* See if this is an absolute path (beginning with a drive letter) */
207
207
  if (git_path_is_absolute(src)) {
208
- if (git__utf8_to_16(dest, MAX_PATH, src) < 0)
208
+ if (git__utf8_to_16(dest, GIT_WIN_PATH_MAX, src) < 0)
209
209
  goto on_error;
210
210
  }
211
211
  /* File-prefixed NT-style paths beginning with \\?\ */
212
212
  else if (path__is_nt_namespace(src)) {
213
213
  /* Skip the NT prefix, the destination already contains it */
214
- if (git__utf8_to_16(dest, MAX_PATH, src + PATH__NT_NAMESPACE_LEN) < 0)
214
+ if (git__utf8_to_16(dest, GIT_WIN_PATH_MAX, src + PATH__NT_NAMESPACE_LEN) < 0)
215
215
  goto on_error;
216
216
  }
217
217
  /* UNC paths */
@@ -220,12 +220,12 @@ int git_win32_path_from_utf8(git_win32_path out, const char *src)
220
220
  dest += 4;
221
221
 
222
222
  /* Skip the leading "\\" */
223
- if (git__utf8_to_16(dest, MAX_PATH - 2, src + 2) < 0)
223
+ if (git__utf8_to_16(dest, GIT_WIN_PATH_MAX - 2, src + 2) < 0)
224
224
  goto on_error;
225
225
  }
226
226
  /* Absolute paths omitting the drive letter */
227
227
  else if (path__startswith_slash(src)) {
228
- if (path__cwd(dest, MAX_PATH) < 0)
228
+ if (path__cwd(dest, GIT_WIN_PATH_MAX) < 0)
229
229
  goto on_error;
230
230
 
231
231
  if (!git_path_is_absolute(dest)) {
@@ -234,19 +234,19 @@ int git_win32_path_from_utf8(git_win32_path out, const char *src)
234
234
  }
235
235
 
236
236
  /* Skip the drive letter specification ("C:") */
237
- if (git__utf8_to_16(dest + 2, MAX_PATH - 2, src) < 0)
237
+ if (git__utf8_to_16(dest + 2, GIT_WIN_PATH_MAX - 2, src) < 0)
238
238
  goto on_error;
239
239
  }
240
240
  /* Relative paths */
241
241
  else {
242
242
  int cwd_len;
243
243
 
244
- if ((cwd_len = win32_path_cwd(dest, MAX_PATH)) < 0)
244
+ if ((cwd_len = win32_path_cwd(dest, GIT_WIN_PATH_MAX)) < 0)
245
245
  goto on_error;
246
246
 
247
247
  dest[cwd_len++] = L'\\';
248
248
 
249
- if (git__utf8_to_16(dest + cwd_len, MAX_PATH - cwd_len, src) < 0)
249
+ if (git__utf8_to_16(dest + cwd_len, GIT_WIN_PATH_MAX - cwd_len, src) < 0)
250
250
  goto on_error;
251
251
  }
252
252
 
@@ -273,7 +273,7 @@ int git_win32_path_relative_from_utf8(git_win32_path out, const char *src)
273
273
  return git_win32_path_from_utf8(out, src);
274
274
  }
275
275
 
276
- if ((len = git__utf8_to_16(dest, MAX_PATH, src)) < 0)
276
+ if ((len = git__utf8_to_16(dest, GIT_WIN_PATH_MAX, src)) < 0)
277
277
  return -1;
278
278
 
279
279
  for (p = dest; p < (dest + len); p++) {
@@ -381,14 +381,14 @@ int git_win32_path_readlink_w(git_win32_path dest, const git_win32_path path)
381
381
 
382
382
  switch (reparse_buf->ReparseTag) {
383
383
  case IO_REPARSE_TAG_SYMLINK:
384
- target = reparse_buf->SymbolicLinkReparseBuffer.PathBuffer +
385
- (reparse_buf->SymbolicLinkReparseBuffer.SubstituteNameOffset / sizeof(WCHAR));
386
- target_len = reparse_buf->SymbolicLinkReparseBuffer.SubstituteNameLength / sizeof(WCHAR);
384
+ target = reparse_buf->ReparseBuffer.SymbolicLink.PathBuffer +
385
+ (reparse_buf->ReparseBuffer.SymbolicLink.SubstituteNameOffset / sizeof(WCHAR));
386
+ target_len = reparse_buf->ReparseBuffer.SymbolicLink.SubstituteNameLength / sizeof(WCHAR);
387
387
  break;
388
388
  case IO_REPARSE_TAG_MOUNT_POINT:
389
- target = reparse_buf->MountPointReparseBuffer.PathBuffer +
390
- (reparse_buf->MountPointReparseBuffer.SubstituteNameOffset / sizeof(WCHAR));
391
- target_len = reparse_buf->MountPointReparseBuffer.SubstituteNameLength / sizeof(WCHAR);
389
+ target = reparse_buf->ReparseBuffer.MountPoint.PathBuffer +
390
+ (reparse_buf->ReparseBuffer.MountPoint.SubstituteNameOffset / sizeof(WCHAR));
391
+ target_len = reparse_buf->ReparseBuffer.MountPoint.SubstituteNameLength / sizeof(WCHAR);
392
392
  break;
393
393
  default:
394
394
  errno = EINVAL;
@@ -492,14 +492,12 @@ size_t git_win32_path_remove_namespace(wchar_t *str, size_t len)
492
492
  prefix_len = CONST_STRLEN(unc_prefix);
493
493
  }
494
494
 
495
- if (remainder) {
496
- /*
497
- * Sanity check that the new string isn't longer than the old one.
498
- * (This could only happen due to programmer error introducing a
499
- * prefix longer than the namespace it replaces.)
500
- */
501
- assert(len >= remainder_len + prefix_len);
502
-
495
+ /*
496
+ * Sanity check that the new string isn't longer than the old one.
497
+ * (This could only happen due to programmer error introducing a
498
+ * prefix longer than the namespace it replaces.)
499
+ */
500
+ if (remainder && len >= remainder_len + prefix_len) {
503
501
  if (prefix)
504
502
  memmove(str, prefix, prefix_len * sizeof(wchar_t));
505
503