rugged 0.27.10.1 → 0.28.0
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 +23 -2
- data/ext/rugged/rugged.c +48 -2
- data/ext/rugged/rugged.h +5 -0
- data/ext/rugged/rugged_allocator.c +89 -0
- data/ext/rugged/rugged_blob.c +3 -3
- data/ext/rugged/rugged_branch.c +1 -1
- data/ext/rugged/rugged_commit.c +8 -8
- data/ext/rugged/rugged_config.c +1 -1
- data/ext/rugged/rugged_diff.c +24 -4
- data/ext/rugged/rugged_note.c +1 -1
- data/ext/rugged/rugged_repo.c +10 -10
- data/ext/rugged/rugged_settings.c +1 -1
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +69 -47
- data/vendor/libgit2/cmake/Modules/AddCFlagIfSupported.cmake +15 -1
- data/vendor/libgit2/cmake/Modules/EnableWarnings.cmake +5 -8
- data/vendor/libgit2/cmake/Modules/FindmbedTLS.cmake +93 -0
- data/vendor/libgit2/deps/http-parser/CMakeLists.txt +2 -0
- data/vendor/libgit2/deps/http-parser/{LICENSE-MIT → COPYING} +0 -0
- data/vendor/libgit2/deps/regex/COPYING +502 -0
- data/vendor/libgit2/deps/winhttp/COPYING.GPL +993 -0
- data/vendor/libgit2/deps/winhttp/COPYING.LGPL +502 -0
- data/vendor/libgit2/deps/zlib/CMakeLists.txt +1 -0
- data/vendor/libgit2/deps/zlib/COPYING +27 -0
- data/vendor/libgit2/include/git2.h +3 -0
- data/vendor/libgit2/include/git2/annotated_commit.h +9 -0
- data/vendor/libgit2/include/git2/apply.h +129 -0
- data/vendor/libgit2/include/git2/attr.h +19 -8
- data/vendor/libgit2/include/git2/blame.h +41 -24
- data/vendor/libgit2/include/git2/blob.h +1 -1
- data/vendor/libgit2/include/git2/branch.h +1 -1
- data/vendor/libgit2/include/git2/buffer.h +2 -2
- data/vendor/libgit2/include/git2/checkout.h +20 -19
- data/vendor/libgit2/include/git2/cherrypick.h +6 -4
- data/vendor/libgit2/include/git2/clone.h +11 -9
- data/vendor/libgit2/include/git2/commit.h +30 -2
- data/vendor/libgit2/include/git2/common.h +54 -4
- data/vendor/libgit2/include/git2/config.h +18 -7
- data/vendor/libgit2/include/git2/deprecated.h +253 -0
- data/vendor/libgit2/include/git2/describe.h +30 -7
- data/vendor/libgit2/include/git2/diff.h +193 -143
- data/vendor/libgit2/include/git2/errors.h +54 -46
- data/vendor/libgit2/include/git2/ignore.h +2 -2
- data/vendor/libgit2/include/git2/index.h +72 -51
- data/vendor/libgit2/include/git2/indexer.h +30 -4
- data/vendor/libgit2/include/git2/mailmap.h +115 -0
- data/vendor/libgit2/include/git2/merge.h +29 -8
- data/vendor/libgit2/include/git2/net.h +1 -1
- data/vendor/libgit2/include/git2/notes.h +1 -1
- data/vendor/libgit2/include/git2/object.h +16 -16
- data/vendor/libgit2/include/git2/odb.h +10 -10
- data/vendor/libgit2/include/git2/odb_backend.h +7 -7
- data/vendor/libgit2/include/git2/oid.h +1 -1
- data/vendor/libgit2/include/git2/pack.h +2 -2
- data/vendor/libgit2/include/git2/proxy.h +9 -5
- data/vendor/libgit2/include/git2/rebase.h +7 -4
- data/vendor/libgit2/include/git2/refs.h +14 -15
- data/vendor/libgit2/include/git2/refspec.h +17 -0
- data/vendor/libgit2/include/git2/remote.h +92 -16
- data/vendor/libgit2/include/git2/repository.h +52 -37
- data/vendor/libgit2/include/git2/revert.h +5 -3
- data/vendor/libgit2/include/git2/revwalk.h +7 -7
- data/vendor/libgit2/include/git2/signature.h +2 -2
- data/vendor/libgit2/include/git2/stash.h +13 -10
- data/vendor/libgit2/include/git2/status.h +8 -4
- data/vendor/libgit2/include/git2/submodule.h +11 -10
- data/vendor/libgit2/include/git2/sys/alloc.h +101 -0
- data/vendor/libgit2/include/git2/sys/commit.h +1 -1
- data/vendor/libgit2/include/git2/sys/config.h +13 -13
- data/vendor/libgit2/include/git2/sys/filter.h +6 -6
- data/vendor/libgit2/include/git2/sys/index.h +3 -0
- data/vendor/libgit2/include/git2/sys/mempack.h +35 -35
- data/vendor/libgit2/include/git2/sys/merge.h +9 -4
- data/vendor/libgit2/include/git2/sys/odb_backend.h +19 -19
- data/vendor/libgit2/include/git2/sys/path.h +64 -0
- data/vendor/libgit2/include/git2/sys/refdb_backend.h +19 -19
- data/vendor/libgit2/include/git2/sys/stream.h +92 -12
- data/vendor/libgit2/include/git2/sys/transport.h +127 -81
- data/vendor/libgit2/include/git2/tag.h +2 -2
- data/vendor/libgit2/include/git2/trace.h +1 -1
- data/vendor/libgit2/include/git2/transaction.h +1 -0
- data/vendor/libgit2/include/git2/transport.h +47 -18
- data/vendor/libgit2/include/git2/tree.h +3 -3
- data/vendor/libgit2/include/git2/types.h +35 -28
- data/vendor/libgit2/include/git2/version.h +4 -4
- data/vendor/libgit2/include/git2/worktree.h +47 -12
- data/vendor/libgit2/src/CMakeLists.txt +87 -26
- data/vendor/libgit2/src/alloc.c +55 -0
- data/vendor/libgit2/src/alloc.h +40 -0
- data/vendor/libgit2/src/annotated_commit.c +15 -8
- data/vendor/libgit2/src/apply.c +490 -14
- data/vendor/libgit2/src/apply.h +3 -1
- data/vendor/libgit2/src/array.h +2 -2
- data/vendor/libgit2/src/attr.c +11 -11
- data/vendor/libgit2/src/attr_file.c +20 -15
- data/vendor/libgit2/src/attrcache.c +11 -11
- data/vendor/libgit2/src/blame.c +30 -15
- data/vendor/libgit2/src/blame.h +1 -0
- data/vendor/libgit2/src/blame_git.c +16 -13
- data/vendor/libgit2/src/blob.c +50 -28
- data/vendor/libgit2/src/blob.h +18 -1
- data/vendor/libgit2/src/branch.c +38 -38
- data/vendor/libgit2/src/buf_text.c +7 -6
- data/vendor/libgit2/src/buffer.c +55 -50
- data/vendor/libgit2/src/buffer.h +1 -1
- data/vendor/libgit2/src/cache.c +16 -16
- data/vendor/libgit2/src/cache.h +2 -2
- data/vendor/libgit2/src/cc-compat.h +15 -3
- data/vendor/libgit2/src/checkout.c +83 -74
- data/vendor/libgit2/src/cherrypick.c +6 -6
- data/vendor/libgit2/src/clone.c +20 -20
- data/vendor/libgit2/src/commit.c +53 -33
- data/vendor/libgit2/src/commit.h +1 -0
- data/vendor/libgit2/src/commit_list.c +6 -10
- data/vendor/libgit2/src/common.h +32 -30
- data/vendor/libgit2/src/config.c +167 -147
- data/vendor/libgit2/src/config.h +1 -14
- data/vendor/libgit2/src/config_backend.h +84 -0
- data/vendor/libgit2/src/config_cache.c +7 -1
- data/vendor/libgit2/src/config_entries.c +259 -0
- data/vendor/libgit2/src/config_entries.h +23 -0
- data/vendor/libgit2/src/config_file.c +167 -439
- data/vendor/libgit2/src/config_mem.c +224 -0
- data/vendor/libgit2/src/config_parse.c +69 -38
- data/vendor/libgit2/src/config_parse.h +4 -4
- data/vendor/libgit2/src/crlf.c +215 -186
- data/vendor/libgit2/src/delta.c +25 -18
- data/vendor/libgit2/src/describe.c +23 -23
- data/vendor/libgit2/src/diff.c +12 -12
- data/vendor/libgit2/src/diff_driver.c +14 -15
- data/vendor/libgit2/src/diff_file.c +10 -10
- data/vendor/libgit2/src/diff_generate.c +29 -23
- data/vendor/libgit2/src/diff_generate.h +1 -1
- data/vendor/libgit2/src/diff_parse.c +3 -3
- data/vendor/libgit2/src/diff_print.c +17 -17
- data/vendor/libgit2/src/diff_stats.c +22 -7
- data/vendor/libgit2/src/diff_tform.c +12 -12
- data/vendor/libgit2/src/diff_xdiff.c +15 -3
- data/vendor/libgit2/src/errors.c +42 -20
- data/vendor/libgit2/src/features.h.in +2 -1
- data/vendor/libgit2/src/fetch.c +3 -3
- data/vendor/libgit2/src/fetchhead.c +16 -16
- data/vendor/libgit2/src/filebuf.c +28 -28
- data/vendor/libgit2/src/fileops.c +54 -54
- data/vendor/libgit2/src/fileops.h +1 -1
- data/vendor/libgit2/src/filter.c +30 -30
- data/vendor/libgit2/src/filter.h +0 -10
- data/vendor/libgit2/src/global.c +36 -23
- data/vendor/libgit2/src/hash.h +4 -1
- data/vendor/libgit2/src/hash/hash_collisiondetect.h +6 -2
- data/vendor/libgit2/src/hash/hash_common_crypto.h +5 -1
- data/vendor/libgit2/src/hash/hash_generic.h +5 -1
- data/vendor/libgit2/src/hash/hash_mbedtls.c +38 -0
- data/vendor/libgit2/src/hash/hash_mbedtls.h +24 -0
- data/vendor/libgit2/src/hash/hash_openssl.h +8 -4
- data/vendor/libgit2/src/hash/hash_win32.c +13 -13
- data/vendor/libgit2/src/hashsig.c +4 -4
- data/vendor/libgit2/src/idxmap.c +25 -5
- data/vendor/libgit2/src/idxmap.h +4 -18
- data/vendor/libgit2/src/ignore.c +9 -9
- data/vendor/libgit2/src/index.c +280 -198
- data/vendor/libgit2/src/index.h +16 -0
- data/vendor/libgit2/src/indexer.c +311 -139
- data/vendor/libgit2/src/integer.h +32 -22
- data/vendor/libgit2/src/iterator.c +116 -49
- data/vendor/libgit2/src/iterator.h +15 -0
- data/vendor/libgit2/src/khash.h +3 -1
- data/vendor/libgit2/src/mailmap.c +485 -0
- data/vendor/libgit2/src/mailmap.h +35 -0
- data/vendor/libgit2/src/merge.c +89 -59
- data/vendor/libgit2/src/merge_driver.c +7 -7
- data/vendor/libgit2/src/merge_file.c +1 -1
- data/vendor/libgit2/src/mwindow.c +8 -8
- data/vendor/libgit2/src/netops.c +22 -13
- data/vendor/libgit2/src/netops.h +2 -0
- data/vendor/libgit2/src/notes.c +15 -10
- data/vendor/libgit2/src/object.c +118 -67
- data/vendor/libgit2/src/object.h +20 -9
- data/vendor/libgit2/src/object_api.c +8 -8
- data/vendor/libgit2/src/odb.c +72 -72
- data/vendor/libgit2/src/odb.h +7 -7
- data/vendor/libgit2/src/odb_loose.c +46 -46
- data/vendor/libgit2/src/odb_mempack.c +14 -14
- data/vendor/libgit2/src/odb_pack.c +14 -10
- data/vendor/libgit2/src/offmap.c +30 -0
- data/vendor/libgit2/src/offmap.h +20 -11
- data/vendor/libgit2/src/oid.c +6 -6
- data/vendor/libgit2/src/oidmap.c +20 -0
- data/vendor/libgit2/src/oidmap.h +9 -12
- data/vendor/libgit2/src/pack-objects.c +71 -63
- data/vendor/libgit2/src/pack-objects.h +1 -7
- data/vendor/libgit2/src/pack.c +58 -58
- data/vendor/libgit2/src/pack.h +6 -6
- data/vendor/libgit2/src/parse.h +1 -1
- data/vendor/libgit2/src/patch.c +3 -3
- data/vendor/libgit2/src/patch_generate.c +18 -18
- data/vendor/libgit2/src/patch_parse.c +13 -13
- data/vendor/libgit2/src/path.c +93 -225
- data/vendor/libgit2/src/path.h +2 -84
- data/vendor/libgit2/src/pathspec.c +6 -6
- data/vendor/libgit2/src/posix.c +3 -3
- data/vendor/libgit2/src/proxy.c +1 -1
- data/vendor/libgit2/src/push.c +27 -26
- data/vendor/libgit2/src/push.h +2 -1
- data/vendor/libgit2/src/reader.c +265 -0
- data/vendor/libgit2/src/reader.h +107 -0
- data/vendor/libgit2/src/rebase.c +49 -52
- data/vendor/libgit2/src/refdb.c +3 -3
- data/vendor/libgit2/src/refdb_fs.c +181 -103
- data/vendor/libgit2/src/reflog.c +3 -3
- data/vendor/libgit2/src/refs.c +98 -74
- data/vendor/libgit2/src/refs.h +5 -3
- data/vendor/libgit2/src/refspec.c +47 -21
- data/vendor/libgit2/src/refspec.h +1 -1
- data/vendor/libgit2/src/remote.c +219 -166
- data/vendor/libgit2/src/remote.h +9 -0
- data/vendor/libgit2/src/repository.c +173 -133
- data/vendor/libgit2/src/repository.h +6 -3
- data/vendor/libgit2/src/reset.c +8 -8
- data/vendor/libgit2/src/revert.c +6 -6
- data/vendor/libgit2/src/revparse.c +30 -30
- data/vendor/libgit2/src/revwalk.c +60 -30
- data/vendor/libgit2/src/revwalk.h +2 -1
- data/vendor/libgit2/src/settings.c +42 -10
- data/vendor/libgit2/src/signature.c +11 -11
- data/vendor/libgit2/src/sortedcache.c +13 -13
- data/vendor/libgit2/src/stash.c +91 -45
- data/vendor/libgit2/src/status.c +13 -13
- data/vendor/libgit2/src/stdalloc.c +120 -0
- data/vendor/libgit2/src/{streams/curl.h → stdalloc.h} +6 -6
- data/vendor/libgit2/src/stream.h +17 -2
- data/vendor/libgit2/src/streams/mbedtls.c +483 -0
- data/vendor/libgit2/src/streams/mbedtls.h +23 -0
- data/vendor/libgit2/src/streams/openssl.c +204 -114
- data/vendor/libgit2/src/streams/openssl.h +4 -108
- data/vendor/libgit2/src/streams/registry.c +118 -0
- data/vendor/libgit2/src/streams/registry.h +19 -0
- data/vendor/libgit2/src/streams/socket.c +54 -29
- data/vendor/libgit2/src/streams/stransport.c +57 -32
- data/vendor/libgit2/src/streams/stransport.h +5 -0
- data/vendor/libgit2/src/streams/tls.c +50 -19
- data/vendor/libgit2/src/streams/tls.h +12 -4
- data/vendor/libgit2/src/strmap.c +22 -2
- data/vendor/libgit2/src/strmap.h +18 -15
- data/vendor/libgit2/src/submodule.c +179 -155
- data/vendor/libgit2/src/sysdir.c +18 -18
- data/vendor/libgit2/src/tag.c +31 -26
- data/vendor/libgit2/src/tag.h +2 -1
- data/vendor/libgit2/src/trace.c +1 -1
- data/vendor/libgit2/src/trace.h +1 -1
- data/vendor/libgit2/src/trailer.c +6 -6
- data/vendor/libgit2/src/transaction.c +23 -23
- data/vendor/libgit2/src/transport.c +5 -5
- data/vendor/libgit2/src/transports/auth.c +7 -4
- data/vendor/libgit2/src/transports/auth.h +1 -1
- data/vendor/libgit2/src/transports/auth_negotiate.c +12 -11
- data/vendor/libgit2/src/transports/cred.c +18 -18
- data/vendor/libgit2/src/transports/git.c +15 -15
- data/vendor/libgit2/src/transports/http.c +606 -216
- data/vendor/libgit2/src/transports/http.h +2 -0
- data/vendor/libgit2/src/transports/local.c +26 -26
- data/vendor/libgit2/src/transports/smart.c +54 -31
- data/vendor/libgit2/src/transports/smart.h +1 -2
- data/vendor/libgit2/src/transports/smart_pkt.c +43 -40
- data/vendor/libgit2/src/transports/smart_protocol.c +61 -57
- data/vendor/libgit2/src/transports/ssh.c +34 -33
- data/vendor/libgit2/src/transports/winhttp.c +99 -119
- data/vendor/libgit2/src/tree-cache.c +5 -5
- data/vendor/libgit2/src/tree.c +96 -121
- data/vendor/libgit2/src/tree.h +1 -12
- data/vendor/libgit2/src/unix/map.c +2 -2
- data/vendor/libgit2/src/util.c +22 -6
- data/vendor/libgit2/src/util.h +12 -135
- data/vendor/libgit2/src/vector.c +4 -4
- data/vendor/libgit2/src/win32/dir.c +3 -3
- data/vendor/libgit2/src/win32/findfile.c +3 -3
- data/vendor/libgit2/src/win32/map.c +6 -6
- data/vendor/libgit2/src/win32/msvc-compat.h +6 -0
- data/vendor/libgit2/src/win32/path_w32.c +101 -7
- data/vendor/libgit2/src/win32/path_w32.h +18 -0
- data/vendor/libgit2/src/win32/posix_w32.c +24 -43
- data/vendor/libgit2/src/win32/w32_buffer.c +2 -2
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +96 -2
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +28 -75
- data/vendor/libgit2/src/win32/w32_stack.c +2 -2
- data/vendor/libgit2/src/win32/w32_util.c +1 -69
- data/vendor/libgit2/src/win32/w32_util.h +1 -19
- data/vendor/libgit2/src/worktree.c +75 -54
- data/vendor/libgit2/src/worktree.h +2 -0
- data/vendor/libgit2/src/xdiff/xdiffi.c +7 -5
- data/vendor/libgit2/src/xdiff/xhistogram.c +1 -1
- data/vendor/libgit2/src/xdiff/xmerge.c +15 -15
- data/vendor/libgit2/src/zstream.c +4 -4
- metadata +33 -7
- data/vendor/libgit2/src/config_file.h +0 -73
- data/vendor/libgit2/src/streams/curl.c +0 -385
@@ -11,6 +11,11 @@
|
|
11
11
|
|
12
12
|
#include "git2/sys/stream.h"
|
13
13
|
|
14
|
+
#ifdef GIT_SECURE_TRANSPORT
|
15
|
+
|
14
16
|
extern int git_stransport_stream_new(git_stream **out, const char *host, const char *port);
|
17
|
+
extern int git_stransport_stream_wrap(git_stream **out, git_stream *in, const char *host);
|
18
|
+
|
19
|
+
#endif
|
15
20
|
|
16
21
|
#endif
|
@@ -5,38 +5,69 @@
|
|
5
5
|
* a Linking Exception. For full terms see the included COPYING file.
|
6
6
|
*/
|
7
7
|
|
8
|
-
#include "streams/tls.h"
|
9
|
-
|
10
8
|
#include "git2/errors.h"
|
11
9
|
|
10
|
+
#include "common.h"
|
11
|
+
#include "global.h"
|
12
|
+
#include "streams/registry.h"
|
13
|
+
#include "streams/tls.h"
|
14
|
+
#include "streams/mbedtls.h"
|
12
15
|
#include "streams/openssl.h"
|
13
16
|
#include "streams/stransport.h"
|
14
17
|
|
15
|
-
|
16
|
-
|
17
|
-
int git_stream_register_tls(git_stream_cb ctor)
|
18
|
+
int git_tls_stream_new(git_stream **out, const char *host, const char *port)
|
18
19
|
{
|
19
|
-
|
20
|
+
int (*init)(git_stream **, const char *, const char *) = NULL;
|
21
|
+
git_stream_registration custom = {0};
|
22
|
+
int error;
|
23
|
+
|
24
|
+
assert(out && host && port);
|
25
|
+
|
26
|
+
if ((error = git_stream_registry_lookup(&custom, GIT_STREAM_TLS)) == 0) {
|
27
|
+
init = custom.init;
|
28
|
+
} else if (error == GIT_ENOTFOUND) {
|
29
|
+
#ifdef GIT_SECURE_TRANSPORT
|
30
|
+
init = git_stransport_stream_new;
|
31
|
+
#elif defined(GIT_OPENSSL)
|
32
|
+
init = git_openssl_stream_new;
|
33
|
+
#elif defined(GIT_MBEDTLS)
|
34
|
+
init = git_mbedtls_stream_new;
|
35
|
+
#endif
|
36
|
+
} else {
|
37
|
+
return error;
|
38
|
+
}
|
39
|
+
|
40
|
+
if (!init) {
|
41
|
+
git_error_set(GIT_ERROR_SSL, "there is no TLS stream available");
|
42
|
+
return -1;
|
43
|
+
}
|
20
44
|
|
21
|
-
return
|
45
|
+
return init(out, host, port);
|
22
46
|
}
|
23
47
|
|
24
|
-
int
|
48
|
+
int git_tls_stream_wrap(git_stream **out, git_stream *in, const char *host)
|
25
49
|
{
|
50
|
+
int (*wrap)(git_stream **, git_stream *, const char *) = NULL;
|
51
|
+
git_stream_registration custom = {0};
|
26
52
|
|
27
|
-
|
28
|
-
return tls_ctor(out, host, port);
|
53
|
+
assert(out && in);
|
29
54
|
|
55
|
+
if (git_stream_registry_lookup(&custom, GIT_STREAM_TLS) == 0) {
|
56
|
+
wrap = custom.wrap;
|
57
|
+
} else {
|
30
58
|
#ifdef GIT_SECURE_TRANSPORT
|
31
|
-
|
59
|
+
wrap = git_stransport_stream_wrap;
|
32
60
|
#elif defined(GIT_OPENSSL)
|
33
|
-
|
34
|
-
#
|
35
|
-
|
36
|
-
GIT_UNUSED(host);
|
37
|
-
GIT_UNUSED(port);
|
38
|
-
|
39
|
-
giterr_set(GITERR_SSL, "there is no TLS stream available");
|
40
|
-
return -1;
|
61
|
+
wrap = git_openssl_stream_wrap;
|
62
|
+
#elif defined(GIT_MBEDTLS)
|
63
|
+
wrap = git_mbedtls_stream_wrap;
|
41
64
|
#endif
|
65
|
+
}
|
66
|
+
|
67
|
+
if (!wrap) {
|
68
|
+
git_error_set(GIT_ERROR_SSL, "there is no TLS stream available");
|
69
|
+
return -1;
|
70
|
+
}
|
71
|
+
|
72
|
+
return wrap(out, in, host);
|
42
73
|
}
|
@@ -13,11 +13,19 @@
|
|
13
13
|
|
14
14
|
/**
|
15
15
|
* Create a TLS stream with the most appropriate backend available for
|
16
|
-
* the current platform
|
17
|
-
*
|
18
|
-
* This allows us to ask for a SecureTransport or OpenSSL stream
|
19
|
-
* according to being on general Unix vs OS X.
|
16
|
+
* the current platform, whether that's SecureTransport on macOS,
|
17
|
+
* OpenSSL or mbedTLS on other Unixes, or something else entirely.
|
20
18
|
*/
|
21
19
|
extern int git_tls_stream_new(git_stream **out, const char *host, const char *port);
|
22
20
|
|
21
|
+
/**
|
22
|
+
* Create a TLS stream on top of an existing insecure stream, using
|
23
|
+
* the most appropriate backend available for the current platform.
|
24
|
+
*
|
25
|
+
* This allows us to create a CONNECT stream on top of a proxy;
|
26
|
+
* using SecureTransport on macOS, OpenSSL or mbedTLS on other
|
27
|
+
* Unixes, or something else entirely.
|
28
|
+
*/
|
29
|
+
extern int git_tls_stream_wrap(git_stream **out, git_stream *in, const char *host);
|
30
|
+
|
23
31
|
#endif
|
data/vendor/libgit2/src/strmap.c
CHANGED
@@ -7,12 +7,21 @@
|
|
7
7
|
|
8
8
|
#include "strmap.h"
|
9
9
|
|
10
|
+
#define kmalloc git__malloc
|
11
|
+
#define kcalloc git__calloc
|
12
|
+
#define krealloc git__realloc
|
13
|
+
#define kreallocarray git__reallocarray
|
14
|
+
#define kfree git__free
|
15
|
+
#include "khash.h"
|
16
|
+
|
17
|
+
__KHASH_TYPE(str, const char *, void *)
|
18
|
+
|
10
19
|
__KHASH_IMPL(str, static kh_inline, const char *, void *, 1, kh_str_hash_func, kh_str_hash_equal)
|
11
20
|
|
12
21
|
int git_strmap_alloc(git_strmap **map)
|
13
22
|
{
|
14
23
|
if ((*map = kh_init(str)) == NULL) {
|
15
|
-
|
24
|
+
git_error_set_oom();
|
16
25
|
return -1;
|
17
26
|
}
|
18
27
|
|
@@ -102,9 +111,20 @@ void git_strmap_delete(git_strmap *map, const char *key)
|
|
102
111
|
git_strmap_delete_at(map, idx);
|
103
112
|
}
|
104
113
|
|
114
|
+
size_t git_strmap_begin(git_strmap *map)
|
115
|
+
{
|
116
|
+
GIT_UNUSED(map);
|
117
|
+
return 0;
|
118
|
+
}
|
119
|
+
|
120
|
+
size_t git_strmap_end(git_strmap *map)
|
121
|
+
{
|
122
|
+
return map->n_buckets;
|
123
|
+
}
|
124
|
+
|
105
125
|
int git_strmap_next(
|
106
126
|
void **data,
|
107
|
-
|
127
|
+
size_t* iter,
|
108
128
|
git_strmap *map)
|
109
129
|
{
|
110
130
|
if (!map)
|
data/vendor/libgit2/src/strmap.h
CHANGED
@@ -9,16 +9,7 @@
|
|
9
9
|
|
10
10
|
#include "common.h"
|
11
11
|
|
12
|
-
|
13
|
-
#define kcalloc git__calloc
|
14
|
-
#define krealloc git__realloc
|
15
|
-
#define kreallocarray git__reallocarray
|
16
|
-
#define kfree git__free
|
17
|
-
#include "khash.h"
|
18
|
-
|
19
|
-
__KHASH_TYPE(str, const char *, void *)
|
20
|
-
typedef khash_t(str) git_strmap;
|
21
|
-
typedef khiter_t git_strmap_iter;
|
12
|
+
typedef struct kh_str_s git_strmap;
|
22
13
|
|
23
14
|
int git_strmap_alloc(git_strmap **map);
|
24
15
|
void git_strmap_free(git_strmap *map);
|
@@ -42,15 +33,27 @@ int git_strmap_put(git_strmap *map, const char *key, int *err);
|
|
42
33
|
void git_strmap_insert(git_strmap *map, const char *key, void *value, int *rval);
|
43
34
|
void git_strmap_delete(git_strmap *map, const char *key);
|
44
35
|
|
45
|
-
#define git_strmap_foreach
|
46
|
-
|
36
|
+
#define git_strmap_foreach(h, kvar, vvar, code) { size_t __i; \
|
37
|
+
for (__i = git_strmap_begin(h); __i != git_strmap_end(h); ++__i) { \
|
38
|
+
if (!git_strmap_has_data(h,__i)) continue; \
|
39
|
+
(kvar) = git_strmap_key(h,__i); \
|
40
|
+
(vvar) = git_strmap_value_at(h,__i); \
|
41
|
+
code; \
|
42
|
+
} }
|
43
|
+
|
44
|
+
#define git_strmap_foreach_value(h, vvar, code) { size_t __i; \
|
45
|
+
for (__i = git_strmap_begin(h); __i != git_strmap_end(h); ++__i) { \
|
46
|
+
if (!git_strmap_has_data(h,__i)) continue; \
|
47
|
+
(vvar) = git_strmap_value_at(h,__i); \
|
48
|
+
code; \
|
49
|
+
} }
|
47
50
|
|
48
|
-
|
49
|
-
|
51
|
+
size_t git_strmap_begin(git_strmap *map);
|
52
|
+
size_t git_strmap_end(git_strmap *map);
|
50
53
|
|
51
54
|
int git_strmap_next(
|
52
55
|
void **data,
|
53
|
-
|
56
|
+
size_t *iter,
|
54
57
|
git_strmap *map);
|
55
58
|
|
56
59
|
#endif
|
@@ -15,7 +15,7 @@
|
|
15
15
|
#include "buf_text.h"
|
16
16
|
#include "vector.h"
|
17
17
|
#include "posix.h"
|
18
|
-
#include "
|
18
|
+
#include "config_backend.h"
|
19
19
|
#include "config.h"
|
20
20
|
#include "repository.h"
|
21
21
|
#include "tree.h"
|
@@ -60,35 +60,6 @@ enum {
|
|
60
60
|
GITMODULES_CREATE = 1,
|
61
61
|
};
|
62
62
|
|
63
|
-
static kh_inline khint_t str_hash_no_trailing_slash(const char *s)
|
64
|
-
{
|
65
|
-
khint_t h;
|
66
|
-
|
67
|
-
for (h = 0; *s; ++s)
|
68
|
-
if (s[1] != '\0' || *s != '/')
|
69
|
-
h = (h << 5) - h + *s;
|
70
|
-
|
71
|
-
return h;
|
72
|
-
}
|
73
|
-
|
74
|
-
static kh_inline int str_equal_no_trailing_slash(const char *a, const char *b)
|
75
|
-
{
|
76
|
-
size_t alen = a ? strlen(a) : 0;
|
77
|
-
size_t blen = b ? strlen(b) : 0;
|
78
|
-
|
79
|
-
if (alen > 0 && a[alen - 1] == '/')
|
80
|
-
alen--;
|
81
|
-
if (blen > 0 && b[blen - 1] == '/')
|
82
|
-
blen--;
|
83
|
-
|
84
|
-
return (alen == 0 && blen == 0) ||
|
85
|
-
(alen == blen && strncmp(a, b, alen) == 0);
|
86
|
-
}
|
87
|
-
|
88
|
-
__KHASH_IMPL(
|
89
|
-
str, static kh_inline, const char *, void *, 1,
|
90
|
-
str_hash_no_trailing_slash, str_equal_no_trailing_slash)
|
91
|
-
|
92
63
|
static int submodule_alloc(git_submodule **out, git_repository *repo, const char *name);
|
93
64
|
static git_config_backend *open_gitmodules(git_repository *repo, int gitmod);
|
94
65
|
static int gitmodules_snapshot(git_config **snap, git_repository *repo);
|
@@ -124,7 +95,7 @@ static void submodule_set_lookup_error(int error, const char *name)
|
|
124
95
|
if (!error)
|
125
96
|
return;
|
126
97
|
|
127
|
-
|
98
|
+
git_error_set(GIT_ERROR_SUBMODULE, (error == GIT_ENOTFOUND) ?
|
128
99
|
"no submodule named '%s'" :
|
129
100
|
"submodule '%s' has not been added yet", name);
|
130
101
|
}
|
@@ -143,24 +114,74 @@ static int find_by_path(const git_config_entry *entry, void *payload)
|
|
143
114
|
fdot = strchr(entry->name, '.');
|
144
115
|
ldot = strrchr(entry->name, '.');
|
145
116
|
data->name = git__strndup(fdot + 1, ldot - fdot - 1);
|
146
|
-
|
117
|
+
GIT_ERROR_CHECK_ALLOC(data->name);
|
147
118
|
}
|
148
119
|
|
149
120
|
return 0;
|
150
121
|
}
|
151
122
|
|
123
|
+
/*
|
124
|
+
* Checks to see if the submodule shares its name with a file or directory that
|
125
|
+
* already exists on the index. If so, the submodule cannot be added.
|
126
|
+
*/
|
127
|
+
static int is_path_occupied(bool *occupied, git_repository *repo, const char *path)
|
128
|
+
{
|
129
|
+
int error = 0;
|
130
|
+
git_index *index;
|
131
|
+
git_buf dir = GIT_BUF_INIT;
|
132
|
+
*occupied = false;
|
133
|
+
|
134
|
+
if ((error = git_repository_index__weakptr(&index, repo)) < 0)
|
135
|
+
goto out;
|
136
|
+
|
137
|
+
if ((error = git_index_find(NULL, index, path)) != GIT_ENOTFOUND) {
|
138
|
+
if (!error) {
|
139
|
+
git_error_set(GIT_ERROR_SUBMODULE,
|
140
|
+
"File '%s' already exists in the index", path);
|
141
|
+
*occupied = true;
|
142
|
+
}
|
143
|
+
goto out;
|
144
|
+
}
|
145
|
+
|
146
|
+
if ((error = git_buf_sets(&dir, path)) < 0)
|
147
|
+
goto out;
|
148
|
+
|
149
|
+
if ((error = git_path_to_dir(&dir)) < 0)
|
150
|
+
goto out;
|
151
|
+
|
152
|
+
if ((error = git_index_find_prefix(NULL, index, dir.ptr)) != GIT_ENOTFOUND) {
|
153
|
+
if (!error) {
|
154
|
+
git_error_set(GIT_ERROR_SUBMODULE,
|
155
|
+
"Directory '%s' already exists in the index", path);
|
156
|
+
*occupied = true;
|
157
|
+
}
|
158
|
+
goto out;
|
159
|
+
}
|
160
|
+
|
161
|
+
error = 0;
|
162
|
+
|
163
|
+
out:
|
164
|
+
git_buf_dispose(&dir);
|
165
|
+
return error;
|
166
|
+
}
|
167
|
+
|
152
168
|
/**
|
153
169
|
* Release the name map returned by 'load_submodule_names'.
|
154
170
|
*/
|
155
171
|
static void free_submodule_names(git_strmap *names)
|
156
172
|
{
|
157
|
-
|
173
|
+
const char *key;
|
174
|
+
char *value;
|
175
|
+
|
158
176
|
if (names == NULL)
|
159
177
|
return;
|
160
|
-
|
161
|
-
|
178
|
+
|
179
|
+
git_strmap_foreach(names, key, value, {
|
180
|
+
git__free((char *) key);
|
181
|
+
git__free(value);
|
162
182
|
});
|
163
183
|
git_strmap_free(names);
|
184
|
+
|
164
185
|
return;
|
165
186
|
}
|
166
187
|
|
@@ -169,25 +190,31 @@ static void free_submodule_names(git_strmap *names)
|
|
169
190
|
* TODO: for some use-cases, this might need case-folding on a
|
170
191
|
* case-insensitive filesystem
|
171
192
|
*/
|
172
|
-
static int load_submodule_names(git_strmap
|
193
|
+
static int load_submodule_names(git_strmap **out, git_repository *repo, git_config *cfg)
|
173
194
|
{
|
174
195
|
const char *key = "submodule\\..*\\.path";
|
175
|
-
git_config_iterator *iter;
|
196
|
+
git_config_iterator *iter = NULL;
|
176
197
|
git_config_entry *entry;
|
177
198
|
git_buf buf = GIT_BUF_INIT;
|
199
|
+
git_strmap *names;
|
178
200
|
int rval, isvalid;
|
179
201
|
int error = 0;
|
180
202
|
|
203
|
+
*out = NULL;
|
204
|
+
|
205
|
+
if ((error = git_strmap_alloc(&names)) < 0)
|
206
|
+
goto out;
|
207
|
+
|
181
208
|
if ((error = git_config_iterator_glob_new(&iter, cfg, key)) < 0)
|
182
|
-
|
209
|
+
goto out;
|
183
210
|
|
184
211
|
while ((error = git_config_next(&entry, iter)) == 0) {
|
185
212
|
const char *fdot, *ldot;
|
186
213
|
fdot = strchr(entry->name, '.');
|
187
214
|
ldot = strrchr(entry->name, '.');
|
188
215
|
|
189
|
-
if (git_strmap_exists(
|
190
|
-
|
216
|
+
if (git_strmap_exists(names, entry->value)) {
|
217
|
+
git_error_set(GIT_ERROR_SUBMODULE,
|
191
218
|
"duplicated submodule path '%s'", entry->value);
|
192
219
|
error = -1;
|
193
220
|
goto out;
|
@@ -203,17 +230,22 @@ static int load_submodule_names(git_strmap *out, git_repository *repo, git_confi
|
|
203
230
|
if (!isvalid)
|
204
231
|
continue;
|
205
232
|
|
206
|
-
git_strmap_insert(
|
233
|
+
git_strmap_insert(names, git__strdup(entry->value), git_buf_detach(&buf), &rval);
|
207
234
|
if (rval < 0) {
|
208
|
-
|
209
|
-
|
235
|
+
git_error_set(GIT_ERROR_NOMEMORY, "error inserting submodule into hash table");
|
236
|
+
error = -1;
|
237
|
+
goto out;
|
210
238
|
}
|
211
239
|
}
|
212
240
|
if (error == GIT_ITEROVER)
|
213
241
|
error = 0;
|
214
242
|
|
243
|
+
*out = names;
|
244
|
+
names = NULL;
|
245
|
+
|
215
246
|
out:
|
216
|
-
|
247
|
+
free_submodule_names(names);
|
248
|
+
git_buf_dispose(&buf);
|
217
249
|
git_config_iterator_free(iter);
|
218
250
|
return error;
|
219
251
|
}
|
@@ -230,12 +262,12 @@ int git_submodule_lookup(
|
|
230
262
|
assert(repo && name);
|
231
263
|
|
232
264
|
if (repo->is_bare) {
|
233
|
-
|
265
|
+
git_error_set(GIT_ERROR_SUBMODULE, "cannot get submodules without a working tree");
|
234
266
|
return -1;
|
235
267
|
}
|
236
268
|
|
237
269
|
if (repo->submodule_cache != NULL) {
|
238
|
-
|
270
|
+
size_t pos = git_strmap_lookup_index(repo->submodule_cache, name);
|
239
271
|
if (git_strmap_valid_index(repo->submodule_cache, pos)) {
|
240
272
|
if (out) {
|
241
273
|
*out = git_strmap_value_at(repo->submodule_cache, pos);
|
@@ -274,13 +306,13 @@ int git_submodule_lookup(
|
|
274
306
|
mods = open_gitmodules(repo, GITMODULES_EXISTING);
|
275
307
|
|
276
308
|
if (mods)
|
277
|
-
error =
|
309
|
+
error = git_config_backend_foreach_match(mods, pattern, find_by_path, &data);
|
278
310
|
|
279
|
-
|
311
|
+
git_config_backend_free(mods);
|
280
312
|
|
281
313
|
if (error < 0) {
|
282
314
|
git_submodule_free(sm);
|
283
|
-
|
315
|
+
git_buf_dispose(&path);
|
284
316
|
return error;
|
285
317
|
}
|
286
318
|
|
@@ -296,7 +328,7 @@ int git_submodule_lookup(
|
|
296
328
|
}
|
297
329
|
}
|
298
330
|
|
299
|
-
|
331
|
+
git_buf_dispose(&path);
|
300
332
|
}
|
301
333
|
|
302
334
|
if ((error = git_submodule_location(&location, sm)) < 0) {
|
@@ -319,7 +351,7 @@ int git_submodule_lookup(
|
|
319
351
|
if (git_path_exists(path.ptr))
|
320
352
|
error = GIT_EEXISTS;
|
321
353
|
|
322
|
-
|
354
|
+
git_buf_dispose(&path);
|
323
355
|
}
|
324
356
|
|
325
357
|
submodule_set_lookup_error(error, name);
|
@@ -351,7 +383,7 @@ int git_submodule_name_is_valid(git_repository *repo, const char *name, int flag
|
|
351
383
|
}
|
352
384
|
|
353
385
|
isvalid = git_path_isvalid(repo, buf.ptr, 0, flags);
|
354
|
-
|
386
|
+
git_buf_dispose(&buf);
|
355
387
|
|
356
388
|
return isvalid;
|
357
389
|
}
|
@@ -364,7 +396,7 @@ static void submodule_free_dup(void *sm)
|
|
364
396
|
static int submodule_get_or_create(git_submodule **out, git_repository *repo, git_strmap *map, const char *name)
|
365
397
|
{
|
366
398
|
int error = 0;
|
367
|
-
|
399
|
+
size_t pos;
|
368
400
|
git_submodule *sm = NULL;
|
369
401
|
|
370
402
|
pos = git_strmap_lookup_index(map, name);
|
@@ -398,17 +430,16 @@ static int submodules_from_index(git_strmap *map, git_index *idx, git_config *cf
|
|
398
430
|
int error;
|
399
431
|
git_iterator *i = NULL;
|
400
432
|
const git_index_entry *entry;
|
401
|
-
git_strmap *names
|
433
|
+
git_strmap *names;
|
402
434
|
|
403
|
-
|
404
|
-
if ((error = load_submodule_names(names, git_index_owner(idx), cfg)))
|
435
|
+
if ((error = load_submodule_names(&names, git_index_owner(idx), cfg)))
|
405
436
|
goto done;
|
406
437
|
|
407
438
|
if ((error = git_iterator_for_index(&i, git_index_owner(idx), idx, NULL)) < 0)
|
408
439
|
goto done;
|
409
440
|
|
410
441
|
while (!(error = git_iterator_advance(&entry, i))) {
|
411
|
-
|
442
|
+
size_t pos = git_strmap_lookup_index(map, entry->path);
|
412
443
|
git_submodule *sm;
|
413
444
|
|
414
445
|
if (git_strmap_valid_index(map, pos)) {
|
@@ -419,7 +450,7 @@ static int submodules_from_index(git_strmap *map, git_index *idx, git_config *cf
|
|
419
450
|
else
|
420
451
|
sm->flags |= GIT_SUBMODULE_STATUS__INDEX_NOT_SUBMODULE;
|
421
452
|
} else if (S_ISGITLINK(entry->mode)) {
|
422
|
-
|
453
|
+
size_t name_pos;
|
423
454
|
const char *name;
|
424
455
|
|
425
456
|
name_pos = git_strmap_lookup_index(names, entry->path);
|
@@ -451,16 +482,16 @@ static int submodules_from_head(git_strmap *map, git_tree *head, git_config *cfg
|
|
451
482
|
int error;
|
452
483
|
git_iterator *i = NULL;
|
453
484
|
const git_index_entry *entry;
|
454
|
-
git_strmap *names
|
455
|
-
|
456
|
-
if ((error = load_submodule_names(names, git_tree_owner(head), cfg)))
|
485
|
+
git_strmap *names;
|
486
|
+
|
487
|
+
if ((error = load_submodule_names(&names, git_tree_owner(head), cfg)))
|
457
488
|
goto done;
|
458
489
|
|
459
490
|
if ((error = git_iterator_for_tree(&i, head, NULL)) < 0)
|
460
491
|
goto done;
|
461
492
|
|
462
493
|
while (!(error = git_iterator_advance(&entry, i))) {
|
463
|
-
|
494
|
+
size_t pos = git_strmap_lookup_index(map, entry->path);
|
464
495
|
git_submodule *sm;
|
465
496
|
|
466
497
|
if (git_strmap_valid_index(map, pos)) {
|
@@ -471,7 +502,7 @@ static int submodules_from_head(git_strmap *map, git_tree *head, git_config *cfg
|
|
471
502
|
else
|
472
503
|
sm->flags |= GIT_SUBMODULE_STATUS__HEAD_NOT_SUBMODULE;
|
473
504
|
} else if (S_ISGITLINK(entry->mode)) {
|
474
|
-
|
505
|
+
size_t name_pos;
|
475
506
|
const char *name;
|
476
507
|
|
477
508
|
name_pos = git_strmap_lookup_index(names, entry->path);
|
@@ -515,36 +546,19 @@ int git_submodule__map(git_repository *repo, git_strmap *map)
|
|
515
546
|
git_buf path = GIT_BUF_INIT;
|
516
547
|
git_submodule *sm;
|
517
548
|
git_config *mods = NULL;
|
518
|
-
uint32_t mask;
|
519
549
|
|
520
550
|
assert(repo && map);
|
521
551
|
|
522
552
|
/* get sources that we will need to check */
|
523
553
|
if (git_repository_index(&idx, repo) < 0)
|
524
|
-
|
554
|
+
git_error_clear();
|
525
555
|
if (git_repository_head_tree(&head, repo) < 0)
|
526
|
-
|
556
|
+
git_error_clear();
|
527
557
|
|
528
558
|
wd = git_repository_workdir(repo);
|
529
559
|
if (wd && (error = git_buf_joinpath(&path, wd, GIT_MODULES_FILE)) < 0)
|
530
560
|
goto cleanup;
|
531
561
|
|
532
|
-
/* clear submodule flags that are to be refreshed */
|
533
|
-
mask = 0;
|
534
|
-
mask |= GIT_SUBMODULE_STATUS_IN_INDEX |
|
535
|
-
GIT_SUBMODULE_STATUS__INDEX_FLAGS |
|
536
|
-
GIT_SUBMODULE_STATUS__INDEX_OID_VALID |
|
537
|
-
GIT_SUBMODULE_STATUS__INDEX_MULTIPLE_ENTRIES;
|
538
|
-
|
539
|
-
mask |= GIT_SUBMODULE_STATUS_IN_HEAD |
|
540
|
-
GIT_SUBMODULE_STATUS__HEAD_OID_VALID;
|
541
|
-
mask |= GIT_SUBMODULE_STATUS_IN_CONFIG;
|
542
|
-
if (mask != 0)
|
543
|
-
mask |= GIT_SUBMODULE_STATUS_IN_WD |
|
544
|
-
GIT_SUBMODULE_STATUS__WD_SCANNED |
|
545
|
-
GIT_SUBMODULE_STATUS__WD_FLAGS |
|
546
|
-
GIT_SUBMODULE_STATUS__WD_OID_VALID;
|
547
|
-
|
548
562
|
/* add submodule information from .gitmodules */
|
549
563
|
if (wd) {
|
550
564
|
lfc_data data = { 0 };
|
@@ -573,7 +587,7 @@ int git_submodule__map(git_repository *repo, git_strmap *map)
|
|
573
587
|
goto cleanup;
|
574
588
|
}
|
575
589
|
/* shallow scan submodules in work tree as needed */
|
576
|
-
if (wd
|
590
|
+
if (wd) {
|
577
591
|
git_strmap_foreach_value(map, sm, {
|
578
592
|
submodule_load_from_wd_lite(sm);
|
579
593
|
});
|
@@ -584,7 +598,7 @@ cleanup:
|
|
584
598
|
/* TODO: if we got an error, mark submodule config as invalid? */
|
585
599
|
git_index_free(idx);
|
586
600
|
git_tree_free(head);
|
587
|
-
|
601
|
+
git_buf_dispose(&path);
|
588
602
|
return error;
|
589
603
|
}
|
590
604
|
|
@@ -600,7 +614,7 @@ int git_submodule_foreach(
|
|
600
614
|
size_t i;
|
601
615
|
|
602
616
|
if (repo->is_bare) {
|
603
|
-
|
617
|
+
git_error_set(GIT_ERROR_SUBMODULE, "cannot get submodules without a working tree");
|
604
618
|
return -1;
|
605
619
|
}
|
606
620
|
|
@@ -627,7 +641,7 @@ int git_submodule_foreach(
|
|
627
641
|
|
628
642
|
git_vector_foreach(&snapshot, i, sm) {
|
629
643
|
if ((error = callback(sm, sm->name, payload)) != 0) {
|
630
|
-
|
644
|
+
git_error_set_after_callback(error);
|
631
645
|
break;
|
632
646
|
}
|
633
647
|
}
|
@@ -689,8 +703,8 @@ static int submodule_repo_init(
|
|
689
703
|
error = git_repository_init_ext(&subrepo, workdir.ptr, &initopt);
|
690
704
|
|
691
705
|
cleanup:
|
692
|
-
|
693
|
-
|
706
|
+
git_buf_dispose(&workdir);
|
707
|
+
git_buf_dispose(&repodir);
|
694
708
|
|
695
709
|
*out = subrepo;
|
696
710
|
|
@@ -709,15 +723,16 @@ int git_submodule_add_setup(
|
|
709
723
|
git_submodule *sm = NULL;
|
710
724
|
git_buf name = GIT_BUF_INIT, real_url = GIT_BUF_INIT;
|
711
725
|
git_repository *subrepo = NULL;
|
726
|
+
bool path_occupied;
|
712
727
|
|
713
728
|
assert(repo && url && path);
|
714
729
|
|
715
730
|
/* see if there is already an entry for this submodule */
|
716
731
|
|
717
732
|
if (git_submodule_lookup(NULL, repo, path) < 0)
|
718
|
-
|
733
|
+
git_error_clear();
|
719
734
|
else {
|
720
|
-
|
735
|
+
git_error_set(GIT_ERROR_SUBMODULE,
|
721
736
|
"attempt to add submodule '%s' that already exists", path);
|
722
737
|
return GIT_EEXISTS;
|
723
738
|
}
|
@@ -728,25 +743,33 @@ int git_submodule_add_setup(
|
|
728
743
|
path += strlen(git_repository_workdir(repo));
|
729
744
|
|
730
745
|
if (git_path_root(path) >= 0) {
|
731
|
-
|
746
|
+
git_error_set(GIT_ERROR_SUBMODULE, "submodule path must be a relative path");
|
732
747
|
error = -1;
|
733
748
|
goto cleanup;
|
734
749
|
}
|
735
750
|
|
751
|
+
if ((error = is_path_occupied(&path_occupied, repo, path)) < 0)
|
752
|
+
goto cleanup;
|
753
|
+
|
754
|
+
if (path_occupied) {
|
755
|
+
error = GIT_EEXISTS;
|
756
|
+
goto cleanup;
|
757
|
+
}
|
758
|
+
|
736
759
|
/* update .gitmodules */
|
737
760
|
|
738
761
|
if (!(mods = open_gitmodules(repo, GITMODULES_CREATE))) {
|
739
|
-
|
762
|
+
git_error_set(GIT_ERROR_SUBMODULE,
|
740
763
|
"adding submodules to a bare repository is not supported");
|
741
764
|
return -1;
|
742
765
|
}
|
743
766
|
|
744
767
|
if ((error = git_buf_printf(&name, "submodule.%s.path", path)) < 0 ||
|
745
|
-
(error =
|
768
|
+
(error = git_config_backend_set_string(mods, name.ptr, path)) < 0)
|
746
769
|
goto cleanup;
|
747
770
|
|
748
771
|
if ((error = submodule_config_key_trunc_puts(&name, "url")) < 0 ||
|
749
|
-
(error =
|
772
|
+
(error = git_config_backend_set_string(mods, name.ptr, url)) < 0)
|
750
773
|
goto cleanup;
|
751
774
|
|
752
775
|
git_buf_clear(&name);
|
@@ -784,10 +807,10 @@ cleanup:
|
|
784
807
|
if (out != NULL)
|
785
808
|
*out = sm;
|
786
809
|
|
787
|
-
|
810
|
+
git_config_backend_free(mods);
|
788
811
|
git_repository_free(subrepo);
|
789
|
-
|
790
|
-
|
812
|
+
git_buf_dispose(&real_url);
|
813
|
+
git_buf_dispose(&name);
|
791
814
|
|
792
815
|
return error;
|
793
816
|
}
|
@@ -816,7 +839,7 @@ int git_submodule_repo_init(
|
|
816
839
|
|
817
840
|
done:
|
818
841
|
git_config_free(cfg);
|
819
|
-
|
842
|
+
git_buf_dispose(&buf);
|
820
843
|
return error;
|
821
844
|
}
|
822
845
|
|
@@ -857,7 +880,7 @@ int git_submodule_add_to_index(git_submodule *sm, int write_index)
|
|
857
880
|
|
858
881
|
/* read stat information for submodule working directory */
|
859
882
|
if (p_stat(path.ptr, &st) < 0) {
|
860
|
-
|
883
|
+
git_error_set(GIT_ERROR_SUBMODULE,
|
861
884
|
"cannot add submodule without working directory");
|
862
885
|
error = -1;
|
863
886
|
goto cleanup;
|
@@ -866,11 +889,11 @@ int git_submodule_add_to_index(git_submodule *sm, int write_index)
|
|
866
889
|
memset(&entry, 0, sizeof(entry));
|
867
890
|
entry.path = sm->path;
|
868
891
|
git_index_entry__init_from_stat(
|
869
|
-
&entry, &st, !(git_index_caps(index) &
|
892
|
+
&entry, &st, !(git_index_caps(index) & GIT_INDEX_CAPABILITY_NO_FILEMODE));
|
870
893
|
|
871
894
|
/* calling git_submodule_open will have set sm->wd_oid if possible */
|
872
895
|
if ((sm->flags & GIT_SUBMODULE_STATUS__WD_OID_VALID) == 0) {
|
873
|
-
|
896
|
+
git_error_set(GIT_ERROR_SUBMODULE,
|
874
897
|
"cannot add submodule without HEAD to index");
|
875
898
|
error = -1;
|
876
899
|
goto cleanup;
|
@@ -900,7 +923,7 @@ int git_submodule_add_to_index(git_submodule *sm, int write_index)
|
|
900
923
|
|
901
924
|
cleanup:
|
902
925
|
git_repository_free(sm_repo);
|
903
|
-
|
926
|
+
git_buf_dispose(&path);
|
904
927
|
return error;
|
905
928
|
}
|
906
929
|
|
@@ -961,11 +984,11 @@ int git_submodule_resolve_url(git_buf *out, git_repository *repo, const char *ur
|
|
961
984
|
} else if (strchr(url, ':') != NULL || url[0] == '/') {
|
962
985
|
error = git_buf_sets(out, url);
|
963
986
|
} else {
|
964
|
-
|
987
|
+
git_error_set(GIT_ERROR_SUBMODULE, "invalid format for submodule URL");
|
965
988
|
error = -1;
|
966
989
|
}
|
967
990
|
|
968
|
-
|
991
|
+
git_buf_dispose(&normalized);
|
969
992
|
return error;
|
970
993
|
}
|
971
994
|
|
@@ -983,14 +1006,14 @@ static int write_var(git_repository *repo, const char *name, const char *var, co
|
|
983
1006
|
goto cleanup;
|
984
1007
|
|
985
1008
|
if (val)
|
986
|
-
error =
|
1009
|
+
error = git_config_backend_set_string(mods, key.ptr, val);
|
987
1010
|
else
|
988
|
-
error =
|
1011
|
+
error = git_config_backend_delete(mods, key.ptr);
|
989
1012
|
|
990
|
-
|
1013
|
+
git_buf_dispose(&key);
|
991
1014
|
|
992
1015
|
cleanup:
|
993
|
-
|
1016
|
+
git_config_backend_free(mods);
|
994
1017
|
return error;
|
995
1018
|
}
|
996
1019
|
|
@@ -1000,7 +1023,7 @@ static int write_mapped_var(git_repository *repo, const char *name, git_cvar_map
|
|
1000
1023
|
const char *val;
|
1001
1024
|
|
1002
1025
|
if (git_config_lookup_map_enum(&type, &val, maps, nmaps, ival) < 0) {
|
1003
|
-
|
1026
|
+
git_error_set(GIT_ERROR_SUBMODULE, "invalid value for %s", var);
|
1004
1027
|
return -1;
|
1005
1028
|
}
|
1006
1029
|
|
@@ -1063,7 +1086,7 @@ const git_oid *git_submodule_wd_id(git_submodule *submodule)
|
|
1063
1086
|
if (!git_submodule_open_bare(&subrepo, submodule))
|
1064
1087
|
git_repository_free(subrepo);
|
1065
1088
|
else
|
1066
|
-
|
1089
|
+
git_error_clear();
|
1067
1090
|
}
|
1068
1091
|
|
1069
1092
|
if (submodule->flags & GIT_SUBMODULE_STATUS__WD_OID_VALID)
|
@@ -1152,8 +1175,8 @@ static int submodule_repo_create(
|
|
1152
1175
|
error = git_repository_init_ext(&subrepo, repodir.ptr, &initopt);
|
1153
1176
|
|
1154
1177
|
cleanup:
|
1155
|
-
|
1156
|
-
|
1178
|
+
git_buf_dispose(&workdir);
|
1179
|
+
git_buf_dispose(&repodir);
|
1157
1180
|
|
1158
1181
|
*out = subrepo;
|
1159
1182
|
|
@@ -1204,7 +1227,7 @@ int git_submodule_update(git_submodule *sm, int init, git_submodule_update_optio
|
|
1204
1227
|
if (_update_options)
|
1205
1228
|
memcpy(&update_options, _update_options, sizeof(git_submodule_update_options));
|
1206
1229
|
|
1207
|
-
|
1230
|
+
GIT_ERROR_CHECK_VERSION(&update_options, GIT_SUBMODULE_UPDATE_OPTIONS_VERSION, "git_submodule_update_options");
|
1208
1231
|
|
1209
1232
|
/* Copy over the remote callbacks */
|
1210
1233
|
memcpy(&clone_options.fetch_opts, &update_options.fetch_opts, sizeof(git_fetch_options));
|
@@ -1235,7 +1258,7 @@ int git_submodule_update(git_submodule *sm, int init, git_submodule_update_optio
|
|
1235
1258
|
goto done;
|
1236
1259
|
|
1237
1260
|
if (!init) {
|
1238
|
-
|
1261
|
+
git_error_set(GIT_ERROR_SUBMODULE, "submodule is not initialized");
|
1239
1262
|
error = GIT_ERROR;
|
1240
1263
|
goto done;
|
1241
1264
|
}
|
@@ -1279,18 +1302,18 @@ int git_submodule_update(git_submodule *sm, int init, git_submodule_update_optio
|
|
1279
1302
|
goto done;
|
1280
1303
|
|
1281
1304
|
if ((oid = git_submodule_index_id(sm)) == NULL) {
|
1282
|
-
|
1305
|
+
git_error_set(GIT_ERROR_SUBMODULE, "could not get ID of submodule in index");
|
1283
1306
|
error = -1;
|
1284
1307
|
goto done;
|
1285
1308
|
}
|
1286
1309
|
|
1287
1310
|
/* Look up the target commit in the submodule. */
|
1288
|
-
if ((error = git_object_lookup(&target_commit, sub_repo, oid,
|
1311
|
+
if ((error = git_object_lookup(&target_commit, sub_repo, oid, GIT_OBJECT_COMMIT)) < 0) {
|
1289
1312
|
/* If it isn't found then fetch and try again. */
|
1290
1313
|
if (error != GIT_ENOTFOUND || !update_options.allow_fetch ||
|
1291
1314
|
(error = lookup_default_remote(&remote, sub_repo)) < 0 ||
|
1292
1315
|
(error = git_remote_fetch(remote, NULL, &update_options.fetch_opts, NULL)) < 0 ||
|
1293
|
-
(error = git_object_lookup(&target_commit, sub_repo, git_submodule_index_id(sm),
|
1316
|
+
(error = git_object_lookup(&target_commit, sub_repo, git_submodule_index_id(sm), GIT_OBJECT_COMMIT)) < 0)
|
1294
1317
|
goto done;
|
1295
1318
|
}
|
1296
1319
|
|
@@ -1306,7 +1329,7 @@ int git_submodule_update(git_submodule *sm, int init, git_submodule_update_optio
|
|
1306
1329
|
}
|
1307
1330
|
|
1308
1331
|
done:
|
1309
|
-
|
1332
|
+
git_buf_dispose(&buf);
|
1310
1333
|
git_config_free(config);
|
1311
1334
|
git_object_free(target_commit);
|
1312
1335
|
git_remote_free(remote);
|
@@ -1323,7 +1346,7 @@ int git_submodule_init(git_submodule *sm, int overwrite)
|
|
1323
1346
|
git_config *cfg = NULL;
|
1324
1347
|
|
1325
1348
|
if (!sm->url) {
|
1326
|
-
|
1349
|
+
git_error_set(GIT_ERROR_SUBMODULE,
|
1327
1350
|
"no URL configured for submodule '%s'", sm->name);
|
1328
1351
|
return -1;
|
1329
1352
|
}
|
@@ -1353,8 +1376,8 @@ int git_submodule_init(git_submodule *sm, int overwrite)
|
|
1353
1376
|
|
1354
1377
|
cleanup:
|
1355
1378
|
git_config_free(cfg);
|
1356
|
-
|
1357
|
-
|
1379
|
+
git_buf_dispose(&key);
|
1380
|
+
git_buf_dispose(&effective_submodule_url);
|
1358
1381
|
|
1359
1382
|
return error;
|
1360
1383
|
}
|
@@ -1367,7 +1390,7 @@ int git_submodule_sync(git_submodule *sm)
|
|
1367
1390
|
git_repository *smrepo = NULL;
|
1368
1391
|
|
1369
1392
|
if (!sm->url) {
|
1370
|
-
|
1393
|
+
git_error_set(GIT_ERROR_SUBMODULE,
|
1371
1394
|
"no URL configured for submodule '%s'", sm->name);
|
1372
1395
|
return -1;
|
1373
1396
|
}
|
@@ -1389,12 +1412,12 @@ int git_submodule_sync(git_submodule *sm)
|
|
1389
1412
|
if ((error = git_repository_config__weakptr(&cfg, smrepo)) < 0)
|
1390
1413
|
/* return error from reading submodule config */;
|
1391
1414
|
else if ((error = lookup_head_remote_key(&remote_name, smrepo)) < 0) {
|
1392
|
-
|
1415
|
+
git_error_clear();
|
1393
1416
|
error = git_buf_sets(&key, "remote.origin.url");
|
1394
1417
|
} else {
|
1395
1418
|
error = git_buf_join3(
|
1396
1419
|
&key, '.', "remote", remote_name.ptr, "url");
|
1397
|
-
|
1420
|
+
git_buf_dispose(&remote_name);
|
1398
1421
|
}
|
1399
1422
|
|
1400
1423
|
if (!error)
|
@@ -1403,7 +1426,7 @@ int git_submodule_sync(git_submodule *sm)
|
|
1403
1426
|
git_repository_free(smrepo);
|
1404
1427
|
}
|
1405
1428
|
|
1406
|
-
|
1429
|
+
git_buf_dispose(&key);
|
1407
1430
|
|
1408
1431
|
return error;
|
1409
1432
|
}
|
@@ -1446,7 +1469,7 @@ static int git_submodule__open(
|
|
1446
1469
|
if (!git_reference_name_to_id(&sm->wd_oid, *subrepo, GIT_HEAD_FILE))
|
1447
1470
|
sm->flags |= GIT_SUBMODULE_STATUS__WD_OID_VALID;
|
1448
1471
|
else
|
1449
|
-
|
1472
|
+
git_error_clear();
|
1450
1473
|
} else if (git_path_exists(path.ptr)) {
|
1451
1474
|
sm->flags |= GIT_SUBMODULE_STATUS__WD_SCANNED |
|
1452
1475
|
GIT_SUBMODULE_STATUS_IN_WD;
|
@@ -1457,7 +1480,7 @@ static int git_submodule__open(
|
|
1457
1480
|
sm->flags |= GIT_SUBMODULE_STATUS__WD_SCANNED;
|
1458
1481
|
}
|
1459
1482
|
|
1460
|
-
|
1483
|
+
git_buf_dispose(&path);
|
1461
1484
|
|
1462
1485
|
return error;
|
1463
1486
|
}
|
@@ -1536,7 +1559,7 @@ static int submodule_update_head(git_submodule *submodule)
|
|
1536
1559
|
/* if we can't look up file in current head, then done */
|
1537
1560
|
if (git_repository_head_tree(&head, submodule->repo) < 0 ||
|
1538
1561
|
git_tree_entry_bypath(&te, head, submodule->path) < 0)
|
1539
|
-
|
1562
|
+
git_error_clear();
|
1540
1563
|
else
|
1541
1564
|
submodule_update_from_head_data(submodule, te->attr, git_tree_entry_id(te));
|
1542
1565
|
|
@@ -1639,12 +1662,12 @@ int git_submodule__status(
|
|
1639
1662
|
if (ign == GIT_SUBMODULE_IGNORE_DIRTY) {
|
1640
1663
|
/* git_submodule_open_bare will load WD OID data */
|
1641
1664
|
if (git_submodule_open_bare(&smrepo, sm) < 0)
|
1642
|
-
|
1665
|
+
git_error_clear();
|
1643
1666
|
else
|
1644
1667
|
git_repository_free(smrepo);
|
1645
1668
|
smrepo = NULL;
|
1646
1669
|
} else if (git_submodule_open(&smrepo, sm) < 0) {
|
1647
|
-
|
1670
|
+
git_error_clear();
|
1648
1671
|
smrepo = NULL;
|
1649
1672
|
}
|
1650
1673
|
|
@@ -1702,12 +1725,12 @@ static int submodule_alloc(
|
|
1702
1725
|
git_submodule *sm;
|
1703
1726
|
|
1704
1727
|
if (!name || !(namelen = strlen(name))) {
|
1705
|
-
|
1728
|
+
git_error_set(GIT_ERROR_SUBMODULE, "invalid submodule name");
|
1706
1729
|
return -1;
|
1707
1730
|
}
|
1708
1731
|
|
1709
1732
|
sm = git__calloc(1, sizeof(git_submodule));
|
1710
|
-
|
1733
|
+
GIT_ERROR_CHECK_ALLOC(sm);
|
1711
1734
|
|
1712
1735
|
sm->name = sm->path = git__strdup(name);
|
1713
1736
|
if (!sm->name) {
|
@@ -1753,7 +1776,7 @@ void git_submodule_free(git_submodule *sm)
|
|
1753
1776
|
|
1754
1777
|
static int submodule_config_error(const char *property, const char *value)
|
1755
1778
|
{
|
1756
|
-
|
1779
|
+
git_error_set(GIT_ERROR_INVALID,
|
1757
1780
|
"invalid value for submodule '%s' property: '%s'", property, value);
|
1758
1781
|
return -1;
|
1759
1782
|
}
|
@@ -1844,7 +1867,7 @@ static int submodule_read_config(git_submodule *sm, git_config *cfg)
|
|
1844
1867
|
if (sm->path != sm->name)
|
1845
1868
|
git__free(sm->path);
|
1846
1869
|
sm->path = git__strdup(value);
|
1847
|
-
|
1870
|
+
GIT_ERROR_CHECK_ALLOC(sm->path);
|
1848
1871
|
}
|
1849
1872
|
|
1850
1873
|
}
|
@@ -1857,7 +1880,7 @@ static int submodule_read_config(git_submodule *sm, git_config *cfg)
|
|
1857
1880
|
if (!looks_like_command_line_option(value)) {
|
1858
1881
|
in_config = 1;
|
1859
1882
|
sm->url = git__strdup(value);
|
1860
|
-
|
1883
|
+
GIT_ERROR_CHECK_ALLOC(sm->url);
|
1861
1884
|
}
|
1862
1885
|
} else if (error != GIT_ENOTFOUND) {
|
1863
1886
|
goto cleanup;
|
@@ -1866,7 +1889,7 @@ static int submodule_read_config(git_submodule *sm, git_config *cfg)
|
|
1866
1889
|
if ((error = get_value(&value, cfg, &key, sm->name, "branch")) == 0) {
|
1867
1890
|
in_config = 1;
|
1868
1891
|
sm->branch = git__strdup(value);
|
1869
|
-
|
1892
|
+
GIT_ERROR_CHECK_ALLOC(sm->branch);
|
1870
1893
|
} else if (error != GIT_ENOTFOUND) {
|
1871
1894
|
goto cleanup;
|
1872
1895
|
}
|
@@ -1904,7 +1927,7 @@ static int submodule_read_config(git_submodule *sm, git_config *cfg)
|
|
1904
1927
|
error = 0;
|
1905
1928
|
|
1906
1929
|
cleanup:
|
1907
|
-
|
1930
|
+
git_buf_dispose(&key);
|
1908
1931
|
return error;
|
1909
1932
|
}
|
1910
1933
|
|
@@ -1912,7 +1935,7 @@ static int submodule_load_each(const git_config_entry *entry, void *payload)
|
|
1912
1935
|
{
|
1913
1936
|
lfc_data *data = payload;
|
1914
1937
|
const char *namestart, *property;
|
1915
|
-
|
1938
|
+
size_t pos;
|
1916
1939
|
git_strmap *map = data->map;
|
1917
1940
|
git_buf name = GIT_BUF_INIT;
|
1918
1941
|
git_submodule *sm;
|
@@ -1966,7 +1989,7 @@ static int submodule_load_each(const git_config_entry *entry, void *payload)
|
|
1966
1989
|
error = 0;
|
1967
1990
|
|
1968
1991
|
done:
|
1969
|
-
|
1992
|
+
git_buf_dispose(&name);
|
1970
1993
|
return error;
|
1971
1994
|
}
|
1972
1995
|
|
@@ -1983,7 +2006,7 @@ static int submodule_load_from_wd_lite(git_submodule *sm)
|
|
1983
2006
|
if (git_path_contains(&path, DOT_GIT))
|
1984
2007
|
sm->flags |= GIT_SUBMODULE_STATUS_IN_WD;
|
1985
2008
|
|
1986
|
-
|
2009
|
+
git_buf_dispose(&path);
|
1987
2010
|
return 0;
|
1988
2011
|
}
|
1989
2012
|
|
@@ -2007,6 +2030,7 @@ static int gitmodules_snapshot(git_config **snap, git_repository *repo)
|
|
2007
2030
|
|
2008
2031
|
if ((error = git_config_open_ondisk(&mods, path.ptr)) < 0)
|
2009
2032
|
goto cleanup;
|
2033
|
+
git_buf_dispose(&path);
|
2010
2034
|
|
2011
2035
|
if ((error = git_config_snapshot(snap, mods)) < 0)
|
2012
2036
|
goto cleanup;
|
@@ -2016,7 +2040,7 @@ static int gitmodules_snapshot(git_config **snap, git_repository *repo)
|
|
2016
2040
|
cleanup:
|
2017
2041
|
if (mods)
|
2018
2042
|
git_config_free(mods);
|
2019
|
-
|
2043
|
+
git_buf_dispose(&path);
|
2020
2044
|
|
2021
2045
|
return error;
|
2022
2046
|
}
|
@@ -2034,18 +2058,18 @@ static git_config_backend *open_gitmodules(
|
|
2034
2058
|
return NULL;
|
2035
2059
|
|
2036
2060
|
if (okay_to_create || git_path_isfile(path.ptr)) {
|
2037
|
-
/*
|
2038
|
-
if (
|
2061
|
+
/* git_config_backend_from_file should only fail if OOM */
|
2062
|
+
if (git_config_backend_from_file(&mods, path.ptr) < 0)
|
2039
2063
|
mods = NULL;
|
2040
2064
|
/* open should only fail here if the file is malformed */
|
2041
|
-
else if (
|
2042
|
-
|
2065
|
+
else if (git_config_backend_open(mods, GIT_CONFIG_LEVEL_LOCAL, repo) < 0) {
|
2066
|
+
git_config_backend_free(mods);
|
2043
2067
|
mods = NULL;
|
2044
2068
|
}
|
2045
2069
|
}
|
2046
2070
|
}
|
2047
2071
|
|
2048
|
-
|
2072
|
+
git_buf_dispose(&path);
|
2049
2073
|
|
2050
2074
|
return mods;
|
2051
2075
|
}
|
@@ -2067,7 +2091,7 @@ static int lookup_head_remote_key(git_buf *remote_name, git_repository *repo)
|
|
2067
2091
|
* a remote key for the local tracking branch HEAD points to.
|
2068
2092
|
**/
|
2069
2093
|
if (!git_reference_is_branch(head)) {
|
2070
|
-
|
2094
|
+
git_error_set(GIT_ERROR_INVALID,
|
2071
2095
|
"HEAD does not refer to a branch.");
|
2072
2096
|
error = GIT_ENOTFOUND;
|
2073
2097
|
goto done;
|
@@ -2085,7 +2109,7 @@ static int lookup_head_remote_key(git_buf *remote_name, git_repository *repo)
|
|
2085
2109
|
goto done;
|
2086
2110
|
|
2087
2111
|
done:
|
2088
|
-
|
2112
|
+
git_buf_dispose(&upstream_name);
|
2089
2113
|
git_reference_free(head);
|
2090
2114
|
|
2091
2115
|
return error;
|
@@ -2101,7 +2125,7 @@ static int lookup_head_remote(git_remote **remote, git_repository *repo)
|
|
2101
2125
|
if (!(error = lookup_head_remote_key(&remote_name, repo)))
|
2102
2126
|
error = git_remote_lookup(remote, repo, remote_name.ptr);
|
2103
2127
|
|
2104
|
-
|
2128
|
+
git_buf_dispose(&remote_name);
|
2105
2129
|
|
2106
2130
|
return error;
|
2107
2131
|
}
|
@@ -2116,8 +2140,8 @@ static int lookup_default_remote(git_remote **remote, git_repository *repo)
|
|
2116
2140
|
error = git_remote_lookup(remote, repo, "origin");
|
2117
2141
|
|
2118
2142
|
if (error == GIT_ENOTFOUND)
|
2119
|
-
|
2120
|
-
|
2143
|
+
git_error_set(
|
2144
|
+
GIT_ERROR_SUBMODULE,
|
2121
2145
|
"cannot get default remote for submodule - no local tracking "
|
2122
2146
|
"branch for HEAD and origin does not exist");
|
2123
2147
|
|
@@ -2136,7 +2160,7 @@ static int get_url_base(git_buf *url, git_repository *repo)
|
|
2136
2160
|
} else if (error != GIT_ENOTFOUND)
|
2137
2161
|
goto out;
|
2138
2162
|
else
|
2139
|
-
|
2163
|
+
git_error_clear();
|
2140
2164
|
|
2141
2165
|
/* if repository does not have a default remote, use workdir instead */
|
2142
2166
|
if (git_repository_is_worktree(repo)) {
|
@@ -2217,11 +2241,11 @@ static void submodule_get_wd_status(
|
|
2217
2241
|
|
2218
2242
|
/* if we don't have an unborn head, check diff with index */
|
2219
2243
|
if (git_repository_head_tree(&sm_head, sm_repo) < 0)
|
2220
|
-
|
2244
|
+
git_error_clear();
|
2221
2245
|
else {
|
2222
2246
|
/* perform head to index diff on submodule */
|
2223
2247
|
if (git_diff_tree_to_index(&diff, sm_repo, sm_head, index, &opt) < 0)
|
2224
|
-
|
2248
|
+
git_error_clear();
|
2225
2249
|
else {
|
2226
2250
|
if (git_diff_num_deltas(diff) > 0)
|
2227
2251
|
*status |= GIT_SUBMODULE_STATUS_WD_INDEX_MODIFIED;
|
@@ -2234,7 +2258,7 @@ static void submodule_get_wd_status(
|
|
2234
2258
|
|
2235
2259
|
/* perform index-to-workdir diff on submodule */
|
2236
2260
|
if (git_diff_index_to_workdir(&diff, sm_repo, index, &opt) < 0)
|
2237
|
-
|
2261
|
+
git_error_clear();
|
2238
2262
|
else {
|
2239
2263
|
size_t untracked =
|
2240
2264
|
git_diff_num_deltas_of_type(diff, GIT_DELTA_UNTRACKED);
|