rugged 0.25.0b5 → 0.25.0b6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/ext/rugged/rugged_patch.c +77 -17
  3. data/lib/rugged/version.rb +1 -1
  4. data/vendor/libgit2/CMakeLists.txt +8 -6
  5. data/vendor/libgit2/include/git2/checkout.h +7 -0
  6. data/vendor/libgit2/include/git2/common.h +1 -0
  7. data/vendor/libgit2/include/git2/diff.h +54 -7
  8. data/vendor/libgit2/include/git2/errors.h +2 -1
  9. data/vendor/libgit2/include/git2/index.h +25 -0
  10. data/vendor/libgit2/include/git2/pack.h +4 -4
  11. data/vendor/libgit2/include/git2/repository.h +20 -1
  12. data/vendor/libgit2/include/git2/submodule.h +11 -3
  13. data/vendor/libgit2/include/git2/sys/odb_backend.h +11 -0
  14. data/vendor/libgit2/src/apply.c +369 -0
  15. data/vendor/libgit2/src/apply.h +21 -0
  16. data/vendor/libgit2/src/array.h +0 -1
  17. data/vendor/libgit2/src/blame_git.c +18 -8
  18. data/vendor/libgit2/src/buffer.c +252 -20
  19. data/vendor/libgit2/src/buffer.h +8 -0
  20. data/vendor/libgit2/src/checkout.c +7 -1
  21. data/vendor/libgit2/src/clone.c +0 -8
  22. data/vendor/libgit2/src/common.h +1 -1
  23. data/vendor/libgit2/src/crlf.c +1 -0
  24. data/vendor/libgit2/src/delta.c +238 -62
  25. data/vendor/libgit2/src/delta.h +79 -58
  26. data/vendor/libgit2/src/diff.c +32 -1547
  27. data/vendor/libgit2/src/diff.h +12 -122
  28. data/vendor/libgit2/src/diff_driver.c +1 -2
  29. data/vendor/libgit2/src/diff_file.c +3 -0
  30. data/vendor/libgit2/src/diff_generate.c +1611 -0
  31. data/vendor/libgit2/src/diff_generate.h +123 -0
  32. data/vendor/libgit2/src/diff_parse.c +105 -0
  33. data/vendor/libgit2/src/diff_print.c +259 -142
  34. data/vendor/libgit2/src/diff_stats.c +3 -2
  35. data/vendor/libgit2/src/diff_tform.c +1 -0
  36. data/vendor/libgit2/src/diff_tform.h +22 -0
  37. data/vendor/libgit2/src/diff_xdiff.c +9 -9
  38. data/vendor/libgit2/src/diff_xdiff.h +5 -5
  39. data/vendor/libgit2/src/fileops.c +13 -0
  40. data/vendor/libgit2/src/fileops.h +6 -0
  41. data/vendor/libgit2/src/global.c +9 -8
  42. data/vendor/libgit2/src/ignore.c +45 -16
  43. data/vendor/libgit2/src/index.c +161 -47
  44. data/vendor/libgit2/src/index.h +2 -0
  45. data/vendor/libgit2/src/merge.c +2 -0
  46. data/vendor/libgit2/src/mwindow.c +8 -19
  47. data/vendor/libgit2/src/mwindow.h +1 -2
  48. data/vendor/libgit2/src/odb.c +46 -10
  49. data/vendor/libgit2/src/odb_loose.c +19 -1
  50. data/vendor/libgit2/src/odb_pack.c +27 -4
  51. data/vendor/libgit2/src/pack-objects.c +106 -77
  52. data/vendor/libgit2/src/pack-objects.h +13 -12
  53. data/vendor/libgit2/src/pack.c +4 -3
  54. data/vendor/libgit2/src/pack.h +2 -0
  55. data/vendor/libgit2/src/patch.c +207 -0
  56. data/vendor/libgit2/src/patch.h +66 -0
  57. data/vendor/libgit2/src/{diff_patch.c → patch_generate.c} +171 -359
  58. data/vendor/libgit2/src/patch_generate.h +66 -0
  59. data/vendor/libgit2/src/patch_parse.c +1121 -0
  60. data/vendor/libgit2/src/patch_parse.h +54 -0
  61. data/vendor/libgit2/src/path.c +19 -0
  62. data/vendor/libgit2/src/path.h +6 -0
  63. data/vendor/libgit2/src/pool.h +5 -0
  64. data/vendor/libgit2/src/remote.c +15 -80
  65. data/vendor/libgit2/src/repository.c +227 -39
  66. data/vendor/libgit2/src/settings.c +11 -5
  67. data/vendor/libgit2/src/stash.c +1 -0
  68. data/vendor/libgit2/src/status.c +1 -0
  69. data/vendor/libgit2/src/stransport_stream.c +14 -9
  70. data/vendor/libgit2/src/submodule.c +16 -4
  71. data/vendor/libgit2/src/sysdir.c +41 -47
  72. data/vendor/libgit2/src/sysdir.h +0 -5
  73. data/vendor/libgit2/src/thread-utils.h +5 -51
  74. data/vendor/libgit2/src/transport.c +3 -5
  75. data/vendor/libgit2/src/transports/http.c +2 -3
  76. data/vendor/libgit2/src/transports/smart_pkt.c +1 -0
  77. data/vendor/libgit2/src/transports/smart_protocol.c +11 -0
  78. data/vendor/libgit2/src/transports/winhttp.c +16 -2
  79. data/vendor/libgit2/src/unix/pthread.h +54 -0
  80. data/vendor/libgit2/src/util.c +23 -5
  81. data/vendor/libgit2/src/util.h +10 -0
  82. data/vendor/libgit2/src/varint.c +44 -0
  83. data/vendor/libgit2/src/varint.h +15 -0
  84. data/vendor/libgit2/src/vector.c +42 -0
  85. data/vendor/libgit2/src/vector.h +3 -0
  86. data/vendor/libgit2/src/win32/precompiled.h +1 -1
  87. data/vendor/libgit2/src/win32/{pthread.c → thread.c} +50 -80
  88. data/vendor/libgit2/src/win32/thread.h +62 -0
  89. data/vendor/libgit2/src/zstream.c +36 -7
  90. data/vendor/libgit2/src/zstream.h +8 -1
  91. metadata +20 -9
  92. data/vendor/libgit2/src/delta-apply.c +0 -166
  93. data/vendor/libgit2/src/delta-apply.h +0 -62
  94. data/vendor/libgit2/src/diff_patch.h +0 -83
  95. data/vendor/libgit2/src/win32/pthread.h +0 -92
@@ -0,0 +1,62 @@
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_win32_thread_h__
9
+ #define INCLUDE_win32_thread_h__
10
+
11
+ #include "../common.h"
12
+
13
+ #if defined (_MSC_VER)
14
+ # define GIT_RESTRICT __restrict
15
+ #else
16
+ # define GIT_RESTRICT __restrict__
17
+ #endif
18
+
19
+ typedef struct {
20
+ HANDLE thread;
21
+ void *(*proc)(void *);
22
+ void *param;
23
+ void *result;
24
+ } git_thread;
25
+
26
+ typedef CRITICAL_SECTION git_mutex;
27
+ typedef HANDLE git_cond;
28
+
29
+ typedef struct { void *Ptr; } GIT_SRWLOCK;
30
+
31
+ typedef struct {
32
+ union {
33
+ GIT_SRWLOCK srwl;
34
+ CRITICAL_SECTION csec;
35
+ } native;
36
+ } git_rwlock;
37
+
38
+ int git_threads_init(void);
39
+
40
+ int git_thread_create(git_thread *GIT_RESTRICT,
41
+ void *(*) (void *),
42
+ void *GIT_RESTRICT);
43
+ int git_thread_join(git_thread *, void **);
44
+
45
+ int git_mutex_init(git_mutex *GIT_RESTRICT mutex);
46
+ int git_mutex_free(git_mutex *);
47
+ int git_mutex_lock(git_mutex *);
48
+ int git_mutex_unlock(git_mutex *);
49
+
50
+ int git_cond_init(git_cond *);
51
+ int git_cond_free(git_cond *);
52
+ int git_cond_wait(git_cond *, git_mutex *);
53
+ int git_cond_signal(git_cond *);
54
+
55
+ int git_rwlock_init(git_rwlock *GIT_RESTRICT lock);
56
+ int git_rwlock_rdlock(git_rwlock *);
57
+ int git_rwlock_rdunlock(git_rwlock *);
58
+ int git_rwlock_wrlock(git_rwlock *);
59
+ int git_rwlock_wrunlock(git_rwlock *);
60
+ int git_rwlock_free(git_rwlock *);
61
+
62
+ #endif /* INCLUDE_win32_thread_h__ */
@@ -28,20 +28,31 @@ static int zstream_seterr(git_zstream *zs)
28
28
  return -1;
29
29
  }
30
30
 
31
- int git_zstream_init(git_zstream *zstream)
31
+ int git_zstream_init(git_zstream *zstream, git_zstream_t type)
32
32
  {
33
- zstream->zerr = deflateInit(&zstream->z, Z_DEFAULT_COMPRESSION);
33
+ zstream->type = type;
34
+
35
+ if (zstream->type == GIT_ZSTREAM_INFLATE)
36
+ zstream->zerr = inflateInit(&zstream->z);
37
+ else
38
+ zstream->zerr = deflateInit(&zstream->z, Z_DEFAULT_COMPRESSION);
34
39
  return zstream_seterr(zstream);
35
40
  }
36
41
 
37
42
  void git_zstream_free(git_zstream *zstream)
38
43
  {
39
- deflateEnd(&zstream->z);
44
+ if (zstream->type == GIT_ZSTREAM_INFLATE)
45
+ inflateEnd(&zstream->z);
46
+ else
47
+ deflateEnd(&zstream->z);
40
48
  }
41
49
 
42
50
  void git_zstream_reset(git_zstream *zstream)
43
51
  {
44
- deflateReset(&zstream->z);
52
+ if (zstream->type == GIT_ZSTREAM_INFLATE)
53
+ inflateReset(&zstream->z);
54
+ else
55
+ deflateReset(&zstream->z);
45
56
  zstream->in = NULL;
46
57
  zstream->in_len = 0;
47
58
  zstream->zerr = Z_STREAM_END;
@@ -75,6 +86,11 @@ int git_zstream_get_output(void *out, size_t *out_len, git_zstream *zstream)
75
86
  int zflush = Z_FINISH;
76
87
  size_t out_remain = *out_len;
77
88
 
89
+ if (zstream->in_len && zstream->zerr == Z_STREAM_END) {
90
+ giterr_set(GITERR_ZLIB, "zlib input had trailing garbage");
91
+ return -1;
92
+ }
93
+
78
94
  while (out_remain > 0 && zstream->zerr != Z_STREAM_END) {
79
95
  size_t out_queued, in_queued, out_used, in_used;
80
96
 
@@ -97,7 +113,10 @@ int git_zstream_get_output(void *out, size_t *out_len, git_zstream *zstream)
97
113
  out_queued = (size_t)zstream->z.avail_out;
98
114
 
99
115
  /* compress next chunk */
100
- zstream->zerr = deflate(&zstream->z, zflush);
116
+ if (zstream->type == GIT_ZSTREAM_INFLATE)
117
+ zstream->zerr = inflate(&zstream->z, zflush);
118
+ else
119
+ zstream->zerr = deflate(&zstream->z, zflush);
101
120
 
102
121
  if (zstream->zerr == Z_STREAM_ERROR)
103
122
  return zstream_seterr(zstream);
@@ -120,12 +139,12 @@ int git_zstream_get_output(void *out, size_t *out_len, git_zstream *zstream)
120
139
  return 0;
121
140
  }
122
141
 
123
- int git_zstream_deflatebuf(git_buf *out, const void *in, size_t in_len)
142
+ static int zstream_buf(git_buf *out, const void *in, size_t in_len, git_zstream_t type)
124
143
  {
125
144
  git_zstream zs = GIT_ZSTREAM_INIT;
126
145
  int error = 0;
127
146
 
128
- if ((error = git_zstream_init(&zs)) < 0)
147
+ if ((error = git_zstream_init(&zs, type)) < 0)
129
148
  return error;
130
149
 
131
150
  if ((error = git_zstream_set_input(&zs, in, in_len)) < 0)
@@ -154,3 +173,13 @@ done:
154
173
  git_zstream_free(&zs);
155
174
  return error;
156
175
  }
176
+
177
+ int git_zstream_deflatebuf(git_buf *out, const void *in, size_t in_len)
178
+ {
179
+ return zstream_buf(out, in, in_len, GIT_ZSTREAM_DEFLATE);
180
+ }
181
+
182
+ int git_zstream_inflatebuf(git_buf *out, const void *in, size_t in_len)
183
+ {
184
+ return zstream_buf(out, in, in_len, GIT_ZSTREAM_INFLATE);
185
+ }
@@ -12,8 +12,14 @@
12
12
  #include "common.h"
13
13
  #include "buffer.h"
14
14
 
15
+ typedef enum {
16
+ GIT_ZSTREAM_INFLATE,
17
+ GIT_ZSTREAM_DEFLATE,
18
+ } git_zstream_t;
19
+
15
20
  typedef struct {
16
21
  z_stream z;
22
+ git_zstream_t type;
17
23
  const char *in;
18
24
  size_t in_len;
19
25
  int zerr;
@@ -21,7 +27,7 @@ typedef struct {
21
27
 
22
28
  #define GIT_ZSTREAM_INIT {{0}}
23
29
 
24
- int git_zstream_init(git_zstream *zstream);
30
+ int git_zstream_init(git_zstream *zstream, git_zstream_t type);
25
31
  void git_zstream_free(git_zstream *zstream);
26
32
 
27
33
  int git_zstream_set_input(git_zstream *zstream, const void *in, size_t in_len);
@@ -35,5 +41,6 @@ bool git_zstream_done(git_zstream *zstream);
35
41
  void git_zstream_reset(git_zstream *zstream);
36
42
 
37
43
  int git_zstream_deflatebuf(git_buf *out, const void *in, size_t in_len);
44
+ int git_zstream_inflatebuf(git_buf *out, const void *in, size_t in_len);
38
45
 
39
46
  #endif /* INCLUDE_zstream_h__ */
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rugged
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.25.0b5
4
+ version: 0.25.0b6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Chacon
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-08-11 00:00:00.000000000 Z
12
+ date: 2016-08-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake-compiler
@@ -242,6 +242,8 @@ files:
242
242
  - vendor/libgit2/libgit2.pc.in
243
243
  - vendor/libgit2/src/annotated_commit.c
244
244
  - vendor/libgit2/src/annotated_commit.h
245
+ - vendor/libgit2/src/apply.c
246
+ - vendor/libgit2/src/apply.h
245
247
  - vendor/libgit2/src/array.h
246
248
  - vendor/libgit2/src/attr.c
247
249
  - vendor/libgit2/src/attr.h
@@ -284,8 +286,6 @@ files:
284
286
  - vendor/libgit2/src/curl_stream.c
285
287
  - vendor/libgit2/src/curl_stream.h
286
288
  - vendor/libgit2/src/date.c
287
- - vendor/libgit2/src/delta-apply.c
288
- - vendor/libgit2/src/delta-apply.h
289
289
  - vendor/libgit2/src/delta.c
290
290
  - vendor/libgit2/src/delta.h
291
291
  - vendor/libgit2/src/describe.c
@@ -295,11 +295,13 @@ files:
295
295
  - vendor/libgit2/src/diff_driver.h
296
296
  - vendor/libgit2/src/diff_file.c
297
297
  - vendor/libgit2/src/diff_file.h
298
- - vendor/libgit2/src/diff_patch.c
299
- - vendor/libgit2/src/diff_patch.h
298
+ - vendor/libgit2/src/diff_generate.c
299
+ - vendor/libgit2/src/diff_generate.h
300
+ - vendor/libgit2/src/diff_parse.c
300
301
  - vendor/libgit2/src/diff_print.c
301
302
  - vendor/libgit2/src/diff_stats.c
302
303
  - vendor/libgit2/src/diff_tform.c
304
+ - vendor/libgit2/src/diff_tform.h
303
305
  - vendor/libgit2/src/diff_xdiff.c
304
306
  - vendor/libgit2/src/diff_xdiff.h
305
307
  - vendor/libgit2/src/errors.c
@@ -372,6 +374,12 @@ files:
372
374
  - vendor/libgit2/src/pack-objects.h
373
375
  - vendor/libgit2/src/pack.c
374
376
  - vendor/libgit2/src/pack.h
377
+ - vendor/libgit2/src/patch.c
378
+ - vendor/libgit2/src/patch.h
379
+ - vendor/libgit2/src/patch_generate.c
380
+ - vendor/libgit2/src/patch_generate.h
381
+ - vendor/libgit2/src/patch_parse.c
382
+ - vendor/libgit2/src/patch_parse.h
375
383
  - vendor/libgit2/src/path.c
376
384
  - vendor/libgit2/src/path.h
377
385
  - vendor/libgit2/src/pathspec.c
@@ -464,10 +472,13 @@ files:
464
472
  - vendor/libgit2/src/tsort.c
465
473
  - vendor/libgit2/src/unix/map.c
466
474
  - vendor/libgit2/src/unix/posix.h
475
+ - vendor/libgit2/src/unix/pthread.h
467
476
  - vendor/libgit2/src/unix/realpath.c
468
477
  - vendor/libgit2/src/userdiff.h
469
478
  - vendor/libgit2/src/util.c
470
479
  - vendor/libgit2/src/util.h
480
+ - vendor/libgit2/src/varint.c
481
+ - vendor/libgit2/src/varint.h
471
482
  - vendor/libgit2/src/vector.c
472
483
  - vendor/libgit2/src/vector.h
473
484
  - vendor/libgit2/src/win32/dir.c
@@ -486,9 +497,9 @@ files:
486
497
  - vendor/libgit2/src/win32/posix_w32.c
487
498
  - vendor/libgit2/src/win32/precompiled.c
488
499
  - vendor/libgit2/src/win32/precompiled.h
489
- - vendor/libgit2/src/win32/pthread.c
490
- - vendor/libgit2/src/win32/pthread.h
491
500
  - vendor/libgit2/src/win32/reparse.h
501
+ - vendor/libgit2/src/win32/thread.c
502
+ - vendor/libgit2/src/win32/thread.h
492
503
  - vendor/libgit2/src/win32/utf-conv.c
493
504
  - vendor/libgit2/src/win32/utf-conv.h
494
505
  - vendor/libgit2/src/win32/version.h
@@ -538,7 +549,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
538
549
  version: 1.3.1
539
550
  requirements: []
540
551
  rubyforge_project:
541
- rubygems_version: 2.6.3
552
+ rubygems_version: 2.4.5
542
553
  signing_key:
543
554
  specification_version: 4
544
555
  summary: Rugged is a Ruby binding to the libgit2 linkable library
@@ -1,166 +0,0 @@
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
- #include "common.h"
8
- #include "git2/odb.h"
9
- #include "delta-apply.h"
10
-
11
- /*
12
- * This file was heavily cribbed from BinaryDelta.java in JGit, which
13
- * itself was heavily cribbed from <code>patch-delta.c</code> in the
14
- * GIT project. The original delta patching code was written by
15
- * Nicolas Pitre <nico@cam.org>.
16
- */
17
-
18
- static int hdr_sz(
19
- size_t *size,
20
- const unsigned char **delta,
21
- const unsigned char *end)
22
- {
23
- const unsigned char *d = *delta;
24
- size_t r = 0;
25
- unsigned int c, shift = 0;
26
-
27
- do {
28
- if (d == end)
29
- return -1;
30
- c = *d++;
31
- r |= (c & 0x7f) << shift;
32
- shift += 7;
33
- } while (c & 0x80);
34
- *delta = d;
35
- *size = r;
36
- return 0;
37
- }
38
-
39
- int git__delta_read_header(
40
- const unsigned char *delta,
41
- size_t delta_len,
42
- size_t *base_sz,
43
- size_t *res_sz)
44
- {
45
- const unsigned char *delta_end = delta + delta_len;
46
- if ((hdr_sz(base_sz, &delta, delta_end) < 0) ||
47
- (hdr_sz(res_sz, &delta, delta_end) < 0))
48
- return -1;
49
- return 0;
50
- }
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
- int git__delta_apply(
84
- git_rawobj *out,
85
- const unsigned char *base,
86
- size_t base_len,
87
- const unsigned char *delta,
88
- size_t delta_len)
89
- {
90
- const unsigned char *delta_end = delta + delta_len;
91
- size_t base_sz, res_sz, alloc_sz;
92
- unsigned char *res_dp;
93
-
94
- /* Check that the base size matches the data we were given;
95
- * if not we would underflow while accessing data from the
96
- * base object, resulting in data corruption or segfault.
97
- */
98
- if ((hdr_sz(&base_sz, &delta, delta_end) < 0) || (base_sz != base_len)) {
99
- giterr_set(GITERR_INVALID, "Failed to apply delta. Base size does not match given data");
100
- return -1;
101
- }
102
-
103
- if (hdr_sz(&res_sz, &delta, delta_end) < 0) {
104
- giterr_set(GITERR_INVALID, "Failed to apply delta. Base size does not match given data");
105
- return -1;
106
- }
107
-
108
- GITERR_CHECK_ALLOC_ADD(&alloc_sz, res_sz, 1);
109
- res_dp = git__malloc(alloc_sz);
110
- GITERR_CHECK_ALLOC(res_dp);
111
-
112
- res_dp[res_sz] = '\0';
113
- out->data = res_dp;
114
- out->len = res_sz;
115
-
116
- while (delta < delta_end) {
117
- unsigned char cmd = *delta++;
118
- if (cmd & 0x80) {
119
- /* cmd is a copy instruction; copy from the base.
120
- */
121
- size_t off = 0, len = 0;
122
-
123
- if (cmd & 0x01) off = *delta++;
124
- if (cmd & 0x02) off |= *delta++ << 8UL;
125
- if (cmd & 0x04) off |= *delta++ << 16UL;
126
- if (cmd & 0x08) off |= *delta++ << 24UL;
127
-
128
- if (cmd & 0x10) len = *delta++;
129
- if (cmd & 0x20) len |= *delta++ << 8UL;
130
- if (cmd & 0x40) len |= *delta++ << 16UL;
131
- if (!len) len = 0x10000;
132
-
133
- if (base_len < off + len || res_sz < len)
134
- goto fail;
135
- memcpy(res_dp, base + off, len);
136
- res_dp += len;
137
- res_sz -= len;
138
-
139
- } else if (cmd) {
140
- /* cmd is a literal insert instruction; copy from
141
- * the delta stream itself.
142
- */
143
- if (delta_end - delta < cmd || res_sz < cmd)
144
- goto fail;
145
- memcpy(res_dp, delta, cmd);
146
- delta += cmd;
147
- res_dp += cmd;
148
- res_sz -= cmd;
149
-
150
- } else {
151
- /* cmd == 0 is reserved for future encodings.
152
- */
153
- goto fail;
154
- }
155
- }
156
-
157
- if (delta != delta_end || res_sz)
158
- goto fail;
159
- return 0;
160
-
161
- fail:
162
- git__free(out->data);
163
- out->data = NULL;
164
- giterr_set(GITERR_INVALID, "Failed to apply delta");
165
- return -1;
166
- }
@@ -1,62 +0,0 @@
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
- #ifndef INCLUDE_delta_apply_h__
8
- #define INCLUDE_delta_apply_h__
9
-
10
- #include "odb.h"
11
- #include "pack.h"
12
-
13
- /**
14
- * Apply a git binary delta to recover the original content.
15
- *
16
- * @param out the output buffer to receive the original data.
17
- * Only out->data and out->len are populated, as this is
18
- * the only information available in the delta.
19
- * @param base the base to copy from during copy instructions.
20
- * @param base_len number of bytes available at base.
21
- * @param delta the delta to execute copy/insert instructions from.
22
- * @param delta_len total number of bytes in the delta.
23
- * @return
24
- * - 0 on a successful delta unpack.
25
- * - GIT_ERROR if the delta is corrupt or doesn't match the base.
26
- */
27
- extern int git__delta_apply(
28
- git_rawobj *out,
29
- const unsigned char *base,
30
- size_t base_len,
31
- const unsigned char *delta,
32
- size_t delta_len);
33
-
34
- /**
35
- * Read the header of a git binary delta.
36
- *
37
- * @param delta the delta to execute copy/insert instructions from.
38
- * @param delta_len total number of bytes in the delta.
39
- * @param base_sz pointer to store the base size field.
40
- * @param res_sz pointer to store the result size field.
41
- * @return
42
- * - 0 on a successful decoding the header.
43
- * - GIT_ERROR if the delta is corrupt.
44
- */
45
- extern int git__delta_read_header(
46
- const unsigned char *delta,
47
- size_t delta_len,
48
- size_t *base_sz,
49
- size_t *res_sz);
50
-
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
- #endif