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.
- checksums.yaml +4 -4
- data/ext/rugged/extconf.rb +2 -2
- data/ext/rugged/rugged_allocator.c +0 -54
- data/ext/rugged/rugged_blame.c +2 -0
- data/ext/rugged/rugged_blob.c +3 -0
- data/ext/rugged/rugged_commit.c +1 -0
- data/ext/rugged/rugged_config.c +2 -0
- data/ext/rugged/rugged_diff.c +1 -0
- data/ext/rugged/rugged_index.c +2 -0
- data/ext/rugged/rugged_patch.c +1 -0
- data/ext/rugged/rugged_rebase.c +1 -0
- data/ext/rugged/rugged_reference.c +1 -0
- data/ext/rugged/rugged_remote.c +1 -0
- data/ext/rugged/rugged_repo.c +5 -2
- data/ext/rugged/rugged_revwalk.c +5 -1
- data/ext/rugged/rugged_submodule.c +1 -0
- data/ext/rugged/rugged_tag.c +1 -0
- data/ext/rugged/rugged_tree.c +4 -0
- data/lib/rugged/index.rb +1 -1
- data/lib/rugged/tree.rb +1 -1
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +7 -8
- data/vendor/libgit2/COPYING +30 -0
- data/vendor/libgit2/cmake/CheckPrototypeDefinitionSafe.cmake +16 -0
- data/vendor/libgit2/cmake/ExperimentalFeatures.cmake +23 -0
- data/vendor/libgit2/cmake/SelectGSSAPI.cmake +3 -3
- data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +21 -2
- data/vendor/libgit2/cmake/SelectHashes.cmake +4 -0
- data/vendor/libgit2/cmake/SelectXdiff.cmake +9 -0
- data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +2 -0
- data/vendor/libgit2/deps/pcre/LICENCE +5 -5
- data/vendor/libgit2/deps/pcre/pcre.h +2 -2
- data/vendor/libgit2/deps/pcre/pcre_compile.c +6 -3
- data/vendor/libgit2/deps/pcre/pcre_exec.c +2 -2
- data/vendor/libgit2/deps/xdiff/CMakeLists.txt +28 -0
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/git-xdiff.h +4 -1
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xdiffi.c +19 -18
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xdiffi.h +2 -4
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xemit.c +3 -3
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xhistogram.c +7 -18
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xmacros.h +18 -1
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xmerge.c +24 -22
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xpatience.c +21 -30
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xprepare.c +13 -30
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xutils.c +18 -1
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xutils.h +2 -1
- data/vendor/libgit2/include/git2/common.h +38 -6
- data/vendor/libgit2/include/git2/deprecated.h +6 -0
- data/vendor/libgit2/include/git2/diff.h +42 -4
- data/vendor/libgit2/include/git2/errors.h +4 -2
- data/vendor/libgit2/include/git2/experimental.h +20 -0
- data/vendor/libgit2/include/git2/index.h +9 -0
- data/vendor/libgit2/include/git2/indexer.h +29 -0
- data/vendor/libgit2/include/git2/object.h +28 -2
- data/vendor/libgit2/include/git2/odb.h +58 -7
- data/vendor/libgit2/include/git2/odb_backend.h +106 -18
- data/vendor/libgit2/include/git2/oid.h +116 -16
- data/vendor/libgit2/include/git2/remote.h +18 -0
- data/vendor/libgit2/include/git2/repository.h +32 -3
- data/vendor/libgit2/include/git2/stash.h +60 -6
- data/vendor/libgit2/include/git2/strarray.h +0 -13
- data/vendor/libgit2/include/git2/sys/alloc.h +0 -34
- data/vendor/libgit2/include/git2/sys/commit_graph.h +12 -2
- data/vendor/libgit2/include/git2/sys/midx.h +5 -1
- data/vendor/libgit2/include/git2/sys/odb_backend.h +1 -1
- data/vendor/libgit2/include/git2/sys/stream.h +16 -2
- data/vendor/libgit2/include/git2/sys/transport.h +32 -2
- data/vendor/libgit2/include/git2/version.h +4 -4
- data/vendor/libgit2/include/git2/worktree.h +3 -1
- data/vendor/libgit2/include/git2.h +1 -0
- data/vendor/libgit2/src/CMakeLists.txt +34 -17
- data/vendor/libgit2/src/cli/CMakeLists.txt +5 -2
- data/vendor/libgit2/src/cli/cmd_clone.c +22 -6
- data/vendor/libgit2/src/cli/cmd_hash_object.c +27 -8
- data/vendor/libgit2/src/cli/opt.c +1 -1
- data/vendor/libgit2/src/cli/progress.c +9 -8
- data/vendor/libgit2/src/cli/progress.h +4 -4
- data/vendor/libgit2/src/libgit2/CMakeLists.txt +25 -34
- data/vendor/libgit2/src/libgit2/annotated_commit.c +2 -2
- data/vendor/libgit2/src/libgit2/annotated_commit.h +1 -1
- data/vendor/libgit2/src/libgit2/apply.c +4 -3
- data/vendor/libgit2/src/libgit2/attr_file.c +1 -1
- data/vendor/libgit2/src/libgit2/attrcache.c +1 -1
- data/vendor/libgit2/src/libgit2/blame.c +23 -14
- data/vendor/libgit2/src/libgit2/blame_git.c +0 -1
- data/vendor/libgit2/src/libgit2/blob.c +4 -2
- data/vendor/libgit2/src/libgit2/blob.h +2 -2
- data/vendor/libgit2/src/libgit2/branch.c +2 -2
- data/vendor/libgit2/src/libgit2/cherrypick.c +3 -3
- data/vendor/libgit2/src/libgit2/clone.c +34 -3
- data/vendor/libgit2/src/libgit2/commit.c +78 -21
- data/vendor/libgit2/src/libgit2/commit.h +25 -7
- data/vendor/libgit2/src/libgit2/commit_graph.c +129 -47
- data/vendor/libgit2/src/libgit2/commit_graph.h +23 -4
- data/vendor/libgit2/src/libgit2/commit_list.c +16 -5
- data/vendor/libgit2/src/libgit2/commit_list.h +1 -0
- data/vendor/libgit2/src/libgit2/config.c +6 -3
- data/vendor/libgit2/src/libgit2/config_file.c +16 -10
- data/vendor/libgit2/src/libgit2/describe.c +11 -8
- data/vendor/libgit2/src/libgit2/diff.c +19 -6
- data/vendor/libgit2/src/libgit2/diff.h +6 -6
- data/vendor/libgit2/src/libgit2/diff_file.c +16 -7
- data/vendor/libgit2/src/libgit2/diff_generate.c +37 -11
- data/vendor/libgit2/src/libgit2/diff_parse.c +20 -4
- data/vendor/libgit2/src/libgit2/diff_print.c +26 -7
- data/vendor/libgit2/src/libgit2/diff_tform.c +4 -0
- data/vendor/libgit2/src/libgit2/diff_xdiff.h +1 -1
- data/vendor/libgit2/src/libgit2/email.c +4 -3
- data/vendor/libgit2/src/libgit2/errors.c +73 -18
- data/vendor/libgit2/src/libgit2/experimental.h.in +13 -0
- data/vendor/libgit2/src/libgit2/fetch.c +38 -13
- data/vendor/libgit2/src/libgit2/fetch.h +0 -2
- data/vendor/libgit2/src/libgit2/fetchhead.c +11 -9
- data/vendor/libgit2/src/libgit2/grafts.c +272 -0
- data/vendor/libgit2/src/libgit2/grafts.h +36 -0
- data/vendor/libgit2/src/libgit2/ident.c +3 -3
- data/vendor/libgit2/src/libgit2/index.c +327 -123
- data/vendor/libgit2/src/libgit2/index.h +14 -1
- data/vendor/libgit2/src/libgit2/indexer.c +116 -46
- data/vendor/libgit2/src/libgit2/iterator.c +21 -4
- data/vendor/libgit2/src/libgit2/iterator.h +3 -0
- data/vendor/libgit2/src/libgit2/libgit2.c +58 -0
- data/vendor/libgit2/src/libgit2/merge.c +14 -9
- data/vendor/libgit2/src/libgit2/merge_file.c +0 -2
- data/vendor/libgit2/src/libgit2/midx.c +68 -38
- data/vendor/libgit2/src/libgit2/midx.h +13 -3
- data/vendor/libgit2/src/libgit2/mwindow.c +5 -2
- data/vendor/libgit2/src/libgit2/mwindow.h +4 -1
- data/vendor/libgit2/src/libgit2/notes.c +9 -8
- data/vendor/libgit2/src/libgit2/object.c +118 -29
- data/vendor/libgit2/src/libgit2/object.h +17 -2
- data/vendor/libgit2/src/libgit2/odb.c +224 -55
- data/vendor/libgit2/src/libgit2/odb.h +43 -4
- data/vendor/libgit2/src/libgit2/odb_loose.c +128 -70
- data/vendor/libgit2/src/libgit2/odb_pack.c +111 -46
- data/vendor/libgit2/src/libgit2/oid.c +141 -77
- data/vendor/libgit2/src/libgit2/oid.h +183 -9
- data/vendor/libgit2/src/libgit2/oidarray.c +49 -3
- data/vendor/libgit2/src/libgit2/oidarray.h +5 -1
- data/vendor/libgit2/src/libgit2/pack-objects.c +31 -13
- data/vendor/libgit2/src/libgit2/pack-objects.h +5 -2
- data/vendor/libgit2/src/libgit2/pack.c +93 -70
- data/vendor/libgit2/src/libgit2/pack.h +29 -15
- data/vendor/libgit2/src/libgit2/parse.c +8 -4
- data/vendor/libgit2/src/libgit2/parse.h +1 -1
- data/vendor/libgit2/src/libgit2/patch.h +7 -1
- data/vendor/libgit2/src/libgit2/patch_generate.c +24 -5
- data/vendor/libgit2/src/libgit2/patch_parse.c +16 -8
- data/vendor/libgit2/src/libgit2/push.c +13 -3
- data/vendor/libgit2/src/libgit2/reader.c +1 -1
- data/vendor/libgit2/src/libgit2/rebase.c +72 -83
- data/vendor/libgit2/src/libgit2/refdb_fs.c +92 -52
- data/vendor/libgit2/src/libgit2/reflog.c +7 -5
- data/vendor/libgit2/src/libgit2/reflog.h +1 -2
- data/vendor/libgit2/src/libgit2/refs.c +9 -0
- data/vendor/libgit2/src/libgit2/remote.c +47 -37
- data/vendor/libgit2/src/libgit2/remote.h +41 -0
- data/vendor/libgit2/src/libgit2/repository.c +784 -329
- data/vendor/libgit2/src/libgit2/repository.h +26 -2
- data/vendor/libgit2/src/libgit2/reset.c +2 -2
- data/vendor/libgit2/src/libgit2/revert.c +8 -11
- data/vendor/libgit2/src/libgit2/revparse.c +23 -7
- data/vendor/libgit2/src/libgit2/revwalk.c +31 -5
- data/vendor/libgit2/src/libgit2/stash.c +209 -33
- data/vendor/libgit2/src/libgit2/strarray.c +1 -0
- data/vendor/libgit2/src/libgit2/strarray.h +25 -0
- data/vendor/libgit2/src/libgit2/streams/mbedtls.c +0 -1
- data/vendor/libgit2/src/libgit2/streams/openssl.c +9 -17
- data/vendor/libgit2/src/libgit2/streams/openssl_dynamic.c +7 -3
- data/vendor/libgit2/src/libgit2/streams/schannel.c +715 -0
- data/vendor/libgit2/src/libgit2/streams/schannel.h +28 -0
- data/vendor/libgit2/src/libgit2/streams/socket.c +240 -51
- data/vendor/libgit2/src/libgit2/streams/socket.h +3 -1
- data/vendor/libgit2/src/libgit2/streams/stransport.c +40 -12
- data/vendor/libgit2/src/libgit2/streams/tls.c +5 -0
- data/vendor/libgit2/src/libgit2/submodule.c +6 -2
- data/vendor/libgit2/src/libgit2/submodule.h +3 -3
- data/vendor/libgit2/src/libgit2/sysdir.c +294 -7
- data/vendor/libgit2/src/libgit2/sysdir.h +41 -9
- data/vendor/libgit2/src/libgit2/tag.c +29 -10
- data/vendor/libgit2/src/libgit2/tag.h +2 -2
- data/vendor/libgit2/src/libgit2/threadstate.c +15 -2
- data/vendor/libgit2/src/libgit2/threadstate.h +1 -3
- data/vendor/libgit2/src/libgit2/transports/auth.h +1 -2
- data/vendor/libgit2/src/libgit2/transports/{auth_negotiate.c → auth_gssapi.c} +32 -32
- data/vendor/libgit2/src/libgit2/transports/auth_negotiate.h +1 -1
- data/vendor/libgit2/src/libgit2/transports/auth_ntlm.h +1 -1
- data/vendor/libgit2/src/libgit2/transports/{auth_ntlm.c → auth_ntlmclient.c} +12 -12
- data/vendor/libgit2/src/libgit2/transports/auth_sspi.c +341 -0
- data/vendor/libgit2/src/libgit2/transports/git.c +7 -8
- data/vendor/libgit2/src/libgit2/transports/http.c +15 -9
- data/vendor/libgit2/src/libgit2/transports/httpclient.c +14 -0
- data/vendor/libgit2/src/libgit2/transports/httpclient.h +10 -0
- data/vendor/libgit2/src/libgit2/transports/local.c +27 -4
- data/vendor/libgit2/src/libgit2/transports/smart.c +68 -27
- data/vendor/libgit2/src/libgit2/transports/smart.h +33 -9
- data/vendor/libgit2/src/libgit2/transports/smart_pkt.c +281 -49
- data/vendor/libgit2/src/libgit2/transports/smart_protocol.c +192 -55
- data/vendor/libgit2/src/libgit2/transports/ssh.c +334 -102
- data/vendor/libgit2/src/libgit2/transports/winhttp.c +22 -18
- data/vendor/libgit2/src/libgit2/tree-cache.c +26 -16
- data/vendor/libgit2/src/libgit2/tree-cache.h +5 -3
- data/vendor/libgit2/src/libgit2/tree.c +23 -17
- data/vendor/libgit2/src/libgit2/tree.h +2 -2
- data/vendor/libgit2/src/libgit2/worktree.c +30 -10
- data/vendor/libgit2/src/util/CMakeLists.txt +6 -1
- data/vendor/libgit2/src/util/alloc.c +65 -6
- data/vendor/libgit2/src/util/alloc.h +34 -9
- data/vendor/libgit2/src/util/allocators/failalloc.c +0 -60
- data/vendor/libgit2/src/util/allocators/failalloc.h +0 -6
- data/vendor/libgit2/src/util/allocators/stdalloc.c +2 -105
- data/vendor/libgit2/src/util/allocators/win32_leakcheck.c +0 -68
- data/vendor/libgit2/src/util/array.h +6 -1
- data/vendor/libgit2/src/util/cc-compat.h +2 -0
- data/vendor/libgit2/src/util/filebuf.c +6 -1
- data/vendor/libgit2/src/util/filebuf.h +19 -6
- data/vendor/libgit2/src/util/fs_path.c +2 -2
- data/vendor/libgit2/src/util/futils.c +8 -8
- data/vendor/libgit2/src/{features.h.in → util/git2_features.h.in} +9 -3
- data/vendor/libgit2/src/util/git2_util.h +2 -2
- data/vendor/libgit2/src/util/hash/openssl.c +4 -3
- data/vendor/libgit2/src/util/hash/rfc6234/sha.h +0 -112
- data/vendor/libgit2/src/util/hash.h +13 -0
- data/vendor/libgit2/src/util/net.c +492 -87
- data/vendor/libgit2/src/util/net.h +32 -0
- data/vendor/libgit2/src/util/posix.c +54 -0
- data/vendor/libgit2/src/util/posix.h +24 -0
- data/vendor/libgit2/src/util/rand.c +10 -4
- data/vendor/libgit2/src/util/regexp.c +3 -3
- data/vendor/libgit2/src/util/staticstr.h +66 -0
- data/vendor/libgit2/src/util/thread.h +20 -19
- data/vendor/libgit2/src/util/util.c +15 -10
- data/vendor/libgit2/src/util/util.h +25 -16
- data/vendor/libgit2/src/util/win32/error.c +1 -1
- data/vendor/libgit2/src/util/win32/path_w32.c +8 -8
- data/vendor/libgit2/src/util/win32/posix_w32.c +1 -1
- data/vendor/libgit2/src/util/win32/utf-conv.c +73 -75
- data/vendor/libgit2/src/util/win32/utf-conv.h +81 -14
- data/vendor/libgit2/src/util/win32/w32_util.c +1 -1
- metadata +34 -26
- data/vendor/libgit2/cmake/SelectWinHTTP.cmake +0 -17
- data/vendor/libgit2/src/libgit2/netops.c +0 -124
- data/vendor/libgit2/src/libgit2/netops.h +0 -68
- data/vendor/libgit2/src/util/win32/findfile.c +0 -286
- data/vendor/libgit2/src/util/win32/findfile.h +0 -22
- /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xdiff.h +0 -0
- /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xemit.h +0 -0
- /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xinclude.h +0 -0
- /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xprepare.h +0 -0
- /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xtypes.h +0 -0
@@ -12,16 +12,262 @@
|
|
12
12
|
#include "fs_path.h"
|
13
13
|
#include <ctype.h>
|
14
14
|
#if GIT_WIN32
|
15
|
-
#include "
|
15
|
+
# include "fs_path.h"
|
16
|
+
# include "win32/path_w32.h"
|
17
|
+
# include "win32/utf-conv.h"
|
16
18
|
#else
|
17
|
-
#include <unistd.h>
|
18
|
-
#include <pwd.h>
|
19
|
+
# include <unistd.h>
|
20
|
+
# include <pwd.h>
|
19
21
|
#endif
|
20
22
|
|
23
|
+
#ifdef GIT_WIN32
|
24
|
+
# define REG_GITFORWINDOWS_KEY L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Git_is1"
|
25
|
+
# define REG_GITFORWINDOWS_KEY_WOW64 L"SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Git_is1"
|
26
|
+
|
27
|
+
static int expand_win32_path(git_win32_path dest, const wchar_t *src)
|
28
|
+
{
|
29
|
+
DWORD len = ExpandEnvironmentStringsW(src, dest, GIT_WIN_PATH_UTF16);
|
30
|
+
|
31
|
+
if (!len || len > GIT_WIN_PATH_UTF16)
|
32
|
+
return -1;
|
33
|
+
|
34
|
+
return 0;
|
35
|
+
}
|
36
|
+
|
37
|
+
static int win32_path_to_utf8(git_str *dest, const wchar_t *src)
|
38
|
+
{
|
39
|
+
git_win32_utf8_path utf8_path;
|
40
|
+
|
41
|
+
if (git_win32_path_to_utf8(utf8_path, src) < 0) {
|
42
|
+
git_error_set(GIT_ERROR_OS, "unable to convert path to UTF-8");
|
43
|
+
return -1;
|
44
|
+
}
|
45
|
+
|
46
|
+
/* Convert backslashes to forward slashes */
|
47
|
+
git_fs_path_mkposix(utf8_path);
|
48
|
+
|
49
|
+
return git_str_sets(dest, utf8_path);
|
50
|
+
}
|
51
|
+
|
52
|
+
static git_win32_path mock_registry;
|
53
|
+
static bool mock_registry_set;
|
54
|
+
|
55
|
+
extern int git_win32__set_registry_system_dir(const wchar_t *mock_sysdir)
|
56
|
+
{
|
57
|
+
if (!mock_sysdir) {
|
58
|
+
mock_registry[0] = L'\0';
|
59
|
+
mock_registry_set = false;
|
60
|
+
} else {
|
61
|
+
size_t len = wcslen(mock_sysdir);
|
62
|
+
|
63
|
+
if (len > GIT_WIN_PATH_MAX) {
|
64
|
+
git_error_set(GIT_ERROR_INVALID, "mock path too long");
|
65
|
+
return -1;
|
66
|
+
}
|
67
|
+
|
68
|
+
wcscpy(mock_registry, mock_sysdir);
|
69
|
+
mock_registry_set = true;
|
70
|
+
}
|
71
|
+
|
72
|
+
return 0;
|
73
|
+
}
|
74
|
+
|
75
|
+
static int lookup_registry_key(
|
76
|
+
git_win32_path out,
|
77
|
+
const HKEY hive,
|
78
|
+
const wchar_t* key,
|
79
|
+
const wchar_t *value)
|
80
|
+
{
|
81
|
+
HKEY hkey;
|
82
|
+
DWORD type, size;
|
83
|
+
int error = GIT_ENOTFOUND;
|
84
|
+
|
85
|
+
/*
|
86
|
+
* Registry data may not be NUL terminated, provide room to do
|
87
|
+
* it ourselves.
|
88
|
+
*/
|
89
|
+
size = (DWORD)((sizeof(git_win32_path) - 1) * sizeof(wchar_t));
|
90
|
+
|
91
|
+
if (RegOpenKeyExW(hive, key, 0, KEY_READ, &hkey) != 0)
|
92
|
+
return GIT_ENOTFOUND;
|
93
|
+
|
94
|
+
if (RegQueryValueExW(hkey, value, NULL, &type, (LPBYTE)out, &size) == 0 &&
|
95
|
+
type == REG_SZ &&
|
96
|
+
size > 0 &&
|
97
|
+
size < sizeof(git_win32_path)) {
|
98
|
+
size_t wsize = size / sizeof(wchar_t);
|
99
|
+
size_t len = wsize - 1;
|
100
|
+
|
101
|
+
if (out[wsize - 1] != L'\0') {
|
102
|
+
len = wsize;
|
103
|
+
out[wsize] = L'\0';
|
104
|
+
}
|
105
|
+
|
106
|
+
if (out[len - 1] == L'\\')
|
107
|
+
out[len - 1] = L'\0';
|
108
|
+
|
109
|
+
if (_waccess(out, F_OK) == 0)
|
110
|
+
error = 0;
|
111
|
+
}
|
112
|
+
|
113
|
+
RegCloseKey(hkey);
|
114
|
+
return error;
|
115
|
+
}
|
116
|
+
|
117
|
+
static int find_sysdir_in_registry(git_win32_path out)
|
118
|
+
{
|
119
|
+
if (mock_registry_set) {
|
120
|
+
if (mock_registry[0] == L'\0')
|
121
|
+
return GIT_ENOTFOUND;
|
122
|
+
|
123
|
+
wcscpy(out, mock_registry);
|
124
|
+
return 0;
|
125
|
+
}
|
126
|
+
|
127
|
+
if (lookup_registry_key(out, HKEY_CURRENT_USER, REG_GITFORWINDOWS_KEY, L"InstallLocation") == 0 ||
|
128
|
+
lookup_registry_key(out, HKEY_CURRENT_USER, REG_GITFORWINDOWS_KEY_WOW64, L"InstallLocation") == 0 ||
|
129
|
+
lookup_registry_key(out, HKEY_LOCAL_MACHINE, REG_GITFORWINDOWS_KEY, L"InstallLocation") == 0 ||
|
130
|
+
lookup_registry_key(out, HKEY_LOCAL_MACHINE, REG_GITFORWINDOWS_KEY_WOW64, L"InstallLocation") == 0)
|
131
|
+
return 0;
|
132
|
+
|
133
|
+
return GIT_ENOTFOUND;
|
134
|
+
}
|
135
|
+
|
136
|
+
static int find_sysdir_in_path(git_win32_path out)
|
137
|
+
{
|
138
|
+
size_t out_len;
|
139
|
+
|
140
|
+
if (git_win32_path_find_executable(out, L"git.exe") < 0 &&
|
141
|
+
git_win32_path_find_executable(out, L"git.cmd") < 0)
|
142
|
+
return GIT_ENOTFOUND;
|
143
|
+
|
144
|
+
out_len = wcslen(out);
|
145
|
+
|
146
|
+
/* Trim the file name */
|
147
|
+
if (out_len <= CONST_STRLEN(L"git.exe"))
|
148
|
+
return GIT_ENOTFOUND;
|
149
|
+
|
150
|
+
out_len -= CONST_STRLEN(L"git.exe");
|
151
|
+
|
152
|
+
if (out_len && out[out_len - 1] == L'\\')
|
153
|
+
out_len--;
|
154
|
+
|
155
|
+
/*
|
156
|
+
* Git for Windows usually places the command in a 'bin' or
|
157
|
+
* 'cmd' directory, trim that.
|
158
|
+
*/
|
159
|
+
if (out_len >= CONST_STRLEN(L"\\bin") &&
|
160
|
+
wcsncmp(&out[out_len - CONST_STRLEN(L"\\bin")], L"\\bin", CONST_STRLEN(L"\\bin")) == 0)
|
161
|
+
out_len -= CONST_STRLEN(L"\\bin");
|
162
|
+
else if (out_len >= CONST_STRLEN(L"\\cmd") &&
|
163
|
+
wcsncmp(&out[out_len - CONST_STRLEN(L"\\cmd")], L"\\cmd", CONST_STRLEN(L"\\cmd")) == 0)
|
164
|
+
out_len -= CONST_STRLEN(L"\\cmd");
|
165
|
+
|
166
|
+
if (!out_len)
|
167
|
+
return GIT_ENOTFOUND;
|
168
|
+
|
169
|
+
out[out_len] = L'\0';
|
170
|
+
return 0;
|
171
|
+
}
|
172
|
+
|
173
|
+
static int find_win32_dirs(
|
174
|
+
git_str *out,
|
175
|
+
const wchar_t* tmpl[])
|
176
|
+
{
|
177
|
+
git_win32_path path16;
|
178
|
+
git_str buf = GIT_STR_INIT;
|
179
|
+
|
180
|
+
git_str_clear(out);
|
181
|
+
|
182
|
+
for (; *tmpl != NULL; tmpl++) {
|
183
|
+
if (!expand_win32_path(path16, *tmpl) &&
|
184
|
+
path16[0] != L'%' &&
|
185
|
+
!_waccess(path16, F_OK)) {
|
186
|
+
win32_path_to_utf8(&buf, path16);
|
187
|
+
|
188
|
+
if (buf.size)
|
189
|
+
git_str_join(out, GIT_PATH_LIST_SEPARATOR, out->ptr, buf.ptr);
|
190
|
+
}
|
191
|
+
}
|
192
|
+
|
193
|
+
git_str_dispose(&buf);
|
194
|
+
|
195
|
+
return (git_str_oom(out) ? -1 : 0);
|
196
|
+
}
|
197
|
+
|
198
|
+
static int append_subdir(git_str *out, git_str *path, const char *subdir)
|
199
|
+
{
|
200
|
+
static const char* architecture_roots[] = {
|
201
|
+
"",
|
202
|
+
"mingw64",
|
203
|
+
"mingw32",
|
204
|
+
NULL
|
205
|
+
};
|
206
|
+
const char **root;
|
207
|
+
size_t orig_path_len = path->size;
|
208
|
+
|
209
|
+
for (root = architecture_roots; *root; root++) {
|
210
|
+
if ((*root[0] && git_str_joinpath(path, path->ptr, *root) < 0) ||
|
211
|
+
git_str_joinpath(path, path->ptr, subdir) < 0)
|
212
|
+
return -1;
|
213
|
+
|
214
|
+
if (git_fs_path_exists(path->ptr) &&
|
215
|
+
git_str_join(out, GIT_PATH_LIST_SEPARATOR, out->ptr, path->ptr) < 0)
|
216
|
+
return -1;
|
217
|
+
|
218
|
+
git_str_truncate(path, orig_path_len);
|
219
|
+
}
|
220
|
+
|
221
|
+
return 0;
|
222
|
+
}
|
223
|
+
|
224
|
+
int git_win32__find_system_dirs(git_str *out, const char *subdir)
|
225
|
+
{
|
226
|
+
git_win32_path pathdir, regdir;
|
227
|
+
git_str path8 = GIT_STR_INIT;
|
228
|
+
bool has_pathdir, has_regdir;
|
229
|
+
int error;
|
230
|
+
|
231
|
+
has_pathdir = (find_sysdir_in_path(pathdir) == 0);
|
232
|
+
has_regdir = (find_sysdir_in_registry(regdir) == 0);
|
233
|
+
|
234
|
+
if (!has_pathdir && !has_regdir)
|
235
|
+
return 0;
|
236
|
+
|
237
|
+
/*
|
238
|
+
* Usually the git in the path is the same git in the registry,
|
239
|
+
* in this case there's no need to duplicate the paths.
|
240
|
+
*/
|
241
|
+
if (has_pathdir && has_regdir && wcscmp(pathdir, regdir) == 0)
|
242
|
+
has_regdir = false;
|
243
|
+
|
244
|
+
if (has_pathdir) {
|
245
|
+
if ((error = win32_path_to_utf8(&path8, pathdir)) < 0 ||
|
246
|
+
(error = append_subdir(out, &path8, subdir)) < 0)
|
247
|
+
goto done;
|
248
|
+
}
|
249
|
+
|
250
|
+
if (has_regdir) {
|
251
|
+
if ((error = win32_path_to_utf8(&path8, regdir)) < 0 ||
|
252
|
+
(error = append_subdir(out, &path8, subdir)) < 0)
|
253
|
+
goto done;
|
254
|
+
}
|
255
|
+
|
256
|
+
done:
|
257
|
+
git_str_dispose(&path8);
|
258
|
+
return error;
|
259
|
+
}
|
260
|
+
#endif /* WIN32 */
|
261
|
+
|
21
262
|
static int git_sysdir_guess_programdata_dirs(git_str *out)
|
22
263
|
{
|
23
264
|
#ifdef GIT_WIN32
|
24
|
-
|
265
|
+
static const wchar_t *programdata_tmpls[2] = {
|
266
|
+
L"%PROGRAMDATA%\\Git",
|
267
|
+
NULL,
|
268
|
+
};
|
269
|
+
|
270
|
+
return find_win32_dirs(out, programdata_tmpls);
|
25
271
|
#else
|
26
272
|
git_str_clear(out);
|
27
273
|
return 0;
|
@@ -75,10 +321,17 @@ out:
|
|
75
321
|
}
|
76
322
|
#endif
|
77
323
|
|
78
|
-
static int
|
324
|
+
static int git_sysdir_guess_home_dirs(git_str *out)
|
79
325
|
{
|
80
326
|
#ifdef GIT_WIN32
|
81
|
-
|
327
|
+
static const wchar_t *global_tmpls[4] = {
|
328
|
+
L"%HOME%\\",
|
329
|
+
L"%HOMEDRIVE%%HOMEPATH%\\",
|
330
|
+
L"%USERPROFILE%\\",
|
331
|
+
NULL,
|
332
|
+
};
|
333
|
+
|
334
|
+
return find_win32_dirs(out, global_tmpls);
|
82
335
|
#else
|
83
336
|
int error;
|
84
337
|
uid_t uid, euid;
|
@@ -114,10 +367,25 @@ static int git_sysdir_guess_global_dirs(git_str *out)
|
|
114
367
|
#endif
|
115
368
|
}
|
116
369
|
|
370
|
+
static int git_sysdir_guess_global_dirs(git_str *out)
|
371
|
+
{
|
372
|
+
return git_sysdir_guess_home_dirs(out);
|
373
|
+
}
|
374
|
+
|
117
375
|
static int git_sysdir_guess_xdg_dirs(git_str *out)
|
118
376
|
{
|
119
377
|
#ifdef GIT_WIN32
|
120
|
-
|
378
|
+
static const wchar_t *global_tmpls[7] = {
|
379
|
+
L"%XDG_CONFIG_HOME%\\git",
|
380
|
+
L"%APPDATA%\\git",
|
381
|
+
L"%LOCALAPPDATA%\\git",
|
382
|
+
L"%HOME%\\.config\\git",
|
383
|
+
L"%HOMEDRIVE%%HOMEPATH%\\.config\\git",
|
384
|
+
L"%USERPROFILE%\\.config\\git",
|
385
|
+
NULL,
|
386
|
+
};
|
387
|
+
|
388
|
+
return find_win32_dirs(out, global_tmpls);
|
121
389
|
#else
|
122
390
|
git_str env = GIT_STR_INIT;
|
123
391
|
int error;
|
@@ -171,6 +439,7 @@ static struct git_sysdir__dir git_sysdir__dirs[] = {
|
|
171
439
|
{ GIT_STR_INIT, git_sysdir_guess_xdg_dirs },
|
172
440
|
{ GIT_STR_INIT, git_sysdir_guess_programdata_dirs },
|
173
441
|
{ GIT_STR_INIT, git_sysdir_guess_template_dirs },
|
442
|
+
{ GIT_STR_INIT, git_sysdir_guess_home_dirs }
|
174
443
|
};
|
175
444
|
|
176
445
|
static void git_sysdir_global_shutdown(void)
|
@@ -350,6 +619,12 @@ int git_sysdir_find_template_dir(git_str *path)
|
|
350
619
|
path, NULL, GIT_SYSDIR_TEMPLATE, "template");
|
351
620
|
}
|
352
621
|
|
622
|
+
int git_sysdir_find_homedir(git_str *path)
|
623
|
+
{
|
624
|
+
return git_sysdir_find_in_dirlist(
|
625
|
+
path, NULL, GIT_SYSDIR_HOME, "home directory");
|
626
|
+
}
|
627
|
+
|
353
628
|
int git_sysdir_expand_global_file(git_str *path, const char *filename)
|
354
629
|
{
|
355
630
|
int error;
|
@@ -361,3 +636,15 @@ int git_sysdir_expand_global_file(git_str *path, const char *filename)
|
|
361
636
|
|
362
637
|
return error;
|
363
638
|
}
|
639
|
+
|
640
|
+
int git_sysdir_expand_homedir_file(git_str *path, const char *filename)
|
641
|
+
{
|
642
|
+
int error;
|
643
|
+
|
644
|
+
if ((error = git_sysdir_find_homedir(path)) == 0) {
|
645
|
+
if (filename)
|
646
|
+
error = git_str_joinpath(path, path->ptr, filename);
|
647
|
+
}
|
648
|
+
|
649
|
+
return error;
|
650
|
+
}
|
@@ -57,10 +57,22 @@ extern int git_sysdir_find_programdata_file(git_str *path, const char *filename)
|
|
57
57
|
extern int git_sysdir_find_template_dir(git_str *path);
|
58
58
|
|
59
59
|
/**
|
60
|
-
*
|
61
|
-
*
|
62
|
-
*
|
63
|
-
*
|
60
|
+
* Find the home directory. On Windows, this will look at the `HOME`,
|
61
|
+
* `HOMEPATH`, and `USERPROFILE` environment variables (in that order)
|
62
|
+
* and return the first path that is set and exists. On other systems,
|
63
|
+
* this will simply return the contents of the `HOME` environment variable.
|
64
|
+
*
|
65
|
+
* @param path buffer to write the full path into
|
66
|
+
* @return 0 if found, GIT_ENOTFOUND if not found, or -1 on other OS error
|
67
|
+
*/
|
68
|
+
extern int git_sysdir_find_homedir(git_str *path);
|
69
|
+
|
70
|
+
/**
|
71
|
+
* Expand the name of a "global" file -- by default inside the user's
|
72
|
+
* home directory, but can be overridden by the user configuration.
|
73
|
+
* Unlike `find_global_file` (above), this makes no attempt to check
|
74
|
+
* for the existence of the file, and is useful if you want the full
|
75
|
+
* path regardless of existence.
|
64
76
|
*
|
65
77
|
* @param path buffer to write the full path into
|
66
78
|
* @param filename name of file in the home directory
|
@@ -68,13 +80,25 @@ extern int git_sysdir_find_template_dir(git_str *path);
|
|
68
80
|
*/
|
69
81
|
extern int git_sysdir_expand_global_file(git_str *path, const char *filename);
|
70
82
|
|
83
|
+
/**
|
84
|
+
* Expand the name of a file in the user's home directory. This
|
85
|
+
* function makes no attempt to check for the existence of the file,
|
86
|
+
* and is useful if you want the full path regardless of existence.
|
87
|
+
*
|
88
|
+
* @param path buffer to write the full path into
|
89
|
+
* @param filename name of file in the home directory
|
90
|
+
* @return 0 on success or -1 on error
|
91
|
+
*/
|
92
|
+
extern int git_sysdir_expand_homedir_file(git_str *path, const char *filename);
|
93
|
+
|
71
94
|
typedef enum {
|
72
|
-
GIT_SYSDIR_SYSTEM
|
73
|
-
GIT_SYSDIR_GLOBAL
|
74
|
-
GIT_SYSDIR_XDG
|
95
|
+
GIT_SYSDIR_SYSTEM = 0,
|
96
|
+
GIT_SYSDIR_GLOBAL = 1,
|
97
|
+
GIT_SYSDIR_XDG = 2,
|
75
98
|
GIT_SYSDIR_PROGRAMDATA = 3,
|
76
|
-
GIT_SYSDIR_TEMPLATE
|
77
|
-
|
99
|
+
GIT_SYSDIR_TEMPLATE = 4,
|
100
|
+
GIT_SYSDIR_HOME = 5,
|
101
|
+
GIT_SYSDIR__MAX = 6
|
78
102
|
} git_sysdir_t;
|
79
103
|
|
80
104
|
/**
|
@@ -110,4 +134,12 @@ extern int git_sysdir_set(git_sysdir_t which, const char *paths);
|
|
110
134
|
*/
|
111
135
|
extern int git_sysdir_reset(void);
|
112
136
|
|
137
|
+
#ifdef GIT_WIN32
|
138
|
+
/** Sets the registry system dir to a mock; for testing. */
|
139
|
+
extern int git_win32__set_registry_system_dir(const wchar_t *mock_sysdir);
|
140
|
+
|
141
|
+
/** Find the given system dir; for testing. */
|
142
|
+
extern int git_win32__find_system_dirs(git_str *out, const char *subdir);
|
143
|
+
#endif
|
144
|
+
|
113
145
|
#endif
|
@@ -65,7 +65,11 @@ static int tag_error(const char *str)
|
|
65
65
|
return GIT_EINVALID;
|
66
66
|
}
|
67
67
|
|
68
|
-
static int tag_parse(
|
68
|
+
static int tag_parse(
|
69
|
+
git_tag *tag,
|
70
|
+
const char *buffer,
|
71
|
+
const char *buffer_end,
|
72
|
+
git_oid_t oid_type)
|
69
73
|
{
|
70
74
|
static const char *tag_types[] = {
|
71
75
|
NULL, "commit\n", "tree\n", "blob\n", "tag\n"
|
@@ -75,7 +79,8 @@ static int tag_parse(git_tag *tag, const char *buffer, const char *buffer_end)
|
|
75
79
|
unsigned int i;
|
76
80
|
int error;
|
77
81
|
|
78
|
-
if (
|
82
|
+
if (git_object__parse_oid_header(&tag->target,
|
83
|
+
&buffer, buffer_end, "object ", oid_type) < 0)
|
79
84
|
return tag_error("object field invalid");
|
80
85
|
|
81
86
|
if (buffer + 5 >= buffer_end)
|
@@ -160,18 +165,25 @@ static int tag_parse(git_tag *tag, const char *buffer, const char *buffer_end)
|
|
160
165
|
return 0;
|
161
166
|
}
|
162
167
|
|
163
|
-
int git_tag__parse_raw(
|
168
|
+
int git_tag__parse_raw(
|
169
|
+
void *_tag,
|
170
|
+
const char *data,
|
171
|
+
size_t size,
|
172
|
+
git_oid_t oid_type)
|
164
173
|
{
|
165
|
-
return tag_parse(_tag, data, data + size);
|
174
|
+
return tag_parse(_tag, data, data + size, oid_type);
|
166
175
|
}
|
167
176
|
|
168
|
-
int git_tag__parse(
|
177
|
+
int git_tag__parse(
|
178
|
+
void *_tag,
|
179
|
+
git_odb_object *odb_obj,
|
180
|
+
git_oid_t oid_type)
|
169
181
|
{
|
170
182
|
git_tag *tag = _tag;
|
171
183
|
const char *buffer = git_odb_object_data(odb_obj);
|
172
184
|
const char *buffer_end = buffer + git_odb_object_size(odb_obj);
|
173
185
|
|
174
|
-
return tag_parse(tag, buffer, buffer_end);
|
186
|
+
return tag_parse(tag, buffer, buffer_end, oid_type);
|
175
187
|
}
|
176
188
|
|
177
189
|
static int retrieve_tag_reference(
|
@@ -220,7 +232,9 @@ static int write_tag_annotation(
|
|
220
232
|
git_str tag = GIT_STR_INIT;
|
221
233
|
git_odb *odb;
|
222
234
|
|
223
|
-
|
235
|
+
if (git_object__write_oid_header(&tag, "object ", git_object_id(target)) < 0)
|
236
|
+
goto on_error;
|
237
|
+
|
224
238
|
git_str_printf(&tag, "type %s\n", git_object_type2string(git_object_type(target)));
|
225
239
|
git_str_printf(&tag, "tag %s\n", tag_name);
|
226
240
|
git_signature__writebuf(&tag, "tagger ", tagger);
|
@@ -296,8 +310,10 @@ static int git_tag_create__internal(
|
|
296
310
|
}
|
297
311
|
|
298
312
|
if (create_tag_annotation) {
|
299
|
-
if (write_tag_annotation(oid, repo, tag_name, target, tagger, message) < 0)
|
313
|
+
if (write_tag_annotation(oid, repo, tag_name, target, tagger, message) < 0) {
|
314
|
+
git_str_dispose(&ref_name);
|
300
315
|
return -1;
|
316
|
+
}
|
301
317
|
} else
|
302
318
|
git_oid_cpy(oid, git_object_id(target));
|
303
319
|
|
@@ -369,7 +385,7 @@ int git_tag_create_from_buffer(git_oid *oid, git_repository *repo, const char *b
|
|
369
385
|
return -1;
|
370
386
|
|
371
387
|
/* validate the buffer */
|
372
|
-
if (tag_parse(&tag, buffer, buffer + strlen(buffer)) < 0)
|
388
|
+
if (tag_parse(&tag, buffer, buffer + strlen(buffer), repo->oid_type) < 0)
|
373
389
|
return -1;
|
374
390
|
|
375
391
|
/* validate the target */
|
@@ -394,14 +410,17 @@ int git_tag_create_from_buffer(git_oid *oid, git_repository *repo, const char *b
|
|
394
410
|
/** Ensure the tag name doesn't conflict with an already existing
|
395
411
|
* reference unless overwriting has explicitly been requested **/
|
396
412
|
if (error == 0 && !allow_ref_overwrite) {
|
413
|
+
git_str_dispose(&ref_name);
|
397
414
|
git_error_set(GIT_ERROR_TAG, "tag already exists");
|
398
415
|
return GIT_EEXISTS;
|
399
416
|
}
|
400
417
|
|
401
418
|
/* write the buffer */
|
402
419
|
if ((error = git_odb_open_wstream(
|
403
|
-
&stream, odb, strlen(buffer), GIT_OBJECT_TAG)) < 0)
|
420
|
+
&stream, odb, strlen(buffer), GIT_OBJECT_TAG)) < 0) {
|
421
|
+
git_str_dispose(&ref_name);
|
404
422
|
return error;
|
423
|
+
}
|
405
424
|
|
406
425
|
if (!(error = git_odb_stream_write(stream, buffer, strlen(buffer))))
|
407
426
|
error = git_odb_stream_finalize_write(oid, stream);
|
@@ -25,7 +25,7 @@ struct git_tag {
|
|
25
25
|
};
|
26
26
|
|
27
27
|
void git_tag__free(void *tag);
|
28
|
-
int git_tag__parse(void *tag, git_odb_object *obj);
|
29
|
-
int git_tag__parse_raw(void *tag, const char *data, size_t size);
|
28
|
+
int git_tag__parse(void *tag, git_odb_object *obj, git_oid_t oid_type);
|
29
|
+
int git_tag__parse_raw(void *tag, const char *data, size_t size, git_oid_t oid_type);
|
30
30
|
|
31
31
|
#endif
|
@@ -75,10 +75,23 @@ git_threadstate *git_threadstate_get(void)
|
|
75
75
|
if ((threadstate = git_tlsdata_get(tls_key)) != NULL)
|
76
76
|
return threadstate;
|
77
77
|
|
78
|
-
|
79
|
-
|
78
|
+
/*
|
79
|
+
* Avoid git__malloc here, since if it fails, it sets an error
|
80
|
+
* message, which requires thread state, which would allocate
|
81
|
+
* here, which would fail, which would set an error message...
|
82
|
+
*/
|
83
|
+
|
84
|
+
if ((threadstate = git__allocator.gmalloc(sizeof(git_threadstate),
|
85
|
+
__FILE__, __LINE__)) == NULL)
|
80
86
|
return NULL;
|
81
87
|
|
88
|
+
memset(threadstate, 0, sizeof(git_threadstate));
|
89
|
+
|
90
|
+
if (git_str_init(&threadstate->error_buf, 0) < 0) {
|
91
|
+
git__allocator.gfree(threadstate);
|
92
|
+
return NULL;
|
93
|
+
}
|
94
|
+
|
82
95
|
git_tlsdata_set(tls_key, threadstate);
|
83
96
|
return threadstate;
|
84
97
|
}
|
@@ -13,12 +13,10 @@ typedef struct {
|
|
13
13
|
git_error *last_error;
|
14
14
|
git_error error_t;
|
15
15
|
git_str error_buf;
|
16
|
-
char oid_fmt[
|
16
|
+
char oid_fmt[GIT_OID_MAX_HEXSIZE+1];
|
17
17
|
} git_threadstate;
|
18
18
|
|
19
19
|
extern int git_threadstate_global_init(void);
|
20
20
|
extern git_threadstate *git_threadstate_get(void);
|
21
21
|
|
22
|
-
#define GIT_THREADSTATE (git_threadstate_get())
|
23
|
-
|
24
22
|
#endif
|