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
@@ -29,7 +29,7 @@
|
|
29
29
|
|
30
30
|
typedef struct git_pobject {
|
31
31
|
git_oid id;
|
32
|
-
|
32
|
+
git_object_t type;
|
33
33
|
git_off_t offset;
|
34
34
|
|
35
35
|
size_t size;
|
@@ -52,12 +52,6 @@ typedef struct git_pobject {
|
|
52
52
|
filled:1;
|
53
53
|
} git_pobject;
|
54
54
|
|
55
|
-
typedef struct {
|
56
|
-
git_oid id;
|
57
|
-
unsigned int uninteresting:1,
|
58
|
-
seen:1;
|
59
|
-
} git_walk_object;
|
60
|
-
|
61
55
|
struct git_packbuilder {
|
62
56
|
git_repository *repo; /* associated repository */
|
63
57
|
git_odb *odb; /* associated object database */
|
data/vendor/libgit2/src/pack.c
CHANGED
@@ -24,7 +24,7 @@ static int packfile_unpack_compressed(
|
|
24
24
|
git_mwindow **w_curs,
|
25
25
|
git_off_t *curpos,
|
26
26
|
size_t size,
|
27
|
-
|
27
|
+
git_object_t type);
|
28
28
|
|
29
29
|
/* Can find the offset of an object given
|
30
30
|
* a prefix of an identifier.
|
@@ -42,7 +42,7 @@ static int pack_entry_find_offset(
|
|
42
42
|
|
43
43
|
static int packfile_error(const char *message)
|
44
44
|
{
|
45
|
-
|
45
|
+
git_error_set(GIT_ERROR_ODB, "invalid pack file - %s", message);
|
46
46
|
return -1;
|
47
47
|
}
|
48
48
|
|
@@ -90,12 +90,12 @@ static void cache_free(git_pack_cache *cache)
|
|
90
90
|
static int cache_init(git_pack_cache *cache)
|
91
91
|
{
|
92
92
|
cache->entries = git_offmap_alloc();
|
93
|
-
|
93
|
+
GIT_ERROR_CHECK_ALLOC(cache->entries);
|
94
94
|
|
95
95
|
cache->memory_limit = GIT_PACK_CACHE_MEMORY_LIMIT;
|
96
96
|
|
97
97
|
if (git_mutex_init(&cache->lock)) {
|
98
|
-
|
98
|
+
git_error_set(GIT_ERROR_OS, "failed to initialize pack cache mutex");
|
99
99
|
|
100
100
|
git__free(cache->entries);
|
101
101
|
cache->entries = NULL;
|
@@ -108,8 +108,8 @@ static int cache_init(git_pack_cache *cache)
|
|
108
108
|
|
109
109
|
static git_pack_cache_entry *cache_get(git_pack_cache *cache, git_off_t offset)
|
110
110
|
{
|
111
|
-
khiter_t k;
|
112
111
|
git_pack_cache_entry *entry = NULL;
|
112
|
+
size_t k;
|
113
113
|
|
114
114
|
if (git_mutex_lock(&cache->lock) < 0)
|
115
115
|
return NULL;
|
@@ -148,7 +148,7 @@ static int cache_add(
|
|
148
148
|
{
|
149
149
|
git_pack_cache_entry *entry;
|
150
150
|
int error, exists = 0;
|
151
|
-
|
151
|
+
size_t k;
|
152
152
|
|
153
153
|
if (base->len > GIT_PACK_CACHE_SIZE_LIMIT)
|
154
154
|
return -1;
|
@@ -156,7 +156,7 @@ static int cache_add(
|
|
156
156
|
entry = new_cache_object(base);
|
157
157
|
if (entry) {
|
158
158
|
if (git_mutex_lock(&cache->lock) < 0) {
|
159
|
-
|
159
|
+
git_error_set(GIT_ERROR_OS, "failed to lock cache");
|
160
160
|
git__free(entry);
|
161
161
|
return -1;
|
162
162
|
}
|
@@ -217,7 +217,7 @@ static int pack_index_check(const char *path, struct git_pack_file *p)
|
|
217
217
|
|
218
218
|
if (p_fstat(fd, &st) < 0) {
|
219
219
|
p_close(fd);
|
220
|
-
|
220
|
+
git_error_set(GIT_ERROR_OS, "unable to stat pack index '%s'", path);
|
221
221
|
return -1;
|
222
222
|
}
|
223
223
|
|
@@ -226,7 +226,7 @@ static int pack_index_check(const char *path, struct git_pack_file *p)
|
|
226
226
|
(idx_size = (size_t)st.st_size) < 4 * 256 + 20 + 20)
|
227
227
|
{
|
228
228
|
p_close(fd);
|
229
|
-
|
229
|
+
git_error_set(GIT_ERROR_ODB, "invalid pack index '%s'", path);
|
230
230
|
return -1;
|
231
231
|
}
|
232
232
|
|
@@ -326,19 +326,19 @@ static int pack_index_open(struct git_pack_file *p)
|
|
326
326
|
git_buf_put(&idx_name, p->pack_name, name_len - strlen(".pack"));
|
327
327
|
git_buf_puts(&idx_name, ".idx");
|
328
328
|
if (git_buf_oom(&idx_name)) {
|
329
|
-
|
329
|
+
git_buf_dispose(&idx_name);
|
330
330
|
return -1;
|
331
331
|
}
|
332
332
|
|
333
333
|
if ((error = git_mutex_lock(&p->lock)) < 0) {
|
334
|
-
|
334
|
+
git_buf_dispose(&idx_name);
|
335
335
|
return error;
|
336
336
|
}
|
337
337
|
|
338
338
|
if (p->index_version == -1)
|
339
339
|
error = pack_index_check(idx_name.ptr, p);
|
340
340
|
|
341
|
-
|
341
|
+
git_buf_dispose(&idx_name);
|
342
342
|
|
343
343
|
git_mutex_unlock(&p->lock);
|
344
344
|
|
@@ -378,12 +378,12 @@ static unsigned char *pack_window_open(
|
|
378
378
|
* - each byte afterwards: low seven bits are size continuation,
|
379
379
|
* with the high bit being "size continues"
|
380
380
|
*/
|
381
|
-
size_t git_packfile__object_header(unsigned char *hdr, size_t size,
|
381
|
+
size_t git_packfile__object_header(unsigned char *hdr, size_t size, git_object_t type)
|
382
382
|
{
|
383
383
|
unsigned char *hdr_base;
|
384
384
|
unsigned char c;
|
385
385
|
|
386
|
-
assert(type >=
|
386
|
+
assert(type >= GIT_OBJECT_COMMIT && type <= GIT_OBJECT_REF_DELTA);
|
387
387
|
|
388
388
|
/* TODO: add support for chunked objects; see git.git 6c0d19b1 */
|
389
389
|
|
@@ -405,7 +405,7 @@ size_t git_packfile__object_header(unsigned char *hdr, size_t size, git_otype ty
|
|
405
405
|
static int packfile_unpack_header1(
|
406
406
|
unsigned long *usedp,
|
407
407
|
size_t *sizep,
|
408
|
-
|
408
|
+
git_object_t *type,
|
409
409
|
const unsigned char *buf,
|
410
410
|
unsigned long len)
|
411
411
|
{
|
@@ -419,13 +419,13 @@ static int packfile_unpack_header1(
|
|
419
419
|
shift = 4;
|
420
420
|
while (c & 0x80) {
|
421
421
|
if (len <= used) {
|
422
|
-
|
422
|
+
git_error_set(GIT_ERROR_ODB, "buffer too small");
|
423
423
|
return GIT_EBUFS;
|
424
424
|
}
|
425
425
|
|
426
426
|
if (bitsizeof(long) <= shift) {
|
427
427
|
*usedp = 0;
|
428
|
-
|
428
|
+
git_error_set(GIT_ERROR_ODB, "packfile corrupted");
|
429
429
|
return -1;
|
430
430
|
}
|
431
431
|
|
@@ -441,7 +441,7 @@ static int packfile_unpack_header1(
|
|
441
441
|
|
442
442
|
int git_packfile_unpack_header(
|
443
443
|
size_t *size_p,
|
444
|
-
|
444
|
+
git_object_t *type_p,
|
445
445
|
git_mwindow_file *mwf,
|
446
446
|
git_mwindow **w_curs,
|
447
447
|
git_off_t *curpos)
|
@@ -475,14 +475,14 @@ int git_packfile_unpack_header(
|
|
475
475
|
|
476
476
|
int git_packfile_resolve_header(
|
477
477
|
size_t *size_p,
|
478
|
-
|
478
|
+
git_object_t *type_p,
|
479
479
|
struct git_pack_file *p,
|
480
480
|
git_off_t offset)
|
481
481
|
{
|
482
482
|
git_mwindow *w_curs = NULL;
|
483
483
|
git_off_t curpos = offset;
|
484
484
|
size_t size;
|
485
|
-
|
485
|
+
git_object_t type;
|
486
486
|
git_off_t base_offset;
|
487
487
|
int error;
|
488
488
|
|
@@ -490,7 +490,7 @@ int git_packfile_resolve_header(
|
|
490
490
|
if (error < 0)
|
491
491
|
return error;
|
492
492
|
|
493
|
-
if (type ==
|
493
|
+
if (type == GIT_OBJECT_OFS_DELTA || type == GIT_OBJECT_REF_DELTA) {
|
494
494
|
size_t base_size;
|
495
495
|
git_packfile_stream stream;
|
496
496
|
|
@@ -499,7 +499,7 @@ int git_packfile_resolve_header(
|
|
499
499
|
if ((error = git_packfile_stream_open(&stream, p, curpos)) < 0)
|
500
500
|
return error;
|
501
501
|
error = git_delta_read_header_fromstream(&base_size, size_p, &stream);
|
502
|
-
|
502
|
+
git_packfile_stream_dispose(&stream);
|
503
503
|
if (error < 0)
|
504
504
|
return error;
|
505
505
|
} else {
|
@@ -507,12 +507,12 @@ int git_packfile_resolve_header(
|
|
507
507
|
base_offset = 0;
|
508
508
|
}
|
509
509
|
|
510
|
-
while (type ==
|
510
|
+
while (type == GIT_OBJECT_OFS_DELTA || type == GIT_OBJECT_REF_DELTA) {
|
511
511
|
curpos = base_offset;
|
512
512
|
error = git_packfile_unpack_header(&size, &type, &p->mwf, &w_curs, &curpos);
|
513
513
|
if (error < 0)
|
514
514
|
return error;
|
515
|
-
if (type !=
|
515
|
+
if (type != GIT_OBJECT_OFS_DELTA && type != GIT_OBJECT_REF_DELTA)
|
516
516
|
break;
|
517
517
|
base_offset = get_delta_base(p, &w_curs, &curpos, type, base_offset);
|
518
518
|
git_mwindow_close(&w_curs);
|
@@ -540,7 +540,7 @@ static int pack_dependency_chain(git_dependency_chain *chain_out,
|
|
540
540
|
git_off_t curpos = obj_offset, base_offset;
|
541
541
|
int error = 0, use_heap = 0;
|
542
542
|
size_t size, elem_pos;
|
543
|
-
|
543
|
+
git_object_t type;
|
544
544
|
|
545
545
|
elem_pos = 0;
|
546
546
|
while (true) {
|
@@ -557,7 +557,7 @@ static int pack_dependency_chain(git_dependency_chain *chain_out,
|
|
557
557
|
/* if we run out of space on the small stack, use the array */
|
558
558
|
if (elem_pos == SMALL_STACK_SIZE) {
|
559
559
|
git_array_init_to_size(chain, elem_pos);
|
560
|
-
|
560
|
+
GIT_ERROR_CHECK_ARRAY(chain);
|
561
561
|
memcpy(chain.ptr, small_stack, elem_pos * sizeof(struct pack_chain_elem));
|
562
562
|
chain.size = elem_pos;
|
563
563
|
use_heap = 1;
|
@@ -586,7 +586,7 @@ static int pack_dependency_chain(git_dependency_chain *chain_out,
|
|
586
586
|
elem->type = type;
|
587
587
|
elem->base_key = obj_offset;
|
588
588
|
|
589
|
-
if (type !=
|
589
|
+
if (type != GIT_OBJECT_OFS_DELTA && type != GIT_OBJECT_REF_DELTA)
|
590
590
|
break;
|
591
591
|
|
592
592
|
base_offset = get_delta_base(p, &w_curs, &curpos, type, obj_offset);
|
@@ -609,7 +609,7 @@ static int pack_dependency_chain(git_dependency_chain *chain_out,
|
|
609
609
|
elem_pos++;
|
610
610
|
}
|
611
611
|
|
612
|
-
|
612
|
+
|
613
613
|
*stack_sz = elem_pos + 1;
|
614
614
|
*chain_out = chain;
|
615
615
|
return error;
|
@@ -632,7 +632,7 @@ int git_packfile_unpack(
|
|
632
632
|
git_pack_cache_entry *cached = NULL;
|
633
633
|
struct pack_chain_elem small_stack[SMALL_STACK_SIZE];
|
634
634
|
size_t stack_size = 0, elem_pos, alloclen;
|
635
|
-
|
635
|
+
git_object_t base_type;
|
636
636
|
|
637
637
|
/*
|
638
638
|
* TODO: optionally check the CRC on the packfile
|
@@ -644,7 +644,7 @@ int git_packfile_unpack(
|
|
644
644
|
|
645
645
|
obj->data = NULL;
|
646
646
|
obj->len = 0;
|
647
|
-
obj->type =
|
647
|
+
obj->type = GIT_OBJECT_INVALID;
|
648
648
|
|
649
649
|
/* let's point to the right stack */
|
650
650
|
stack = chain.ptr ? chain.ptr : small_stack;
|
@@ -660,10 +660,10 @@ int git_packfile_unpack(
|
|
660
660
|
}
|
661
661
|
|
662
662
|
switch (base_type) {
|
663
|
-
case
|
664
|
-
case
|
665
|
-
case
|
666
|
-
case
|
663
|
+
case GIT_OBJECT_COMMIT:
|
664
|
+
case GIT_OBJECT_TREE:
|
665
|
+
case GIT_OBJECT_BLOB:
|
666
|
+
case GIT_OBJECT_TAG:
|
667
667
|
if (!cached) {
|
668
668
|
curpos = elem->offset;
|
669
669
|
error = packfile_unpack_compressed(obj, p, &w_curs, &curpos, elem->size, elem->type);
|
@@ -673,8 +673,8 @@ int git_packfile_unpack(
|
|
673
673
|
if (error < 0)
|
674
674
|
goto cleanup;
|
675
675
|
break;
|
676
|
-
case
|
677
|
-
case
|
676
|
+
case GIT_OBJECT_OFS_DELTA:
|
677
|
+
case GIT_OBJECT_REF_DELTA:
|
678
678
|
error = packfile_error("dependency chain ends in a delta");
|
679
679
|
goto cleanup;
|
680
680
|
default:
|
@@ -691,9 +691,9 @@ int git_packfile_unpack(
|
|
691
691
|
if (cached && stack_size == 1) {
|
692
692
|
void *data = obj->data;
|
693
693
|
|
694
|
-
|
694
|
+
GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, obj->len, 1);
|
695
695
|
obj->data = git__malloc(alloclen);
|
696
|
-
|
696
|
+
GIT_ERROR_CHECK_ALLOC(obj->data);
|
697
697
|
|
698
698
|
memcpy(obj->data, data, obj->len + 1);
|
699
699
|
git_atomic_dec(&cached->refcount);
|
@@ -726,7 +726,7 @@ int git_packfile_unpack(
|
|
726
726
|
base = *obj;
|
727
727
|
obj->data = NULL;
|
728
728
|
obj->len = 0;
|
729
|
-
obj->type =
|
729
|
+
obj->type = GIT_OBJECT_INVALID;
|
730
730
|
|
731
731
|
error = git_delta_apply(&obj->data, &obj->len, base.data, base.len, delta.data, delta.len);
|
732
732
|
obj->type = base_type;
|
@@ -793,7 +793,7 @@ int git_packfile_stream_open(git_packfile_stream *obj, struct git_pack_file *p,
|
|
793
793
|
obj->zstream.next_out = Z_NULL;
|
794
794
|
st = inflateInit(&obj->zstream);
|
795
795
|
if (st != Z_OK) {
|
796
|
-
|
796
|
+
git_error_set(GIT_ERROR_ZLIB, "failed to init packfile stream");
|
797
797
|
return -1;
|
798
798
|
}
|
799
799
|
|
@@ -824,7 +824,7 @@ ssize_t git_packfile_stream_read(git_packfile_stream *obj, void *buffer, size_t
|
|
824
824
|
written = len - obj->zstream.avail_out;
|
825
825
|
|
826
826
|
if (st != Z_OK && st != Z_STREAM_END) {
|
827
|
-
|
827
|
+
git_error_set(GIT_ERROR_ZLIB, "error reading from the zlib stream");
|
828
828
|
return -1;
|
829
829
|
}
|
830
830
|
|
@@ -840,7 +840,7 @@ ssize_t git_packfile_stream_read(git_packfile_stream *obj, void *buffer, size_t
|
|
840
840
|
|
841
841
|
}
|
842
842
|
|
843
|
-
void
|
843
|
+
void git_packfile_stream_dispose(git_packfile_stream *obj)
|
844
844
|
{
|
845
845
|
inflateEnd(&obj->zstream);
|
846
846
|
}
|
@@ -851,16 +851,16 @@ static int packfile_unpack_compressed(
|
|
851
851
|
git_mwindow **w_curs,
|
852
852
|
git_off_t *curpos,
|
853
853
|
size_t size,
|
854
|
-
|
854
|
+
git_object_t type)
|
855
855
|
{
|
856
856
|
size_t buf_size;
|
857
857
|
int st;
|
858
858
|
z_stream stream;
|
859
859
|
unsigned char *buffer, *in;
|
860
860
|
|
861
|
-
|
861
|
+
GIT_ERROR_CHECK_ALLOC_ADD(&buf_size, size, 1);
|
862
862
|
buffer = git__calloc(1, buf_size);
|
863
|
-
|
863
|
+
GIT_ERROR_CHECK_ALLOC(buffer);
|
864
864
|
|
865
865
|
memset(&stream, 0, sizeof(stream));
|
866
866
|
stream.next_out = buffer;
|
@@ -871,7 +871,7 @@ static int packfile_unpack_compressed(
|
|
871
871
|
st = inflateInit(&stream);
|
872
872
|
if (st != Z_OK) {
|
873
873
|
git__free(buffer);
|
874
|
-
|
874
|
+
git_error_set(GIT_ERROR_ZLIB, "failed to init zlib stream on unpack");
|
875
875
|
|
876
876
|
return -1;
|
877
877
|
}
|
@@ -898,7 +898,7 @@ static int packfile_unpack_compressed(
|
|
898
898
|
|
899
899
|
if ((st != Z_STREAM_END) || stream.total_out != size) {
|
900
900
|
git__free(buffer);
|
901
|
-
|
901
|
+
git_error_set(GIT_ERROR_ZLIB, "error inflating zlib stream");
|
902
902
|
return -1;
|
903
903
|
}
|
904
904
|
|
@@ -916,7 +916,7 @@ git_off_t get_delta_base(
|
|
916
916
|
struct git_pack_file *p,
|
917
917
|
git_mwindow **w_curs,
|
918
918
|
git_off_t *curpos,
|
919
|
-
|
919
|
+
git_object_t type,
|
920
920
|
git_off_t delta_obj_offset)
|
921
921
|
{
|
922
922
|
unsigned int left = 0;
|
@@ -934,7 +934,7 @@ git_off_t get_delta_base(
|
|
934
934
|
* that is assured. An OFS_DELTA longer than the hash size
|
935
935
|
* is stupid, as then a REF_DELTA would be smaller to store.
|
936
936
|
*/
|
937
|
-
if (type ==
|
937
|
+
if (type == GIT_OBJECT_OFS_DELTA) {
|
938
938
|
unsigned used = 0;
|
939
939
|
unsigned char c = base_info[used++];
|
940
940
|
size_t unsigned_base_offset = c & 127;
|
@@ -951,11 +951,11 @@ git_off_t get_delta_base(
|
|
951
951
|
return 0; /* out of bound */
|
952
952
|
base_offset = delta_obj_offset - unsigned_base_offset;
|
953
953
|
*curpos += used;
|
954
|
-
} else if (type ==
|
954
|
+
} else if (type == GIT_OBJECT_REF_DELTA) {
|
955
955
|
/* If we have the cooperative cache, search in it first */
|
956
956
|
if (p->has_cache) {
|
957
|
-
khiter_t k;
|
958
957
|
git_oid oid;
|
958
|
+
size_t k;
|
959
959
|
|
960
960
|
git_oid_fromraw(&oid, base_info);
|
961
961
|
k = git_oidmap_lookup_index(p->idx_cache, &oid);
|
@@ -1087,7 +1087,7 @@ static int packfile_open(struct git_pack_file *p)
|
|
1087
1087
|
return 0;
|
1088
1088
|
|
1089
1089
|
cleanup:
|
1090
|
-
|
1090
|
+
git_error_set(GIT_ERROR_OS, "invalid packfile '%s'", p->pack_name);
|
1091
1091
|
|
1092
1092
|
if (p->mwf.fd >= 0)
|
1093
1093
|
p_close(p->mwf.fd);
|
@@ -1126,11 +1126,11 @@ int git_packfile_alloc(struct git_pack_file **pack_out, const char *path)
|
|
1126
1126
|
if (path_len < strlen(".idx"))
|
1127
1127
|
return git_odb__error_notfound("invalid packfile path", NULL, 0);
|
1128
1128
|
|
1129
|
-
|
1130
|
-
|
1129
|
+
GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, sizeof(*p), path_len);
|
1130
|
+
GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 2);
|
1131
1131
|
|
1132
1132
|
p = git__calloc(1, alloc_len);
|
1133
|
-
|
1133
|
+
GIT_ERROR_CHECK_ALLOC(p);
|
1134
1134
|
|
1135
1135
|
memcpy(p->pack_name, path, path_len + 1);
|
1136
1136
|
|
@@ -1163,7 +1163,7 @@ int git_packfile_alloc(struct git_pack_file **pack_out, const char *path)
|
|
1163
1163
|
p->index_version = -1;
|
1164
1164
|
|
1165
1165
|
if (git_mutex_init(&p->lock)) {
|
1166
|
-
|
1166
|
+
git_error_set(GIT_ERROR_OS, "failed to initialize packfile mutex");
|
1167
1167
|
git__free(p);
|
1168
1168
|
return -1;
|
1169
1169
|
}
|
@@ -1266,7 +1266,7 @@ int git_pack_foreach_entry(
|
|
1266
1266
|
|
1267
1267
|
for (i = 0; i < p->num_objects; i++)
|
1268
1268
|
if ((error = cb(p->oids[i], data)) != 0)
|
1269
|
-
return
|
1269
|
+
return git_error_set_after_callback(error);
|
1270
1270
|
|
1271
1271
|
return error;
|
1272
1272
|
}
|
@@ -1352,7 +1352,7 @@ static int pack_entry_find_offset(
|
|
1352
1352
|
return git_odb__error_ambiguous("found multiple offsets for pack entry");
|
1353
1353
|
|
1354
1354
|
if ((offset = nth_packed_object_offset(p, pos)) < 0) {
|
1355
|
-
|
1355
|
+
git_error_set(GIT_ERROR_ODB, "packfile index is corrupt");
|
1356
1356
|
return -1;
|
1357
1357
|
}
|
1358
1358
|
|