rugged 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (288) 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 +18 -5
  16. data/vendor/libgit2/deps/ntlmclient/compat.h +0 -34
  17. data/vendor/libgit2/deps/ntlmclient/crypt.h +14 -9
  18. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +20 -20
  19. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +3 -3
  20. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +37 -36
  21. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +4 -3
  22. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +178 -51
  23. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +74 -5
  24. data/vendor/libgit2/deps/ntlmclient/ntlm.c +156 -124
  25. data/vendor/libgit2/deps/ntlmclient/ntlm.h +13 -9
  26. data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +16 -3
  27. data/vendor/libgit2/deps/ntlmclient/unicode.h +10 -4
  28. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +16 -27
  29. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.h +20 -0
  30. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +28 -52
  31. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.h +22 -0
  32. data/vendor/libgit2/deps/ntlmclient/util.c +15 -1
  33. data/vendor/libgit2/deps/ntlmclient/util.h +2 -1
  34. data/vendor/libgit2/include/git2/apply.h +2 -0
  35. data/vendor/libgit2/include/git2/attr.h +89 -0
  36. data/vendor/libgit2/include/git2/blame.h +93 -42
  37. data/vendor/libgit2/include/git2/blob.h +31 -3
  38. data/vendor/libgit2/include/git2/branch.h +25 -0
  39. data/vendor/libgit2/include/git2/cert.h +42 -5
  40. data/vendor/libgit2/include/git2/checkout.h +28 -12
  41. data/vendor/libgit2/include/git2/commit.h +35 -19
  42. data/vendor/libgit2/include/git2/common.h +19 -4
  43. data/vendor/libgit2/include/git2/config.h +1 -1
  44. data/vendor/libgit2/include/git2/deprecated.h +206 -6
  45. data/vendor/libgit2/include/git2/diff.h +35 -20
  46. data/vendor/libgit2/include/git2/errors.h +6 -6
  47. data/vendor/libgit2/include/git2/filter.h +57 -17
  48. data/vendor/libgit2/include/git2/graph.h +20 -2
  49. data/vendor/libgit2/include/git2/index.h +3 -3
  50. data/vendor/libgit2/include/git2/indexer.h +2 -1
  51. data/vendor/libgit2/include/git2/odb.h +44 -20
  52. data/vendor/libgit2/include/git2/patch.h +8 -0
  53. data/vendor/libgit2/include/git2/rebase.h +25 -1
  54. data/vendor/libgit2/include/git2/refs.h +9 -5
  55. data/vendor/libgit2/include/git2/remote.h +59 -6
  56. data/vendor/libgit2/include/git2/repository.h +95 -52
  57. data/vendor/libgit2/include/git2/revparse.h +5 -5
  58. data/vendor/libgit2/include/git2/status.h +115 -59
  59. data/vendor/libgit2/include/git2/submodule.h +9 -0
  60. data/vendor/libgit2/include/git2/sys/commit_graph.h +174 -0
  61. data/vendor/libgit2/include/git2/sys/filter.h +49 -28
  62. data/vendor/libgit2/include/git2/sys/midx.h +74 -0
  63. data/vendor/libgit2/include/git2/sys/odb_backend.h +7 -0
  64. data/vendor/libgit2/include/git2/sys/transport.h +1 -0
  65. data/vendor/libgit2/include/git2/tag.h +12 -0
  66. data/vendor/libgit2/include/git2/transport.h +1 -1
  67. data/vendor/libgit2/include/git2/tree.h +2 -14
  68. data/vendor/libgit2/include/git2/types.h +9 -0
  69. data/vendor/libgit2/include/git2/version.h +3 -3
  70. data/vendor/libgit2/include/git2/worktree.h +1 -0
  71. data/vendor/libgit2/src/CMakeLists.txt +25 -4
  72. data/vendor/libgit2/src/alloc.c +21 -8
  73. data/vendor/libgit2/src/allocators/failalloc.c +92 -0
  74. data/vendor/libgit2/src/allocators/failalloc.h +23 -0
  75. data/vendor/libgit2/src/allocators/stdalloc.c +41 -10
  76. data/vendor/libgit2/src/allocators/win32_leakcheck.c +118 -0
  77. data/vendor/libgit2/src/allocators/{win32_crtdbg.h → win32_leakcheck.h} +3 -3
  78. data/vendor/libgit2/src/annotated_commit.c +21 -9
  79. data/vendor/libgit2/src/apply.c +16 -7
  80. data/vendor/libgit2/src/array.h +11 -11
  81. data/vendor/libgit2/src/attr.c +181 -74
  82. data/vendor/libgit2/src/attr_file.c +84 -39
  83. data/vendor/libgit2/src/attr_file.h +32 -11
  84. data/vendor/libgit2/src/attrcache.c +42 -37
  85. data/vendor/libgit2/src/attrcache.h +4 -5
  86. data/vendor/libgit2/src/blame.c +26 -15
  87. data/vendor/libgit2/src/blob.c +44 -24
  88. data/vendor/libgit2/src/branch.c +69 -17
  89. data/vendor/libgit2/src/buffer.c +334 -25
  90. data/vendor/libgit2/src/buffer.h +153 -2
  91. data/vendor/libgit2/src/cache.c +2 -2
  92. data/vendor/libgit2/src/cache.h +7 -7
  93. data/vendor/libgit2/src/cc-compat.h +10 -2
  94. data/vendor/libgit2/src/checkout.c +48 -26
  95. data/vendor/libgit2/src/cherrypick.c +6 -2
  96. data/vendor/libgit2/src/clone.c +26 -11
  97. data/vendor/libgit2/src/commit.c +41 -28
  98. data/vendor/libgit2/src/commit_graph.c +1209 -0
  99. data/vendor/libgit2/src/commit_graph.h +162 -0
  100. data/vendor/libgit2/src/commit_list.c +46 -0
  101. data/vendor/libgit2/src/commit_list.h +2 -0
  102. data/vendor/libgit2/src/common.h +25 -2
  103. data/vendor/libgit2/src/config.c +37 -15
  104. data/vendor/libgit2/src/config_cache.c +9 -4
  105. data/vendor/libgit2/src/config_file.c +16 -8
  106. data/vendor/libgit2/src/config_parse.c +4 -6
  107. data/vendor/libgit2/src/crlf.c +16 -6
  108. data/vendor/libgit2/src/date.c +4 -3
  109. data/vendor/libgit2/src/delta.c +1 -1
  110. data/vendor/libgit2/src/describe.c +6 -3
  111. data/vendor/libgit2/src/diff.c +11 -8
  112. data/vendor/libgit2/src/diff_driver.c +21 -17
  113. data/vendor/libgit2/src/diff_file.c +2 -6
  114. data/vendor/libgit2/src/diff_generate.c +46 -17
  115. data/vendor/libgit2/src/diff_print.c +19 -6
  116. data/vendor/libgit2/src/diff_stats.c +7 -5
  117. data/vendor/libgit2/src/diff_tform.c +11 -10
  118. data/vendor/libgit2/src/diff_xdiff.c +4 -2
  119. data/vendor/libgit2/src/diff_xdiff.h +1 -1
  120. data/vendor/libgit2/src/errors.c +24 -19
  121. data/vendor/libgit2/src/features.h.in +5 -1
  122. data/vendor/libgit2/src/fetch.c +5 -2
  123. data/vendor/libgit2/src/fetchhead.c +8 -4
  124. data/vendor/libgit2/src/filebuf.c +9 -7
  125. data/vendor/libgit2/src/filter.c +206 -110
  126. data/vendor/libgit2/src/filter.h +24 -5
  127. data/vendor/libgit2/src/futils.c +5 -5
  128. data/vendor/libgit2/src/futils.h +1 -1
  129. data/vendor/libgit2/src/graph.c +64 -9
  130. data/vendor/libgit2/src/hash/sha1/collisiondetect.c +3 -3
  131. data/vendor/libgit2/src/hash/sha1/common_crypto.c +3 -3
  132. data/vendor/libgit2/src/hash/sha1/generic.h +1 -1
  133. data/vendor/libgit2/src/hash/sha1/mbedtls.c +12 -12
  134. data/vendor/libgit2/src/hash/sha1/openssl.c +3 -3
  135. data/vendor/libgit2/src/hash/sha1/sha1dc/sha1.c +0 -2
  136. data/vendor/libgit2/src/hash/sha1/win32.c +15 -11
  137. data/vendor/libgit2/src/hash.c +16 -13
  138. data/vendor/libgit2/src/hash.h +1 -1
  139. data/vendor/libgit2/src/hashsig.c +23 -10
  140. data/vendor/libgit2/src/ident.c +13 -3
  141. data/vendor/libgit2/src/ignore.c +35 -19
  142. data/vendor/libgit2/src/index.c +112 -75
  143. data/vendor/libgit2/src/index.h +1 -1
  144. data/vendor/libgit2/src/indexer.c +50 -32
  145. data/vendor/libgit2/src/integer.h +79 -2
  146. data/vendor/libgit2/src/iterator.c +36 -24
  147. data/vendor/libgit2/src/iterator.h +1 -1
  148. data/vendor/libgit2/src/khash.h +2 -11
  149. data/vendor/libgit2/src/{settings.c → libgit2.c} +117 -50
  150. data/vendor/libgit2/src/libgit2.h +15 -0
  151. data/vendor/libgit2/src/mailmap.c +23 -10
  152. data/vendor/libgit2/src/map.h +3 -3
  153. data/vendor/libgit2/src/merge.c +75 -32
  154. data/vendor/libgit2/src/merge.h +2 -1
  155. data/vendor/libgit2/src/merge_driver.c +19 -13
  156. data/vendor/libgit2/src/merge_file.c +11 -3
  157. data/vendor/libgit2/src/message.c +3 -1
  158. data/vendor/libgit2/src/midx.c +471 -10
  159. data/vendor/libgit2/src/midx.h +28 -1
  160. data/vendor/libgit2/src/mwindow.c +106 -60
  161. data/vendor/libgit2/src/mwindow.h +3 -3
  162. data/vendor/libgit2/src/net.c +127 -3
  163. data/vendor/libgit2/src/net.h +16 -2
  164. data/vendor/libgit2/src/netops.c +6 -4
  165. data/vendor/libgit2/src/netops.h +2 -2
  166. data/vendor/libgit2/src/notes.c +10 -10
  167. data/vendor/libgit2/src/object.c +22 -14
  168. data/vendor/libgit2/src/odb.c +289 -51
  169. data/vendor/libgit2/src/odb.h +16 -2
  170. data/vendor/libgit2/src/odb_loose.c +28 -18
  171. data/vendor/libgit2/src/odb_mempack.c +1 -1
  172. data/vendor/libgit2/src/odb_pack.c +391 -114
  173. data/vendor/libgit2/src/oid.c +5 -4
  174. data/vendor/libgit2/src/pack-objects.c +54 -48
  175. data/vendor/libgit2/src/pack.c +339 -125
  176. data/vendor/libgit2/src/pack.h +25 -7
  177. data/vendor/libgit2/src/patch.c +14 -7
  178. data/vendor/libgit2/src/patch_generate.c +2 -2
  179. data/vendor/libgit2/src/patch_parse.c +2 -1
  180. data/vendor/libgit2/src/path.c +98 -53
  181. data/vendor/libgit2/src/path.h +79 -6
  182. data/vendor/libgit2/src/pathspec.c +8 -8
  183. data/vendor/libgit2/src/pool.c +13 -7
  184. data/vendor/libgit2/src/posix.c +43 -12
  185. data/vendor/libgit2/src/posix.h +9 -0
  186. data/vendor/libgit2/src/reader.c +10 -6
  187. data/vendor/libgit2/src/rebase.c +93 -49
  188. data/vendor/libgit2/src/refdb.c +30 -13
  189. data/vendor/libgit2/src/refdb_fs.c +125 -71
  190. data/vendor/libgit2/src/reflog.c +19 -14
  191. data/vendor/libgit2/src/refs.c +91 -43
  192. data/vendor/libgit2/src/refs.h +1 -1
  193. data/vendor/libgit2/src/refspec.c +80 -44
  194. data/vendor/libgit2/src/remote.c +281 -105
  195. data/vendor/libgit2/src/remote.h +2 -1
  196. data/vendor/libgit2/src/repository.c +191 -118
  197. data/vendor/libgit2/src/repository.h +13 -2
  198. data/vendor/libgit2/src/reset.c +7 -6
  199. data/vendor/libgit2/src/revert.c +6 -2
  200. data/vendor/libgit2/src/revparse.c +14 -9
  201. data/vendor/libgit2/src/revwalk.c +32 -15
  202. data/vendor/libgit2/src/runtime.c +162 -0
  203. data/vendor/libgit2/src/runtime.h +62 -0
  204. data/vendor/libgit2/src/settings.h +11 -0
  205. data/vendor/libgit2/src/signature.c +6 -5
  206. data/vendor/libgit2/src/sortedcache.h +10 -8
  207. data/vendor/libgit2/src/stash.c +3 -1
  208. data/vendor/libgit2/src/status.c +7 -4
  209. data/vendor/libgit2/src/strarray.c +2 -1
  210. data/vendor/libgit2/src/streams/mbedtls.c +14 -17
  211. data/vendor/libgit2/src/streams/mbedtls.h +1 -1
  212. data/vendor/libgit2/src/streams/openssl.c +101 -201
  213. data/vendor/libgit2/src/streams/openssl.h +9 -1
  214. data/vendor/libgit2/src/streams/openssl_dynamic.c +309 -0
  215. data/vendor/libgit2/src/streams/openssl_dynamic.h +348 -0
  216. data/vendor/libgit2/src/streams/openssl_legacy.c +203 -0
  217. data/vendor/libgit2/src/streams/openssl_legacy.h +63 -0
  218. data/vendor/libgit2/src/streams/registry.c +5 -6
  219. data/vendor/libgit2/src/streams/socket.c +6 -2
  220. data/vendor/libgit2/src/streams/stransport.c +6 -3
  221. data/vendor/libgit2/src/streams/tls.c +5 -3
  222. data/vendor/libgit2/src/submodule.c +128 -62
  223. data/vendor/libgit2/src/submodule.h +9 -9
  224. data/vendor/libgit2/src/sysdir.c +4 -6
  225. data/vendor/libgit2/src/tag.c +47 -11
  226. data/vendor/libgit2/src/thread.c +140 -0
  227. data/vendor/libgit2/src/thread.h +479 -0
  228. data/vendor/libgit2/src/threadstate.c +83 -0
  229. data/vendor/libgit2/src/threadstate.h +24 -0
  230. data/vendor/libgit2/src/trace.c +2 -2
  231. data/vendor/libgit2/src/trace.h +17 -13
  232. data/vendor/libgit2/src/transaction.c +19 -8
  233. data/vendor/libgit2/src/transport.c +3 -3
  234. data/vendor/libgit2/src/transports/auth.c +1 -1
  235. data/vendor/libgit2/src/transports/auth_negotiate.c +11 -4
  236. data/vendor/libgit2/src/transports/auth_ntlm.c +10 -6
  237. data/vendor/libgit2/src/transports/credential.c +15 -7
  238. data/vendor/libgit2/src/transports/git.c +1 -3
  239. data/vendor/libgit2/src/transports/http.c +19 -17
  240. data/vendor/libgit2/src/transports/http.h +1 -0
  241. data/vendor/libgit2/src/transports/httpclient.c +62 -30
  242. data/vendor/libgit2/src/transports/httpclient.h +1 -1
  243. data/vendor/libgit2/src/transports/local.c +3 -3
  244. data/vendor/libgit2/src/transports/smart.c +12 -7
  245. data/vendor/libgit2/src/transports/smart.h +1 -1
  246. data/vendor/libgit2/src/transports/smart_protocol.c +11 -5
  247. data/vendor/libgit2/src/transports/ssh.c +51 -17
  248. data/vendor/libgit2/src/transports/winhttp.c +138 -81
  249. data/vendor/libgit2/src/tree.c +100 -77
  250. data/vendor/libgit2/src/tree.h +1 -0
  251. data/vendor/libgit2/src/tsort.c +0 -2
  252. data/vendor/libgit2/src/unix/map.c +3 -1
  253. data/vendor/libgit2/src/unix/posix.h +3 -0
  254. data/vendor/libgit2/src/unix/pthread.h +2 -1
  255. data/vendor/libgit2/src/utf8.c +150 -0
  256. data/vendor/libgit2/src/utf8.h +52 -0
  257. data/vendor/libgit2/src/util.c +53 -129
  258. data/vendor/libgit2/src/util.h +33 -39
  259. data/vendor/libgit2/src/vector.c +23 -19
  260. data/vendor/libgit2/src/vector.h +4 -2
  261. data/vendor/libgit2/src/win32/findfile.c +4 -2
  262. data/vendor/libgit2/src/win32/map.c +1 -1
  263. data/vendor/libgit2/src/win32/msvc-compat.h +9 -1
  264. data/vendor/libgit2/src/win32/path_w32.c +22 -24
  265. data/vendor/libgit2/src/win32/path_w32.h +0 -1
  266. data/vendor/libgit2/src/win32/posix_w32.c +77 -1
  267. data/vendor/libgit2/src/win32/precompiled.h +0 -1
  268. data/vendor/libgit2/src/win32/reparse.h +4 -4
  269. data/vendor/libgit2/src/win32/thread.c +24 -15
  270. data/vendor/libgit2/src/win32/thread.h +1 -1
  271. data/vendor/libgit2/src/win32/w32_buffer.c +3 -3
  272. data/vendor/libgit2/src/win32/w32_common.h +18 -9
  273. data/vendor/libgit2/src/win32/{w32_crtdbg_stacktrace.c → w32_leakcheck.c} +269 -33
  274. data/vendor/libgit2/src/win32/w32_leakcheck.h +222 -0
  275. data/vendor/libgit2/src/win32/w32_util.h +6 -6
  276. data/vendor/libgit2/src/worktree.c +32 -14
  277. data/vendor/libgit2/src/zstream.c +1 -1
  278. metadata +32 -16
  279. data/vendor/libgit2/src/allocators/win32_crtdbg.c +0 -118
  280. data/vendor/libgit2/src/buf_text.c +0 -316
  281. data/vendor/libgit2/src/buf_text.h +0 -122
  282. data/vendor/libgit2/src/global.c +0 -363
  283. data/vendor/libgit2/src/global.h +0 -41
  284. data/vendor/libgit2/src/thread-utils.c +0 -58
  285. data/vendor/libgit2/src/thread-utils.h +0 -364
  286. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +0 -127
  287. data/vendor/libgit2/src/win32/w32_stack.c +0 -188
  288. data/vendor/libgit2/src/win32/w32_stack.h +0 -140
@@ -13,6 +13,11 @@
13
13
  # include "win32/utf-conv.h"
14
14
  # include "win32/w32_buffer.h"
15
15
 
16
+ # ifndef WIN32_LEAN_AND_MEAN
17
+ # define WIN32_LEAN_AND_MEAN
18
+ # endif
19
+ # include <windows.h>
20
+
16
21
  # ifdef HAVE_QSORT_S
17
22
  # include <search.h>
18
23
  # endif
@@ -22,11 +27,15 @@
22
27
  # include <Shlwapi.h>
23
28
  #endif
24
29
 
30
+ #if defined(hpux) || defined(__hpux) || defined(_hpux)
31
+ # include <sys/pstat.h>
32
+ #endif
33
+
25
34
  int git__strntol64(int64_t *result, const char *nptr, size_t nptr_len, const char **endptr, int base)
26
35
  {
27
36
  const char *p;
28
- int64_t n, nn;
29
- int c, ovfl, v, neg, ndig;
37
+ int64_t n, nn, v;
38
+ int c, ovfl, neg, ndig;
30
39
 
31
40
  p = nptr;
32
41
  neg = 0;
@@ -101,19 +110,11 @@ int git__strntol64(int64_t *result, const char *nptr, size_t nptr_len, const cha
101
110
  if (v >= base)
102
111
  break;
103
112
  v = neg ? -v : v;
104
- if (n > INT64_MAX / base || n < INT64_MIN / base) {
105
- ovfl = 1;
106
- /* Keep on iterating until the end of this number */
107
- continue;
108
- }
109
- nn = n * base;
110
- if ((v > 0 && nn > INT64_MAX - v) ||
111
- (v < 0 && nn < INT64_MIN - v)) {
113
+ if (git__multiply_int64_overflow(&nn, n, base) || git__add_int64_overflow(&n, nn, v)) {
112
114
  ovfl = 1;
113
115
  /* Keep on iterating until the end of this number */
114
116
  continue;
115
117
  }
116
- n = nn + v;
117
118
  }
118
119
 
119
120
  Return:
@@ -678,7 +679,7 @@ typedef struct {
678
679
  void *payload;
679
680
  } git__qsort_r_glue;
680
681
 
681
- static int GIT_STDLIB_CALL git__qsort_r_glue_cmp(
682
+ static int GIT_LIBGIT2_CALL git__qsort_r_glue_cmp(
682
683
  void *payload, const void *a, const void *b)
683
684
  {
684
685
  git__qsort_r_glue *glue = payload;
@@ -733,123 +734,6 @@ void git__qsort_r(
733
734
  #endif
734
735
  }
735
736
 
736
- /*
737
- * git__utf8_iterate is taken from the utf8proc project,
738
- * http://www.public-software-group.org/utf8proc
739
- *
740
- * Copyright (c) 2009 Public Software Group e. V., Berlin, Germany
741
- *
742
- * Permission is hereby granted, free of charge, to any person obtaining a
743
- * copy of this software and associated documentation files (the ""Software""),
744
- * to deal in the Software without restriction, including without limitation
745
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
746
- * and/or sell copies of the Software, and to permit persons to whom the
747
- * Software is furnished to do so, subject to the following conditions:
748
- *
749
- * The above copyright notice and this permission notice shall be included in
750
- * all copies or substantial portions of the Software.
751
- *
752
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
753
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
754
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
755
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
756
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
757
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
758
- * DEALINGS IN THE SOFTWARE.
759
- */
760
-
761
- static const int8_t utf8proc_utf8class[256] = {
762
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
763
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
764
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
765
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
766
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
767
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
768
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
769
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
770
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
771
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
772
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
773
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
774
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
775
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
776
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
777
- 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0
778
- };
779
-
780
- static int util_utf8_charlen(const uint8_t *str, size_t str_len)
781
- {
782
- size_t length, i;
783
-
784
- length = utf8proc_utf8class[str[0]];
785
- if (!length)
786
- return -1;
787
-
788
- if (str_len > 0 && length > str_len)
789
- return -1;
790
-
791
- for (i = 1; i < length; i++) {
792
- if ((str[i] & 0xC0) != 0x80)
793
- return -1;
794
- }
795
-
796
- return (int)length;
797
- }
798
-
799
- int git__utf8_iterate(const uint8_t *str, int str_len, int32_t *dst)
800
- {
801
- int length;
802
- int32_t uc = -1;
803
-
804
- *dst = -1;
805
- length = util_utf8_charlen(str, str_len);
806
- if (length < 0)
807
- return -1;
808
-
809
- switch (length) {
810
- case 1:
811
- uc = str[0];
812
- break;
813
- case 2:
814
- uc = ((str[0] & 0x1F) << 6) + (str[1] & 0x3F);
815
- if (uc < 0x80) uc = -1;
816
- break;
817
- case 3:
818
- uc = ((str[0] & 0x0F) << 12) + ((str[1] & 0x3F) << 6)
819
- + (str[2] & 0x3F);
820
- if (uc < 0x800 || (uc >= 0xD800 && uc < 0xE000) ||
821
- (uc >= 0xFDD0 && uc < 0xFDF0)) uc = -1;
822
- break;
823
- case 4:
824
- uc = ((str[0] & 0x07) << 18) + ((str[1] & 0x3F) << 12)
825
- + ((str[2] & 0x3F) << 6) + (str[3] & 0x3F);
826
- if (uc < 0x10000 || uc >= 0x110000) uc = -1;
827
- break;
828
- }
829
-
830
- if (uc < 0 || ((uc & 0xFFFF) >= 0xFFFE))
831
- return -1;
832
-
833
- *dst = uc;
834
- return length;
835
- }
836
-
837
- size_t git__utf8_valid_buf_length(const uint8_t *str, size_t str_len)
838
- {
839
- size_t offset = 0;
840
-
841
- while (offset < str_len) {
842
- int length = util_utf8_charlen(str + offset, str_len - offset);
843
-
844
- if (length < 0)
845
- break;
846
-
847
- offset += length;
848
- }
849
-
850
- return offset;
851
- }
852
-
853
737
  #ifdef GIT_WIN32
854
738
  int git__getenv(git_buf *out, const char *name)
855
739
  {
@@ -893,3 +777,43 @@ int git__getenv(git_buf *out, const char *name)
893
777
  return git_buf_puts(out, val);
894
778
  }
895
779
  #endif
780
+
781
+ /*
782
+ * By doing this in two steps we can at least get
783
+ * the function to be somewhat coherent, even
784
+ * with this disgusting nest of #ifdefs.
785
+ */
786
+ #ifndef _SC_NPROCESSORS_ONLN
787
+ # ifdef _SC_NPROC_ONLN
788
+ # define _SC_NPROCESSORS_ONLN _SC_NPROC_ONLN
789
+ # elif defined _SC_CRAY_NCPU
790
+ # define _SC_NPROCESSORS_ONLN _SC_CRAY_NCPU
791
+ # endif
792
+ #endif
793
+
794
+ int git__online_cpus(void)
795
+ {
796
+ #ifdef _SC_NPROCESSORS_ONLN
797
+ long ncpus;
798
+ #endif
799
+
800
+ #ifdef _WIN32
801
+ SYSTEM_INFO info;
802
+ GetSystemInfo(&info);
803
+
804
+ if ((int)info.dwNumberOfProcessors > 0)
805
+ return (int)info.dwNumberOfProcessors;
806
+ #elif defined(hpux) || defined(__hpux) || defined(_hpux)
807
+ struct pst_dynamic psd;
808
+
809
+ if (!pstat_getdynamic(&psd, sizeof(psd), (size_t)1, 0))
810
+ return (int)psd.psd_proc_cnt;
811
+ #endif
812
+
813
+ #ifdef _SC_NPROCESSORS_ONLN
814
+ if ((ncpus = (long)sysconf(_SC_NPROCESSORS_ONLN)) > 0)
815
+ return (int)ncpus;
816
+ #endif
817
+
818
+ return 1;
819
+ }
@@ -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
 
@@ -8,7 +8,6 @@
8
8
  #define INCLUDE_win32_path_w32_h__
9
9
 
10
10
  #include "common.h"
11
- #include "vector.h"
12
11
 
13
12
  /**
14
13
  * Create a Win32 path (in UCS-2 format) from a UTF-8 string. If the given