rugged 0.25.0b5 → 0.25.0b6
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_patch.c +77 -17
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +8 -6
- data/vendor/libgit2/include/git2/checkout.h +7 -0
- data/vendor/libgit2/include/git2/common.h +1 -0
- data/vendor/libgit2/include/git2/diff.h +54 -7
- data/vendor/libgit2/include/git2/errors.h +2 -1
- data/vendor/libgit2/include/git2/index.h +25 -0
- data/vendor/libgit2/include/git2/pack.h +4 -4
- data/vendor/libgit2/include/git2/repository.h +20 -1
- data/vendor/libgit2/include/git2/submodule.h +11 -3
- data/vendor/libgit2/include/git2/sys/odb_backend.h +11 -0
- data/vendor/libgit2/src/apply.c +369 -0
- data/vendor/libgit2/src/apply.h +21 -0
- data/vendor/libgit2/src/array.h +0 -1
- data/vendor/libgit2/src/blame_git.c +18 -8
- data/vendor/libgit2/src/buffer.c +252 -20
- data/vendor/libgit2/src/buffer.h +8 -0
- data/vendor/libgit2/src/checkout.c +7 -1
- data/vendor/libgit2/src/clone.c +0 -8
- data/vendor/libgit2/src/common.h +1 -1
- data/vendor/libgit2/src/crlf.c +1 -0
- data/vendor/libgit2/src/delta.c +238 -62
- data/vendor/libgit2/src/delta.h +79 -58
- data/vendor/libgit2/src/diff.c +32 -1547
- data/vendor/libgit2/src/diff.h +12 -122
- data/vendor/libgit2/src/diff_driver.c +1 -2
- data/vendor/libgit2/src/diff_file.c +3 -0
- data/vendor/libgit2/src/diff_generate.c +1611 -0
- data/vendor/libgit2/src/diff_generate.h +123 -0
- data/vendor/libgit2/src/diff_parse.c +105 -0
- data/vendor/libgit2/src/diff_print.c +259 -142
- data/vendor/libgit2/src/diff_stats.c +3 -2
- data/vendor/libgit2/src/diff_tform.c +1 -0
- data/vendor/libgit2/src/diff_tform.h +22 -0
- data/vendor/libgit2/src/diff_xdiff.c +9 -9
- data/vendor/libgit2/src/diff_xdiff.h +5 -5
- data/vendor/libgit2/src/fileops.c +13 -0
- data/vendor/libgit2/src/fileops.h +6 -0
- data/vendor/libgit2/src/global.c +9 -8
- data/vendor/libgit2/src/ignore.c +45 -16
- data/vendor/libgit2/src/index.c +161 -47
- data/vendor/libgit2/src/index.h +2 -0
- data/vendor/libgit2/src/merge.c +2 -0
- data/vendor/libgit2/src/mwindow.c +8 -19
- data/vendor/libgit2/src/mwindow.h +1 -2
- data/vendor/libgit2/src/odb.c +46 -10
- data/vendor/libgit2/src/odb_loose.c +19 -1
- data/vendor/libgit2/src/odb_pack.c +27 -4
- data/vendor/libgit2/src/pack-objects.c +106 -77
- data/vendor/libgit2/src/pack-objects.h +13 -12
- data/vendor/libgit2/src/pack.c +4 -3
- data/vendor/libgit2/src/pack.h +2 -0
- data/vendor/libgit2/src/patch.c +207 -0
- data/vendor/libgit2/src/patch.h +66 -0
- data/vendor/libgit2/src/{diff_patch.c → patch_generate.c} +171 -359
- data/vendor/libgit2/src/patch_generate.h +66 -0
- data/vendor/libgit2/src/patch_parse.c +1121 -0
- data/vendor/libgit2/src/patch_parse.h +54 -0
- data/vendor/libgit2/src/path.c +19 -0
- data/vendor/libgit2/src/path.h +6 -0
- data/vendor/libgit2/src/pool.h +5 -0
- data/vendor/libgit2/src/remote.c +15 -80
- data/vendor/libgit2/src/repository.c +227 -39
- data/vendor/libgit2/src/settings.c +11 -5
- data/vendor/libgit2/src/stash.c +1 -0
- data/vendor/libgit2/src/status.c +1 -0
- data/vendor/libgit2/src/stransport_stream.c +14 -9
- data/vendor/libgit2/src/submodule.c +16 -4
- data/vendor/libgit2/src/sysdir.c +41 -47
- data/vendor/libgit2/src/sysdir.h +0 -5
- data/vendor/libgit2/src/thread-utils.h +5 -51
- data/vendor/libgit2/src/transport.c +3 -5
- data/vendor/libgit2/src/transports/http.c +2 -3
- data/vendor/libgit2/src/transports/smart_pkt.c +1 -0
- data/vendor/libgit2/src/transports/smart_protocol.c +11 -0
- data/vendor/libgit2/src/transports/winhttp.c +16 -2
- data/vendor/libgit2/src/unix/pthread.h +54 -0
- data/vendor/libgit2/src/util.c +23 -5
- data/vendor/libgit2/src/util.h +10 -0
- data/vendor/libgit2/src/varint.c +44 -0
- data/vendor/libgit2/src/varint.h +15 -0
- data/vendor/libgit2/src/vector.c +42 -0
- data/vendor/libgit2/src/vector.h +3 -0
- data/vendor/libgit2/src/win32/precompiled.h +1 -1
- data/vendor/libgit2/src/win32/{pthread.c → thread.c} +50 -80
- data/vendor/libgit2/src/win32/thread.h +62 -0
- data/vendor/libgit2/src/zstream.c +36 -7
- data/vendor/libgit2/src/zstream.h +8 -1
- metadata +20 -9
- data/vendor/libgit2/src/delta-apply.c +0 -166
- data/vendor/libgit2/src/delta-apply.h +0 -62
- data/vendor/libgit2/src/diff_patch.h +0 -83
- data/vendor/libgit2/src/win32/pthread.h +0 -92
data/vendor/libgit2/src/buffer.c
CHANGED
@@ -273,42 +273,51 @@ int git_buf_encode_base64(git_buf *buf, const char *data, size_t len)
|
|
273
273
|
return 0;
|
274
274
|
}
|
275
275
|
|
276
|
-
/* The inverse of base64_encode
|
276
|
+
/* The inverse of base64_encode */
|
277
277
|
static const int8_t base64_decode[] = {
|
278
|
-
|
279
|
-
-1, -1, -1,
|
280
|
-
63,
|
281
|
-
52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
|
282
|
-
-1,
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
278
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
279
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
280
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
|
281
|
+
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, 0, -1, -1,
|
282
|
+
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
|
283
|
+
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
|
284
|
+
-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
|
285
|
+
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1,
|
286
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
287
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
288
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
289
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
290
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
291
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
292
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
293
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
|
288
294
|
};
|
289
295
|
|
290
|
-
#define BASE64_DECODE_VALUE(c) (((c) < 43 || (c) > 122) ? -1 : base64_decode[c - 43])
|
291
|
-
|
292
296
|
int git_buf_decode_base64(git_buf *buf, const char *base64, size_t len)
|
293
297
|
{
|
294
298
|
size_t i;
|
295
299
|
int8_t a, b, c, d;
|
296
300
|
size_t orig_size = buf->size, new_size;
|
297
301
|
|
302
|
+
if (len % 4) {
|
303
|
+
giterr_set(GITERR_INVALID, "invalid base64 input");
|
304
|
+
return -1;
|
305
|
+
}
|
306
|
+
|
298
307
|
assert(len % 4 == 0);
|
299
308
|
GITERR_CHECK_ALLOC_ADD(&new_size, (len / 4 * 3), buf->size);
|
300
309
|
GITERR_CHECK_ALLOC_ADD(&new_size, new_size, 1);
|
301
310
|
ENSURE_SIZE(buf, new_size);
|
302
311
|
|
303
312
|
for (i = 0; i < len; i += 4) {
|
304
|
-
if ((a =
|
305
|
-
(b =
|
306
|
-
(c =
|
307
|
-
(d =
|
313
|
+
if ((a = base64_decode[(unsigned char)base64[i]]) < 0 ||
|
314
|
+
(b = base64_decode[(unsigned char)base64[i+1]]) < 0 ||
|
315
|
+
(c = base64_decode[(unsigned char)base64[i+2]]) < 0 ||
|
316
|
+
(d = base64_decode[(unsigned char)base64[i+3]]) < 0) {
|
308
317
|
buf->size = orig_size;
|
309
318
|
buf->ptr[buf->size] = '\0';
|
310
319
|
|
311
|
-
giterr_set(GITERR_INVALID, "
|
320
|
+
giterr_set(GITERR_INVALID, "invalid base64 input");
|
312
321
|
return -1;
|
313
322
|
}
|
314
323
|
|
@@ -321,7 +330,7 @@ int git_buf_decode_base64(git_buf *buf, const char *base64, size_t len)
|
|
321
330
|
return 0;
|
322
331
|
}
|
323
332
|
|
324
|
-
static const char
|
333
|
+
static const char base85_encode[] =
|
325
334
|
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~";
|
326
335
|
|
327
336
|
int git_buf_encode_base85(git_buf *buf, const char *data, size_t len)
|
@@ -351,7 +360,7 @@ int git_buf_encode_base85(git_buf *buf, const char *data, size_t len)
|
|
351
360
|
int val = acc % 85;
|
352
361
|
acc /= 85;
|
353
362
|
|
354
|
-
b85[i] =
|
363
|
+
b85[i] = base85_encode[val];
|
355
364
|
}
|
356
365
|
|
357
366
|
for (i = 0; i < 5; i++)
|
@@ -363,6 +372,88 @@ int git_buf_encode_base85(git_buf *buf, const char *data, size_t len)
|
|
363
372
|
return 0;
|
364
373
|
}
|
365
374
|
|
375
|
+
/* The inverse of base85_encode */
|
376
|
+
static const int8_t base85_decode[] = {
|
377
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
378
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
379
|
+
-1, 63, -1, 64, 65, 66, 67, -1, 68, 69, 70, 71, -1, 72, -1, -1,
|
380
|
+
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, 73, 74, 75, 76, 77,
|
381
|
+
78, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
|
382
|
+
26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, -1, -1, -1, 79, 80,
|
383
|
+
81, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
|
384
|
+
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 82, 83, 84, 85, -1,
|
385
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
386
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
387
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
388
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
389
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
390
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
391
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
392
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
|
393
|
+
};
|
394
|
+
|
395
|
+
int git_buf_decode_base85(
|
396
|
+
git_buf *buf,
|
397
|
+
const char *base85,
|
398
|
+
size_t base85_len,
|
399
|
+
size_t output_len)
|
400
|
+
{
|
401
|
+
size_t orig_size = buf->size, new_size;
|
402
|
+
|
403
|
+
if (base85_len % 5 ||
|
404
|
+
output_len > base85_len * 4 / 5) {
|
405
|
+
giterr_set(GITERR_INVALID, "invalid base85 input");
|
406
|
+
return -1;
|
407
|
+
}
|
408
|
+
|
409
|
+
GITERR_CHECK_ALLOC_ADD(&new_size, output_len, buf->size);
|
410
|
+
GITERR_CHECK_ALLOC_ADD(&new_size, new_size, 1);
|
411
|
+
ENSURE_SIZE(buf, new_size);
|
412
|
+
|
413
|
+
while (output_len) {
|
414
|
+
unsigned acc = 0;
|
415
|
+
int de, cnt = 4;
|
416
|
+
unsigned char ch;
|
417
|
+
do {
|
418
|
+
ch = *base85++;
|
419
|
+
de = base85_decode[ch];
|
420
|
+
if (--de < 0)
|
421
|
+
goto on_error;
|
422
|
+
|
423
|
+
acc = acc * 85 + de;
|
424
|
+
} while (--cnt);
|
425
|
+
ch = *base85++;
|
426
|
+
de = base85_decode[ch];
|
427
|
+
if (--de < 0)
|
428
|
+
goto on_error;
|
429
|
+
|
430
|
+
/* Detect overflow. */
|
431
|
+
if (0xffffffff / 85 < acc ||
|
432
|
+
0xffffffff - de < (acc *= 85))
|
433
|
+
goto on_error;
|
434
|
+
|
435
|
+
acc += de;
|
436
|
+
|
437
|
+
cnt = (output_len < 4) ? output_len : 4;
|
438
|
+
output_len -= cnt;
|
439
|
+
do {
|
440
|
+
acc = (acc << 8) | (acc >> 24);
|
441
|
+
buf->ptr[buf->size++] = acc;
|
442
|
+
} while (--cnt);
|
443
|
+
}
|
444
|
+
|
445
|
+
buf->ptr[buf->size] = 0;
|
446
|
+
|
447
|
+
return 0;
|
448
|
+
|
449
|
+
on_error:
|
450
|
+
buf->size = orig_size;
|
451
|
+
buf->ptr[buf->size] = '\0';
|
452
|
+
|
453
|
+
giterr_set(GITERR_INVALID, "invalid base85 input");
|
454
|
+
return -1;
|
455
|
+
}
|
456
|
+
|
366
457
|
int git_buf_vprintf(git_buf *buf, const char *format, va_list ap)
|
367
458
|
{
|
368
459
|
size_t expected_size, new_size;
|
@@ -766,3 +857,144 @@ int git_buf_splice(
|
|
766
857
|
buf->ptr[buf->size] = '\0';
|
767
858
|
return 0;
|
768
859
|
}
|
860
|
+
|
861
|
+
/* Quote per http://marc.info/?l=git&m=112927316408690&w=2 */
|
862
|
+
int git_buf_quote(git_buf *buf)
|
863
|
+
{
|
864
|
+
const char whitespace[] = { 'a', 'b', 't', 'n', 'v', 'f', 'r' };
|
865
|
+
git_buf quoted = GIT_BUF_INIT;
|
866
|
+
size_t i = 0;
|
867
|
+
bool quote = false;
|
868
|
+
int error = 0;
|
869
|
+
|
870
|
+
/* walk to the first char that needs quoting */
|
871
|
+
if (buf->size && buf->ptr[0] == '!')
|
872
|
+
quote = true;
|
873
|
+
|
874
|
+
for (i = 0; !quote && i < buf->size; i++) {
|
875
|
+
if (buf->ptr[i] == '"' || buf->ptr[i] == '\\' ||
|
876
|
+
buf->ptr[i] < ' ' || buf->ptr[i] > '~') {
|
877
|
+
quote = true;
|
878
|
+
break;
|
879
|
+
}
|
880
|
+
}
|
881
|
+
|
882
|
+
if (!quote)
|
883
|
+
goto done;
|
884
|
+
|
885
|
+
git_buf_putc("ed, '"');
|
886
|
+
git_buf_put("ed, buf->ptr, i);
|
887
|
+
|
888
|
+
for (; i < buf->size; i++) {
|
889
|
+
/* whitespace - use the map above, which is ordered by ascii value */
|
890
|
+
if (buf->ptr[i] >= '\a' && buf->ptr[i] <= '\r') {
|
891
|
+
git_buf_putc("ed, '\\');
|
892
|
+
git_buf_putc("ed, whitespace[buf->ptr[i] - '\a']);
|
893
|
+
}
|
894
|
+
|
895
|
+
/* double quote and backslash must be escaped */
|
896
|
+
else if (buf->ptr[i] == '"' || buf->ptr[i] == '\\') {
|
897
|
+
git_buf_putc("ed, '\\');
|
898
|
+
git_buf_putc("ed, buf->ptr[i]);
|
899
|
+
}
|
900
|
+
|
901
|
+
/* escape anything unprintable as octal */
|
902
|
+
else if (buf->ptr[i] != ' ' &&
|
903
|
+
(buf->ptr[i] < '!' || buf->ptr[i] > '~')) {
|
904
|
+
git_buf_printf("ed, "\\%03o", (unsigned char)buf->ptr[i]);
|
905
|
+
}
|
906
|
+
|
907
|
+
/* yay, printable! */
|
908
|
+
else {
|
909
|
+
git_buf_putc("ed, buf->ptr[i]);
|
910
|
+
}
|
911
|
+
}
|
912
|
+
|
913
|
+
git_buf_putc("ed, '"');
|
914
|
+
|
915
|
+
if (git_buf_oom("ed)) {
|
916
|
+
error = -1;
|
917
|
+
goto done;
|
918
|
+
}
|
919
|
+
|
920
|
+
git_buf_swap("ed, buf);
|
921
|
+
|
922
|
+
done:
|
923
|
+
git_buf_free("ed);
|
924
|
+
return error;
|
925
|
+
}
|
926
|
+
|
927
|
+
/* Unquote per http://marc.info/?l=git&m=112927316408690&w=2 */
|
928
|
+
int git_buf_unquote(git_buf *buf)
|
929
|
+
{
|
930
|
+
size_t i, j;
|
931
|
+
char ch;
|
932
|
+
|
933
|
+
git_buf_rtrim(buf);
|
934
|
+
|
935
|
+
if (buf->size < 2 || buf->ptr[0] != '"' || buf->ptr[buf->size-1] != '"')
|
936
|
+
goto invalid;
|
937
|
+
|
938
|
+
for (i = 0, j = 1; j < buf->size-1; i++, j++) {
|
939
|
+
ch = buf->ptr[j];
|
940
|
+
|
941
|
+
if (ch == '\\') {
|
942
|
+
if (j == buf->size-2)
|
943
|
+
goto invalid;
|
944
|
+
|
945
|
+
ch = buf->ptr[++j];
|
946
|
+
|
947
|
+
switch (ch) {
|
948
|
+
/* \" or \\ simply copy the char in */
|
949
|
+
case '"': case '\\':
|
950
|
+
break;
|
951
|
+
|
952
|
+
/* add the appropriate escaped char */
|
953
|
+
case 'a': ch = '\a'; break;
|
954
|
+
case 'b': ch = '\b'; break;
|
955
|
+
case 'f': ch = '\f'; break;
|
956
|
+
case 'n': ch = '\n'; break;
|
957
|
+
case 'r': ch = '\r'; break;
|
958
|
+
case 't': ch = '\t'; break;
|
959
|
+
case 'v': ch = '\v'; break;
|
960
|
+
|
961
|
+
/* \xyz digits convert to the char*/
|
962
|
+
case '0': case '1': case '2': case '3':
|
963
|
+
if (j == buf->size-3) {
|
964
|
+
giterr_set(GITERR_INVALID,
|
965
|
+
"Truncated quoted character \\%c", ch);
|
966
|
+
return -1;
|
967
|
+
}
|
968
|
+
|
969
|
+
if (buf->ptr[j+1] < '0' || buf->ptr[j+1] > '7' ||
|
970
|
+
buf->ptr[j+2] < '0' || buf->ptr[j+2] > '7') {
|
971
|
+
giterr_set(GITERR_INVALID,
|
972
|
+
"Truncated quoted character \\%c%c%c",
|
973
|
+
buf->ptr[j], buf->ptr[j+1], buf->ptr[j+2]);
|
974
|
+
return -1;
|
975
|
+
}
|
976
|
+
|
977
|
+
ch = ((buf->ptr[j] - '0') << 6) |
|
978
|
+
((buf->ptr[j+1] - '0') << 3) |
|
979
|
+
(buf->ptr[j+2] - '0');
|
980
|
+
j += 2;
|
981
|
+
break;
|
982
|
+
|
983
|
+
default:
|
984
|
+
giterr_set(GITERR_INVALID, "Invalid quoted character \\%c", ch);
|
985
|
+
return -1;
|
986
|
+
}
|
987
|
+
}
|
988
|
+
|
989
|
+
buf->ptr[i] = ch;
|
990
|
+
}
|
991
|
+
|
992
|
+
buf->ptr[i] = '\0';
|
993
|
+
buf->size = i;
|
994
|
+
|
995
|
+
return 0;
|
996
|
+
|
997
|
+
invalid:
|
998
|
+
giterr_set(GITERR_INVALID, "Invalid quoted line");
|
999
|
+
return -1;
|
1000
|
+
}
|
data/vendor/libgit2/src/buffer.h
CHANGED
@@ -173,6 +173,12 @@ void git_buf_rtrim(git_buf *buf);
|
|
173
173
|
|
174
174
|
int git_buf_cmp(const git_buf *a, const git_buf *b);
|
175
175
|
|
176
|
+
/* Quote and unquote a buffer as specified in
|
177
|
+
* http://marc.info/?l=git&m=112927316408690&w=2
|
178
|
+
*/
|
179
|
+
int git_buf_quote(git_buf *buf);
|
180
|
+
int git_buf_unquote(git_buf *buf);
|
181
|
+
|
176
182
|
/* Write data as base64 encoded in buffer */
|
177
183
|
int git_buf_encode_base64(git_buf *buf, const char *data, size_t len);
|
178
184
|
/* Decode the given bas64 and write the result to the buffer */
|
@@ -180,6 +186,8 @@ int git_buf_decode_base64(git_buf *buf, const char *base64, size_t len);
|
|
180
186
|
|
181
187
|
/* Write data as "base85" encoded in buffer */
|
182
188
|
int git_buf_encode_base85(git_buf *buf, const char *data, size_t len);
|
189
|
+
/* Decode the given "base85" and write the result to the buffer */
|
190
|
+
int git_buf_decode_base85(git_buf *buf, const char *base64, size_t len, size_t output_len);
|
183
191
|
|
184
192
|
/*
|
185
193
|
* Insert, remove or replace a portion of the buffer.
|
@@ -26,6 +26,7 @@
|
|
26
26
|
#include "filter.h"
|
27
27
|
#include "blob.h"
|
28
28
|
#include "diff.h"
|
29
|
+
#include "diff_generate.h"
|
29
30
|
#include "pathspec.h"
|
30
31
|
#include "buf_text.h"
|
31
32
|
#include "diff_xdiff.h"
|
@@ -2430,8 +2431,13 @@ static int checkout_data_init(
|
|
2430
2431
|
|
2431
2432
|
if (!data->opts.baseline && !data->opts.baseline_index) {
|
2432
2433
|
data->opts_free_baseline = true;
|
2434
|
+
error = 0;
|
2433
2435
|
|
2434
|
-
|
2436
|
+
/* if we don't have an index, this is an initial checkout and
|
2437
|
+
* should be against an empty baseline
|
2438
|
+
*/
|
2439
|
+
if (data->index->on_disk)
|
2440
|
+
error = checkout_lookup_head_tree(&data->opts.baseline, repo);
|
2435
2441
|
|
2436
2442
|
if (error == GIT_EUNBORNBRANCH) {
|
2437
2443
|
error = 0;
|
data/vendor/libgit2/src/clone.c
CHANGED
@@ -461,14 +461,6 @@ int git_clone_init_options(git_clone_options *opts, unsigned int version)
|
|
461
461
|
return 0;
|
462
462
|
}
|
463
463
|
|
464
|
-
static const char *repository_base(git_repository *repo)
|
465
|
-
{
|
466
|
-
if (git_repository_is_bare(repo))
|
467
|
-
return git_repository_path(repo);
|
468
|
-
|
469
|
-
return git_repository_workdir(repo);
|
470
|
-
}
|
471
|
-
|
472
464
|
static bool can_link(const char *src, const char *dst, int link)
|
473
465
|
{
|
474
466
|
#ifdef GIT_WIN32
|
data/vendor/libgit2/src/common.h
CHANGED
data/vendor/libgit2/src/crlf.c
CHANGED
data/vendor/libgit2/src/delta.c
CHANGED
@@ -114,7 +114,7 @@ struct index_entry {
|
|
114
114
|
struct git_delta_index {
|
115
115
|
unsigned long memsize;
|
116
116
|
const void *src_buf;
|
117
|
-
|
117
|
+
size_t src_size;
|
118
118
|
unsigned int hash_mask;
|
119
119
|
struct index_entry *hash[GIT_FLEX_ARRAY];
|
120
120
|
};
|
@@ -142,8 +142,8 @@ static int lookup_index_alloc(
|
|
142
142
|
return 0;
|
143
143
|
}
|
144
144
|
|
145
|
-
|
146
|
-
|
145
|
+
int git_delta_index_init(
|
146
|
+
git_delta_index **out, const void *buf, size_t bufsize)
|
147
147
|
{
|
148
148
|
unsigned int i, hsize, hmask, entries, prev_val, *hash_count;
|
149
149
|
const unsigned char *data, *buffer = buf;
|
@@ -152,8 +152,10 @@ git_delta_create_index(const void *buf, unsigned long bufsize)
|
|
152
152
|
void *mem;
|
153
153
|
unsigned long memsize;
|
154
154
|
|
155
|
+
*out = NULL;
|
156
|
+
|
155
157
|
if (!buf || !bufsize)
|
156
|
-
return
|
158
|
+
return 0;
|
157
159
|
|
158
160
|
/* Determine index hash size. Note that indexing skips the
|
159
161
|
first byte to allow for optimizing the rabin polynomial
|
@@ -172,7 +174,7 @@ git_delta_create_index(const void *buf, unsigned long bufsize)
|
|
172
174
|
hmask = hsize - 1;
|
173
175
|
|
174
176
|
if (lookup_index_alloc(&mem, &memsize, entries, hsize) < 0)
|
175
|
-
return
|
177
|
+
return -1;
|
176
178
|
|
177
179
|
index = mem;
|
178
180
|
mem = index->hash;
|
@@ -190,7 +192,7 @@ git_delta_create_index(const void *buf, unsigned long bufsize)
|
|
190
192
|
hash_count = git__calloc(hsize, sizeof(*hash_count));
|
191
193
|
if (!hash_count) {
|
192
194
|
git__free(index);
|
193
|
-
return
|
195
|
+
return -1;
|
194
196
|
}
|
195
197
|
|
196
198
|
/* then populate the index */
|
@@ -243,20 +245,20 @@ git_delta_create_index(const void *buf, unsigned long bufsize)
|
|
243
245
|
}
|
244
246
|
git__free(hash_count);
|
245
247
|
|
246
|
-
|
248
|
+
*out = index;
|
249
|
+
return 0;
|
247
250
|
}
|
248
251
|
|
249
|
-
void
|
252
|
+
void git_delta_index_free(git_delta_index *index)
|
250
253
|
{
|
251
254
|
git__free(index);
|
252
255
|
}
|
253
256
|
|
254
|
-
|
257
|
+
size_t git_delta_index_size(git_delta_index *index)
|
255
258
|
{
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
return 0;
|
259
|
+
assert(index);
|
260
|
+
|
261
|
+
return index->memsize;
|
260
262
|
}
|
261
263
|
|
262
264
|
/*
|
@@ -265,55 +267,57 @@ unsigned long git_delta_sizeof_index(struct git_delta_index *index)
|
|
265
267
|
*/
|
266
268
|
#define MAX_OP_SIZE (5 + 5 + 1 + RABIN_WINDOW + 7)
|
267
269
|
|
268
|
-
|
269
|
-
|
270
|
+
int git_delta_create_from_index(
|
271
|
+
void **out,
|
272
|
+
size_t *out_len,
|
270
273
|
const struct git_delta_index *index,
|
271
274
|
const void *trg_buf,
|
272
|
-
|
273
|
-
|
274
|
-
unsigned long max_size)
|
275
|
+
size_t trg_size,
|
276
|
+
size_t max_size)
|
275
277
|
{
|
276
|
-
unsigned int i,
|
278
|
+
unsigned int i, bufpos, bufsize, moff, msize, val;
|
277
279
|
int inscnt;
|
278
280
|
const unsigned char *ref_data, *ref_top, *data, *top;
|
279
|
-
unsigned char *
|
281
|
+
unsigned char *buf;
|
282
|
+
|
283
|
+
*out = NULL;
|
284
|
+
*out_len = 0;
|
280
285
|
|
281
286
|
if (!trg_buf || !trg_size)
|
282
|
-
return
|
287
|
+
return 0;
|
283
288
|
|
284
|
-
|
285
|
-
|
286
|
-
if (max_size &&
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
return NULL;
|
289
|
+
bufpos = 0;
|
290
|
+
bufsize = 8192;
|
291
|
+
if (max_size && bufsize >= max_size)
|
292
|
+
bufsize = (unsigned int)(max_size + MAX_OP_SIZE + 1);
|
293
|
+
buf = git__malloc(bufsize);
|
294
|
+
GITERR_CHECK_ALLOC(buf);
|
291
295
|
|
292
296
|
/* store reference buffer size */
|
293
297
|
i = index->src_size;
|
294
298
|
while (i >= 0x80) {
|
295
|
-
|
299
|
+
buf[bufpos++] = i | 0x80;
|
296
300
|
i >>= 7;
|
297
301
|
}
|
298
|
-
|
302
|
+
buf[bufpos++] = i;
|
299
303
|
|
300
304
|
/* store target buffer size */
|
301
305
|
i = trg_size;
|
302
306
|
while (i >= 0x80) {
|
303
|
-
|
307
|
+
buf[bufpos++] = i | 0x80;
|
304
308
|
i >>= 7;
|
305
309
|
}
|
306
|
-
|
310
|
+
buf[bufpos++] = i;
|
307
311
|
|
308
312
|
ref_data = index->src_buf;
|
309
313
|
ref_top = ref_data + index->src_size;
|
310
314
|
data = trg_buf;
|
311
315
|
top = (const unsigned char *) trg_buf + trg_size;
|
312
316
|
|
313
|
-
|
317
|
+
bufpos++;
|
314
318
|
val = 0;
|
315
319
|
for (i = 0; i < RABIN_WINDOW && data < top; i++, data++) {
|
316
|
-
|
320
|
+
buf[bufpos++] = *data;
|
317
321
|
val = ((val << 8) | *data) ^ T[val >> RABIN_SHIFT];
|
318
322
|
}
|
319
323
|
inscnt = i;
|
@@ -350,11 +354,11 @@ git_delta_create(
|
|
350
354
|
|
351
355
|
if (msize < 4) {
|
352
356
|
if (!inscnt)
|
353
|
-
|
354
|
-
|
357
|
+
bufpos++;
|
358
|
+
buf[bufpos++] = *data++;
|
355
359
|
inscnt++;
|
356
360
|
if (inscnt == 0x7f) {
|
357
|
-
|
361
|
+
buf[bufpos - inscnt - 1] = inscnt;
|
358
362
|
inscnt = 0;
|
359
363
|
}
|
360
364
|
msize = 0;
|
@@ -368,14 +372,14 @@ git_delta_create(
|
|
368
372
|
msize++;
|
369
373
|
moff--;
|
370
374
|
data--;
|
371
|
-
|
375
|
+
bufpos--;
|
372
376
|
if (--inscnt)
|
373
377
|
continue;
|
374
|
-
|
378
|
+
bufpos--; /* remove count slot */
|
375
379
|
inscnt--; /* make it -1 */
|
376
380
|
break;
|
377
381
|
}
|
378
|
-
|
382
|
+
buf[bufpos - inscnt - 1] = inscnt;
|
379
383
|
inscnt = 0;
|
380
384
|
}
|
381
385
|
|
@@ -383,22 +387,22 @@ git_delta_create(
|
|
383
387
|
left = (msize < 0x10000) ? 0 : (msize - 0x10000);
|
384
388
|
msize -= left;
|
385
389
|
|
386
|
-
op =
|
390
|
+
op = buf + bufpos++;
|
387
391
|
i = 0x80;
|
388
392
|
|
389
393
|
if (moff & 0x000000ff)
|
390
|
-
|
394
|
+
buf[bufpos++] = moff >> 0, i |= 0x01;
|
391
395
|
if (moff & 0x0000ff00)
|
392
|
-
|
396
|
+
buf[bufpos++] = moff >> 8, i |= 0x02;
|
393
397
|
if (moff & 0x00ff0000)
|
394
|
-
|
398
|
+
buf[bufpos++] = moff >> 16, i |= 0x04;
|
395
399
|
if (moff & 0xff000000)
|
396
|
-
|
400
|
+
buf[bufpos++] = moff >> 24, i |= 0x08;
|
397
401
|
|
398
402
|
if (msize & 0x00ff)
|
399
|
-
|
403
|
+
buf[bufpos++] = msize >> 0, i |= 0x10;
|
400
404
|
if (msize & 0xff00)
|
401
|
-
|
405
|
+
buf[bufpos++] = msize >> 8, i |= 0x20;
|
402
406
|
|
403
407
|
*op = i;
|
404
408
|
|
@@ -415,29 +419,201 @@ git_delta_create(
|
|
415
419
|
}
|
416
420
|
}
|
417
421
|
|
418
|
-
if (
|
419
|
-
void *tmp =
|
420
|
-
|
421
|
-
if (max_size &&
|
422
|
-
|
423
|
-
if (max_size &&
|
422
|
+
if (bufpos >= bufsize - MAX_OP_SIZE) {
|
423
|
+
void *tmp = buf;
|
424
|
+
bufsize = bufsize * 3 / 2;
|
425
|
+
if (max_size && bufsize >= max_size)
|
426
|
+
bufsize = max_size + MAX_OP_SIZE + 1;
|
427
|
+
if (max_size && bufpos > max_size)
|
424
428
|
break;
|
425
|
-
|
426
|
-
if (!
|
429
|
+
buf = git__realloc(buf, bufsize);
|
430
|
+
if (!buf) {
|
427
431
|
git__free(tmp);
|
428
|
-
return
|
432
|
+
return -1;
|
429
433
|
}
|
430
434
|
}
|
431
435
|
}
|
432
436
|
|
433
437
|
if (inscnt)
|
434
|
-
|
438
|
+
buf[bufpos - inscnt - 1] = inscnt;
|
435
439
|
|
436
|
-
if (max_size &&
|
437
|
-
|
438
|
-
|
440
|
+
if (max_size && bufpos > max_size) {
|
441
|
+
giterr_set(GITERR_NOMEMORY, "delta would be larger than maximum size");
|
442
|
+
git__free(buf);
|
443
|
+
return GIT_EBUFS;
|
439
444
|
}
|
440
445
|
|
441
|
-
*
|
442
|
-
|
446
|
+
*out_len = bufpos;
|
447
|
+
*out = buf;
|
448
|
+
return 0;
|
449
|
+
}
|
450
|
+
|
451
|
+
/*
|
452
|
+
* Delta application was heavily cribbed from BinaryDelta.java in JGit, which
|
453
|
+
* itself was heavily cribbed from <code>patch-delta.c</code> in the
|
454
|
+
* GIT project. The original delta patching code was written by
|
455
|
+
* Nicolas Pitre <nico@cam.org>.
|
456
|
+
*/
|
457
|
+
|
458
|
+
static int hdr_sz(
|
459
|
+
size_t *size,
|
460
|
+
const unsigned char **delta,
|
461
|
+
const unsigned char *end)
|
462
|
+
{
|
463
|
+
const unsigned char *d = *delta;
|
464
|
+
size_t r = 0;
|
465
|
+
unsigned int c, shift = 0;
|
466
|
+
|
467
|
+
do {
|
468
|
+
if (d == end) {
|
469
|
+
giterr_set(GITERR_INVALID, "truncated delta");
|
470
|
+
return -1;
|
471
|
+
}
|
472
|
+
|
473
|
+
c = *d++;
|
474
|
+
r |= (c & 0x7f) << shift;
|
475
|
+
shift += 7;
|
476
|
+
} while (c & 0x80);
|
477
|
+
*delta = d;
|
478
|
+
*size = r;
|
479
|
+
return 0;
|
480
|
+
}
|
481
|
+
|
482
|
+
int git_delta_read_header(
|
483
|
+
size_t *base_out,
|
484
|
+
size_t *result_out,
|
485
|
+
const unsigned char *delta,
|
486
|
+
size_t delta_len)
|
487
|
+
{
|
488
|
+
const unsigned char *delta_end = delta + delta_len;
|
489
|
+
if ((hdr_sz(base_out, &delta, delta_end) < 0) ||
|
490
|
+
(hdr_sz(result_out, &delta, delta_end) < 0))
|
491
|
+
return -1;
|
492
|
+
return 0;
|
493
|
+
}
|
494
|
+
|
495
|
+
#define DELTA_HEADER_BUFFER_LEN 16
|
496
|
+
int git_delta_read_header_fromstream(
|
497
|
+
size_t *base_sz, size_t *res_sz, git_packfile_stream *stream)
|
498
|
+
{
|
499
|
+
static const size_t buffer_len = DELTA_HEADER_BUFFER_LEN;
|
500
|
+
unsigned char buffer[DELTA_HEADER_BUFFER_LEN];
|
501
|
+
const unsigned char *delta, *delta_end;
|
502
|
+
size_t len;
|
503
|
+
ssize_t read;
|
504
|
+
|
505
|
+
len = read = 0;
|
506
|
+
while (len < buffer_len) {
|
507
|
+
read = git_packfile_stream_read(stream, &buffer[len], buffer_len - len);
|
508
|
+
|
509
|
+
if (read == 0)
|
510
|
+
break;
|
511
|
+
|
512
|
+
if (read == GIT_EBUFS)
|
513
|
+
continue;
|
514
|
+
|
515
|
+
len += read;
|
516
|
+
}
|
517
|
+
|
518
|
+
delta = buffer;
|
519
|
+
delta_end = delta + len;
|
520
|
+
if ((hdr_sz(base_sz, &delta, delta_end) < 0) ||
|
521
|
+
(hdr_sz(res_sz, &delta, delta_end) < 0))
|
522
|
+
return -1;
|
523
|
+
|
524
|
+
return 0;
|
525
|
+
}
|
526
|
+
|
527
|
+
int git_delta_apply(
|
528
|
+
void **out,
|
529
|
+
size_t *out_len,
|
530
|
+
const unsigned char *base,
|
531
|
+
size_t base_len,
|
532
|
+
const unsigned char *delta,
|
533
|
+
size_t delta_len)
|
534
|
+
{
|
535
|
+
const unsigned char *delta_end = delta + delta_len;
|
536
|
+
size_t base_sz, res_sz, alloc_sz;
|
537
|
+
unsigned char *res_dp;
|
538
|
+
|
539
|
+
*out = NULL;
|
540
|
+
*out_len = 0;
|
541
|
+
|
542
|
+
/* Check that the base size matches the data we were given;
|
543
|
+
* if not we would underflow while accessing data from the
|
544
|
+
* base object, resulting in data corruption or segfault.
|
545
|
+
*/
|
546
|
+
if ((hdr_sz(&base_sz, &delta, delta_end) < 0) || (base_sz != base_len)) {
|
547
|
+
giterr_set(GITERR_INVALID, "Failed to apply delta. Base size does not match given data");
|
548
|
+
return -1;
|
549
|
+
}
|
550
|
+
|
551
|
+
if (hdr_sz(&res_sz, &delta, delta_end) < 0) {
|
552
|
+
giterr_set(GITERR_INVALID, "Failed to apply delta. Base size does not match given data");
|
553
|
+
return -1;
|
554
|
+
}
|
555
|
+
|
556
|
+
GITERR_CHECK_ALLOC_ADD(&alloc_sz, res_sz, 1);
|
557
|
+
res_dp = git__malloc(alloc_sz);
|
558
|
+
GITERR_CHECK_ALLOC(res_dp);
|
559
|
+
|
560
|
+
res_dp[res_sz] = '\0';
|
561
|
+
*out = res_dp;
|
562
|
+
*out_len = res_sz;
|
563
|
+
|
564
|
+
while (delta < delta_end) {
|
565
|
+
unsigned char cmd = *delta++;
|
566
|
+
if (cmd & 0x80) {
|
567
|
+
/* cmd is a copy instruction; copy from the base.
|
568
|
+
*/
|
569
|
+
size_t off = 0, len = 0;
|
570
|
+
|
571
|
+
if (cmd & 0x01) off = *delta++;
|
572
|
+
if (cmd & 0x02) off |= *delta++ << 8UL;
|
573
|
+
if (cmd & 0x04) off |= *delta++ << 16UL;
|
574
|
+
if (cmd & 0x08) off |= *delta++ << 24UL;
|
575
|
+
|
576
|
+
if (cmd & 0x10) len = *delta++;
|
577
|
+
if (cmd & 0x20) len |= *delta++ << 8UL;
|
578
|
+
if (cmd & 0x40) len |= *delta++ << 16UL;
|
579
|
+
if (!len) len = 0x10000;
|
580
|
+
|
581
|
+
if (base_len < off + len || res_sz < len)
|
582
|
+
goto fail;
|
583
|
+
memcpy(res_dp, base + off, len);
|
584
|
+
res_dp += len;
|
585
|
+
res_sz -= len;
|
586
|
+
|
587
|
+
}
|
588
|
+
else if (cmd) {
|
589
|
+
/* cmd is a literal insert instruction; copy from
|
590
|
+
* the delta stream itself.
|
591
|
+
*/
|
592
|
+
if (delta_end - delta < cmd || res_sz < cmd)
|
593
|
+
goto fail;
|
594
|
+
memcpy(res_dp, delta, cmd);
|
595
|
+
delta += cmd;
|
596
|
+
res_dp += cmd;
|
597
|
+
res_sz -= cmd;
|
598
|
+
|
599
|
+
}
|
600
|
+
else {
|
601
|
+
/* cmd == 0 is reserved for future encodings.
|
602
|
+
*/
|
603
|
+
goto fail;
|
604
|
+
}
|
605
|
+
}
|
606
|
+
|
607
|
+
if (delta != delta_end || res_sz)
|
608
|
+
goto fail;
|
609
|
+
return 0;
|
610
|
+
|
611
|
+
fail:
|
612
|
+
git__free(*out);
|
613
|
+
|
614
|
+
*out = NULL;
|
615
|
+
*out_len = 0;
|
616
|
+
|
617
|
+
giterr_set(GITERR_INVALID, "Failed to apply delta");
|
618
|
+
return -1;
|
443
619
|
}
|