rugged 1.5.0.1 → 1.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (250) hide show
  1. checksums.yaml +4 -4
  2. data/ext/rugged/extconf.rb +2 -2
  3. data/ext/rugged/rugged_allocator.c +0 -54
  4. data/ext/rugged/rugged_blame.c +2 -0
  5. data/ext/rugged/rugged_blob.c +3 -0
  6. data/ext/rugged/rugged_commit.c +1 -0
  7. data/ext/rugged/rugged_config.c +2 -0
  8. data/ext/rugged/rugged_diff.c +1 -0
  9. data/ext/rugged/rugged_index.c +2 -0
  10. data/ext/rugged/rugged_patch.c +1 -0
  11. data/ext/rugged/rugged_rebase.c +1 -0
  12. data/ext/rugged/rugged_reference.c +1 -0
  13. data/ext/rugged/rugged_remote.c +1 -0
  14. data/ext/rugged/rugged_repo.c +5 -2
  15. data/ext/rugged/rugged_revwalk.c +5 -1
  16. data/ext/rugged/rugged_submodule.c +1 -0
  17. data/ext/rugged/rugged_tag.c +1 -0
  18. data/ext/rugged/rugged_tree.c +4 -0
  19. data/lib/rugged/index.rb +1 -1
  20. data/lib/rugged/tree.rb +1 -1
  21. data/lib/rugged/version.rb +1 -1
  22. data/vendor/libgit2/CMakeLists.txt +7 -8
  23. data/vendor/libgit2/COPYING +30 -0
  24. data/vendor/libgit2/cmake/CheckPrototypeDefinitionSafe.cmake +16 -0
  25. data/vendor/libgit2/cmake/ExperimentalFeatures.cmake +23 -0
  26. data/vendor/libgit2/cmake/SelectGSSAPI.cmake +3 -3
  27. data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +21 -2
  28. data/vendor/libgit2/cmake/SelectHashes.cmake +4 -0
  29. data/vendor/libgit2/cmake/SelectXdiff.cmake +9 -0
  30. data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +2 -0
  31. data/vendor/libgit2/deps/pcre/LICENCE +5 -5
  32. data/vendor/libgit2/deps/pcre/pcre.h +2 -2
  33. data/vendor/libgit2/deps/pcre/pcre_compile.c +6 -3
  34. data/vendor/libgit2/deps/pcre/pcre_exec.c +2 -2
  35. data/vendor/libgit2/deps/xdiff/CMakeLists.txt +28 -0
  36. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/git-xdiff.h +4 -1
  37. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xdiffi.c +19 -18
  38. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xdiffi.h +2 -4
  39. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xemit.c +3 -3
  40. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xhistogram.c +7 -18
  41. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xmacros.h +18 -1
  42. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xmerge.c +24 -22
  43. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xpatience.c +21 -30
  44. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xprepare.c +13 -30
  45. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xutils.c +18 -1
  46. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xutils.h +2 -1
  47. data/vendor/libgit2/include/git2/common.h +38 -6
  48. data/vendor/libgit2/include/git2/deprecated.h +6 -0
  49. data/vendor/libgit2/include/git2/diff.h +42 -4
  50. data/vendor/libgit2/include/git2/errors.h +4 -2
  51. data/vendor/libgit2/include/git2/experimental.h +20 -0
  52. data/vendor/libgit2/include/git2/index.h +9 -0
  53. data/vendor/libgit2/include/git2/indexer.h +29 -0
  54. data/vendor/libgit2/include/git2/object.h +28 -2
  55. data/vendor/libgit2/include/git2/odb.h +58 -7
  56. data/vendor/libgit2/include/git2/odb_backend.h +106 -18
  57. data/vendor/libgit2/include/git2/oid.h +116 -16
  58. data/vendor/libgit2/include/git2/remote.h +18 -0
  59. data/vendor/libgit2/include/git2/repository.h +32 -3
  60. data/vendor/libgit2/include/git2/stash.h +60 -6
  61. data/vendor/libgit2/include/git2/strarray.h +0 -13
  62. data/vendor/libgit2/include/git2/sys/alloc.h +0 -34
  63. data/vendor/libgit2/include/git2/sys/commit_graph.h +12 -2
  64. data/vendor/libgit2/include/git2/sys/midx.h +5 -1
  65. data/vendor/libgit2/include/git2/sys/odb_backend.h +1 -1
  66. data/vendor/libgit2/include/git2/sys/stream.h +16 -2
  67. data/vendor/libgit2/include/git2/sys/transport.h +32 -2
  68. data/vendor/libgit2/include/git2/version.h +4 -4
  69. data/vendor/libgit2/include/git2/worktree.h +3 -1
  70. data/vendor/libgit2/include/git2.h +1 -0
  71. data/vendor/libgit2/src/CMakeLists.txt +34 -17
  72. data/vendor/libgit2/src/cli/CMakeLists.txt +5 -2
  73. data/vendor/libgit2/src/cli/cmd_clone.c +22 -6
  74. data/vendor/libgit2/src/cli/cmd_hash_object.c +27 -8
  75. data/vendor/libgit2/src/cli/opt.c +1 -1
  76. data/vendor/libgit2/src/cli/progress.c +9 -8
  77. data/vendor/libgit2/src/cli/progress.h +4 -4
  78. data/vendor/libgit2/src/libgit2/CMakeLists.txt +25 -34
  79. data/vendor/libgit2/src/libgit2/annotated_commit.c +2 -2
  80. data/vendor/libgit2/src/libgit2/annotated_commit.h +1 -1
  81. data/vendor/libgit2/src/libgit2/apply.c +4 -3
  82. data/vendor/libgit2/src/libgit2/attr_file.c +1 -1
  83. data/vendor/libgit2/src/libgit2/attrcache.c +1 -1
  84. data/vendor/libgit2/src/libgit2/blame.c +23 -14
  85. data/vendor/libgit2/src/libgit2/blame_git.c +0 -1
  86. data/vendor/libgit2/src/libgit2/blob.c +4 -2
  87. data/vendor/libgit2/src/libgit2/blob.h +2 -2
  88. data/vendor/libgit2/src/libgit2/branch.c +2 -2
  89. data/vendor/libgit2/src/libgit2/cherrypick.c +3 -3
  90. data/vendor/libgit2/src/libgit2/clone.c +34 -3
  91. data/vendor/libgit2/src/libgit2/commit.c +78 -21
  92. data/vendor/libgit2/src/libgit2/commit.h +25 -7
  93. data/vendor/libgit2/src/libgit2/commit_graph.c +129 -47
  94. data/vendor/libgit2/src/libgit2/commit_graph.h +23 -4
  95. data/vendor/libgit2/src/libgit2/commit_list.c +16 -5
  96. data/vendor/libgit2/src/libgit2/commit_list.h +1 -0
  97. data/vendor/libgit2/src/libgit2/config.c +6 -3
  98. data/vendor/libgit2/src/libgit2/config_file.c +16 -10
  99. data/vendor/libgit2/src/libgit2/describe.c +11 -8
  100. data/vendor/libgit2/src/libgit2/diff.c +19 -6
  101. data/vendor/libgit2/src/libgit2/diff.h +6 -6
  102. data/vendor/libgit2/src/libgit2/diff_file.c +16 -7
  103. data/vendor/libgit2/src/libgit2/diff_generate.c +37 -11
  104. data/vendor/libgit2/src/libgit2/diff_parse.c +20 -4
  105. data/vendor/libgit2/src/libgit2/diff_print.c +26 -7
  106. data/vendor/libgit2/src/libgit2/diff_tform.c +4 -0
  107. data/vendor/libgit2/src/libgit2/diff_xdiff.h +1 -1
  108. data/vendor/libgit2/src/libgit2/email.c +4 -3
  109. data/vendor/libgit2/src/libgit2/errors.c +73 -18
  110. data/vendor/libgit2/src/libgit2/experimental.h.in +13 -0
  111. data/vendor/libgit2/src/libgit2/fetch.c +38 -13
  112. data/vendor/libgit2/src/libgit2/fetch.h +0 -2
  113. data/vendor/libgit2/src/libgit2/fetchhead.c +11 -9
  114. data/vendor/libgit2/src/libgit2/grafts.c +272 -0
  115. data/vendor/libgit2/src/libgit2/grafts.h +36 -0
  116. data/vendor/libgit2/src/libgit2/ident.c +3 -3
  117. data/vendor/libgit2/src/libgit2/index.c +327 -123
  118. data/vendor/libgit2/src/libgit2/index.h +14 -1
  119. data/vendor/libgit2/src/libgit2/indexer.c +116 -46
  120. data/vendor/libgit2/src/libgit2/iterator.c +21 -4
  121. data/vendor/libgit2/src/libgit2/iterator.h +3 -0
  122. data/vendor/libgit2/src/libgit2/libgit2.c +58 -0
  123. data/vendor/libgit2/src/libgit2/merge.c +14 -9
  124. data/vendor/libgit2/src/libgit2/merge_file.c +0 -2
  125. data/vendor/libgit2/src/libgit2/midx.c +68 -38
  126. data/vendor/libgit2/src/libgit2/midx.h +13 -3
  127. data/vendor/libgit2/src/libgit2/mwindow.c +5 -2
  128. data/vendor/libgit2/src/libgit2/mwindow.h +4 -1
  129. data/vendor/libgit2/src/libgit2/notes.c +9 -8
  130. data/vendor/libgit2/src/libgit2/object.c +118 -29
  131. data/vendor/libgit2/src/libgit2/object.h +17 -2
  132. data/vendor/libgit2/src/libgit2/odb.c +224 -55
  133. data/vendor/libgit2/src/libgit2/odb.h +43 -4
  134. data/vendor/libgit2/src/libgit2/odb_loose.c +128 -70
  135. data/vendor/libgit2/src/libgit2/odb_pack.c +111 -46
  136. data/vendor/libgit2/src/libgit2/oid.c +141 -77
  137. data/vendor/libgit2/src/libgit2/oid.h +183 -9
  138. data/vendor/libgit2/src/libgit2/oidarray.c +49 -3
  139. data/vendor/libgit2/src/libgit2/oidarray.h +5 -1
  140. data/vendor/libgit2/src/libgit2/pack-objects.c +31 -13
  141. data/vendor/libgit2/src/libgit2/pack-objects.h +5 -2
  142. data/vendor/libgit2/src/libgit2/pack.c +93 -70
  143. data/vendor/libgit2/src/libgit2/pack.h +29 -15
  144. data/vendor/libgit2/src/libgit2/parse.c +8 -4
  145. data/vendor/libgit2/src/libgit2/parse.h +1 -1
  146. data/vendor/libgit2/src/libgit2/patch.h +7 -1
  147. data/vendor/libgit2/src/libgit2/patch_generate.c +24 -5
  148. data/vendor/libgit2/src/libgit2/patch_parse.c +16 -8
  149. data/vendor/libgit2/src/libgit2/push.c +13 -3
  150. data/vendor/libgit2/src/libgit2/reader.c +1 -1
  151. data/vendor/libgit2/src/libgit2/rebase.c +72 -83
  152. data/vendor/libgit2/src/libgit2/refdb_fs.c +92 -52
  153. data/vendor/libgit2/src/libgit2/reflog.c +7 -5
  154. data/vendor/libgit2/src/libgit2/reflog.h +1 -2
  155. data/vendor/libgit2/src/libgit2/refs.c +9 -0
  156. data/vendor/libgit2/src/libgit2/remote.c +47 -37
  157. data/vendor/libgit2/src/libgit2/remote.h +41 -0
  158. data/vendor/libgit2/src/libgit2/repository.c +784 -329
  159. data/vendor/libgit2/src/libgit2/repository.h +26 -2
  160. data/vendor/libgit2/src/libgit2/reset.c +2 -2
  161. data/vendor/libgit2/src/libgit2/revert.c +8 -11
  162. data/vendor/libgit2/src/libgit2/revparse.c +23 -7
  163. data/vendor/libgit2/src/libgit2/revwalk.c +31 -5
  164. data/vendor/libgit2/src/libgit2/stash.c +209 -33
  165. data/vendor/libgit2/src/libgit2/strarray.c +1 -0
  166. data/vendor/libgit2/src/libgit2/strarray.h +25 -0
  167. data/vendor/libgit2/src/libgit2/streams/mbedtls.c +0 -1
  168. data/vendor/libgit2/src/libgit2/streams/openssl.c +9 -17
  169. data/vendor/libgit2/src/libgit2/streams/openssl_dynamic.c +7 -3
  170. data/vendor/libgit2/src/libgit2/streams/schannel.c +715 -0
  171. data/vendor/libgit2/src/libgit2/streams/schannel.h +28 -0
  172. data/vendor/libgit2/src/libgit2/streams/socket.c +240 -51
  173. data/vendor/libgit2/src/libgit2/streams/socket.h +3 -1
  174. data/vendor/libgit2/src/libgit2/streams/stransport.c +40 -12
  175. data/vendor/libgit2/src/libgit2/streams/tls.c +5 -0
  176. data/vendor/libgit2/src/libgit2/submodule.c +6 -2
  177. data/vendor/libgit2/src/libgit2/submodule.h +3 -3
  178. data/vendor/libgit2/src/libgit2/sysdir.c +294 -7
  179. data/vendor/libgit2/src/libgit2/sysdir.h +41 -9
  180. data/vendor/libgit2/src/libgit2/tag.c +29 -10
  181. data/vendor/libgit2/src/libgit2/tag.h +2 -2
  182. data/vendor/libgit2/src/libgit2/threadstate.c +15 -2
  183. data/vendor/libgit2/src/libgit2/threadstate.h +1 -3
  184. data/vendor/libgit2/src/libgit2/transports/auth.h +1 -2
  185. data/vendor/libgit2/src/libgit2/transports/{auth_negotiate.c → auth_gssapi.c} +32 -32
  186. data/vendor/libgit2/src/libgit2/transports/auth_negotiate.h +1 -1
  187. data/vendor/libgit2/src/libgit2/transports/auth_ntlm.h +1 -1
  188. data/vendor/libgit2/src/libgit2/transports/{auth_ntlm.c → auth_ntlmclient.c} +12 -12
  189. data/vendor/libgit2/src/libgit2/transports/auth_sspi.c +341 -0
  190. data/vendor/libgit2/src/libgit2/transports/git.c +7 -8
  191. data/vendor/libgit2/src/libgit2/transports/http.c +15 -9
  192. data/vendor/libgit2/src/libgit2/transports/httpclient.c +14 -0
  193. data/vendor/libgit2/src/libgit2/transports/httpclient.h +10 -0
  194. data/vendor/libgit2/src/libgit2/transports/local.c +27 -4
  195. data/vendor/libgit2/src/libgit2/transports/smart.c +68 -27
  196. data/vendor/libgit2/src/libgit2/transports/smart.h +33 -9
  197. data/vendor/libgit2/src/libgit2/transports/smart_pkt.c +281 -49
  198. data/vendor/libgit2/src/libgit2/transports/smart_protocol.c +192 -55
  199. data/vendor/libgit2/src/libgit2/transports/ssh.c +334 -102
  200. data/vendor/libgit2/src/libgit2/transports/winhttp.c +22 -18
  201. data/vendor/libgit2/src/libgit2/tree-cache.c +26 -16
  202. data/vendor/libgit2/src/libgit2/tree-cache.h +5 -3
  203. data/vendor/libgit2/src/libgit2/tree.c +23 -17
  204. data/vendor/libgit2/src/libgit2/tree.h +2 -2
  205. data/vendor/libgit2/src/libgit2/worktree.c +30 -10
  206. data/vendor/libgit2/src/util/CMakeLists.txt +6 -1
  207. data/vendor/libgit2/src/util/alloc.c +65 -6
  208. data/vendor/libgit2/src/util/alloc.h +34 -9
  209. data/vendor/libgit2/src/util/allocators/failalloc.c +0 -60
  210. data/vendor/libgit2/src/util/allocators/failalloc.h +0 -6
  211. data/vendor/libgit2/src/util/allocators/stdalloc.c +2 -105
  212. data/vendor/libgit2/src/util/allocators/win32_leakcheck.c +0 -68
  213. data/vendor/libgit2/src/util/array.h +6 -1
  214. data/vendor/libgit2/src/util/cc-compat.h +2 -0
  215. data/vendor/libgit2/src/util/filebuf.c +6 -1
  216. data/vendor/libgit2/src/util/filebuf.h +19 -6
  217. data/vendor/libgit2/src/util/fs_path.c +2 -2
  218. data/vendor/libgit2/src/util/futils.c +8 -8
  219. data/vendor/libgit2/src/{features.h.in → util/git2_features.h.in} +9 -3
  220. data/vendor/libgit2/src/util/git2_util.h +2 -2
  221. data/vendor/libgit2/src/util/hash/openssl.c +4 -3
  222. data/vendor/libgit2/src/util/hash/rfc6234/sha.h +0 -112
  223. data/vendor/libgit2/src/util/hash.h +13 -0
  224. data/vendor/libgit2/src/util/net.c +492 -87
  225. data/vendor/libgit2/src/util/net.h +32 -0
  226. data/vendor/libgit2/src/util/posix.c +54 -0
  227. data/vendor/libgit2/src/util/posix.h +24 -0
  228. data/vendor/libgit2/src/util/rand.c +10 -4
  229. data/vendor/libgit2/src/util/regexp.c +3 -3
  230. data/vendor/libgit2/src/util/staticstr.h +66 -0
  231. data/vendor/libgit2/src/util/thread.h +20 -19
  232. data/vendor/libgit2/src/util/util.c +15 -10
  233. data/vendor/libgit2/src/util/util.h +25 -16
  234. data/vendor/libgit2/src/util/win32/error.c +1 -1
  235. data/vendor/libgit2/src/util/win32/path_w32.c +8 -8
  236. data/vendor/libgit2/src/util/win32/posix_w32.c +1 -1
  237. data/vendor/libgit2/src/util/win32/utf-conv.c +73 -75
  238. data/vendor/libgit2/src/util/win32/utf-conv.h +81 -14
  239. data/vendor/libgit2/src/util/win32/w32_util.c +1 -1
  240. metadata +34 -26
  241. data/vendor/libgit2/cmake/SelectWinHTTP.cmake +0 -17
  242. data/vendor/libgit2/src/libgit2/netops.c +0 -124
  243. data/vendor/libgit2/src/libgit2/netops.h +0 -68
  244. data/vendor/libgit2/src/util/win32/findfile.c +0 -286
  245. data/vendor/libgit2/src/util/win32/findfile.h +0 -22
  246. /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xdiff.h +0 -0
  247. /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xemit.h +0 -0
  248. /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xinclude.h +0 -0
  249. /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xprepare.h +0 -0
  250. /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xtypes.h +0 -0
@@ -1,68 +0,0 @@
1
- /*
2
- * Copyright (C) the libgit2 contributors. All rights reserved.
3
- *
4
- * This file is part of libgit2, distributed under the GNU GPL v2 with
5
- * a Linking Exception. For full terms see the included COPYING file.
6
- */
7
- #ifndef INCLUDE_netops_h__
8
- #define INCLUDE_netops_h__
9
-
10
- #include "common.h"
11
-
12
- #include "posix.h"
13
- #include "stream.h"
14
- #include "net.h"
15
-
16
- #ifdef GIT_OPENSSL
17
- # include "streams/openssl.h"
18
- #endif
19
-
20
- typedef struct gitno_ssl {
21
- #ifdef GIT_OPENSSL
22
- SSL *ssl;
23
- #else
24
- size_t dummy;
25
- #endif
26
- } gitno_ssl;
27
-
28
- /* Represents a socket that may or may not be using SSL */
29
- typedef struct gitno_socket {
30
- GIT_SOCKET socket;
31
- gitno_ssl ssl;
32
- } gitno_socket;
33
-
34
- typedef struct gitno_buffer {
35
- char *data;
36
- size_t len;
37
- size_t offset;
38
- int (*recv)(struct gitno_buffer *buffer);
39
- void *cb_data;
40
- } gitno_buffer;
41
-
42
- /* Flags to gitno_connect */
43
- enum {
44
- /* Attempt to create an SSL connection. */
45
- GITNO_CONNECT_SSL = 1
46
- };
47
-
48
- /**
49
- * Check if the name in a cert matches the wanted hostname
50
- *
51
- * Check if a pattern from a certificate matches the hostname we
52
- * wanted to connect to according to RFC2818 rules (which specifies
53
- * HTTP over TLS). Mainly, an asterisk matches anything, but is
54
- * limited to a single url component.
55
- *
56
- * Note that this does not set an error message. It expects the user
57
- * to provide the message for the user.
58
- */
59
- int gitno__match_host(const char *pattern, const char *host);
60
-
61
- void gitno_buffer_setup_fromstream(git_stream *st, gitno_buffer *buf, char *data, size_t len);
62
- void gitno_buffer_setup_callback(gitno_buffer *buf, char *data, size_t len, int (*recv)(gitno_buffer *buf), void *cb_data);
63
- int gitno_recv(gitno_buffer *buf);
64
-
65
- int gitno_consume(gitno_buffer *buf, const char *ptr);
66
- void gitno_consume_n(gitno_buffer *buf, size_t cons);
67
-
68
- #endif
@@ -1,286 +0,0 @@
1
- /*
2
- * Copyright (C) the libgit2 contributors. All rights reserved.
3
- *
4
- * This file is part of libgit2, distributed under the GNU GPL v2 with
5
- * a Linking Exception. For full terms see the included COPYING file.
6
- */
7
-
8
- #include "findfile.h"
9
-
10
- #include "path_w32.h"
11
- #include "utf-conv.h"
12
- #include "fs_path.h"
13
-
14
- #define REG_GITFORWINDOWS_KEY L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Git_is1"
15
- #define REG_GITFORWINDOWS_KEY_WOW64 L"SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Git_is1"
16
-
17
- static int git_win32__expand_path(git_win32_path dest, const wchar_t *src)
18
- {
19
- DWORD len = ExpandEnvironmentStringsW(src, dest, GIT_WIN_PATH_UTF16);
20
-
21
- if (!len || len > GIT_WIN_PATH_UTF16)
22
- return -1;
23
-
24
- return 0;
25
- }
26
-
27
- static int win32_path_to_8(git_str *dest, const wchar_t *src)
28
- {
29
- git_win32_utf8_path utf8_path;
30
-
31
- if (git_win32_path_to_utf8(utf8_path, src) < 0) {
32
- git_error_set(GIT_ERROR_OS, "unable to convert path to UTF-8");
33
- return -1;
34
- }
35
-
36
- /* Convert backslashes to forward slashes */
37
- git_fs_path_mkposix(utf8_path);
38
-
39
- return git_str_sets(dest, utf8_path);
40
- }
41
-
42
- static git_win32_path mock_registry;
43
- static bool mock_registry_set;
44
-
45
- extern int git_win32__set_registry_system_dir(const wchar_t *mock_sysdir)
46
- {
47
- if (!mock_sysdir) {
48
- mock_registry[0] = L'\0';
49
- mock_registry_set = false;
50
- } else {
51
- size_t len = wcslen(mock_sysdir);
52
-
53
- if (len > GIT_WIN_PATH_MAX) {
54
- git_error_set(GIT_ERROR_INVALID, "mock path too long");
55
- return -1;
56
- }
57
-
58
- wcscpy(mock_registry, mock_sysdir);
59
- mock_registry_set = true;
60
- }
61
-
62
- return 0;
63
- }
64
-
65
- static int lookup_registry_key(
66
- git_win32_path out,
67
- const HKEY hive,
68
- const wchar_t* key,
69
- const wchar_t *value)
70
- {
71
- HKEY hkey;
72
- DWORD type, size;
73
- int error = GIT_ENOTFOUND;
74
-
75
- /*
76
- * Registry data may not be NUL terminated, provide room to do
77
- * it ourselves.
78
- */
79
- size = (DWORD)((sizeof(git_win32_path) - 1) * sizeof(wchar_t));
80
-
81
- if (RegOpenKeyExW(hive, key, 0, KEY_READ, &hkey) != 0)
82
- return GIT_ENOTFOUND;
83
-
84
- if (RegQueryValueExW(hkey, value, NULL, &type, (LPBYTE)out, &size) == 0 &&
85
- type == REG_SZ &&
86
- size > 0 &&
87
- size < sizeof(git_win32_path)) {
88
- size_t wsize = size / sizeof(wchar_t);
89
- size_t len = wsize - 1;
90
-
91
- if (out[wsize - 1] != L'\0') {
92
- len = wsize;
93
- out[wsize] = L'\0';
94
- }
95
-
96
- if (out[len - 1] == L'\\')
97
- out[len - 1] = L'\0';
98
-
99
- if (_waccess(out, F_OK) == 0)
100
- error = 0;
101
- }
102
-
103
- RegCloseKey(hkey);
104
- return error;
105
- }
106
-
107
- static int find_sysdir_in_registry(git_win32_path out)
108
- {
109
- if (mock_registry_set) {
110
- if (mock_registry[0] == L'\0')
111
- return GIT_ENOTFOUND;
112
-
113
- wcscpy(out, mock_registry);
114
- return 0;
115
- }
116
-
117
- if (lookup_registry_key(out, HKEY_CURRENT_USER, REG_GITFORWINDOWS_KEY, L"InstallLocation") == 0 ||
118
- lookup_registry_key(out, HKEY_CURRENT_USER, REG_GITFORWINDOWS_KEY_WOW64, L"InstallLocation") == 0 ||
119
- lookup_registry_key(out, HKEY_LOCAL_MACHINE, REG_GITFORWINDOWS_KEY, L"InstallLocation") == 0 ||
120
- lookup_registry_key(out, HKEY_LOCAL_MACHINE, REG_GITFORWINDOWS_KEY_WOW64, L"InstallLocation") == 0)
121
- return 0;
122
-
123
- return GIT_ENOTFOUND;
124
- }
125
-
126
- static int find_sysdir_in_path(git_win32_path out)
127
- {
128
- size_t out_len;
129
-
130
- if (git_win32_path_find_executable(out, L"git.exe") < 0 &&
131
- git_win32_path_find_executable(out, L"git.cmd") < 0)
132
- return GIT_ENOTFOUND;
133
-
134
- out_len = wcslen(out);
135
-
136
- /* Trim the file name */
137
- if (out_len <= CONST_STRLEN(L"git.exe"))
138
- return GIT_ENOTFOUND;
139
-
140
- out_len -= CONST_STRLEN(L"git.exe");
141
-
142
- if (out_len && out[out_len - 1] == L'\\')
143
- out_len--;
144
-
145
- /*
146
- * Git for Windows usually places the command in a 'bin' or
147
- * 'cmd' directory, trim that.
148
- */
149
- if (out_len >= CONST_STRLEN(L"\\bin") &&
150
- wcsncmp(&out[out_len - CONST_STRLEN(L"\\bin")], L"\\bin", CONST_STRLEN(L"\\bin")) == 0)
151
- out_len -= CONST_STRLEN(L"\\bin");
152
- else if (out_len >= CONST_STRLEN(L"\\cmd") &&
153
- wcsncmp(&out[out_len - CONST_STRLEN(L"\\cmd")], L"\\cmd", CONST_STRLEN(L"\\cmd")) == 0)
154
- out_len -= CONST_STRLEN(L"\\cmd");
155
-
156
- if (!out_len)
157
- return GIT_ENOTFOUND;
158
-
159
- out[out_len] = L'\0';
160
- return 0;
161
- }
162
-
163
- static int win32_find_existing_dirs(
164
- git_str* out,
165
- const wchar_t* tmpl[])
166
- {
167
- git_win32_path path16;
168
- git_str buf = GIT_STR_INIT;
169
-
170
- git_str_clear(out);
171
-
172
- for (; *tmpl != NULL; tmpl++) {
173
- if (!git_win32__expand_path(path16, *tmpl) &&
174
- path16[0] != L'%' &&
175
- !_waccess(path16, F_OK)) {
176
- win32_path_to_8(&buf, path16);
177
-
178
- if (buf.size)
179
- git_str_join(out, GIT_PATH_LIST_SEPARATOR, out->ptr, buf.ptr);
180
- }
181
- }
182
-
183
- git_str_dispose(&buf);
184
-
185
- return (git_str_oom(out) ? -1 : 0);
186
- }
187
-
188
- static int append_subdir(git_str *out, git_str *path, const char *subdir)
189
- {
190
- static const char* architecture_roots[] = {
191
- "",
192
- "mingw64",
193
- "mingw32",
194
- NULL
195
- };
196
- const char **root;
197
- size_t orig_path_len = path->size;
198
-
199
- for (root = architecture_roots; *root; root++) {
200
- if ((*root[0] && git_str_joinpath(path, path->ptr, *root) < 0) ||
201
- git_str_joinpath(path, path->ptr, subdir) < 0)
202
- return -1;
203
-
204
- if (git_fs_path_exists(path->ptr) &&
205
- git_str_join(out, GIT_PATH_LIST_SEPARATOR, out->ptr, path->ptr) < 0)
206
- return -1;
207
-
208
- git_str_truncate(path, orig_path_len);
209
- }
210
-
211
- return 0;
212
- }
213
-
214
- int git_win32__find_system_dirs(git_str *out, const char *subdir)
215
- {
216
- git_win32_path pathdir, regdir;
217
- git_str path8 = GIT_STR_INIT;
218
- bool has_pathdir, has_regdir;
219
- int error;
220
-
221
- has_pathdir = (find_sysdir_in_path(pathdir) == 0);
222
- has_regdir = (find_sysdir_in_registry(regdir) == 0);
223
-
224
- if (!has_pathdir && !has_regdir)
225
- return 0;
226
-
227
- /*
228
- * Usually the git in the path is the same git in the registry,
229
- * in this case there's no need to duplicate the paths.
230
- */
231
- if (has_pathdir && has_regdir && wcscmp(pathdir, regdir) == 0)
232
- has_regdir = false;
233
-
234
- if (has_pathdir) {
235
- if ((error = win32_path_to_8(&path8, pathdir)) < 0 ||
236
- (error = append_subdir(out, &path8, subdir)) < 0)
237
- goto done;
238
- }
239
-
240
- if (has_regdir) {
241
- if ((error = win32_path_to_8(&path8, regdir)) < 0 ||
242
- (error = append_subdir(out, &path8, subdir)) < 0)
243
- goto done;
244
- }
245
-
246
- done:
247
- git_str_dispose(&path8);
248
- return error;
249
- }
250
-
251
- int git_win32__find_global_dirs(git_str *out)
252
- {
253
- static const wchar_t *global_tmpls[4] = {
254
- L"%HOME%\\",
255
- L"%HOMEDRIVE%%HOMEPATH%\\",
256
- L"%USERPROFILE%\\",
257
- NULL,
258
- };
259
-
260
- return win32_find_existing_dirs(out, global_tmpls);
261
- }
262
-
263
- int git_win32__find_xdg_dirs(git_str *out)
264
- {
265
- static const wchar_t *global_tmpls[7] = {
266
- L"%XDG_CONFIG_HOME%\\git",
267
- L"%APPDATA%\\git",
268
- L"%LOCALAPPDATA%\\git",
269
- L"%HOME%\\.config\\git",
270
- L"%HOMEDRIVE%%HOMEPATH%\\.config\\git",
271
- L"%USERPROFILE%\\.config\\git",
272
- NULL,
273
- };
274
-
275
- return win32_find_existing_dirs(out, global_tmpls);
276
- }
277
-
278
- int git_win32__find_programdata_dirs(git_str *out)
279
- {
280
- static const wchar_t *programdata_tmpls[2] = {
281
- L"%PROGRAMDATA%\\Git",
282
- NULL,
283
- };
284
-
285
- return win32_find_existing_dirs(out, programdata_tmpls);
286
- }
@@ -1,22 +0,0 @@
1
- /*
2
- * Copyright (C) the libgit2 contributors. All rights reserved.
3
- *
4
- * This file is part of libgit2, distributed under the GNU GPL v2 with
5
- * a Linking Exception. For full terms see the included COPYING file.
6
- */
7
-
8
- #ifndef INCLUDE_win32_findfile_h__
9
- #define INCLUDE_win32_findfile_h__
10
-
11
- #include "git2_util.h"
12
-
13
- /** Sets the mock registry root for Git for Windows for testing. */
14
- extern int git_win32__set_registry_system_dir(const wchar_t *mock_sysdir);
15
-
16
- extern int git_win32__find_system_dirs(git_str *out, const char *subpath);
17
- extern int git_win32__find_global_dirs(git_str *out);
18
- extern int git_win32__find_xdg_dirs(git_str *out);
19
- extern int git_win32__find_programdata_dirs(git_str *out);
20
-
21
- #endif
22
-
File without changes
File without changes