rugged 0.24.6.1 → 0.25.0b1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/rugged/rugged_repo.c +44 -36
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +10 -21
- data/vendor/libgit2/include/git2/checkout.h +0 -7
- data/vendor/libgit2/include/git2/commit.h +46 -0
- data/vendor/libgit2/include/git2/common.h +1 -16
- data/vendor/libgit2/include/git2/odb.h +47 -1
- data/vendor/libgit2/include/git2/version.h +2 -2
- data/vendor/libgit2/src/array.h +0 -40
- data/vendor/libgit2/src/blame.c +3 -8
- data/vendor/libgit2/src/blame_git.c +9 -20
- data/vendor/libgit2/src/checkout.c +5 -13
- data/vendor/libgit2/src/commit.c +132 -52
- data/vendor/libgit2/src/common.h +1 -1
- data/vendor/libgit2/src/config_cache.c +1 -2
- data/vendor/libgit2/src/config_file.c +20 -14
- data/vendor/libgit2/src/delta-apply.c +5 -36
- data/vendor/libgit2/src/delta-apply.h +0 -12
- data/vendor/libgit2/src/describe.c +1 -2
- data/vendor/libgit2/src/diff_tform.c +3 -5
- data/vendor/libgit2/src/filebuf.c +1 -6
- data/vendor/libgit2/src/global.c +8 -28
- data/vendor/libgit2/src/global.h +0 -1
- data/vendor/libgit2/src/ignore.c +19 -56
- data/vendor/libgit2/src/index.c +8 -27
- data/vendor/libgit2/src/indexer.c +7 -11
- data/vendor/libgit2/src/iterator.c +2 -2
- data/vendor/libgit2/src/merge.c +0 -1
- data/vendor/libgit2/src/mwindow.c +19 -8
- data/vendor/libgit2/src/mwindow.h +2 -1
- data/vendor/libgit2/src/object.c +6 -3
- data/vendor/libgit2/src/odb.c +188 -48
- data/vendor/libgit2/src/odb_loose.c +1 -1
- data/vendor/libgit2/src/odb_pack.c +3 -0
- data/vendor/libgit2/src/openssl_stream.c +27 -60
- data/vendor/libgit2/src/openssl_stream.h +0 -106
- data/vendor/libgit2/src/pack-objects.c +2 -4
- data/vendor/libgit2/src/pack.c +9 -5
- data/vendor/libgit2/src/posix.c +0 -7
- data/vendor/libgit2/src/posix.h +0 -1
- data/vendor/libgit2/src/push.c +6 -6
- data/vendor/libgit2/src/refdb_fs.c +0 -1
- data/vendor/libgit2/src/refs.c +0 -3
- data/vendor/libgit2/src/refspec.c +2 -4
- data/vendor/libgit2/src/remote.c +5 -15
- data/vendor/libgit2/src/repository.c +21 -29
- data/vendor/libgit2/src/settings.c +1 -23
- data/vendor/libgit2/src/stransport_stream.c +9 -15
- data/vendor/libgit2/src/submodule.c +2 -3
- data/vendor/libgit2/src/sysdir.c +47 -41
- data/vendor/libgit2/src/sysdir.h +5 -0
- data/vendor/libgit2/src/tag.c +2 -8
- data/vendor/libgit2/src/thread-utils.h +51 -5
- data/vendor/libgit2/src/transports/http.c +3 -3
- data/vendor/libgit2/src/transports/smart_pkt.c +4 -13
- data/vendor/libgit2/src/transports/smart_protocol.c +17 -61
- data/vendor/libgit2/src/tree.c +100 -83
- data/vendor/libgit2/src/tree.h +5 -4
- data/vendor/libgit2/src/unix/map.c +0 -5
- data/vendor/libgit2/src/util.c +3 -3
- data/vendor/libgit2/src/win32/map.c +5 -24
- data/vendor/libgit2/src/win32/precompiled.h +1 -1
- data/vendor/libgit2/src/win32/{thread.c → pthread.c} +80 -50
- data/vendor/libgit2/src/win32/pthread.h +92 -0
- data/vendor/libgit2/src/xdiff/xprepare.c +1 -2
- metadata +7 -8
- data/vendor/libgit2/src/unix/pthread.h +0 -54
- data/vendor/libgit2/src/win32/thread.h +0 -62
@@ -49,37 +49,6 @@ int git__delta_read_header(
|
|
49
49
|
return 0;
|
50
50
|
}
|
51
51
|
|
52
|
-
#define DELTA_HEADER_BUFFER_LEN 16
|
53
|
-
int git__delta_read_header_fromstream(size_t *base_sz, size_t *res_sz, git_packfile_stream *stream)
|
54
|
-
{
|
55
|
-
static const size_t buffer_len = DELTA_HEADER_BUFFER_LEN;
|
56
|
-
unsigned char buffer[DELTA_HEADER_BUFFER_LEN];
|
57
|
-
const unsigned char *delta, *delta_end;
|
58
|
-
size_t len;
|
59
|
-
ssize_t read;
|
60
|
-
|
61
|
-
len = read = 0;
|
62
|
-
while (len < buffer_len) {
|
63
|
-
read = git_packfile_stream_read(stream, &buffer[len], buffer_len - len);
|
64
|
-
|
65
|
-
if (read == 0)
|
66
|
-
break;
|
67
|
-
|
68
|
-
if (read == GIT_EBUFS)
|
69
|
-
continue;
|
70
|
-
|
71
|
-
len += read;
|
72
|
-
}
|
73
|
-
|
74
|
-
delta = buffer;
|
75
|
-
delta_end = delta + len;
|
76
|
-
if ((hdr_sz(base_sz, &delta, delta_end) < 0) ||
|
77
|
-
(hdr_sz(res_sz, &delta, delta_end) < 0))
|
78
|
-
return -1;
|
79
|
-
|
80
|
-
return 0;
|
81
|
-
}
|
82
|
-
|
83
52
|
int git__delta_apply(
|
84
53
|
git_rawobj *out,
|
85
54
|
const unsigned char *base,
|
@@ -121,13 +90,13 @@ int git__delta_apply(
|
|
121
90
|
size_t off = 0, len = 0;
|
122
91
|
|
123
92
|
if (cmd & 0x01) off = *delta++;
|
124
|
-
if (cmd & 0x02) off |= *delta++ <<
|
125
|
-
if (cmd & 0x04) off |= *delta++ <<
|
126
|
-
if (cmd & 0x08) off |= *delta++ <<
|
93
|
+
if (cmd & 0x02) off |= *delta++ << 8;
|
94
|
+
if (cmd & 0x04) off |= *delta++ << 16;
|
95
|
+
if (cmd & 0x08) off |= *delta++ << 24;
|
127
96
|
|
128
97
|
if (cmd & 0x10) len = *delta++;
|
129
|
-
if (cmd & 0x20) len |= *delta++ <<
|
130
|
-
if (cmd & 0x40) len |= *delta++ <<
|
98
|
+
if (cmd & 0x20) len |= *delta++ << 8;
|
99
|
+
if (cmd & 0x40) len |= *delta++ << 16;
|
131
100
|
if (!len) len = 0x10000;
|
132
101
|
|
133
102
|
if (base_len < off + len || res_sz < len)
|
@@ -8,7 +8,6 @@
|
|
8
8
|
#define INCLUDE_delta_apply_h__
|
9
9
|
|
10
10
|
#include "odb.h"
|
11
|
-
#include "pack.h"
|
12
11
|
|
13
12
|
/**
|
14
13
|
* Apply a git binary delta to recover the original content.
|
@@ -48,15 +47,4 @@ extern int git__delta_read_header(
|
|
48
47
|
size_t *base_sz,
|
49
48
|
size_t *res_sz);
|
50
49
|
|
51
|
-
/**
|
52
|
-
* Read the header of a git binary delta
|
53
|
-
*
|
54
|
-
* This variant reads just enough from the packfile stream to read the
|
55
|
-
* delta header.
|
56
|
-
*/
|
57
|
-
extern int git__delta_read_header_fromstream(
|
58
|
-
size_t *base_sz,
|
59
|
-
size_t *res_sz,
|
60
|
-
git_packfile_stream *stream);
|
61
|
-
|
62
50
|
#endif
|
@@ -582,8 +582,7 @@ static int describe(
|
|
582
582
|
best = (struct possible_tag *)git_vector_get(&all_matches, 0);
|
583
583
|
|
584
584
|
if (gave_up_on) {
|
585
|
-
|
586
|
-
goto cleanup;
|
585
|
+
git_pqueue_insert(&list, gave_up_on);
|
587
586
|
seen_commits--;
|
588
587
|
}
|
589
588
|
if ((error = finish_depth_computation(
|
@@ -261,7 +261,7 @@ static int normalize_find_opts(
|
|
261
261
|
if (!given ||
|
262
262
|
(given->flags & GIT_DIFF_FIND_ALL) == GIT_DIFF_FIND_BY_CONFIG)
|
263
263
|
{
|
264
|
-
if (
|
264
|
+
if (diff->repo) {
|
265
265
|
char *rule =
|
266
266
|
git_config__get_string_force(cfg, "diff.renames", "true");
|
267
267
|
int boolval;
|
@@ -318,10 +318,8 @@ static int normalize_find_opts(
|
|
318
318
|
#undef USE_DEFAULT
|
319
319
|
|
320
320
|
if (!opts->rename_limit) {
|
321
|
-
|
322
|
-
|
323
|
-
cfg, "diff.renamelimit", DEFAULT_RENAME_LIMIT);
|
324
|
-
}
|
321
|
+
opts->rename_limit = git_config__get_int_force(
|
322
|
+
cfg, "diff.renamelimit", DEFAULT_RENAME_LIMIT);
|
325
323
|
|
326
324
|
if (opts->rename_limit <= 0)
|
327
325
|
opts->rename_limit = DEFAULT_RENAME_LIMIT;
|
@@ -70,7 +70,6 @@ static int lock_file(git_filebuf *file, int flags, mode_t mode)
|
|
70
70
|
git_file source;
|
71
71
|
char buffer[FILEIO_BUFSIZE];
|
72
72
|
ssize_t read_bytes;
|
73
|
-
int error = 0;
|
74
73
|
|
75
74
|
source = p_open(file->path_original, O_RDONLY);
|
76
75
|
if (source < 0) {
|
@@ -81,8 +80,7 @@ static int lock_file(git_filebuf *file, int flags, mode_t mode)
|
|
81
80
|
}
|
82
81
|
|
83
82
|
while ((read_bytes = p_read(source, buffer, sizeof(buffer))) > 0) {
|
84
|
-
|
85
|
-
break;
|
83
|
+
p_write(file->fd, buffer, read_bytes);
|
86
84
|
if (file->compute_digest)
|
87
85
|
git_hash_update(&file->digest, buffer, read_bytes);
|
88
86
|
}
|
@@ -92,9 +90,6 @@ static int lock_file(git_filebuf *file, int flags, mode_t mode)
|
|
92
90
|
if (read_bytes < 0) {
|
93
91
|
giterr_set(GITERR_OS, "Failed to read file '%s'", file->path_original);
|
94
92
|
return -1;
|
95
|
-
} else if (error < 0) {
|
96
|
-
giterr_set(GITERR_OS, "Failed to write file '%s'", file->path_lock);
|
97
|
-
return -1;
|
98
93
|
}
|
99
94
|
}
|
100
95
|
|
data/vendor/libgit2/src/global.c
CHANGED
@@ -27,7 +27,6 @@ static git_global_shutdown_fn git__shutdown_callbacks[MAX_SHUTDOWN_CB];
|
|
27
27
|
static git_atomic git__n_shutdown_callbacks;
|
28
28
|
static git_atomic git__n_inits;
|
29
29
|
char *git__user_agent;
|
30
|
-
char *git__ssl_ciphers;
|
31
30
|
|
32
31
|
void git__on_shutdown(git_global_shutdown_fn callback)
|
33
32
|
{
|
@@ -59,9 +58,8 @@ static int init_common(void)
|
|
59
58
|
if ((ret = git_hash_global_init()) == 0 &&
|
60
59
|
(ret = git_sysdir_global_init()) == 0 &&
|
61
60
|
(ret = git_filter_global_init()) == 0 &&
|
62
|
-
(ret = git_transport_ssh_global_init()) == 0
|
63
|
-
|
64
|
-
ret = git_mwindow_global_init();
|
61
|
+
(ret = git_transport_ssh_global_init()) == 0)
|
62
|
+
ret = git_openssl_stream_global_init();
|
65
63
|
|
66
64
|
GIT_MEMORY_BARRIER;
|
67
65
|
|
@@ -85,7 +83,11 @@ static void shutdown_common(void)
|
|
85
83
|
}
|
86
84
|
|
87
85
|
git__free(git__user_agent);
|
88
|
-
|
86
|
+
|
87
|
+
#if defined(GIT_MSVC_CRTDBG)
|
88
|
+
git_win32__crtdbg_stacktrace_cleanup();
|
89
|
+
git_win32__stack_cleanup();
|
90
|
+
#endif
|
89
91
|
}
|
90
92
|
|
91
93
|
/**
|
@@ -133,7 +135,7 @@ static int synchronized_threads_init(void)
|
|
133
135
|
|
134
136
|
_tls_index = TlsAlloc();
|
135
137
|
|
136
|
-
|
138
|
+
win32_pthread_initialize();
|
137
139
|
|
138
140
|
if (git_mutex_init(&git__mwindow_mutex))
|
139
141
|
return -1;
|
@@ -177,11 +179,6 @@ int git_libgit2_shutdown(void)
|
|
177
179
|
|
178
180
|
TlsFree(_tls_index);
|
179
181
|
git_mutex_free(&git__mwindow_mutex);
|
180
|
-
|
181
|
-
#if defined(GIT_MSVC_CRTDBG)
|
182
|
-
git_win32__crtdbg_stacktrace_cleanup();
|
183
|
-
git_win32__stack_cleanup();
|
184
|
-
#endif
|
185
182
|
}
|
186
183
|
|
187
184
|
/* Exit the lock */
|
@@ -225,23 +222,6 @@ void git__free_tls_data(void)
|
|
225
222
|
TlsSetValue(_tls_index, NULL);
|
226
223
|
}
|
227
224
|
|
228
|
-
BOOL WINAPI DllMain(HINSTANCE hInstDll, DWORD fdwReason, LPVOID lpvReserved)
|
229
|
-
{
|
230
|
-
GIT_UNUSED(hInstDll);
|
231
|
-
GIT_UNUSED(lpvReserved);
|
232
|
-
|
233
|
-
/* This is how Windows lets us know our thread is being shut down */
|
234
|
-
if (fdwReason == DLL_THREAD_DETACH) {
|
235
|
-
git__free_tls_data();
|
236
|
-
}
|
237
|
-
|
238
|
-
/*
|
239
|
-
* Windows pays attention to this during library loading. We don't do anything
|
240
|
-
* so we trivially succeed.
|
241
|
-
*/
|
242
|
-
return TRUE;
|
243
|
-
}
|
244
|
-
|
245
225
|
#elif defined(GIT_THREADS) && defined(_POSIX_THREADS)
|
246
226
|
|
247
227
|
static pthread_key_t _tls_key;
|
data/vendor/libgit2/src/global.h
CHANGED
data/vendor/libgit2/src/ignore.c
CHANGED
@@ -11,64 +11,35 @@
|
|
11
11
|
#define GIT_IGNORE_DEFAULT_RULES ".\n..\n.git\n"
|
12
12
|
|
13
13
|
/**
|
14
|
-
* A negative ignore pattern can
|
15
|
-
* wildcards if
|
16
|
-
*
|
14
|
+
* A negative ignore pattern can match a positive one without
|
15
|
+
* wildcards if its pattern equals the tail of the positive
|
16
|
+
* pattern. Thus
|
17
17
|
*
|
18
18
|
* foo/bar
|
19
19
|
* !bar
|
20
20
|
*
|
21
|
-
* would result in foo/bar being unignored again
|
22
|
-
*
|
23
|
-
* moo/foo/bar
|
24
|
-
* !foo/bar
|
25
|
-
*
|
26
|
-
* would do nothing. The reverse also holds true: a positive
|
27
|
-
* basename pattern can be negated by unignoring the basename in
|
28
|
-
* subdirectories. Thus
|
29
|
-
*
|
30
|
-
* bar
|
31
|
-
* !foo/bar
|
32
|
-
*
|
33
|
-
* would result in foo/bar being unignored again. As with the
|
34
|
-
* first case,
|
35
|
-
*
|
36
|
-
* foo/bar
|
37
|
-
* !moo/foo/bar
|
38
|
-
*
|
39
|
-
* would do nothing, again.
|
21
|
+
* would result in foo/bar being unignored again.
|
40
22
|
*/
|
41
23
|
static int does_negate_pattern(git_attr_fnmatch *rule, git_attr_fnmatch *neg)
|
42
24
|
{
|
43
|
-
git_attr_fnmatch *longer, *shorter;
|
44
25
|
char *p;
|
45
26
|
|
46
27
|
if ((rule->flags & GIT_ATTR_FNMATCH_NEGATIVE) == 0
|
47
28
|
&& (neg->flags & GIT_ATTR_FNMATCH_NEGATIVE) != 0) {
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
shorter = rule;
|
54
|
-
longer = neg;
|
55
|
-
} else {
|
56
|
-
shorter = neg;
|
57
|
-
longer = rule;
|
58
|
-
}
|
59
|
-
|
60
|
-
/* Otherwise, we need to check if the shorter
|
61
|
-
* rule is a basename only (that is, it contains
|
62
|
-
* no path separator) and, if so, if it
|
63
|
-
* matches the tail of the longer rule */
|
64
|
-
p = longer->pattern + longer->length - shorter->length;
|
65
|
-
|
66
|
-
if (p[-1] != '/')
|
67
|
-
return false;
|
68
|
-
if (memchr(shorter->pattern, '/', shorter->length) != NULL)
|
29
|
+
/*
|
30
|
+
* no chance of matching if rule is shorter than
|
31
|
+
* the negated one
|
32
|
+
*/
|
33
|
+
if (rule->length < neg->length)
|
69
34
|
return false;
|
70
35
|
|
71
|
-
|
36
|
+
/*
|
37
|
+
* shift pattern so its tail aligns with the
|
38
|
+
* negated pattern
|
39
|
+
*/
|
40
|
+
p = rule->pattern + rule->length - neg->length;
|
41
|
+
if (strcmp(p, neg->pattern) == 0)
|
42
|
+
return true;
|
72
43
|
}
|
73
44
|
|
74
45
|
return false;
|
@@ -292,18 +263,10 @@ int git_ignore__for_path(
|
|
292
263
|
goto cleanup;
|
293
264
|
|
294
265
|
/* given a unrooted path in a non-bare repo, resolve it */
|
295
|
-
if (workdir && git_path_root(path) < 0)
|
296
|
-
|
297
|
-
|
298
|
-
if ((error = git_path_dirname_r(&local, path)) < 0 ||
|
299
|
-
(error = git_path_resolve_relative(&local, 0)) < 0 ||
|
300
|
-
(error = git_path_to_dir(&local)) < 0 ||
|
301
|
-
(error = git_buf_joinpath(&ignores->dir, workdir, local.ptr)) < 0)
|
302
|
-
{;} /* Nothing, we just want to stop on the first error */
|
303
|
-
git_buf_free(&local);
|
304
|
-
} else {
|
266
|
+
if (workdir && git_path_root(path) < 0)
|
267
|
+
error = git_path_find_dir(&ignores->dir, path, workdir);
|
268
|
+
else
|
305
269
|
error = git_buf_joinpath(&ignores->dir, path, "");
|
306
|
-
}
|
307
270
|
if (error < 0)
|
308
271
|
goto cleanup;
|
309
272
|
|
data/vendor/libgit2/src/index.c
CHANGED
@@ -505,11 +505,10 @@ static int index_remove_entry(git_index *index, size_t pos)
|
|
505
505
|
int error = 0;
|
506
506
|
git_index_entry *entry = git_vector_get(&index->entries, pos);
|
507
507
|
|
508
|
-
if (entry != NULL)
|
508
|
+
if (entry != NULL)
|
509
509
|
git_tree_cache_invalidate_path(index->tree, entry->path);
|
510
|
-
DELETE_IN_MAP(index, entry);
|
511
|
-
}
|
512
510
|
|
511
|
+
DELETE_IN_MAP(index, entry);
|
513
512
|
error = git_vector_remove(&index->entries, pos);
|
514
513
|
|
515
514
|
if (!error) {
|
@@ -964,20 +963,14 @@ static int index_entry_reuc_init(git_index_reuc_entry **reuc_out,
|
|
964
963
|
*reuc_out = reuc = reuc_entry_alloc(path);
|
965
964
|
GITERR_CHECK_ALLOC(reuc);
|
966
965
|
|
967
|
-
if ((reuc->mode[0] = ancestor_mode) > 0)
|
968
|
-
assert(ancestor_oid);
|
966
|
+
if ((reuc->mode[0] = ancestor_mode) > 0)
|
969
967
|
git_oid_cpy(&reuc->oid[0], ancestor_oid);
|
970
|
-
}
|
971
968
|
|
972
|
-
if ((reuc->mode[1] = our_mode) > 0)
|
973
|
-
assert(our_oid);
|
969
|
+
if ((reuc->mode[1] = our_mode) > 0)
|
974
970
|
git_oid_cpy(&reuc->oid[1], our_oid);
|
975
|
-
}
|
976
971
|
|
977
|
-
if ((reuc->mode[2] = their_mode) > 0)
|
978
|
-
assert(their_oid);
|
972
|
+
if ((reuc->mode[2] = their_mode) > 0)
|
979
973
|
git_oid_cpy(&reuc->oid[2], their_oid);
|
980
|
-
}
|
981
974
|
|
982
975
|
return 0;
|
983
976
|
}
|
@@ -2837,7 +2830,7 @@ static int read_tree_cb(
|
|
2837
2830
|
return -1;
|
2838
2831
|
|
2839
2832
|
entry->mode = tentry->attr;
|
2840
|
-
|
2833
|
+
entry->id = tentry->oid;
|
2841
2834
|
|
2842
2835
|
/* look for corresponding old entry and copy data to new entry */
|
2843
2836
|
if (data->old_entries != NULL &&
|
@@ -2969,8 +2962,6 @@ int git_index_read_index(
|
|
2969
2962
|
*remove_entry = NULL;
|
2970
2963
|
int diff;
|
2971
2964
|
|
2972
|
-
error = 0;
|
2973
|
-
|
2974
2965
|
if (old_entry && new_entry)
|
2975
2966
|
diff = git_index_entry_cmp(old_entry, new_entry);
|
2976
2967
|
else if (!old_entry && new_entry)
|
@@ -2988,8 +2979,7 @@ int git_index_read_index(
|
|
2988
2979
|
/* Path and stage are equal, if the OID is equal, keep it to
|
2989
2980
|
* keep the stat cache data.
|
2990
2981
|
*/
|
2991
|
-
if (git_oid_equal(&old_entry->id, &new_entry->id)
|
2992
|
-
old_entry->mode == new_entry->mode) {
|
2982
|
+
if (git_oid_equal(&old_entry->id, &new_entry->id)) {
|
2993
2983
|
add_entry = (git_index_entry *)old_entry;
|
2994
2984
|
} else {
|
2995
2985
|
dup_entry = (git_index_entry *)new_entry;
|
@@ -3000,17 +2990,8 @@ int git_index_read_index(
|
|
3000
2990
|
if (dup_entry) {
|
3001
2991
|
if ((error = index_entry_dup_nocache(&add_entry, index, dup_entry)) < 0)
|
3002
2992
|
goto done;
|
3003
|
-
|
3004
|
-
index_entry_adjust_namemask(add_entry,
|
3005
|
-
((struct entry_internal *)add_entry)->pathlen);
|
3006
2993
|
}
|
3007
2994
|
|
3008
|
-
/* invalidate this path in the tree cache if this is new (to
|
3009
|
-
* invalidate the parent trees)
|
3010
|
-
*/
|
3011
|
-
if (dup_entry && !remove_entry && index->tree)
|
3012
|
-
git_tree_cache_invalidate_path(index->tree, dup_entry->path);
|
3013
|
-
|
3014
2995
|
if (add_entry) {
|
3015
2996
|
if ((error = git_vector_insert(&new_entries, add_entry)) == 0)
|
3016
2997
|
INSERT_IN_MAP_EX(index, new_entries_map, add_entry, error);
|
@@ -3021,7 +3002,7 @@ int git_index_read_index(
|
|
3021
3002
|
|
3022
3003
|
if (error < 0) {
|
3023
3004
|
giterr_set(GITERR_INDEX, "failed to insert entry");
|
3024
|
-
|
3005
|
+
return error;
|
3025
3006
|
}
|
3026
3007
|
|
3027
3008
|
if (diff <= 0) {
|
@@ -449,7 +449,7 @@ static void hash_partially(git_indexer *idx, const uint8_t *data, size_t size)
|
|
449
449
|
static int write_at(git_indexer *idx, const void *data, git_off_t offset, size_t size)
|
450
450
|
{
|
451
451
|
git_file fd = idx->pack->mwf.fd;
|
452
|
-
size_t
|
452
|
+
size_t page_size;
|
453
453
|
size_t page_offset;
|
454
454
|
git_off_t page_start;
|
455
455
|
unsigned char *map_data;
|
@@ -458,11 +458,11 @@ static int write_at(git_indexer *idx, const void *data, git_off_t offset, size_t
|
|
458
458
|
|
459
459
|
assert(data && size);
|
460
460
|
|
461
|
-
if ((error =
|
461
|
+
if ((error = git__page_size(&page_size)) < 0)
|
462
462
|
return error;
|
463
463
|
|
464
|
-
/* the offset needs to be at the
|
465
|
-
page_offset = offset %
|
464
|
+
/* the offset needs to be at the beginning of the a page boundary */
|
465
|
+
page_offset = offset % page_size;
|
466
466
|
page_start = offset - page_offset;
|
467
467
|
|
468
468
|
if ((error = p_mmap(&map, page_offset + size, GIT_PROT_WRITE, GIT_MAP_SHARED, fd, page_start)) < 0)
|
@@ -777,6 +777,7 @@ static int fix_thin_pack(git_indexer *idx, git_transfer_progress *stats)
|
|
777
777
|
|
778
778
|
curpos = delta->delta_off;
|
779
779
|
error = git_packfile_unpack_header(&size, &type, &idx->pack->mwf, &w, &curpos);
|
780
|
+
git_mwindow_close(&w);
|
780
781
|
if (error < 0)
|
781
782
|
return error;
|
782
783
|
|
@@ -913,17 +914,12 @@ int git_indexer_commit(git_indexer *idx, git_transfer_progress *stats)
|
|
913
914
|
git_filebuf index_file = {0};
|
914
915
|
void *packfile_trailer;
|
915
916
|
|
916
|
-
if (!idx->parsed_header) {
|
917
|
-
giterr_set(GITERR_INDEXER, "incomplete pack header");
|
918
|
-
return -1;
|
919
|
-
}
|
920
|
-
|
921
917
|
if (git_hash_ctx_init(&ctx) < 0)
|
922
918
|
return -1;
|
923
919
|
|
924
920
|
/* Test for this before resolve_deltas(), as it plays with idx->off */
|
925
|
-
if (idx->off
|
926
|
-
giterr_set(GITERR_INDEXER, "
|
921
|
+
if (idx->off < idx->pack->mwf.size - 20) {
|
922
|
+
giterr_set(GITERR_INDEXER, "Unexpected data at the end of the pack");
|
927
923
|
return -1;
|
928
924
|
}
|
929
925
|
|