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
@@ -0,0 +1,24 @@
|
|
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_hash_mbedtld_h__
|
9
|
+
#define INCLUDE_hash_mbedtld_h__
|
10
|
+
|
11
|
+
#include <mbedtls/sha1.h>
|
12
|
+
|
13
|
+
struct git_hash_ctx {
|
14
|
+
mbedtls_sha1_context c;
|
15
|
+
};
|
16
|
+
|
17
|
+
#define git_hash_ctx_init(ctx) git_hash_init(ctx)
|
18
|
+
|
19
|
+
GIT_INLINE(int) git_hash_global_init(void)
|
20
|
+
{
|
21
|
+
return 0;
|
22
|
+
}
|
23
|
+
|
24
|
+
#endif /* INCLUDE_hash_mbedtld_h__ */
|
@@ -16,16 +16,20 @@ struct git_hash_ctx {
|
|
16
16
|
SHA_CTX c;
|
17
17
|
};
|
18
18
|
|
19
|
-
#define git_hash_global_init() 0
|
20
19
|
#define git_hash_ctx_init(ctx) git_hash_init(ctx)
|
21
20
|
#define git_hash_ctx_cleanup(ctx)
|
22
21
|
|
22
|
+
GIT_INLINE(int) git_hash_global_init(void)
|
23
|
+
{
|
24
|
+
return 0;
|
25
|
+
}
|
26
|
+
|
23
27
|
GIT_INLINE(int) git_hash_init(git_hash_ctx *ctx)
|
24
28
|
{
|
25
29
|
assert(ctx);
|
26
30
|
|
27
31
|
if (SHA1_Init(&ctx->c) != 1) {
|
28
|
-
|
32
|
+
git_error_set(GIT_ERROR_SHA1, "hash_openssl: failed to initialize hash context");
|
29
33
|
return -1;
|
30
34
|
}
|
31
35
|
|
@@ -37,7 +41,7 @@ GIT_INLINE(int) git_hash_update(git_hash_ctx *ctx, const void *data, size_t len)
|
|
37
41
|
assert(ctx);
|
38
42
|
|
39
43
|
if (SHA1_Update(&ctx->c, data, len) != 1) {
|
40
|
-
|
44
|
+
git_error_set(GIT_ERROR_SHA1, "hash_openssl: failed to update hash");
|
41
45
|
return -1;
|
42
46
|
}
|
43
47
|
|
@@ -49,7 +53,7 @@ GIT_INLINE(int) git_hash_final(git_oid *out, git_hash_ctx *ctx)
|
|
49
53
|
assert(ctx);
|
50
54
|
|
51
55
|
if (SHA1_Final(out->id, &ctx->c) != 1) {
|
52
|
-
|
56
|
+
git_error_set(GIT_ERROR_SHA1, "hash_openssl: failed to finalize hash");
|
53
57
|
return -1;
|
54
58
|
}
|
55
59
|
|
@@ -25,7 +25,7 @@ GIT_INLINE(int) hash_cng_prov_init(void)
|
|
25
25
|
|
26
26
|
/* Only use CNG on Windows 2008 / Vista SP1 or better (Windows 6.0 SP1) */
|
27
27
|
if (!git_has_win32_version(6, 0, 1)) {
|
28
|
-
|
28
|
+
git_error_set(GIT_ERROR_SHA1, "CryptoNG is not supported on this platform");
|
29
29
|
return -1;
|
30
30
|
}
|
31
31
|
|
@@ -35,7 +35,7 @@ GIT_INLINE(int) hash_cng_prov_init(void)
|
|
35
35
|
StringCchCat(dll_path, MAX_PATH, "\\") < 0 ||
|
36
36
|
StringCchCat(dll_path, MAX_PATH, GIT_HASH_CNG_DLL_NAME) < 0 ||
|
37
37
|
(hash_prov.prov.cng.dll = LoadLibrary(dll_path)) == NULL) {
|
38
|
-
|
38
|
+
git_error_set(GIT_ERROR_SHA1, "CryptoNG library could not be loaded");
|
39
39
|
return -1;
|
40
40
|
}
|
41
41
|
|
@@ -49,7 +49,7 @@ GIT_INLINE(int) hash_cng_prov_init(void)
|
|
49
49
|
(hash_prov.prov.cng.close_algorithm_provider = (hash_win32_cng_close_algorithm_provider_fn)GetProcAddress(hash_prov.prov.cng.dll, "BCryptCloseAlgorithmProvider")) == NULL) {
|
50
50
|
FreeLibrary(hash_prov.prov.cng.dll);
|
51
51
|
|
52
|
-
|
52
|
+
git_error_set(GIT_ERROR_OS, "CryptoNG functions could not be loaded");
|
53
53
|
return -1;
|
54
54
|
}
|
55
55
|
|
@@ -57,7 +57,7 @@ GIT_INLINE(int) hash_cng_prov_init(void)
|
|
57
57
|
if (hash_prov.prov.cng.open_algorithm_provider(&hash_prov.prov.cng.handle, GIT_HASH_CNG_HASH_TYPE, NULL, GIT_HASH_CNG_HASH_REUSABLE) < 0) {
|
58
58
|
FreeLibrary(hash_prov.prov.cng.dll);
|
59
59
|
|
60
|
-
|
60
|
+
git_error_set(GIT_ERROR_OS, "algorithm provider could not be initialized");
|
61
61
|
return -1;
|
62
62
|
}
|
63
63
|
|
@@ -66,7 +66,7 @@ GIT_INLINE(int) hash_cng_prov_init(void)
|
|
66
66
|
hash_prov.prov.cng.close_algorithm_provider(hash_prov.prov.cng.handle, 0);
|
67
67
|
FreeLibrary(hash_prov.prov.cng.dll);
|
68
68
|
|
69
|
-
|
69
|
+
git_error_set(GIT_ERROR_OS, "algorithm handle could not be found");
|
70
70
|
return -1;
|
71
71
|
}
|
72
72
|
|
@@ -86,7 +86,7 @@ GIT_INLINE(void) hash_cng_prov_shutdown(void)
|
|
86
86
|
GIT_INLINE(int) hash_cryptoapi_prov_init()
|
87
87
|
{
|
88
88
|
if (!CryptAcquireContext(&hash_prov.prov.cryptoapi.handle, NULL, 0, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) {
|
89
|
-
|
89
|
+
git_error_set(GIT_ERROR_OS, "legacy hash context could not be started");
|
90
90
|
return -1;
|
91
91
|
}
|
92
92
|
|
@@ -141,7 +141,7 @@ GIT_INLINE(int) hash_cryptoapi_init(git_hash_ctx *ctx)
|
|
141
141
|
|
142
142
|
if (!CryptCreateHash(ctx->prov->prov.cryptoapi.handle, CALG_SHA1, 0, 0, &ctx->ctx.cryptoapi.hash_handle)) {
|
143
143
|
ctx->ctx.cryptoapi.valid = 0;
|
144
|
-
|
144
|
+
git_error_set(GIT_ERROR_OS, "legacy hash implementation could not be created");
|
145
145
|
return -1;
|
146
146
|
}
|
147
147
|
|
@@ -159,7 +159,7 @@ GIT_INLINE(int) hash_cryptoapi_update(git_hash_ctx *ctx, const void *_data, size
|
|
159
159
|
DWORD chunk = (len > MAXDWORD) ? MAXDWORD : (DWORD)len;
|
160
160
|
|
161
161
|
if (!CryptHashData(ctx->ctx.cryptoapi.hash_handle, data, chunk, 0)) {
|
162
|
-
|
162
|
+
git_error_set(GIT_ERROR_OS, "legacy hash data could not be updated");
|
163
163
|
return -1;
|
164
164
|
}
|
165
165
|
|
@@ -178,7 +178,7 @@ GIT_INLINE(int) hash_cryptoapi_final(git_oid *out, git_hash_ctx *ctx)
|
|
178
178
|
assert(ctx->ctx.cryptoapi.valid);
|
179
179
|
|
180
180
|
if (!CryptGetHashParam(ctx->ctx.cryptoapi.hash_handle, HP_HASHVAL, out->id, &len, 0)) {
|
181
|
-
|
181
|
+
git_error_set(GIT_ERROR_OS, "legacy hash data could not be finished");
|
182
182
|
error = -1;
|
183
183
|
}
|
184
184
|
|
@@ -204,7 +204,7 @@ GIT_INLINE(int) hash_ctx_cng_init(git_hash_ctx *ctx)
|
|
204
204
|
if (hash_prov.prov.cng.create_hash(hash_prov.prov.cng.handle, &ctx->ctx.cng.hash_handle, ctx->ctx.cng.hash_object, hash_prov.prov.cng.hash_object_size, NULL, 0, 0) < 0) {
|
205
205
|
git__free(ctx->ctx.cng.hash_object);
|
206
206
|
|
207
|
-
|
207
|
+
git_error_set(GIT_ERROR_OS, "hash implementation could not be created");
|
208
208
|
return -1;
|
209
209
|
}
|
210
210
|
|
@@ -223,7 +223,7 @@ GIT_INLINE(int) hash_cng_init(git_hash_ctx *ctx)
|
|
223
223
|
|
224
224
|
/* CNG needs to be finished to restart */
|
225
225
|
if (ctx->prov->prov.cng.finish_hash(ctx->ctx.cng.hash_handle, hash, GIT_OID_RAWSZ, 0) < 0) {
|
226
|
-
|
226
|
+
git_error_set(GIT_ERROR_OS, "hash implementation could not be finished");
|
227
227
|
return -1;
|
228
228
|
}
|
229
229
|
|
@@ -240,7 +240,7 @@ GIT_INLINE(int) hash_cng_update(git_hash_ctx *ctx, const void *_data, size_t len
|
|
240
240
|
ULONG chunk = (len > ULONG_MAX) ? ULONG_MAX : (ULONG)len;
|
241
241
|
|
242
242
|
if (ctx->prov->prov.cng.hash_data(ctx->ctx.cng.hash_handle, data, chunk, 0) < 0) {
|
243
|
-
|
243
|
+
git_error_set(GIT_ERROR_OS, "hash could not be updated");
|
244
244
|
return -1;
|
245
245
|
}
|
246
246
|
|
@@ -254,7 +254,7 @@ GIT_INLINE(int) hash_cng_update(git_hash_ctx *ctx, const void *_data, size_t len
|
|
254
254
|
GIT_INLINE(int) hash_cng_final(git_oid *out, git_hash_ctx *ctx)
|
255
255
|
{
|
256
256
|
if (ctx->prov->prov.cng.finish_hash(ctx->ctx.cng.hash_handle, out->id, GIT_OID_RAWSZ, 0) < 0) {
|
257
|
-
|
257
|
+
git_error_set(GIT_ERROR_OS, "hash could not be finished");
|
258
258
|
return -1;
|
259
259
|
}
|
260
260
|
|
@@ -216,7 +216,7 @@ static int hashsig_finalize_hashes(git_hashsig *sig)
|
|
216
216
|
{
|
217
217
|
if (sig->mins.size < HASHSIG_HEAP_MIN_SIZE &&
|
218
218
|
!(sig->opt & GIT_HASHSIG_ALLOW_SMALL_FILES)) {
|
219
|
-
|
219
|
+
git_error_set(GIT_ERROR_INVALID,
|
220
220
|
"file too small for similarity signature calculation");
|
221
221
|
return GIT_EBUFS;
|
222
222
|
}
|
@@ -249,7 +249,7 @@ int git_hashsig_create(
|
|
249
249
|
int error;
|
250
250
|
hashsig_in_progress prog;
|
251
251
|
git_hashsig *sig = hashsig_alloc(opts);
|
252
|
-
|
252
|
+
GIT_ERROR_CHECK_ALLOC(sig);
|
253
253
|
|
254
254
|
hashsig_in_progress_init(&prog, sig);
|
255
255
|
|
@@ -276,7 +276,7 @@ int git_hashsig_create_fromfile(
|
|
276
276
|
int error = 0, fd;
|
277
277
|
hashsig_in_progress prog;
|
278
278
|
git_hashsig *sig = hashsig_alloc(opts);
|
279
|
-
|
279
|
+
GIT_ERROR_CHECK_ALLOC(sig);
|
280
280
|
|
281
281
|
if ((fd = git_futils_open_ro(path)) < 0) {
|
282
282
|
git__free(sig);
|
@@ -288,7 +288,7 @@ int git_hashsig_create_fromfile(
|
|
288
288
|
while (!error) {
|
289
289
|
if ((buflen = p_read(fd, buf, sizeof(buf))) <= 0) {
|
290
290
|
if ((error = (int)buflen) < 0)
|
291
|
-
|
291
|
+
git_error_set(GIT_ERROR_OS,
|
292
292
|
"read error on '%s' calculating similarity hashes", path);
|
293
293
|
break;
|
294
294
|
}
|
data/vendor/libgit2/src/idxmap.c
CHANGED
@@ -7,17 +7,27 @@
|
|
7
7
|
|
8
8
|
#include "idxmap.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(idx, const git_index_entry *, git_index_entry *)
|
18
|
+
__KHASH_TYPE(idxicase, const git_index_entry *, git_index_entry *)
|
19
|
+
|
10
20
|
/* This is __ac_X31_hash_string but with tolower and it takes the entry's stage into account */
|
11
21
|
static kh_inline khint_t idxentry_hash(const git_index_entry *e)
|
12
22
|
{
|
13
23
|
const char *s = e->path;
|
14
24
|
khint_t h = (khint_t)git__tolower(*s);
|
15
25
|
if (h) for (++s ; *s; ++s) h = (h << 5) - h + (khint_t)git__tolower(*s);
|
16
|
-
return h +
|
26
|
+
return h + GIT_INDEX_ENTRY_STAGE(e);
|
17
27
|
}
|
18
28
|
|
19
|
-
#define idxentry_equal(a, b) (
|
20
|
-
#define idxentry_icase_equal(a, b) (
|
29
|
+
#define idxentry_equal(a, b) (GIT_INDEX_ENTRY_STAGE(a) == GIT_INDEX_ENTRY_STAGE(b) && strcmp(a->path, b->path) == 0)
|
30
|
+
#define idxentry_icase_equal(a, b) (GIT_INDEX_ENTRY_STAGE(a) == GIT_INDEX_ENTRY_STAGE(b) && strcasecmp(a->path, b->path) == 0)
|
21
31
|
|
22
32
|
__KHASH_IMPL(idx, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_equal)
|
23
33
|
__KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entry *, 1, idxentry_hash, idxentry_icase_equal)
|
@@ -25,7 +35,7 @@ __KHASH_IMPL(idxicase, static kh_inline, const git_index_entry *, git_index_entr
|
|
25
35
|
int git_idxmap_alloc(git_idxmap **map)
|
26
36
|
{
|
27
37
|
if ((*map = kh_init(idx)) == NULL) {
|
28
|
-
|
38
|
+
git_error_set_oom();
|
29
39
|
return -1;
|
30
40
|
}
|
31
41
|
|
@@ -35,7 +45,7 @@ int git_idxmap_alloc(git_idxmap **map)
|
|
35
45
|
int git_idxmap_icase_alloc(git_idxmap_icase **map)
|
36
46
|
{
|
37
47
|
if ((*map = kh_init(idxicase)) == NULL) {
|
38
|
-
|
48
|
+
git_error_set_oom();
|
39
49
|
return -1;
|
40
50
|
}
|
41
51
|
|
@@ -104,11 +114,21 @@ void git_idxmap_free(git_idxmap *map)
|
|
104
114
|
kh_destroy(idx, map);
|
105
115
|
}
|
106
116
|
|
117
|
+
void git_idxmap_icase_free(git_idxmap_icase *map)
|
118
|
+
{
|
119
|
+
kh_destroy(idxicase, map);
|
120
|
+
}
|
121
|
+
|
107
122
|
void git_idxmap_clear(git_idxmap *map)
|
108
123
|
{
|
109
124
|
kh_clear(idx, map);
|
110
125
|
}
|
111
126
|
|
127
|
+
void git_idxmap_icase_clear(git_idxmap_icase *map)
|
128
|
+
{
|
129
|
+
kh_clear(idxicase, map);
|
130
|
+
}
|
131
|
+
|
112
132
|
void git_idxmap_delete_at(git_idxmap *map, size_t idx)
|
113
133
|
{
|
114
134
|
kh_del(idx, map, idx);
|
data/vendor/libgit2/src/idxmap.h
CHANGED
@@ -9,23 +9,10 @@
|
|
9
9
|
|
10
10
|
#include "common.h"
|
11
11
|
|
12
|
-
#include <ctype.h>
|
13
12
|
#include "git2/index.h"
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
#define krealloc git__realloc
|
18
|
-
#define kreallocarray git__reallocarray
|
19
|
-
#define kfree git__free
|
20
|
-
#include "khash.h"
|
21
|
-
|
22
|
-
__KHASH_TYPE(idx, const git_index_entry *, git_index_entry *)
|
23
|
-
__KHASH_TYPE(idxicase, const git_index_entry *, git_index_entry *)
|
24
|
-
|
25
|
-
typedef khash_t(idx) git_idxmap;
|
26
|
-
typedef khash_t(idxicase) git_idxmap_icase;
|
27
|
-
|
28
|
-
typedef khiter_t git_idxmap_iter;
|
14
|
+
typedef struct kh_idx_s git_idxmap;
|
15
|
+
typedef struct kh_idxicase_s git_idxmap_icase;
|
29
16
|
|
30
17
|
int git_idxmap_alloc(git_idxmap **map);
|
31
18
|
int git_idxmap_icase_alloc(git_idxmap_icase **map);
|
@@ -41,7 +28,9 @@ int git_idxmap_has_data(git_idxmap *map, size_t idx);
|
|
41
28
|
void git_idxmap_resize(git_idxmap *map, size_t size);
|
42
29
|
void git_idxmap_icase_resize(git_idxmap_icase *map, size_t size);
|
43
30
|
void git_idxmap_free(git_idxmap *map);
|
31
|
+
void git_idxmap_icase_free(git_idxmap_icase *map);
|
44
32
|
void git_idxmap_clear(git_idxmap *map);
|
33
|
+
void git_idxmap_icase_clear(git_idxmap_icase *map);
|
45
34
|
|
46
35
|
void git_idxmap_delete_at(git_idxmap *map, size_t idx);
|
47
36
|
void git_idxmap_icase_delete_at(git_idxmap_icase *map, size_t idx);
|
@@ -49,7 +38,4 @@ void git_idxmap_icase_delete_at(git_idxmap_icase *map, size_t idx);
|
|
49
38
|
void git_idxmap_delete(git_idxmap *map, const git_index_entry *key);
|
50
39
|
void git_idxmap_icase_delete(git_idxmap_icase *map, const git_index_entry *key);
|
51
40
|
|
52
|
-
#define git_idxmap_begin kh_begin
|
53
|
-
#define git_idxmap_end kh_end
|
54
|
-
|
55
41
|
#endif
|
data/vendor/libgit2/src/ignore.c
CHANGED
@@ -142,7 +142,7 @@ static int does_negate_rule(int *out, git_vector *rules, git_attr_fnmatch *match
|
|
142
142
|
goto out;
|
143
143
|
|
144
144
|
if ((error = p_fnmatch(git_buf_cstr(&buf), path, fnflags)) < 0) {
|
145
|
-
|
145
|
+
git_error_set(GIT_ERROR_INVALID, "error matching pattern");
|
146
146
|
goto out;
|
147
147
|
}
|
148
148
|
|
@@ -158,7 +158,7 @@ static int does_negate_rule(int *out, git_vector *rules, git_attr_fnmatch *match
|
|
158
158
|
|
159
159
|
out:
|
160
160
|
git__free(path);
|
161
|
-
|
161
|
+
git_buf_dispose(&buf);
|
162
162
|
return error;
|
163
163
|
}
|
164
164
|
|
@@ -171,7 +171,7 @@ static int parse_ignore_file(
|
|
171
171
|
git_attr_fnmatch *match = NULL;
|
172
172
|
|
173
173
|
if (git_repository__cvar(&ignore_case, repo, GIT_CVAR_IGNORECASE) < 0)
|
174
|
-
|
174
|
+
git_error_clear();
|
175
175
|
|
176
176
|
/* if subdir file path, convert context for file paths */
|
177
177
|
if (attrs->entry &&
|
@@ -180,7 +180,7 @@ static int parse_ignore_file(
|
|
180
180
|
context = attrs->entry->path;
|
181
181
|
|
182
182
|
if (git_mutex_lock(&attrs->lock) < 0) {
|
183
|
-
|
183
|
+
git_error_set(GIT_ERROR_OS, "failed to lock ignore file");
|
184
184
|
return -1;
|
185
185
|
}
|
186
186
|
|
@@ -315,7 +315,7 @@ int git_ignore__for_path(
|
|
315
315
|
(error = git_path_to_dir(&local)) < 0 ||
|
316
316
|
(error = git_buf_joinpath(&ignores->dir, workdir, local.ptr)) < 0)
|
317
317
|
{;} /* Nothing, we just want to stop on the first error */
|
318
|
-
|
318
|
+
git_buf_dispose(&local);
|
319
319
|
} else {
|
320
320
|
error = git_buf_joinpath(&ignores->dir, path, "");
|
321
321
|
}
|
@@ -355,7 +355,7 @@ int git_ignore__for_path(
|
|
355
355
|
git_repository_attr_cache(repo)->cfg_excl_file);
|
356
356
|
|
357
357
|
cleanup:
|
358
|
-
|
358
|
+
git_buf_dispose(&infopath);
|
359
359
|
if (error < 0)
|
360
360
|
git_ignore__free(ignores);
|
361
361
|
|
@@ -427,7 +427,7 @@ void git_ignore__free(git_ignores *ignores)
|
|
427
427
|
}
|
428
428
|
git_vector_free(&ignores->ign_global);
|
429
429
|
|
430
|
-
|
430
|
+
git_buf_dispose(&ignores->dir);
|
431
431
|
}
|
432
432
|
|
433
433
|
static bool ignore_lookup_in_rules(
|
@@ -624,7 +624,7 @@ int git_ignore__check_pathspec_for_exact_ignores(
|
|
624
624
|
break;
|
625
625
|
|
626
626
|
if (ignored) {
|
627
|
-
|
627
|
+
git_error_set(GIT_ERROR_INVALID, "pathspec contains ignored file '%s'",
|
628
628
|
filename);
|
629
629
|
error = GIT_EINVALIDSPEC;
|
630
630
|
break;
|
@@ -632,7 +632,7 @@ int git_ignore__check_pathspec_for_exact_ignores(
|
|
632
632
|
}
|
633
633
|
|
634
634
|
git_index_free(idx);
|
635
|
-
|
635
|
+
git_buf_dispose(&path);
|
636
636
|
|
637
637
|
return error;
|
638
638
|
}
|
data/vendor/libgit2/src/index.c
CHANGED
@@ -29,7 +29,7 @@
|
|
29
29
|
|
30
30
|
#define INSERT_IN_MAP_EX(idx, map, e, err) do { \
|
31
31
|
if ((idx)->ignore_case) \
|
32
|
-
git_idxmap_icase_insert((
|
32
|
+
git_idxmap_icase_insert((git_idxmap_icase *) (map), (e), (e), (err)); \
|
33
33
|
else \
|
34
34
|
git_idxmap_insert((map), (e), (e), (err)); \
|
35
35
|
} while (0)
|
@@ -38,14 +38,14 @@
|
|
38
38
|
|
39
39
|
#define LOOKUP_IN_MAP(p, idx, k) do { \
|
40
40
|
if ((idx)->ignore_case) \
|
41
|
-
(p) = git_idxmap_icase_lookup_index((
|
41
|
+
(p) = git_idxmap_icase_lookup_index((git_idxmap_icase *) index->entries_map, (k)); \
|
42
42
|
else \
|
43
43
|
(p) = git_idxmap_lookup_index(index->entries_map, (k)); \
|
44
44
|
} while (0)
|
45
45
|
|
46
46
|
#define DELETE_IN_MAP(idx, e) do { \
|
47
47
|
if ((idx)->ignore_case) \
|
48
|
-
git_idxmap_icase_delete((
|
48
|
+
git_idxmap_icase_delete((git_idxmap_icase *) (idx)->entries_map, (e)); \
|
49
49
|
else \
|
50
50
|
git_idxmap_delete((idx)->entries_map, (e)); \
|
51
51
|
} while (0)
|
@@ -135,8 +135,10 @@ struct reuc_entry_internal {
|
|
135
135
|
char path[GIT_FLEX_ARRAY];
|
136
136
|
};
|
137
137
|
|
138
|
+
bool git_index__enforce_unsaved_safety = false;
|
139
|
+
|
138
140
|
/* local declarations */
|
139
|
-
static
|
141
|
+
static int read_extension(size_t *read_len, git_index *index, const char *buffer, size_t buffer_size);
|
140
142
|
static int read_header(struct index_header *dest, const void *buffer);
|
141
143
|
|
142
144
|
static int parse_index(git_index *index, const char *buffer, size_t buffer_size);
|
@@ -166,7 +168,7 @@ int git_index_entry_srch(const void *key, const void *array_member)
|
|
166
168
|
return 1;
|
167
169
|
|
168
170
|
if (srch_key->stage != GIT_INDEX_STAGE_ANY)
|
169
|
-
return srch_key->stage -
|
171
|
+
return srch_key->stage - GIT_INDEX_ENTRY_STAGE(&entry->entry);
|
170
172
|
|
171
173
|
return 0;
|
172
174
|
}
|
@@ -192,7 +194,7 @@ int git_index_entry_isrch(const void *key, const void *array_member)
|
|
192
194
|
return 1;
|
193
195
|
|
194
196
|
if (srch_key->stage != GIT_INDEX_STAGE_ANY)
|
195
|
-
return srch_key->stage -
|
197
|
+
return srch_key->stage - GIT_INDEX_ENTRY_STAGE(&entry->entry);
|
196
198
|
|
197
199
|
return 0;
|
198
200
|
}
|
@@ -220,7 +222,7 @@ int git_index_entry_cmp(const void *a, const void *b)
|
|
220
222
|
diff = strcmp(entry_a->path, entry_b->path);
|
221
223
|
|
222
224
|
if (diff == 0)
|
223
|
-
diff = (
|
225
|
+
diff = (GIT_INDEX_ENTRY_STAGE(entry_a) - GIT_INDEX_ENTRY_STAGE(entry_b));
|
224
226
|
|
225
227
|
return diff;
|
226
228
|
}
|
@@ -234,7 +236,7 @@ int git_index_entry_icmp(const void *a, const void *b)
|
|
234
236
|
diff = strcasecmp(entry_a->path, entry_b->path);
|
235
237
|
|
236
238
|
if (diff == 0)
|
237
|
-
diff = (
|
239
|
+
diff = (GIT_INDEX_ENTRY_STAGE(entry_a) - GIT_INDEX_ENTRY_STAGE(entry_b));
|
238
240
|
|
239
241
|
return diff;
|
240
242
|
}
|
@@ -406,7 +408,7 @@ int git_index_open(git_index **index_out, const char *index_path)
|
|
406
408
|
assert(index_out);
|
407
409
|
|
408
410
|
index = git__calloc(1, sizeof(git_index));
|
409
|
-
|
411
|
+
GIT_ERROR_CHECK_ALLOC(index);
|
410
412
|
|
411
413
|
git_pool_init(&index->tree_pool, 1);
|
412
414
|
|
@@ -516,6 +518,8 @@ static int index_remove_entry(git_index *index, size_t pos)
|
|
516
518
|
} else {
|
517
519
|
index_entry_free(entry);
|
518
520
|
}
|
521
|
+
|
522
|
+
index->dirty = 1;
|
519
523
|
}
|
520
524
|
|
521
525
|
return error;
|
@@ -527,6 +531,7 @@ int git_index_clear(git_index *index)
|
|
527
531
|
|
528
532
|
assert(index);
|
529
533
|
|
534
|
+
index->dirty = 1;
|
530
535
|
index->tree = NULL;
|
531
536
|
git_pool_clear(&index->tree_pool);
|
532
537
|
|
@@ -545,7 +550,7 @@ int git_index_clear(git_index *index)
|
|
545
550
|
|
546
551
|
static int create_index_error(int error, const char *msg)
|
547
552
|
{
|
548
|
-
|
553
|
+
git_error_set_str(GIT_ERROR_INDEX, msg);
|
549
554
|
return error;
|
550
555
|
}
|
551
556
|
|
@@ -557,7 +562,7 @@ int git_index_set_caps(git_index *index, int caps)
|
|
557
562
|
|
558
563
|
old_ignore_case = index->ignore_case;
|
559
564
|
|
560
|
-
if (caps ==
|
565
|
+
if (caps == GIT_INDEX_CAPABILITY_FROM_OWNER) {
|
561
566
|
git_repository *repo = INDEX_OWNER(index);
|
562
567
|
int val;
|
563
568
|
|
@@ -573,9 +578,9 @@ int git_index_set_caps(git_index *index, int caps)
|
|
573
578
|
index->no_symlinks = (val == 0);
|
574
579
|
}
|
575
580
|
else {
|
576
|
-
index->ignore_case = ((caps &
|
577
|
-
index->distrust_filemode = ((caps &
|
578
|
-
index->no_symlinks = ((caps &
|
581
|
+
index->ignore_case = ((caps & GIT_INDEX_CAPABILITY_IGNORE_CASE) != 0);
|
582
|
+
index->distrust_filemode = ((caps & GIT_INDEX_CAPABILITY_NO_FILEMODE) != 0);
|
583
|
+
index->no_symlinks = ((caps & GIT_INDEX_CAPABILITY_NO_SYMLINKS) != 0);
|
579
584
|
}
|
580
585
|
|
581
586
|
if (old_ignore_case != index->ignore_case) {
|
@@ -587,9 +592,9 @@ int git_index_set_caps(git_index *index, int caps)
|
|
587
592
|
|
588
593
|
int git_index_caps(const git_index *index)
|
589
594
|
{
|
590
|
-
return ((index->ignore_case ?
|
591
|
-
(index->distrust_filemode ?
|
592
|
-
(index->no_symlinks ?
|
595
|
+
return ((index->ignore_case ? GIT_INDEX_CAPABILITY_IGNORE_CASE : 0) |
|
596
|
+
(index->distrust_filemode ? GIT_INDEX_CAPABILITY_NO_FILEMODE : 0) |
|
597
|
+
(index->no_symlinks ? GIT_INDEX_CAPABILITY_NO_SYMLINKS : 0));
|
593
598
|
}
|
594
599
|
|
595
600
|
const git_oid *git_index_checksum(git_index *index)
|
@@ -611,7 +616,7 @@ static int compare_checksum(git_index *index)
|
|
611
616
|
|
612
617
|
if (p_lseek(fd, -20, SEEK_END) < 0) {
|
613
618
|
p_close(fd);
|
614
|
-
|
619
|
+
git_error_set(GIT_ERROR_OS, "failed to seek to end of file");
|
615
620
|
return -1;
|
616
621
|
}
|
617
622
|
|
@@ -637,19 +642,22 @@ int git_index_read(git_index *index, int force)
|
|
637
642
|
index->on_disk = git_path_exists(index->index_file_path);
|
638
643
|
|
639
644
|
if (!index->on_disk) {
|
640
|
-
if (force)
|
641
|
-
return
|
645
|
+
if (force && (error = git_index_clear(index)) < 0)
|
646
|
+
return error;
|
647
|
+
|
648
|
+
index->dirty = 0;
|
642
649
|
return 0;
|
643
650
|
}
|
644
651
|
|
645
652
|
if ((updated = git_futils_filestamp_check(&stamp, index->index_file_path) < 0) ||
|
646
653
|
((updated = compare_checksum(index)) < 0)) {
|
647
|
-
|
648
|
-
|
654
|
+
git_error_set(
|
655
|
+
GIT_ERROR_INDEX,
|
649
656
|
"failed to read index: '%s' no longer exists",
|
650
657
|
index->index_file_path);
|
651
658
|
return updated;
|
652
659
|
}
|
660
|
+
|
653
661
|
if (!updated && !force)
|
654
662
|
return 0;
|
655
663
|
|
@@ -665,19 +673,32 @@ int git_index_read(git_index *index, int force)
|
|
665
673
|
if (!error)
|
666
674
|
error = parse_index(index, buffer.ptr, buffer.size);
|
667
675
|
|
668
|
-
if (!error)
|
676
|
+
if (!error) {
|
669
677
|
git_futils_filestamp_set(&index->stamp, &stamp);
|
678
|
+
index->dirty = 0;
|
679
|
+
}
|
670
680
|
|
671
|
-
|
681
|
+
git_buf_dispose(&buffer);
|
672
682
|
return error;
|
673
683
|
}
|
674
684
|
|
685
|
+
int git_index_read_safely(git_index *index)
|
686
|
+
{
|
687
|
+
if (git_index__enforce_unsaved_safety && index->dirty) {
|
688
|
+
git_error_set(GIT_ERROR_INDEX,
|
689
|
+
"the index has unsaved changes that would be overwritten by this operation");
|
690
|
+
return GIT_EINDEXDIRTY;
|
691
|
+
}
|
692
|
+
|
693
|
+
return git_index_read(index, false);
|
694
|
+
}
|
695
|
+
|
675
696
|
int git_index__changed_relative_to(
|
676
697
|
git_index *index, const git_oid *checksum)
|
677
698
|
{
|
678
699
|
/* attempt to update index (ignoring errors) */
|
679
700
|
if (git_index_read(index, false) < 0)
|
680
|
-
|
701
|
+
git_error_clear();
|
681
702
|
|
682
703
|
return !!git_oid_cmp(&index->checksum, checksum);
|
683
704
|
}
|
@@ -715,7 +736,7 @@ static int truncate_racily_clean(git_index *index)
|
|
715
736
|
|
716
737
|
diff_opts.flags |= GIT_DIFF_INCLUDE_TYPECHANGE | GIT_DIFF_IGNORE_SUBMODULES | GIT_DIFF_DISABLE_PATHSPEC_MATCH;
|
717
738
|
git_vector_foreach(&index->entries, i, entry) {
|
718
|
-
if ((entry->flags_extended &
|
739
|
+
if ((entry->flags_extended & GIT_INDEX_ENTRY_UPTODATE) == 0 &&
|
719
740
|
is_racy_entry(index, entry))
|
720
741
|
git_vector_insert(&paths, (char *)entry->path);
|
721
742
|
}
|
@@ -735,8 +756,10 @@ static int truncate_racily_clean(git_index *index)
|
|
735
756
|
/* Ensure that we have a stage 0 for this file (ie, it's not a
|
736
757
|
* conflict), otherwise smudging it is quite pointless.
|
737
758
|
*/
|
738
|
-
if (entry)
|
759
|
+
if (entry) {
|
739
760
|
entry->file_size = 0;
|
761
|
+
index->dirty = 1;
|
762
|
+
}
|
740
763
|
}
|
741
764
|
|
742
765
|
done:
|
@@ -758,7 +781,7 @@ int git_index_set_version(git_index *index, unsigned int version)
|
|
758
781
|
|
759
782
|
if (version < INDEX_VERSION_NUMBER_LB ||
|
760
783
|
version > INDEX_VERSION_NUMBER_UB) {
|
761
|
-
|
784
|
+
git_error_set(GIT_ERROR_INDEX, "invalid version number");
|
762
785
|
return -1;
|
763
786
|
}
|
764
787
|
|
@@ -774,8 +797,9 @@ int git_index_write(git_index *index)
|
|
774
797
|
|
775
798
|
truncate_racily_clean(index);
|
776
799
|
|
777
|
-
if ((error = git_indexwriter_init(&writer, index)) == 0
|
778
|
-
error = git_indexwriter_commit(&writer)
|
800
|
+
if ((error = git_indexwriter_init(&writer, index)) == 0 &&
|
801
|
+
(error = git_indexwriter_commit(&writer)) == 0)
|
802
|
+
index->dirty = 0;
|
779
803
|
|
780
804
|
git_indexwriter_cleanup(&writer);
|
781
805
|
|
@@ -827,20 +851,20 @@ const git_index_entry *git_index_get_byindex(
|
|
827
851
|
const git_index_entry *git_index_get_bypath(
|
828
852
|
git_index *index, const char *path, int stage)
|
829
853
|
{
|
830
|
-
khiter_t pos;
|
831
854
|
git_index_entry key = {{ 0 }};
|
855
|
+
size_t pos;
|
832
856
|
|
833
857
|
assert(index);
|
834
858
|
|
835
859
|
key.path = path;
|
836
|
-
|
860
|
+
GIT_INDEX_ENTRY_STAGE_SET(&key, stage);
|
837
861
|
|
838
862
|
LOOKUP_IN_MAP(pos, index, &key);
|
839
863
|
|
840
864
|
if (git_idxmap_valid_index(index->entries_map, pos))
|
841
865
|
return git_idxmap_value_at(index->entries_map, pos);
|
842
866
|
|
843
|
-
|
867
|
+
git_error_set(GIT_ERROR_INDEX, "index does not contain '%s'", path);
|
844
868
|
return NULL;
|
845
869
|
}
|
846
870
|
|
@@ -866,12 +890,12 @@ static void index_entry_adjust_namemask(
|
|
866
890
|
git_index_entry *entry,
|
867
891
|
size_t path_length)
|
868
892
|
{
|
869
|
-
entry->flags &= ~
|
893
|
+
entry->flags &= ~GIT_INDEX_ENTRY_NAMEMASK;
|
870
894
|
|
871
|
-
if (path_length <
|
872
|
-
entry->flags |= path_length &
|
895
|
+
if (path_length < GIT_INDEX_ENTRY_NAMEMASK)
|
896
|
+
entry->flags |= path_length & GIT_INDEX_ENTRY_NAMEMASK;
|
873
897
|
else
|
874
|
-
entry->flags |=
|
898
|
+
entry->flags |= GIT_INDEX_ENTRY_NAMEMASK;
|
875
899
|
}
|
876
900
|
|
877
901
|
/* When `from_workdir` is true, we will validate the paths to avoid placing
|
@@ -902,14 +926,14 @@ static int index_entry_create(
|
|
902
926
|
mode = st->st_mode;
|
903
927
|
|
904
928
|
if (!git_path_isvalid(repo, path, mode, path_valid_flags)) {
|
905
|
-
|
929
|
+
git_error_set(GIT_ERROR_INDEX, "invalid path: '%s'", path);
|
906
930
|
return -1;
|
907
931
|
}
|
908
932
|
|
909
|
-
|
910
|
-
|
933
|
+
GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, sizeof(struct entry_internal), pathlen);
|
934
|
+
GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1);
|
911
935
|
entry = git__calloc(1, alloclen);
|
912
|
-
|
936
|
+
GIT_ERROR_CHECK_ALLOC(entry);
|
913
937
|
|
914
938
|
entry->pathlen = pathlen;
|
915
939
|
memcpy(entry->path, path, pathlen);
|
@@ -949,7 +973,7 @@ static int index_entry_init(
|
|
949
973
|
return -1;
|
950
974
|
|
951
975
|
error = git_path_lstat(path.ptr, &st);
|
952
|
-
|
976
|
+
git_buf_dispose(&path);
|
953
977
|
|
954
978
|
if (error < 0)
|
955
979
|
return error;
|
@@ -1006,7 +1030,7 @@ static int index_entry_reuc_init(git_index_reuc_entry **reuc_out,
|
|
1006
1030
|
assert(reuc_out && path);
|
1007
1031
|
|
1008
1032
|
*reuc_out = reuc = reuc_entry_alloc(path);
|
1009
|
-
|
1033
|
+
GIT_ERROR_CHECK_ALLOC(reuc);
|
1010
1034
|
|
1011
1035
|
if ((reuc->mode[0] = ancestor_mode) > 0) {
|
1012
1036
|
assert(ancestor_oid);
|
@@ -1054,7 +1078,7 @@ static void index_entry_cpy_nocache(
|
|
1054
1078
|
git_oid_cpy(&tgt->id, &src->id);
|
1055
1079
|
tgt->mode = src->mode;
|
1056
1080
|
tgt->flags = src->flags;
|
1057
|
-
tgt->flags_extended = (src->flags_extended &
|
1081
|
+
tgt->flags_extended = (src->flags_extended & GIT_INDEX_ENTRY_EXTENDED_FLAGS);
|
1058
1082
|
}
|
1059
1083
|
|
1060
1084
|
static int index_entry_dup_nocache(
|
@@ -1072,9 +1096,8 @@ static int index_entry_dup_nocache(
|
|
1072
1096
|
static int has_file_name(git_index *index,
|
1073
1097
|
const git_index_entry *entry, size_t pos, int ok_to_replace)
|
1074
1098
|
{
|
1075
|
-
int retval = 0;
|
1076
1099
|
size_t len = strlen(entry->path);
|
1077
|
-
int stage =
|
1100
|
+
int stage = GIT_INDEX_ENTRY_STAGE(entry);
|
1078
1101
|
const char *name = entry->path;
|
1079
1102
|
|
1080
1103
|
while (pos < index->entries.length) {
|
@@ -1084,18 +1107,17 @@ static int has_file_name(git_index *index,
|
|
1084
1107
|
break;
|
1085
1108
|
if (memcmp(name, p->path, len))
|
1086
1109
|
break;
|
1087
|
-
if (
|
1110
|
+
if (GIT_INDEX_ENTRY_STAGE(&p->entry) != stage)
|
1088
1111
|
continue;
|
1089
1112
|
if (p->path[len] != '/')
|
1090
1113
|
continue;
|
1091
|
-
retval = -1;
|
1092
1114
|
if (!ok_to_replace)
|
1093
|
-
|
1115
|
+
return -1;
|
1094
1116
|
|
1095
1117
|
if (index_remove_entry(index, --pos) < 0)
|
1096
1118
|
break;
|
1097
1119
|
}
|
1098
|
-
return
|
1120
|
+
return 0;
|
1099
1121
|
}
|
1100
1122
|
|
1101
1123
|
/*
|
@@ -1105,8 +1127,7 @@ static int has_file_name(git_index *index,
|
|
1105
1127
|
static int has_dir_name(git_index *index,
|
1106
1128
|
const git_index_entry *entry, int ok_to_replace)
|
1107
1129
|
{
|
1108
|
-
int
|
1109
|
-
int stage = GIT_IDXENTRY_STAGE(entry);
|
1130
|
+
int stage = GIT_INDEX_ENTRY_STAGE(entry);
|
1110
1131
|
const char *name = entry->path;
|
1111
1132
|
const char *slash = name + strlen(name);
|
1112
1133
|
|
@@ -1117,14 +1138,13 @@ static int has_dir_name(git_index *index,
|
|
1117
1138
|
if (*--slash == '/')
|
1118
1139
|
break;
|
1119
1140
|
if (slash <= entry->path)
|
1120
|
-
return
|
1141
|
+
return 0;
|
1121
1142
|
}
|
1122
1143
|
len = slash - name;
|
1123
1144
|
|
1124
1145
|
if (!index_find(&pos, index, name, len, stage)) {
|
1125
|
-
retval = -1;
|
1126
1146
|
if (!ok_to_replace)
|
1127
|
-
|
1147
|
+
return -1;
|
1128
1148
|
|
1129
1149
|
if (index_remove_entry(index, pos) < 0)
|
1130
1150
|
break;
|
@@ -1144,22 +1164,20 @@ static int has_dir_name(git_index *index,
|
|
1144
1164
|
memcmp(p->path, name, len))
|
1145
1165
|
break; /* not our subdirectory */
|
1146
1166
|
|
1147
|
-
if (
|
1148
|
-
return
|
1167
|
+
if (GIT_INDEX_ENTRY_STAGE(&p->entry) == stage)
|
1168
|
+
return 0;
|
1149
1169
|
}
|
1150
1170
|
}
|
1151
1171
|
|
1152
|
-
return
|
1172
|
+
return 0;
|
1153
1173
|
}
|
1154
1174
|
|
1155
1175
|
static int check_file_directory_collision(git_index *index,
|
1156
1176
|
git_index_entry *entry, size_t pos, int ok_to_replace)
|
1157
1177
|
{
|
1158
|
-
|
1159
|
-
|
1160
|
-
|
1161
|
-
if (retval) {
|
1162
|
-
giterr_set(GITERR_INDEX,
|
1178
|
+
if (has_file_name(index, entry, pos, ok_to_replace) < 0 ||
|
1179
|
+
has_dir_name(index, entry, ok_to_replace) < 0) {
|
1180
|
+
git_error_set(GIT_ERROR_INDEX,
|
1163
1181
|
"'%s' appears as both a file and a directory", entry->path);
|
1164
1182
|
return -1;
|
1165
1183
|
}
|
@@ -1204,7 +1222,7 @@ static int canonicalize_directory_path(
|
|
1204
1222
|
&pos, &index->entries, index->entries_search_path, search);
|
1205
1223
|
|
1206
1224
|
while ((match = git_vector_get(&index->entries, pos))) {
|
1207
|
-
if (
|
1225
|
+
if (GIT_INDEX_ENTRY_STAGE(match) != 0) {
|
1208
1226
|
/* conflicts do not contribute to canonical paths */
|
1209
1227
|
} else if (strncmp(search, match->path, search_len) == 0) {
|
1210
1228
|
/* prefer an exact match to the input filename */
|
@@ -1241,8 +1259,8 @@ static int index_no_dups(void **old, void *new)
|
|
1241
1259
|
{
|
1242
1260
|
const git_index_entry *entry = new;
|
1243
1261
|
GIT_UNUSED(old);
|
1244
|
-
|
1245
|
-
entry->path,
|
1262
|
+
git_error_set(GIT_ERROR_INDEX, "'%s' appears multiple times at stage %d",
|
1263
|
+
entry->path, GIT_INDEX_ENTRY_STAGE(entry));
|
1246
1264
|
return GIT_EEXISTS;
|
1247
1265
|
}
|
1248
1266
|
|
@@ -1258,7 +1276,7 @@ static void index_existing_and_best(
|
|
1258
1276
|
int error;
|
1259
1277
|
|
1260
1278
|
error = index_find(&pos,
|
1261
|
-
index, entry->path, 0,
|
1279
|
+
index, entry->path, 0, GIT_INDEX_ENTRY_STAGE(entry));
|
1262
1280
|
|
1263
1281
|
if (error == 0) {
|
1264
1282
|
*existing = index->entries.contents[pos];
|
@@ -1271,7 +1289,7 @@ static void index_existing_and_best(
|
|
1271
1289
|
*existing_position = 0;
|
1272
1290
|
*best = NULL;
|
1273
1291
|
|
1274
|
-
if (
|
1292
|
+
if (GIT_INDEX_ENTRY_STAGE(entry) == 0) {
|
1275
1293
|
for (; pos < index->entries.length; pos++) {
|
1276
1294
|
int (*strcomp)(const char *a, const char *b) =
|
1277
1295
|
index->ignore_case ? git__strcasecmp : git__strcmp;
|
@@ -1281,7 +1299,7 @@ static void index_existing_and_best(
|
|
1281
1299
|
if (strcomp(entry->path, e->path) != 0)
|
1282
1300
|
break;
|
1283
1301
|
|
1284
|
-
if (
|
1302
|
+
if (GIT_INDEX_ENTRY_STAGE(e) == GIT_INDEX_STAGE_ANCESTOR) {
|
1285
1303
|
*best = e;
|
1286
1304
|
continue;
|
1287
1305
|
} else {
|
@@ -1313,57 +1331,58 @@ static int index_insert(
|
|
1313
1331
|
bool trust_mode,
|
1314
1332
|
bool trust_id)
|
1315
1333
|
{
|
1316
|
-
int error = 0;
|
1317
|
-
size_t path_length, position;
|
1318
1334
|
git_index_entry *existing, *best, *entry;
|
1335
|
+
size_t path_length, position;
|
1336
|
+
int error;
|
1319
1337
|
|
1320
1338
|
assert(index && entry_ptr);
|
1321
1339
|
|
1322
1340
|
entry = *entry_ptr;
|
1323
1341
|
|
1324
|
-
/*
|
1342
|
+
/* Make sure that the path length flag is correct */
|
1325
1343
|
path_length = ((struct entry_internal *)entry)->pathlen;
|
1326
1344
|
index_entry_adjust_namemask(entry, path_length);
|
1327
1345
|
|
1328
|
-
/*
|
1329
|
-
entry->flags_extended |=
|
1346
|
+
/* This entry is now up-to-date and should not be checked for raciness */
|
1347
|
+
entry->flags_extended |= GIT_INDEX_ENTRY_UPTODATE;
|
1330
1348
|
|
1331
1349
|
git_vector_sort(&index->entries);
|
1332
1350
|
|
1333
|
-
/*
|
1351
|
+
/*
|
1352
|
+
* Look if an entry with this path already exists, either staged, or (if
|
1334
1353
|
* this entry is a regular staged item) as the "ours" side of a conflict.
|
1335
1354
|
*/
|
1336
1355
|
index_existing_and_best(&existing, &position, &best, index, entry);
|
1337
1356
|
|
1338
|
-
/*
|
1357
|
+
/* Update the file mode */
|
1339
1358
|
entry->mode = trust_mode ?
|
1340
1359
|
git_index__create_mode(entry->mode) :
|
1341
1360
|
index_merge_mode(index, best, entry->mode);
|
1342
1361
|
|
1343
|
-
/*
|
1344
|
-
if (!trust_path)
|
1345
|
-
|
1362
|
+
/* Canonicalize the directory name */
|
1363
|
+
if (!trust_path && (error = canonicalize_directory_path(index, entry, best)) < 0)
|
1364
|
+
goto out;
|
1346
1365
|
|
1347
|
-
/*
|
1348
|
-
if (!
|
1349
|
-
|
1366
|
+
/* Ensure that the given id exists (unless it's a submodule) */
|
1367
|
+
if (!trust_id && INDEX_OWNER(index) &&
|
1368
|
+
(entry->mode & GIT_FILEMODE_COMMIT) != GIT_FILEMODE_COMMIT) {
|
1350
1369
|
|
1351
1370
|
if (!git_object__is_valid(INDEX_OWNER(index), &entry->id,
|
1352
|
-
|
1371
|
+
git_object__type_from_filemode(entry->mode))) {
|
1353
1372
|
error = -1;
|
1373
|
+
goto out;
|
1374
|
+
}
|
1354
1375
|
}
|
1355
1376
|
|
1356
|
-
/*
|
1357
|
-
if (
|
1358
|
-
|
1377
|
+
/* Look for tree / blob name collisions, removing conflicts if requested */
|
1378
|
+
if ((error = check_file_directory_collision(index, entry, position, replace)) < 0)
|
1379
|
+
goto out;
|
1359
1380
|
|
1360
|
-
|
1361
|
-
|
1362
|
-
|
1363
|
-
/* if we are replacing an existing item, overwrite the existing entry
|
1381
|
+
/*
|
1382
|
+
* If we are replacing an existing item, overwrite the existing entry
|
1364
1383
|
* and return it in place of the passed in one.
|
1365
1384
|
*/
|
1366
|
-
|
1385
|
+
if (existing) {
|
1367
1386
|
if (replace) {
|
1368
1387
|
index_entry_cpy(existing, entry);
|
1369
1388
|
|
@@ -1372,20 +1391,22 @@ static int index_insert(
|
|
1372
1391
|
}
|
1373
1392
|
|
1374
1393
|
index_entry_free(entry);
|
1375
|
-
*entry_ptr =
|
1376
|
-
}
|
1377
|
-
|
1378
|
-
|
1394
|
+
*entry_ptr = existing;
|
1395
|
+
} else {
|
1396
|
+
/*
|
1397
|
+
* If replace is not requested or no existing entry exists, insert
|
1379
1398
|
* at the sorted position. (Since we re-sort after each insert to
|
1380
1399
|
* check for dups, this is actually cheaper in the long run.)
|
1381
1400
|
*/
|
1382
|
-
error = git_vector_insert_sorted(&index->entries, entry, index_no_dups)
|
1401
|
+
if ((error = git_vector_insert_sorted(&index->entries, entry, index_no_dups)) < 0)
|
1402
|
+
goto out;
|
1383
1403
|
|
1384
|
-
|
1385
|
-
INSERT_IN_MAP(index, entry, &error);
|
1386
|
-
}
|
1404
|
+
INSERT_IN_MAP(index, entry, &error);
|
1387
1405
|
}
|
1388
1406
|
|
1407
|
+
index->dirty = 1;
|
1408
|
+
|
1409
|
+
out:
|
1389
1410
|
if (error < 0) {
|
1390
1411
|
index_entry_free(*entry_ptr);
|
1391
1412
|
*entry_ptr = NULL;
|
@@ -1448,7 +1469,7 @@ int git_index_add_frombuffer(
|
|
1448
1469
|
"Index is not backed up by an existing repository.");
|
1449
1470
|
|
1450
1471
|
if (!is_file_or_link(source_entry->mode)) {
|
1451
|
-
|
1472
|
+
git_error_set(GIT_ERROR_INDEX, "invalid filemode");
|
1452
1473
|
return -1;
|
1453
1474
|
}
|
1454
1475
|
|
@@ -1489,7 +1510,7 @@ static int add_repo_as_submodule(git_index_entry **out, git_index *index, const
|
|
1489
1510
|
return error;
|
1490
1511
|
|
1491
1512
|
if ((error = p_stat(abspath.ptr, &st)) < 0) {
|
1492
|
-
|
1513
|
+
git_error_set(GIT_ERROR_OS, "failed to stat repository dir");
|
1493
1514
|
return -1;
|
1494
1515
|
}
|
1495
1516
|
|
@@ -1509,7 +1530,7 @@ static int add_repo_as_submodule(git_index_entry **out, git_index *index, const
|
|
1509
1530
|
|
1510
1531
|
git_reference_free(head);
|
1511
1532
|
git_repository_free(sub);
|
1512
|
-
|
1533
|
+
git_buf_dispose(&abspath);
|
1513
1534
|
|
1514
1535
|
*out = entry;
|
1515
1536
|
return 0;
|
@@ -1533,13 +1554,13 @@ int git_index_add_bypath(git_index *index, const char *path)
|
|
1533
1554
|
git_submodule *sm;
|
1534
1555
|
git_error_state err;
|
1535
1556
|
|
1536
|
-
|
1557
|
+
git_error_state_capture(&err, ret);
|
1537
1558
|
|
1538
1559
|
ret = git_submodule_lookup(&sm, INDEX_OWNER(index), path);
|
1539
1560
|
if (ret == GIT_ENOTFOUND)
|
1540
|
-
return
|
1561
|
+
return git_error_state_restore(&err);
|
1541
1562
|
|
1542
|
-
|
1563
|
+
git_error_state_free(&err);
|
1543
1564
|
|
1544
1565
|
/*
|
1545
1566
|
* EEXISTS means that there is a repository at that path, but it's not known
|
@@ -1581,7 +1602,7 @@ int git_index_remove_bypath(git_index *index, const char *path)
|
|
1581
1602
|
return ret;
|
1582
1603
|
|
1583
1604
|
if (ret == GIT_ENOTFOUND)
|
1584
|
-
|
1605
|
+
git_error_clear();
|
1585
1606
|
|
1586
1607
|
return 0;
|
1587
1608
|
}
|
@@ -1598,7 +1619,7 @@ int git_index__fill(git_index *index, const git_vector *source_entries)
|
|
1598
1619
|
return 0;
|
1599
1620
|
|
1600
1621
|
git_vector_size_hint(&index->entries, source_entries->length);
|
1601
|
-
git_idxmap_resize(index->entries_map, (
|
1622
|
+
git_idxmap_resize(index->entries_map, (size_t)(source_entries->length * 1.3));
|
1602
1623
|
|
1603
1624
|
git_vector_foreach(source_entries, i, source_entry) {
|
1604
1625
|
git_index_entry *entry = NULL;
|
@@ -1607,7 +1628,7 @@ int git_index__fill(git_index *index, const git_vector *source_entries)
|
|
1607
1628
|
break;
|
1608
1629
|
|
1609
1630
|
index_entry_adjust_namemask(entry, ((struct entry_internal *)entry)->pathlen);
|
1610
|
-
entry->flags_extended |=
|
1631
|
+
entry->flags_extended |= GIT_INDEX_ENTRY_UPTODATE;
|
1611
1632
|
entry->mode = git_index__create_mode(entry->mode);
|
1612
1633
|
|
1613
1634
|
if ((ret = git_vector_insert(&index->entries, entry)) < 0)
|
@@ -1616,6 +1637,8 @@ int git_index__fill(git_index *index, const git_vector *source_entries)
|
|
1616
1637
|
INSERT_IN_MAP(index, entry, &ret);
|
1617
1638
|
if (ret < 0)
|
1618
1639
|
break;
|
1640
|
+
|
1641
|
+
index->dirty = 1;
|
1619
1642
|
}
|
1620
1643
|
|
1621
1644
|
if (!ret)
|
@@ -1633,7 +1656,7 @@ int git_index_add(git_index *index, const git_index_entry *source_entry)
|
|
1633
1656
|
assert(index && source_entry && source_entry->path);
|
1634
1657
|
|
1635
1658
|
if (!valid_filemode(source_entry->mode)) {
|
1636
|
-
|
1659
|
+
git_error_set(GIT_ERROR_INDEX, "invalid entry mode");
|
1637
1660
|
return -1;
|
1638
1661
|
}
|
1639
1662
|
|
@@ -1652,13 +1675,13 @@ int git_index_remove(git_index *index, const char *path, int stage)
|
|
1652
1675
|
git_index_entry remove_key = {{ 0 }};
|
1653
1676
|
|
1654
1677
|
remove_key.path = path;
|
1655
|
-
|
1678
|
+
GIT_INDEX_ENTRY_STAGE_SET(&remove_key, stage);
|
1656
1679
|
|
1657
1680
|
DELETE_IN_MAP(index, &remove_key);
|
1658
1681
|
|
1659
1682
|
if (index_find(&position, index, path, 0, stage) < 0) {
|
1660
|
-
|
1661
|
-
|
1683
|
+
git_error_set(
|
1684
|
+
GIT_ERROR_INDEX, "index does not contain %s at stage %d", path, stage);
|
1662
1685
|
error = GIT_ENOTFOUND;
|
1663
1686
|
} else {
|
1664
1687
|
error = index_remove_entry(index, position);
|
@@ -1683,7 +1706,7 @@ int git_index_remove_directory(git_index *index, const char *dir, int stage)
|
|
1683
1706
|
if (!entry || git__prefixcmp(entry->path, pfx.ptr) != 0)
|
1684
1707
|
break;
|
1685
1708
|
|
1686
|
-
if (
|
1709
|
+
if (GIT_INDEX_ENTRY_STAGE(entry) != stage) {
|
1687
1710
|
++pos;
|
1688
1711
|
continue;
|
1689
1712
|
}
|
@@ -1693,7 +1716,7 @@ int git_index_remove_directory(git_index *index, const char *dir, int stage)
|
|
1693
1716
|
/* removed entry at 'pos' so we don't need to increment */
|
1694
1717
|
}
|
1695
1718
|
|
1696
|
-
|
1719
|
+
git_buf_dispose(&pfx);
|
1697
1720
|
|
1698
1721
|
return error;
|
1699
1722
|
}
|
@@ -1730,7 +1753,7 @@ int git_index_find(size_t *at_pos, git_index *index, const char *path)
|
|
1730
1753
|
|
1731
1754
|
if (git_vector_bsearch2(
|
1732
1755
|
&pos, &index->entries, index->entries_search_path, path) < 0) {
|
1733
|
-
|
1756
|
+
git_error_set(GIT_ERROR_INDEX, "index does not contain %s", path);
|
1734
1757
|
return GIT_ENOTFOUND;
|
1735
1758
|
}
|
1736
1759
|
|
@@ -1772,7 +1795,7 @@ int git_index_conflict_add(git_index *index,
|
|
1772
1795
|
/* Validate entries */
|
1773
1796
|
for (i = 0; i < 3; i++) {
|
1774
1797
|
if (entries[i] && !valid_filemode(entries[i]->mode)) {
|
1775
|
-
|
1798
|
+
git_error_set(GIT_ERROR_INDEX, "invalid filemode for stage %d entry",
|
1776
1799
|
i + 1);
|
1777
1800
|
ret = -1;
|
1778
1801
|
goto on_error;
|
@@ -1788,7 +1811,7 @@ int git_index_conflict_add(git_index *index,
|
|
1788
1811
|
if (ret != GIT_ENOTFOUND)
|
1789
1812
|
goto on_error;
|
1790
1813
|
|
1791
|
-
|
1814
|
+
git_error_clear();
|
1792
1815
|
ret = 0;
|
1793
1816
|
}
|
1794
1817
|
}
|
@@ -1799,7 +1822,7 @@ int git_index_conflict_add(git_index *index,
|
|
1799
1822
|
continue;
|
1800
1823
|
|
1801
1824
|
/* Make sure stage is correct */
|
1802
|
-
|
1825
|
+
GIT_INDEX_ENTRY_STAGE_SET(entries[i], i + 1);
|
1803
1826
|
|
1804
1827
|
if ((ret = index_insert(index, &entries[i], 1, true, true, false)) < 0)
|
1805
1828
|
goto on_error;
|
@@ -1842,7 +1865,7 @@ static int index_conflict__get_byindex(
|
|
1842
1865
|
if (path && index->entries_cmp_path(conflict_entry->path, path) != 0)
|
1843
1866
|
break;
|
1844
1867
|
|
1845
|
-
stage =
|
1868
|
+
stage = GIT_INDEX_ENTRY_STAGE(conflict_entry);
|
1846
1869
|
path = conflict_entry->path;
|
1847
1870
|
|
1848
1871
|
switch (stage) {
|
@@ -1909,7 +1932,7 @@ static int index_conflict_remove(git_index *index, const char *path)
|
|
1909
1932
|
index->entries_cmp_path(conflict_entry->path, path) != 0)
|
1910
1933
|
break;
|
1911
1934
|
|
1912
|
-
if (
|
1935
|
+
if (GIT_INDEX_ENTRY_STAGE(conflict_entry) == 0) {
|
1913
1936
|
pos++;
|
1914
1937
|
continue;
|
1915
1938
|
}
|
@@ -1941,13 +1964,58 @@ int git_index_has_conflicts(const git_index *index)
|
|
1941
1964
|
assert(index);
|
1942
1965
|
|
1943
1966
|
git_vector_foreach(&index->entries, i, entry) {
|
1944
|
-
if (
|
1967
|
+
if (GIT_INDEX_ENTRY_STAGE(entry) > 0)
|
1945
1968
|
return 1;
|
1946
1969
|
}
|
1947
1970
|
|
1948
1971
|
return 0;
|
1949
1972
|
}
|
1950
1973
|
|
1974
|
+
int git_index_iterator_new(
|
1975
|
+
git_index_iterator **iterator_out,
|
1976
|
+
git_index *index)
|
1977
|
+
{
|
1978
|
+
git_index_iterator *it;
|
1979
|
+
int error;
|
1980
|
+
|
1981
|
+
assert(iterator_out && index);
|
1982
|
+
|
1983
|
+
it = git__calloc(1, sizeof(git_index_iterator));
|
1984
|
+
GIT_ERROR_CHECK_ALLOC(it);
|
1985
|
+
|
1986
|
+
if ((error = git_index_snapshot_new(&it->snap, index)) < 0) {
|
1987
|
+
git__free(it);
|
1988
|
+
return error;
|
1989
|
+
}
|
1990
|
+
|
1991
|
+
it->index = index;
|
1992
|
+
|
1993
|
+
*iterator_out = it;
|
1994
|
+
return 0;
|
1995
|
+
}
|
1996
|
+
|
1997
|
+
int git_index_iterator_next(
|
1998
|
+
const git_index_entry **out,
|
1999
|
+
git_index_iterator *it)
|
2000
|
+
{
|
2001
|
+
assert(out && it);
|
2002
|
+
|
2003
|
+
if (it->cur >= git_vector_length(&it->snap))
|
2004
|
+
return GIT_ITEROVER;
|
2005
|
+
|
2006
|
+
*out = (git_index_entry *)git_vector_get(&it->snap, it->cur++);
|
2007
|
+
return 0;
|
2008
|
+
}
|
2009
|
+
|
2010
|
+
void git_index_iterator_free(git_index_iterator *it)
|
2011
|
+
{
|
2012
|
+
if (it == NULL)
|
2013
|
+
return;
|
2014
|
+
|
2015
|
+
git_index_snapshot_release(&it->snap, it->index);
|
2016
|
+
git__free(it);
|
2017
|
+
}
|
2018
|
+
|
1951
2019
|
int git_index_conflict_iterator_new(
|
1952
2020
|
git_index_conflict_iterator **iterator_out,
|
1953
2021
|
git_index *index)
|
@@ -1957,7 +2025,7 @@ int git_index_conflict_iterator_new(
|
|
1957
2025
|
assert(iterator_out && index);
|
1958
2026
|
|
1959
2027
|
it = git__calloc(1, sizeof(git_index_conflict_iterator));
|
1960
|
-
|
2028
|
+
GIT_ERROR_CHECK_ALLOC(it);
|
1961
2029
|
|
1962
2030
|
it->index = index;
|
1963
2031
|
|
@@ -2043,7 +2111,7 @@ int git_index_name_add(git_index *index,
|
|
2043
2111
|
assert((ancestor && ours) || (ancestor && theirs) || (ours && theirs));
|
2044
2112
|
|
2045
2113
|
conflict_name = git__calloc(1, sizeof(git_index_name_entry));
|
2046
|
-
|
2114
|
+
GIT_ERROR_CHECK_ALLOC(conflict_name);
|
2047
2115
|
|
2048
2116
|
if ((ancestor && !(conflict_name->ancestor = git__strdup(ancestor))) ||
|
2049
2117
|
(ours && !(conflict_name->ours = git__strdup(ours))) ||
|
@@ -2054,6 +2122,7 @@ int git_index_name_add(git_index *index,
|
|
2054
2122
|
return -1;
|
2055
2123
|
}
|
2056
2124
|
|
2125
|
+
index->dirty = 1;
|
2057
2126
|
return 0;
|
2058
2127
|
}
|
2059
2128
|
|
@@ -2068,6 +2137,8 @@ void git_index_name_clear(git_index *index)
|
|
2068
2137
|
index_name_entry_free(conflict_name);
|
2069
2138
|
|
2070
2139
|
git_vector_clear(&index->names);
|
2140
|
+
|
2141
|
+
index->dirty = 1;
|
2071
2142
|
}
|
2072
2143
|
|
2073
2144
|
size_t git_index_reuc_entrycount(git_index *index)
|
@@ -2093,6 +2164,8 @@ static int index_reuc_insert(
|
|
2093
2164
|
assert(git_vector_is_sorted(&index->reuc));
|
2094
2165
|
|
2095
2166
|
res = git_vector_insert_sorted(&index->reuc, reuc, &index_reuc_on_dup);
|
2167
|
+
index->dirty = 1;
|
2168
|
+
|
2096
2169
|
return res == GIT_EEXISTS ? 0 : res;
|
2097
2170
|
}
|
2098
2171
|
|
@@ -2158,6 +2231,7 @@ int git_index_reuc_remove(git_index *index, size_t position)
|
|
2158
2231
|
if (!error)
|
2159
2232
|
index_entry_reuc_free(reuc);
|
2160
2233
|
|
2234
|
+
index->dirty = 1;
|
2161
2235
|
return error;
|
2162
2236
|
}
|
2163
2237
|
|
@@ -2171,11 +2245,13 @@ void git_index_reuc_clear(git_index *index)
|
|
2171
2245
|
index_entry_reuc_free(git__swap(index->reuc.contents[i], NULL));
|
2172
2246
|
|
2173
2247
|
git_vector_clear(&index->reuc);
|
2248
|
+
|
2249
|
+
index->dirty = 1;
|
2174
2250
|
}
|
2175
2251
|
|
2176
2252
|
static int index_error_invalid(const char *message)
|
2177
2253
|
{
|
2178
|
-
|
2254
|
+
git_error_set(GIT_ERROR_INDEX, "invalid data in index - %s", message);
|
2179
2255
|
return -1;
|
2180
2256
|
}
|
2181
2257
|
|
@@ -2198,7 +2274,7 @@ static int read_reuc(git_index *index, const char *buffer, size_t size)
|
|
2198
2274
|
return index_error_invalid("reading reuc entries");
|
2199
2275
|
|
2200
2276
|
lost = reuc_entry_alloc(buffer);
|
2201
|
-
|
2277
|
+
GIT_ERROR_CHECK_ALLOC(lost);
|
2202
2278
|
|
2203
2279
|
size -= len;
|
2204
2280
|
buffer += len;
|
@@ -2271,7 +2347,7 @@ static int read_conflict_names(git_index *index, const char *buffer, size_t size
|
|
2271
2347
|
ptr = NULL; \
|
2272
2348
|
else { \
|
2273
2349
|
ptr = git__malloc(len); \
|
2274
|
-
|
2350
|
+
GIT_ERROR_CHECK_ALLOC(ptr); \
|
2275
2351
|
memcpy(ptr, buffer, len); \
|
2276
2352
|
} \
|
2277
2353
|
\
|
@@ -2280,7 +2356,7 @@ static int read_conflict_names(git_index *index, const char *buffer, size_t size
|
|
2280
2356
|
|
2281
2357
|
while (size) {
|
2282
2358
|
git_index_name_entry *conflict_name = git__calloc(1, sizeof(git_index_name_entry));
|
2283
|
-
|
2359
|
+
GIT_ERROR_CHECK_ALLOC(conflict_name);
|
2284
2360
|
|
2285
2361
|
read_conflict_name(conflict_name->ancestor);
|
2286
2362
|
read_conflict_name(conflict_name->ours);
|
@@ -2310,13 +2386,13 @@ out_err:
|
|
2310
2386
|
static size_t index_entry_size(size_t path_len, size_t varint_len, uint32_t flags)
|
2311
2387
|
{
|
2312
2388
|
if (varint_len) {
|
2313
|
-
if (flags &
|
2389
|
+
if (flags & GIT_INDEX_ENTRY_EXTENDED)
|
2314
2390
|
return offsetof(struct entry_long, path) + path_len + 1 + varint_len;
|
2315
2391
|
else
|
2316
2392
|
return offsetof(struct entry_short, path) + path_len + 1 + varint_len;
|
2317
2393
|
} else {
|
2318
2394
|
#define entry_size(type,len) ((offsetof(type, path) + (len) + 8) & ~7)
|
2319
|
-
if (flags &
|
2395
|
+
if (flags & GIT_INDEX_ENTRY_EXTENDED)
|
2320
2396
|
return entry_size(struct entry_long, path_len);
|
2321
2397
|
else
|
2322
2398
|
return entry_size(struct entry_short, path_len);
|
@@ -2358,7 +2434,7 @@ static int read_entry(
|
|
2358
2434
|
git_oid_cpy(&entry.id, &source.oid);
|
2359
2435
|
entry.flags = ntohs(source.flags);
|
2360
2436
|
|
2361
|
-
if (entry.flags &
|
2437
|
+
if (entry.flags & GIT_INDEX_ENTRY_EXTENDED) {
|
2362
2438
|
uint16_t flags_raw;
|
2363
2439
|
size_t flags_offset;
|
2364
2440
|
|
@@ -2373,7 +2449,7 @@ static int read_entry(
|
|
2373
2449
|
path_ptr = (const char *) buffer + offsetof(struct entry_short, path);
|
2374
2450
|
|
2375
2451
|
if (!compressed) {
|
2376
|
-
path_length = entry.flags &
|
2452
|
+
path_length = entry.flags & GIT_INDEX_ENTRY_NAMEMASK;
|
2377
2453
|
|
2378
2454
|
/* if this is a very long string, we must find its
|
2379
2455
|
* real length without overflowing */
|
@@ -2399,17 +2475,17 @@ static int read_entry(
|
|
2399
2475
|
if (varint_len == 0 || last_len < strip_len)
|
2400
2476
|
return index_error_invalid("incorrect prefix length");
|
2401
2477
|
|
2402
|
-
prefix_len = last_len - strip_len;
|
2478
|
+
prefix_len = last_len - (size_t)strip_len;
|
2403
2479
|
suffix_len = strlen(path_ptr + varint_len);
|
2404
2480
|
|
2405
|
-
|
2406
|
-
|
2481
|
+
GIT_ERROR_CHECK_ALLOC_ADD(&path_len, prefix_len, suffix_len);
|
2482
|
+
GIT_ERROR_CHECK_ALLOC_ADD(&path_len, path_len, 1);
|
2407
2483
|
|
2408
2484
|
if (path_len > GIT_PATH_MAX)
|
2409
2485
|
return index_error_invalid("unreasonable path length");
|
2410
2486
|
|
2411
2487
|
tmp_path = git__malloc(path_len);
|
2412
|
-
|
2488
|
+
GIT_ERROR_CHECK_ALLOC(tmp_path);
|
2413
2489
|
|
2414
2490
|
memcpy(tmp_path, last, prefix_len);
|
2415
2491
|
memcpy(tmp_path + prefix_len, path_ptr + varint_len, suffix_len + 1);
|
@@ -2450,7 +2526,7 @@ static int read_header(struct index_header *dest, const void *buffer)
|
|
2450
2526
|
return 0;
|
2451
2527
|
}
|
2452
2528
|
|
2453
|
-
static
|
2529
|
+
static int read_extension(size_t *read_len, git_index *index, const char *buffer, size_t buffer_size)
|
2454
2530
|
{
|
2455
2531
|
struct index_extension dest;
|
2456
2532
|
size_t total_size;
|
@@ -2463,31 +2539,36 @@ static size_t read_extension(git_index *index, const char *buffer, size_t buffer
|
|
2463
2539
|
|
2464
2540
|
if (dest.extension_size > total_size ||
|
2465
2541
|
buffer_size < total_size ||
|
2466
|
-
buffer_size - total_size < INDEX_FOOTER_SIZE)
|
2467
|
-
|
2542
|
+
buffer_size - total_size < INDEX_FOOTER_SIZE) {
|
2543
|
+
index_error_invalid("extension is truncated");
|
2544
|
+
return -1;
|
2545
|
+
}
|
2468
2546
|
|
2469
2547
|
/* optional extension */
|
2470
2548
|
if (dest.signature[0] >= 'A' && dest.signature[0] <= 'Z') {
|
2471
2549
|
/* tree cache */
|
2472
2550
|
if (memcmp(dest.signature, INDEX_EXT_TREECACHE_SIG, 4) == 0) {
|
2473
2551
|
if (git_tree_cache_read(&index->tree, buffer + 8, dest.extension_size, &index->tree_pool) < 0)
|
2474
|
-
return
|
2552
|
+
return -1;
|
2475
2553
|
} else if (memcmp(dest.signature, INDEX_EXT_UNMERGED_SIG, 4) == 0) {
|
2476
2554
|
if (read_reuc(index, buffer + 8, dest.extension_size) < 0)
|
2477
|
-
return
|
2555
|
+
return -1;
|
2478
2556
|
} else if (memcmp(dest.signature, INDEX_EXT_CONFLICT_NAME_SIG, 4) == 0) {
|
2479
2557
|
if (read_conflict_names(index, buffer + 8, dest.extension_size) < 0)
|
2480
|
-
return
|
2558
|
+
return -1;
|
2481
2559
|
}
|
2482
2560
|
/* else, unsupported extension. We cannot parse this, but we can skip
|
2483
2561
|
* it by returning `total_size */
|
2484
2562
|
} else {
|
2485
2563
|
/* we cannot handle non-ignorable extensions;
|
2486
2564
|
* in fact they aren't even defined in the standard */
|
2487
|
-
|
2565
|
+
git_error_set(GIT_ERROR_INDEX, "unsupported mandatory extension: '%.4s'", dest.signature);
|
2566
|
+
return -1;
|
2488
2567
|
}
|
2489
2568
|
|
2490
|
-
|
2569
|
+
*read_len = total_size;
|
2570
|
+
|
2571
|
+
return 0;
|
2491
2572
|
}
|
2492
2573
|
|
2493
2574
|
static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
|
@@ -2527,7 +2608,7 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
|
|
2527
2608
|
assert(!index->entries.length);
|
2528
2609
|
|
2529
2610
|
if (index->ignore_case)
|
2530
|
-
git_idxmap_icase_resize((
|
2611
|
+
git_idxmap_icase_resize((git_idxmap_icase *) index->entries_map, header.entry_count);
|
2531
2612
|
else
|
2532
2613
|
git_idxmap_resize(index->entries_map, header.entry_count);
|
2533
2614
|
|
@@ -2569,11 +2650,7 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
|
|
2569
2650
|
while (buffer_size > INDEX_FOOTER_SIZE) {
|
2570
2651
|
size_t extension_size;
|
2571
2652
|
|
2572
|
-
|
2573
|
-
|
2574
|
-
/* see if we have read any bytes from the extension */
|
2575
|
-
if (extension_size == 0) {
|
2576
|
-
error = index_error_invalid("extension is truncated");
|
2653
|
+
if ((error = read_extension(&extension_size, index, buffer, buffer_size)) < 0) {
|
2577
2654
|
goto done;
|
2578
2655
|
}
|
2579
2656
|
|
@@ -2605,6 +2682,7 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
|
|
2605
2682
|
git_vector_set_sorted(&index->entries, !index->ignore_case);
|
2606
2683
|
git_vector_sort(&index->entries);
|
2607
2684
|
|
2685
|
+
index->dirty = 0;
|
2608
2686
|
done:
|
2609
2687
|
return error;
|
2610
2688
|
}
|
@@ -2617,10 +2695,10 @@ static bool is_index_extended(git_index *index)
|
|
2617
2695
|
extended = 0;
|
2618
2696
|
|
2619
2697
|
git_vector_foreach(&index->entries, i, entry) {
|
2620
|
-
entry->flags &= ~
|
2621
|
-
if (entry->flags_extended &
|
2698
|
+
entry->flags &= ~GIT_INDEX_ENTRY_EXTENDED;
|
2699
|
+
if (entry->flags_extended & GIT_INDEX_ENTRY_EXTENDED_FLAGS) {
|
2622
2700
|
extended++;
|
2623
|
-
entry->flags |=
|
2701
|
+
entry->flags |= GIT_INDEX_ENTRY_EXTENDED;
|
2624
2702
|
}
|
2625
2703
|
}
|
2626
2704
|
|
@@ -2630,7 +2708,7 @@ static bool is_index_extended(git_index *index)
|
|
2630
2708
|
static int write_disk_entry(git_filebuf *file, git_index_entry *entry, const char *last)
|
2631
2709
|
{
|
2632
2710
|
void *mem = NULL;
|
2633
|
-
struct entry_short
|
2711
|
+
struct entry_short ondisk;
|
2634
2712
|
size_t path_len, disk_size;
|
2635
2713
|
int varint_len = 0;
|
2636
2714
|
char *path;
|
@@ -2658,9 +2736,7 @@ static int write_disk_entry(git_filebuf *file, git_index_entry *entry, const cha
|
|
2658
2736
|
if (git_filebuf_reserve(file, &mem, disk_size) < 0)
|
2659
2737
|
return -1;
|
2660
2738
|
|
2661
|
-
|
2662
|
-
|
2663
|
-
memset(ondisk, 0x0, disk_size);
|
2739
|
+
memset(mem, 0x0, disk_size);
|
2664
2740
|
|
2665
2741
|
/**
|
2666
2742
|
* Yes, we have to truncate.
|
@@ -2672,30 +2748,32 @@ static int write_disk_entry(git_filebuf *file, git_index_entry *entry, const cha
|
|
2672
2748
|
*
|
2673
2749
|
* In 2038 I will be either too dead or too rich to care about this
|
2674
2750
|
*/
|
2675
|
-
ondisk
|
2676
|
-
ondisk
|
2677
|
-
ondisk
|
2678
|
-
ondisk
|
2679
|
-
ondisk
|
2680
|
-
ondisk
|
2681
|
-
ondisk
|
2682
|
-
ondisk
|
2683
|
-
ondisk
|
2684
|
-
ondisk
|
2685
|
-
|
2686
|
-
git_oid_cpy(&ondisk
|
2687
|
-
|
2688
|
-
ondisk
|
2689
|
-
|
2690
|
-
if (entry->flags &
|
2691
|
-
struct entry_long
|
2692
|
-
ondisk_ext
|
2693
|
-
ondisk_ext
|
2694
|
-
|
2695
|
-
|
2751
|
+
ondisk.ctime.seconds = htonl((uint32_t)entry->ctime.seconds);
|
2752
|
+
ondisk.mtime.seconds = htonl((uint32_t)entry->mtime.seconds);
|
2753
|
+
ondisk.ctime.nanoseconds = htonl(entry->ctime.nanoseconds);
|
2754
|
+
ondisk.mtime.nanoseconds = htonl(entry->mtime.nanoseconds);
|
2755
|
+
ondisk.dev = htonl(entry->dev);
|
2756
|
+
ondisk.ino = htonl(entry->ino);
|
2757
|
+
ondisk.mode = htonl(entry->mode);
|
2758
|
+
ondisk.uid = htonl(entry->uid);
|
2759
|
+
ondisk.gid = htonl(entry->gid);
|
2760
|
+
ondisk.file_size = htonl((uint32_t)entry->file_size);
|
2761
|
+
|
2762
|
+
git_oid_cpy(&ondisk.oid, &entry->id);
|
2763
|
+
|
2764
|
+
ondisk.flags = htons(entry->flags);
|
2765
|
+
|
2766
|
+
if (entry->flags & GIT_INDEX_ENTRY_EXTENDED) {
|
2767
|
+
struct entry_long ondisk_ext;
|
2768
|
+
memcpy(&ondisk_ext, &ondisk, sizeof(struct entry_short));
|
2769
|
+
ondisk_ext.flags_extended = htons(entry->flags_extended &
|
2770
|
+
GIT_INDEX_ENTRY_EXTENDED_FLAGS);
|
2771
|
+
memcpy(mem, &ondisk_ext, offsetof(struct entry_long, path));
|
2772
|
+
path = ((struct entry_long*)mem)->path;
|
2696
2773
|
disk_size -= offsetof(struct entry_long, path);
|
2697
2774
|
} else {
|
2698
|
-
|
2775
|
+
memcpy(mem, &ondisk, offsetof(struct entry_short, path));
|
2776
|
+
path = ((struct entry_short*)mem)->path;
|
2699
2777
|
disk_size -= offsetof(struct entry_short, path);
|
2700
2778
|
}
|
2701
2779
|
|
@@ -2820,7 +2898,7 @@ static int write_name_extension(git_index *index, git_filebuf *file)
|
|
2820
2898
|
|
2821
2899
|
error = write_extension(file, &extension, &name_buf);
|
2822
2900
|
|
2823
|
-
|
2901
|
+
git_buf_dispose(&name_buf);
|
2824
2902
|
|
2825
2903
|
done:
|
2826
2904
|
return error;
|
@@ -2868,7 +2946,7 @@ static int write_reuc_extension(git_index *index, git_filebuf *file)
|
|
2868
2946
|
|
2869
2947
|
error = write_extension(file, &extension, &reuc_buf);
|
2870
2948
|
|
2871
|
-
|
2949
|
+
git_buf_dispose(&reuc_buf);
|
2872
2950
|
|
2873
2951
|
done:
|
2874
2952
|
return error;
|
@@ -2892,7 +2970,7 @@ static int write_tree_extension(git_index *index, git_filebuf *file)
|
|
2892
2970
|
|
2893
2971
|
error = write_extension(file, &extension, &buf);
|
2894
2972
|
|
2895
|
-
|
2973
|
+
git_buf_dispose(&buf);
|
2896
2974
|
|
2897
2975
|
return error;
|
2898
2976
|
}
|
@@ -2903,7 +2981,7 @@ static void clear_uptodate(git_index *index)
|
|
2903
2981
|
size_t i;
|
2904
2982
|
|
2905
2983
|
git_vector_foreach(&index->entries, i, entry)
|
2906
|
-
entry->flags_extended &= ~
|
2984
|
+
entry->flags_extended &= ~GIT_INDEX_ENTRY_UPTODATE;
|
2907
2985
|
}
|
2908
2986
|
|
2909
2987
|
static int write_index(git_oid *checksum, git_index *index, git_filebuf *file)
|
@@ -2960,12 +3038,12 @@ static int write_index(git_oid *checksum, git_index *index, git_filebuf *file)
|
|
2960
3038
|
|
2961
3039
|
int git_index_entry_stage(const git_index_entry *entry)
|
2962
3040
|
{
|
2963
|
-
return
|
3041
|
+
return GIT_INDEX_ENTRY_STAGE(entry);
|
2964
3042
|
}
|
2965
3043
|
|
2966
3044
|
int git_index_entry_is_conflict(const git_index_entry *entry)
|
2967
3045
|
{
|
2968
|
-
return (
|
3046
|
+
return (GIT_INDEX_ENTRY_STAGE(entry) > 0);
|
2969
3047
|
}
|
2970
3048
|
|
2971
3049
|
typedef struct read_tree_data {
|
@@ -3009,7 +3087,7 @@ static int read_tree_cb(
|
|
3009
3087
|
}
|
3010
3088
|
|
3011
3089
|
index_entry_adjust_namemask(entry, path.size);
|
3012
|
-
|
3090
|
+
git_buf_dispose(&path);
|
3013
3091
|
|
3014
3092
|
if (git_vector_insert(data->new_entries, entry) < 0) {
|
3015
3093
|
index_entry_free(entry);
|
@@ -3047,7 +3125,7 @@ int git_index_read_tree(git_index *index, const git_tree *tree)
|
|
3047
3125
|
goto cleanup;
|
3048
3126
|
|
3049
3127
|
if (index->ignore_case)
|
3050
|
-
git_idxmap_icase_resize((
|
3128
|
+
git_idxmap_icase_resize((git_idxmap_icase *) entries_map, entries.length);
|
3051
3129
|
else
|
3052
3130
|
git_idxmap_resize(entries_map, entries.length);
|
3053
3131
|
|
@@ -3055,7 +3133,7 @@ int git_index_read_tree(git_index *index, const git_tree *tree)
|
|
3055
3133
|
INSERT_IN_MAP_EX(index, entries_map, e, &error);
|
3056
3134
|
|
3057
3135
|
if (error < 0) {
|
3058
|
-
|
3136
|
+
git_error_set(GIT_ERROR_INDEX, "failed to insert entry into map");
|
3059
3137
|
return error;
|
3060
3138
|
}
|
3061
3139
|
}
|
@@ -3071,6 +3149,8 @@ int git_index_read_tree(git_index *index, const git_tree *tree)
|
|
3071
3149
|
entries_map = git__swap(index->entries_map, entries_map);
|
3072
3150
|
}
|
3073
3151
|
|
3152
|
+
index->dirty = 1;
|
3153
|
+
|
3074
3154
|
cleanup:
|
3075
3155
|
git_vector_free(&entries);
|
3076
3156
|
git_idxmap_free(entries_map);
|
@@ -3105,7 +3185,7 @@ static int git_index_read_iterator(
|
|
3105
3185
|
goto done;
|
3106
3186
|
|
3107
3187
|
if (index->ignore_case && new_length_hint)
|
3108
|
-
git_idxmap_icase_resize((
|
3188
|
+
git_idxmap_icase_resize((git_idxmap_icase *) new_entries_map, new_length_hint);
|
3109
3189
|
else if (new_length_hint)
|
3110
3190
|
git_idxmap_resize(new_entries_map, new_length_hint);
|
3111
3191
|
|
@@ -3178,7 +3258,7 @@ static int git_index_read_iterator(
|
|
3178
3258
|
error = git_vector_insert(&remove_entries, remove_entry);
|
3179
3259
|
|
3180
3260
|
if (error < 0) {
|
3181
|
-
|
3261
|
+
git_error_set(GIT_ERROR_INDEX, "failed to insert entry");
|
3182
3262
|
goto done;
|
3183
3263
|
}
|
3184
3264
|
|
@@ -3210,6 +3290,7 @@ static int git_index_read_iterator(
|
|
3210
3290
|
|
3211
3291
|
clear_uptodate(index);
|
3212
3292
|
|
3293
|
+
index->dirty = 1;
|
3213
3294
|
error = 0;
|
3214
3295
|
|
3215
3296
|
done:
|
@@ -3286,7 +3367,7 @@ int git_index_add_all(
|
|
3286
3367
|
error = index_apply_to_wd_diff(index, INDEX_ACTION_ADDALL, paths, flags, cb, payload);
|
3287
3368
|
|
3288
3369
|
if (error)
|
3289
|
-
|
3370
|
+
git_error_set_after_callback(error);
|
3290
3371
|
|
3291
3372
|
cleanup:
|
3292
3373
|
git_iterator_free(wditer);
|
@@ -3388,7 +3469,7 @@ static int index_apply_to_wd_diff(git_index *index, int action, const git_strarr
|
|
3388
3469
|
git_diff_free(diff);
|
3389
3470
|
|
3390
3471
|
if (error) /* make sure error is set if callback stopped iteration */
|
3391
|
-
|
3472
|
+
git_error_set_after_callback(error);
|
3392
3473
|
|
3393
3474
|
cleanup:
|
3394
3475
|
git_pathspec__clear(&ps);
|
@@ -3445,7 +3526,7 @@ static int index_apply_to_all(
|
|
3445
3526
|
error = git_index_add_bypath(index, path.ptr);
|
3446
3527
|
|
3447
3528
|
if (error == GIT_ENOTFOUND) {
|
3448
|
-
|
3529
|
+
git_error_clear();
|
3449
3530
|
|
3450
3531
|
error = git_index_remove_bypath(index, path.ptr);
|
3451
3532
|
|
@@ -3458,13 +3539,13 @@ static int index_apply_to_all(
|
|
3458
3539
|
i--; /* back up foreach if we removed this */
|
3459
3540
|
break;
|
3460
3541
|
default:
|
3461
|
-
|
3542
|
+
git_error_set(GIT_ERROR_INVALID, "unknown index action %d", action);
|
3462
3543
|
error = -1;
|
3463
3544
|
break;
|
3464
3545
|
}
|
3465
3546
|
}
|
3466
3547
|
|
3467
|
-
|
3548
|
+
git_buf_dispose(&path);
|
3468
3549
|
git_pathspec__clear(&ps);
|
3469
3550
|
|
3470
3551
|
return error;
|
@@ -3480,7 +3561,7 @@ int git_index_remove_all(
|
|
3480
3561
|
index, INDEX_ACTION_REMOVE, pathspec, cb, payload);
|
3481
3562
|
|
3482
3563
|
if (error) /* make sure error is set if callback stopped iteration */
|
3483
|
-
|
3564
|
+
git_error_set_after_callback(error);
|
3484
3565
|
|
3485
3566
|
return error;
|
3486
3567
|
}
|
@@ -3493,7 +3574,7 @@ int git_index_update_all(
|
|
3493
3574
|
{
|
3494
3575
|
int error = index_apply_to_wd_diff(index, INDEX_ACTION_UPDATE, pathspec, 0, cb, payload);
|
3495
3576
|
if (error) /* make sure error is set if callback stopped iteration */
|
3496
|
-
|
3577
|
+
git_error_set_after_callback(error);
|
3497
3578
|
|
3498
3579
|
return error;
|
3499
3580
|
}
|
@@ -3549,7 +3630,7 @@ int git_indexwriter_init(
|
|
3549
3630
|
&writer->file, index->index_file_path, GIT_FILEBUF_HASH_CONTENTS, GIT_INDEX_FILE_MODE)) < 0) {
|
3550
3631
|
|
3551
3632
|
if (error == GIT_ELOCKED)
|
3552
|
-
|
3633
|
+
git_error_set(GIT_ERROR_INDEX, "the index is locked; this might be due to a concurrent or crashed process");
|
3553
3634
|
|
3554
3635
|
return error;
|
3555
3636
|
}
|
@@ -3598,10 +3679,11 @@ int git_indexwriter_commit(git_indexwriter *writer)
|
|
3598
3679
|
|
3599
3680
|
if ((error = git_futils_filestamp_check(
|
3600
3681
|
&writer->index->stamp, writer->index->index_file_path)) < 0) {
|
3601
|
-
|
3682
|
+
git_error_set(GIT_ERROR_OS, "could not read index timestamp");
|
3602
3683
|
return -1;
|
3603
3684
|
}
|
3604
3685
|
|
3686
|
+
writer->index->dirty = 0;
|
3605
3687
|
writer->index->on_disk = 1;
|
3606
3688
|
git_oid_cpy(&writer->index->checksum, &checksum);
|
3607
3689
|
|