rugged 0.23.2 → 0.23.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +12 -3
- data/vendor/libgit2/COPYING +46 -0
- data/vendor/libgit2/include/git2/config.h +4 -2
- data/vendor/libgit2/include/git2/cred_helpers.h +1 -1
- data/vendor/libgit2/include/git2/diff.h +0 -19
- data/vendor/libgit2/include/git2/errors.h +12 -0
- data/vendor/libgit2/include/git2/sys/filter.h +1 -4
- data/vendor/libgit2/include/git2/sys/refdb_backend.h +2 -3
- data/vendor/libgit2/include/git2/transport.h +21 -14
- data/vendor/libgit2/include/git2/version.h +2 -2
- data/vendor/libgit2/src/blame.c +1 -1
- data/vendor/libgit2/src/blame_git.c +27 -7
- data/vendor/libgit2/src/blame_git.h +1 -1
- data/vendor/libgit2/src/branch.c +12 -1
- data/vendor/libgit2/src/checkout.c +2 -1
- data/vendor/libgit2/src/clone.c +2 -2
- data/vendor/libgit2/src/common.h +13 -13
- data/vendor/libgit2/src/curl_stream.c +8 -7
- data/vendor/libgit2/src/diff.c +0 -25
- data/vendor/libgit2/src/diff_driver.c +6 -7
- data/vendor/libgit2/src/diff_patch.c +4 -0
- data/vendor/libgit2/src/diff_xdiff.c +7 -0
- data/vendor/libgit2/src/diff_xdiff.h +5 -0
- data/vendor/libgit2/src/errors.c +40 -75
- data/vendor/libgit2/src/filter.c +2 -5
- data/vendor/libgit2/src/global.c +9 -25
- data/vendor/libgit2/src/global.h +0 -1
- data/vendor/libgit2/src/index.c +3 -3
- data/vendor/libgit2/src/iterator.c +2 -2
- data/vendor/libgit2/src/merge.c +0 -56
- data/vendor/libgit2/src/merge_file.c +76 -22
- data/vendor/libgit2/src/openssl_stream.c +2 -3
- data/vendor/libgit2/src/path.c +0 -16
- data/vendor/libgit2/src/path.h +0 -5
- data/vendor/libgit2/src/refdb_fs.c +0 -7
- data/vendor/libgit2/src/remote.c +9 -18
- data/vendor/libgit2/src/stransport_stream.c +1 -1
- data/vendor/libgit2/src/submodule.c +7 -3
- data/vendor/libgit2/src/sysdir.c +8 -22
- data/vendor/libgit2/src/transports/http.c +9 -1
- data/vendor/libgit2/src/transports/smart_protocol.c +1 -1
- data/vendor/libgit2/src/transports/ssh.c +2 -2
- data/vendor/libgit2/src/transports/winhttp.c +1 -1
- data/vendor/libgit2/src/util.c +0 -48
- data/vendor/libgit2/src/util.h +5 -13
- data/vendor/libgit2/src/win32/posix_w32.c +0 -2
- data/vendor/libgit2/src/xdiff/xdiff.h +5 -3
- data/vendor/libgit2/src/xdiff/xdiffi.c +8 -4
- data/vendor/libgit2/src/xdiff/xhistogram.c +4 -2
- data/vendor/libgit2/src/xdiff/xmerge.c +98 -44
- metadata +76 -81
- data/vendor/libgit2/src/merge_file.h +0 -14
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +0 -343
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +0 -93
- data/vendor/libgit2/src/win32/w32_stack.c +0 -192
- data/vendor/libgit2/src/win32/w32_stack.h +0 -138
data/vendor/libgit2/src/sysdir.c
CHANGED
@@ -29,14 +29,7 @@ static int git_sysdir_guess_global_dirs(git_buf *out)
|
|
29
29
|
#ifdef GIT_WIN32
|
30
30
|
return git_win32__find_global_dirs(out);
|
31
31
|
#else
|
32
|
-
|
33
|
-
|
34
|
-
if (error == GIT_ENOTFOUND) {
|
35
|
-
giterr_clear();
|
36
|
-
error = 0;
|
37
|
-
}
|
38
|
-
|
39
|
-
return error;
|
32
|
+
return git_buf_sets(out, getenv("HOME"));
|
40
33
|
#endif
|
41
34
|
}
|
42
35
|
|
@@ -45,22 +38,15 @@ static int git_sysdir_guess_xdg_dirs(git_buf *out)
|
|
45
38
|
#ifdef GIT_WIN32
|
46
39
|
return git_win32__find_xdg_dirs(out);
|
47
40
|
#else
|
48
|
-
|
49
|
-
int error;
|
50
|
-
|
51
|
-
if ((error = git__getenv(&env, "XDG_CONFIG_HOME")) == 0)
|
52
|
-
error = git_buf_joinpath(out, env.ptr, "git");
|
41
|
+
const char *env = NULL;
|
53
42
|
|
54
|
-
if (
|
55
|
-
|
43
|
+
if ((env = getenv("XDG_CONFIG_HOME")) != NULL)
|
44
|
+
return git_buf_joinpath(out, env, "git");
|
45
|
+
else if ((env = getenv("HOME")) != NULL)
|
46
|
+
return git_buf_joinpath(out, env, ".config/git");
|
56
47
|
|
57
|
-
|
58
|
-
|
59
|
-
error = 0;
|
60
|
-
}
|
61
|
-
|
62
|
-
git_buf_free(&env);
|
63
|
-
return error;
|
48
|
+
git_buf_clear(out);
|
49
|
+
return 0;
|
64
50
|
#endif
|
65
51
|
}
|
66
52
|
|
@@ -36,6 +36,8 @@ static const char *post_verb = "POST";
|
|
36
36
|
|
37
37
|
#define PARSE_ERROR_GENERIC -1
|
38
38
|
#define PARSE_ERROR_REPLAY -2
|
39
|
+
/** Look at the user field */
|
40
|
+
#define PARSE_ERROR_EXT -3
|
39
41
|
|
40
42
|
#define CHUNK_SIZE 4096
|
41
43
|
|
@@ -78,6 +80,7 @@ typedef struct {
|
|
78
80
|
git_vector www_authenticate;
|
79
81
|
enum last_cb last_cb;
|
80
82
|
int parse_error;
|
83
|
+
int error;
|
81
84
|
unsigned parse_finished : 1;
|
82
85
|
|
83
86
|
/* Authentication */
|
@@ -351,7 +354,8 @@ static int on_headers_complete(http_parser *parser)
|
|
351
354
|
if (error == GIT_PASSTHROUGH) {
|
352
355
|
no_callback = 1;
|
353
356
|
} else if (error < 0) {
|
354
|
-
|
357
|
+
t->error = error;
|
358
|
+
return t->parse_error = PARSE_ERROR_EXT;
|
355
359
|
} else {
|
356
360
|
assert(t->cred);
|
357
361
|
|
@@ -712,6 +716,10 @@ replay:
|
|
712
716
|
goto replay;
|
713
717
|
}
|
714
718
|
|
719
|
+
if (t->parse_error == PARSE_ERROR_EXT) {
|
720
|
+
return t->error;
|
721
|
+
}
|
722
|
+
|
715
723
|
if (t->parse_error < 0)
|
716
724
|
return -1;
|
717
725
|
|
@@ -957,7 +957,7 @@ int git_smart__push(git_transport *transport, git_push *push, const git_remote_c
|
|
957
957
|
|
958
958
|
packbuilder_payload.pb = push->pb;
|
959
959
|
|
960
|
-
if (cbs && cbs->
|
960
|
+
if (cbs && cbs->push_transfer_progress) {
|
961
961
|
packbuilder_payload.cb = cbs->push_transfer_progress;
|
962
962
|
packbuilder_payload.cb_payload = cbs->payload;
|
963
963
|
}
|
@@ -527,10 +527,10 @@ static int _git_ssh_setup_conn(
|
|
527
527
|
goto done;
|
528
528
|
|
529
529
|
if (t->owner->certificate_check_cb != NULL) {
|
530
|
-
git_cert_hostkey cert = {
|
530
|
+
git_cert_hostkey cert = { 0 }, *cert_ptr;
|
531
531
|
const char *key;
|
532
532
|
|
533
|
-
cert.
|
533
|
+
cert.cert_type = GIT_CERT_HOSTKEY_LIBSSH2;
|
534
534
|
|
535
535
|
key = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_SHA1);
|
536
536
|
if (key != NULL) {
|
@@ -228,7 +228,7 @@ static int certificate_check(winhttp_stream *s, int valid)
|
|
228
228
|
}
|
229
229
|
|
230
230
|
giterr_clear();
|
231
|
-
cert.
|
231
|
+
cert.cert_type = GIT_CERT_X509;
|
232
232
|
cert.data = cert_ctx->pbCertEncoded;
|
233
233
|
cert.len = cert_ctx->cbCertEncoded;
|
234
234
|
error = t->owner->certificate_check_cb((git_cert *) &cert, valid, t->connection_data.host, t->owner->cred_acquire_payload);
|
data/vendor/libgit2/src/util.c
CHANGED
@@ -10,10 +10,6 @@
|
|
10
10
|
#include <ctype.h>
|
11
11
|
#include "posix.h"
|
12
12
|
|
13
|
-
#ifdef GIT_WIN32
|
14
|
-
# include "win32/w32_buffer.h"
|
15
|
-
#endif
|
16
|
-
|
17
13
|
#ifdef _MSC_VER
|
18
14
|
# include <Shlwapi.h>
|
19
15
|
#endif
|
@@ -769,47 +765,3 @@ int git__utf8_iterate(const uint8_t *str, int str_len, int32_t *dst)
|
|
769
765
|
*dst = uc;
|
770
766
|
return length;
|
771
767
|
}
|
772
|
-
|
773
|
-
#ifdef GIT_WIN32
|
774
|
-
int git__getenv(git_buf *out, const char *name)
|
775
|
-
{
|
776
|
-
wchar_t *wide_name = NULL, *wide_value = NULL;
|
777
|
-
DWORD value_len;
|
778
|
-
int error = -1;
|
779
|
-
|
780
|
-
git_buf_clear(out);
|
781
|
-
|
782
|
-
if (git__utf8_to_16_alloc(&wide_name, name) < 0)
|
783
|
-
return -1;
|
784
|
-
|
785
|
-
if ((value_len = GetEnvironmentVariableW(wide_name, NULL, 0)) > 0) {
|
786
|
-
wide_value = git__malloc(value_len * sizeof(wchar_t));
|
787
|
-
GITERR_CHECK_ALLOC(wide_value);
|
788
|
-
|
789
|
-
value_len = GetEnvironmentVariableW(wide_name, wide_value, value_len);
|
790
|
-
}
|
791
|
-
|
792
|
-
if (value_len)
|
793
|
-
error = git_buf_put_w(out, wide_value, value_len);
|
794
|
-
else if (GetLastError() == ERROR_ENVVAR_NOT_FOUND)
|
795
|
-
error = GIT_ENOTFOUND;
|
796
|
-
else
|
797
|
-
giterr_set(GITERR_OS, "could not read environment variable '%s'", name);
|
798
|
-
|
799
|
-
git__free(wide_name);
|
800
|
-
git__free(wide_value);
|
801
|
-
return error;
|
802
|
-
}
|
803
|
-
#else
|
804
|
-
int git__getenv(git_buf *out, const char *name)
|
805
|
-
{
|
806
|
-
const char *val = getenv(name);
|
807
|
-
|
808
|
-
git_buf_clear(out);
|
809
|
-
|
810
|
-
if (!val)
|
811
|
-
return GIT_ENOTFOUND;
|
812
|
-
|
813
|
-
return git_buf_puts(out, val);
|
814
|
-
}
|
815
|
-
#endif
|
data/vendor/libgit2/src/util.h
CHANGED
@@ -7,9 +7,6 @@
|
|
7
7
|
#ifndef INCLUDE_util_h__
|
8
8
|
#define INCLUDE_util_h__
|
9
9
|
|
10
|
-
#include "git2/buffer.h"
|
11
|
-
#include "buffer.h"
|
12
|
-
|
13
10
|
#if defined(GIT_MSVC_CRTDBG)
|
14
11
|
/* Enable MSVC CRTDBG memory leak reporting.
|
15
12
|
*
|
@@ -38,7 +35,6 @@
|
|
38
35
|
*/
|
39
36
|
#include <stdlib.h>
|
40
37
|
#include <crtdbg.h>
|
41
|
-
#include "win32/w32_crtdbg_stacktrace.h"
|
42
38
|
#endif
|
43
39
|
|
44
40
|
#include "common.h"
|
@@ -66,24 +62,23 @@
|
|
66
62
|
#define CONST_STRLEN(x) ((sizeof(x)/sizeof(x[0])) - 1)
|
67
63
|
|
68
64
|
#if defined(GIT_MSVC_CRTDBG)
|
69
|
-
|
70
65
|
GIT_INLINE(void *) git__crtdbg__malloc(size_t len, const char *file, int line)
|
71
66
|
{
|
72
|
-
void *ptr = _malloc_dbg(len, _NORMAL_BLOCK,
|
67
|
+
void *ptr = _malloc_dbg(len, _NORMAL_BLOCK, file, line);
|
73
68
|
if (!ptr) giterr_set_oom();
|
74
69
|
return ptr;
|
75
70
|
}
|
76
71
|
|
77
72
|
GIT_INLINE(void *) git__crtdbg__calloc(size_t nelem, size_t elsize, const char *file, int line)
|
78
73
|
{
|
79
|
-
void *ptr = _calloc_dbg(nelem, elsize, _NORMAL_BLOCK,
|
74
|
+
void *ptr = _calloc_dbg(nelem, elsize, _NORMAL_BLOCK, file, line);
|
80
75
|
if (!ptr) giterr_set_oom();
|
81
76
|
return ptr;
|
82
77
|
}
|
83
78
|
|
84
79
|
GIT_INLINE(char *) git__crtdbg__strdup(const char *str, const char *file, int line)
|
85
80
|
{
|
86
|
-
char *ptr = _strdup_dbg(str, _NORMAL_BLOCK,
|
81
|
+
char *ptr = _strdup_dbg(str, _NORMAL_BLOCK, file, line);
|
87
82
|
if (!ptr) giterr_set_oom();
|
88
83
|
return ptr;
|
89
84
|
}
|
@@ -123,7 +118,7 @@ GIT_INLINE(char *) git__crtdbg__substrdup(const char *start, size_t n, const cha
|
|
123
118
|
|
124
119
|
GIT_INLINE(void *) git__crtdbg__realloc(void *ptr, size_t size, const char *file, int line)
|
125
120
|
{
|
126
|
-
void *new_ptr = _realloc_dbg(ptr, size, _NORMAL_BLOCK,
|
121
|
+
void *new_ptr = _realloc_dbg(ptr, size, _NORMAL_BLOCK, file, line);
|
127
122
|
if (!new_ptr) giterr_set_oom();
|
128
123
|
return new_ptr;
|
129
124
|
}
|
@@ -131,9 +126,8 @@ GIT_INLINE(void *) git__crtdbg__realloc(void *ptr, size_t size, const char *file
|
|
131
126
|
GIT_INLINE(void *) git__crtdbg__reallocarray(void *ptr, size_t nelem, size_t elsize, const char *file, int line)
|
132
127
|
{
|
133
128
|
size_t newsize;
|
134
|
-
|
135
129
|
return GIT_MULTIPLY_SIZET_OVERFLOW(&newsize, nelem, elsize) ?
|
136
|
-
NULL : _realloc_dbg(ptr, newsize, _NORMAL_BLOCK,
|
130
|
+
NULL : _realloc_dbg(ptr, newsize, _NORMAL_BLOCK, file, line);
|
137
131
|
}
|
138
132
|
|
139
133
|
GIT_INLINE(void *) git__crtdbg__mallocarray(size_t nelem, size_t elsize, const char *file, int line)
|
@@ -602,6 +596,4 @@ GIT_INLINE(double) git__timer(void)
|
|
602
596
|
|
603
597
|
#endif
|
604
598
|
|
605
|
-
extern int git__getenv(git_buf *out, const char *name);
|
606
|
-
|
607
599
|
#endif /* INCLUDE_util_h__ */
|
@@ -20,6 +20,8 @@
|
|
20
20
|
*
|
21
21
|
*/
|
22
22
|
|
23
|
+
#include "util.h"
|
24
|
+
|
23
25
|
#if !defined(XDIFF_H)
|
24
26
|
#define XDIFF_H
|
25
27
|
|
@@ -106,9 +108,9 @@ typedef struct s_bdiffparam {
|
|
106
108
|
} bdiffparam_t;
|
107
109
|
|
108
110
|
|
109
|
-
#define xdl_malloc(x)
|
110
|
-
#define xdl_free(ptr)
|
111
|
-
#define xdl_realloc(ptr,x)
|
111
|
+
#define xdl_malloc(x) git__malloc(x)
|
112
|
+
#define xdl_free(ptr) git__free(ptr)
|
113
|
+
#define xdl_realloc(ptr,x) git__realloc(ptr,x)
|
112
114
|
|
113
115
|
void *xdl_mmfile_first(mmfile_t *mmf, long *size);
|
114
116
|
long xdl_mmfile_size(mmfile_t *mmf);
|
@@ -21,7 +21,8 @@
|
|
21
21
|
*/
|
22
22
|
|
23
23
|
#include "xinclude.h"
|
24
|
-
|
24
|
+
#include "common.h"
|
25
|
+
#include "integer.h"
|
25
26
|
|
26
27
|
|
27
28
|
#define XDL_MAX_COST_MIN 256
|
@@ -323,7 +324,7 @@ int xdl_recs_cmp(diffdata_t *dd1, long off1, long lim1,
|
|
323
324
|
|
324
325
|
int xdl_do_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
|
325
326
|
xdfenv_t *xe) {
|
326
|
-
|
327
|
+
size_t ndiags, allocsize;
|
327
328
|
long *kvd, *kvdf, *kvdb;
|
328
329
|
xdalgoenv_t xenv;
|
329
330
|
diffdata_t dd1, dd2;
|
@@ -343,9 +344,12 @@ int xdl_do_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
|
|
343
344
|
* Allocate and setup K vectors to be used by the differential algorithm.
|
344
345
|
* One is to store the forward path and one to store the backward path.
|
345
346
|
*/
|
346
|
-
ndiags
|
347
|
-
|
347
|
+
GITERR_CHECK_ALLOC_ADD3(&ndiags, xe->xdf1.nreff, xe->xdf2.nreff, 3);
|
348
|
+
GITERR_CHECK_ALLOC_MULTIPLY(&allocsize, ndiags, 2);
|
349
|
+
GITERR_CHECK_ALLOC_ADD(&allocsize, allocsize, 2);
|
350
|
+
GITERR_CHECK_ALLOC_MULTIPLY(&allocsize, allocsize, sizeof(long));
|
348
351
|
|
352
|
+
if (!(kvd = (long *) xdl_malloc(allocsize))) {
|
349
353
|
xdl_free_env(xe);
|
350
354
|
return -1;
|
351
355
|
}
|
@@ -44,6 +44,7 @@
|
|
44
44
|
#include "xinclude.h"
|
45
45
|
#include "xtypes.h"
|
46
46
|
#include "xdiff.h"
|
47
|
+
#include "common.h"
|
47
48
|
|
48
49
|
#define MAX_PTR UINT_MAX
|
49
50
|
#define MAX_CNT UINT_MAX
|
@@ -271,7 +272,7 @@ static int histogram_diff(
|
|
271
272
|
{
|
272
273
|
struct histindex index;
|
273
274
|
struct region lcs;
|
274
|
-
|
275
|
+
size_t sz;
|
275
276
|
int result = -1;
|
276
277
|
|
277
278
|
if (count1 <= 0 && count2 <= 0)
|
@@ -302,7 +303,8 @@ static int histogram_diff(
|
|
302
303
|
|
303
304
|
index.table_bits = xdl_hashbits(count1);
|
304
305
|
sz = index.records_size = 1 << index.table_bits;
|
305
|
-
sz
|
306
|
+
GITERR_CHECK_ALLOC_MULTIPLY(&sz, sz, sizeof(struct record *));
|
307
|
+
|
306
308
|
if (!(index.records = (struct record **) xdl_malloc(sz)))
|
307
309
|
goto cleanup;
|
308
310
|
memset(index.records, 0, sz);
|
@@ -21,6 +21,7 @@
|
|
21
21
|
*/
|
22
22
|
|
23
23
|
#include "xinclude.h"
|
24
|
+
#include "common.h"
|
24
25
|
|
25
26
|
typedef struct s_xdmerge {
|
26
27
|
struct s_xdmerge *next;
|
@@ -109,59 +110,74 @@ static int xdl_merge_cmp_lines(xdfenv_t *xe1, int i1, xdfenv_t *xe2, int i2,
|
|
109
110
|
return 0;
|
110
111
|
}
|
111
112
|
|
112
|
-
static int xdl_recs_copy_0(int use_orig, xdfenv_t *xe, int i, int count, int add_nl, char *dest)
|
113
|
+
static int xdl_recs_copy_0(size_t *out, int use_orig, xdfenv_t *xe, int i, int count, int add_nl, char *dest)
|
113
114
|
{
|
114
115
|
xrecord_t **recs;
|
115
|
-
|
116
|
+
size_t size = 0;
|
117
|
+
|
118
|
+
*out = 0;
|
116
119
|
|
117
120
|
recs = (use_orig ? xe->xdf1.recs : xe->xdf2.recs) + i;
|
118
121
|
|
119
122
|
if (count < 1)
|
120
123
|
return 0;
|
121
124
|
|
122
|
-
for (i = 0; i < count;
|
125
|
+
for (i = 0; i < count; ) {
|
123
126
|
if (dest)
|
124
127
|
memcpy(dest + size, recs[i]->ptr, recs[i]->size);
|
128
|
+
|
129
|
+
GITERR_CHECK_ALLOC_ADD(&size, size, recs[i++]->size);
|
130
|
+
}
|
131
|
+
|
125
132
|
if (add_nl) {
|
126
133
|
i = recs[count - 1]->size;
|
127
134
|
if (i == 0 || recs[count - 1]->ptr[i - 1] != '\n') {
|
128
135
|
if (dest)
|
129
136
|
dest[size] = '\n';
|
130
|
-
|
137
|
+
|
138
|
+
GITERR_CHECK_ALLOC_ADD(&size, size, 1);
|
131
139
|
}
|
132
140
|
}
|
133
|
-
|
141
|
+
|
142
|
+
*out = size;
|
143
|
+
return 0;
|
134
144
|
}
|
135
145
|
|
136
|
-
static int xdl_recs_copy(xdfenv_t *xe, int i, int count, int add_nl, char *dest)
|
146
|
+
static int xdl_recs_copy(size_t *out, xdfenv_t *xe, int i, int count, int add_nl, char *dest)
|
137
147
|
{
|
138
|
-
return xdl_recs_copy_0(0, xe, i, count, add_nl, dest);
|
148
|
+
return xdl_recs_copy_0(out, 0, xe, i, count, add_nl, dest);
|
139
149
|
}
|
140
150
|
|
141
|
-
static int xdl_orig_copy(xdfenv_t *xe, int i, int count, int add_nl, char *dest)
|
151
|
+
static int xdl_orig_copy(size_t *out, xdfenv_t *xe, int i, int count, int add_nl, char *dest)
|
142
152
|
{
|
143
|
-
return xdl_recs_copy_0(1, xe, i, count, add_nl, dest);
|
153
|
+
return xdl_recs_copy_0(out, 1, xe, i, count, add_nl, dest);
|
144
154
|
}
|
145
155
|
|
146
|
-
static int fill_conflict_hunk(xdfenv_t *xe1, const char *name1,
|
156
|
+
static int fill_conflict_hunk(size_t *out, xdfenv_t *xe1, const char *name1,
|
147
157
|
xdfenv_t *xe2, const char *name2,
|
148
158
|
const char *name3,
|
149
|
-
|
159
|
+
size_t size, int i, int style,
|
150
160
|
xdmerge_t *m, char *dest, int marker_size)
|
151
161
|
{
|
152
162
|
int marker1_size = (name1 ? (int)strlen(name1) + 1 : 0);
|
153
163
|
int marker2_size = (name2 ? (int)strlen(name2) + 1 : 0);
|
154
164
|
int marker3_size = (name3 ? (int)strlen(name3) + 1 : 0);
|
165
|
+
size_t copied;
|
166
|
+
|
167
|
+
*out = 0;
|
155
168
|
|
156
169
|
if (marker_size <= 0)
|
157
170
|
marker_size = DEFAULT_CONFLICT_MARKER_SIZE;
|
158
171
|
|
159
172
|
/* Before conflicting part */
|
160
|
-
|
161
|
-
dest ? dest + size : NULL)
|
173
|
+
if (xdl_recs_copy(&copied, xe1, i, m->i1 - i, 0,
|
174
|
+
dest ? dest + size : NULL) < 0)
|
175
|
+
return -1;
|
176
|
+
|
177
|
+
GITERR_CHECK_ALLOC_ADD(&size, size, copied);
|
162
178
|
|
163
179
|
if (!dest) {
|
164
|
-
size
|
180
|
+
GITERR_CHECK_ALLOC_ADD4(&size, size, marker_size, 1, marker1_size);
|
165
181
|
} else {
|
166
182
|
memset(dest + size, '<', marker_size);
|
167
183
|
size += marker_size;
|
@@ -174,13 +190,16 @@ static int fill_conflict_hunk(xdfenv_t *xe1, const char *name1,
|
|
174
190
|
}
|
175
191
|
|
176
192
|
/* Postimage from side #1 */
|
177
|
-
|
178
|
-
dest ? dest + size : NULL)
|
193
|
+
if (xdl_recs_copy(&copied, xe1, m->i1, m->chg1, 1,
|
194
|
+
dest ? dest + size : NULL) < 0)
|
195
|
+
return -1;
|
196
|
+
|
197
|
+
GITERR_CHECK_ALLOC_ADD(&size, size, copied);
|
179
198
|
|
180
199
|
if (style == XDL_MERGE_DIFF3) {
|
181
200
|
/* Shared preimage */
|
182
201
|
if (!dest) {
|
183
|
-
size
|
202
|
+
GITERR_CHECK_ALLOC_ADD4(&size, size, marker_size, 1, marker3_size);
|
184
203
|
} else {
|
185
204
|
memset(dest + size, '|', marker_size);
|
186
205
|
size += marker_size;
|
@@ -191,12 +210,15 @@ static int fill_conflict_hunk(xdfenv_t *xe1, const char *name1,
|
|
191
210
|
}
|
192
211
|
dest[size++] = '\n';
|
193
212
|
}
|
194
|
-
|
195
|
-
|
213
|
+
|
214
|
+
if (xdl_orig_copy(&copied, xe1, m->i0, m->chg0, 1,
|
215
|
+
dest ? dest + size : NULL) < 0)
|
216
|
+
return -1;
|
217
|
+
GITERR_CHECK_ALLOC_ADD(&size, size, copied);
|
196
218
|
}
|
197
219
|
|
198
220
|
if (!dest) {
|
199
|
-
size
|
221
|
+
GITERR_CHECK_ALLOC_ADD3(&size, size, marker_size, 1);
|
200
222
|
} else {
|
201
223
|
memset(dest + size, '=', marker_size);
|
202
224
|
size += marker_size;
|
@@ -204,10 +226,14 @@ static int fill_conflict_hunk(xdfenv_t *xe1, const char *name1,
|
|
204
226
|
}
|
205
227
|
|
206
228
|
/* Postimage from side #2 */
|
207
|
-
|
208
|
-
|
229
|
+
|
230
|
+
if (xdl_recs_copy(&copied, xe2, m->i2, m->chg2, 1,
|
231
|
+
dest ? dest + size : NULL) < 0)
|
232
|
+
return -1;
|
233
|
+
GITERR_CHECK_ALLOC_ADD(&size, size, copied);
|
234
|
+
|
209
235
|
if (!dest) {
|
210
|
-
size
|
236
|
+
GITERR_CHECK_ALLOC_ADD4(&size, size, marker_size, 1, marker2_size);
|
211
237
|
} else {
|
212
238
|
memset(dest + size, '>', marker_size);
|
213
239
|
size += marker_size;
|
@@ -218,46 +244,69 @@ static int fill_conflict_hunk(xdfenv_t *xe1, const char *name1,
|
|
218
244
|
}
|
219
245
|
dest[size++] = '\n';
|
220
246
|
}
|
221
|
-
|
247
|
+
|
248
|
+
*out = size;
|
249
|
+
return 0;
|
222
250
|
}
|
223
251
|
|
224
|
-
static int xdl_fill_merge_buffer(
|
252
|
+
static int xdl_fill_merge_buffer(size_t *out,
|
253
|
+
xdfenv_t *xe1, const char *name1,
|
225
254
|
xdfenv_t *xe2, const char *name2,
|
226
255
|
const char *ancestor_name,
|
227
256
|
int favor,
|
228
257
|
xdmerge_t *m, char *dest, int style,
|
229
258
|
int marker_size)
|
230
259
|
{
|
231
|
-
|
260
|
+
size_t size, copied;
|
261
|
+
int i;
|
262
|
+
|
263
|
+
*out = 0;
|
232
264
|
|
233
265
|
for (size = i = 0; m; m = m->next) {
|
234
266
|
if (favor && !m->mode)
|
235
267
|
m->mode = favor;
|
236
268
|
|
237
|
-
if (m->mode == 0)
|
238
|
-
|
269
|
+
if (m->mode == 0) {
|
270
|
+
if (fill_conflict_hunk(&size, xe1, name1, xe2, name2,
|
239
271
|
ancestor_name,
|
240
272
|
size, i, style, m, dest,
|
241
|
-
marker_size)
|
273
|
+
marker_size) < 0)
|
274
|
+
return -1;
|
275
|
+
}
|
242
276
|
else if (m->mode & 3) {
|
243
277
|
/* Before conflicting part */
|
244
|
-
|
245
|
-
dest ? dest + size : NULL)
|
278
|
+
if (xdl_recs_copy(&copied, xe1, i, m->i1 - i, 0,
|
279
|
+
dest ? dest + size : NULL) < 0)
|
280
|
+
return -1;
|
281
|
+
GITERR_CHECK_ALLOC_ADD(&size, size, copied);
|
282
|
+
|
246
283
|
/* Postimage from side #1 */
|
247
|
-
if (m->mode & 1)
|
248
|
-
|
249
|
-
dest ? dest + size : NULL)
|
284
|
+
if (m->mode & 1) {
|
285
|
+
if (xdl_recs_copy(&copied, xe1, m->i1, m->chg1, (m->mode & 2),
|
286
|
+
dest ? dest + size : NULL) < 0)
|
287
|
+
return -1;
|
288
|
+
GITERR_CHECK_ALLOC_ADD(&size, size, copied);
|
289
|
+
}
|
290
|
+
|
250
291
|
/* Postimage from side #2 */
|
251
|
-
if (m->mode & 2)
|
252
|
-
|
253
|
-
dest ? dest + size : NULL)
|
292
|
+
if (m->mode & 2) {
|
293
|
+
if (xdl_recs_copy(&copied, xe2, m->i2, m->chg2, 0,
|
294
|
+
dest ? dest + size : NULL) < 0)
|
295
|
+
return -1;
|
296
|
+
GITERR_CHECK_ALLOC_ADD(&size, size, copied);
|
297
|
+
}
|
254
298
|
} else
|
255
299
|
continue;
|
256
300
|
i = m->i1 + m->chg1;
|
257
301
|
}
|
258
|
-
|
259
|
-
|
260
|
-
|
302
|
+
|
303
|
+
if (xdl_recs_copy(&copied, xe1, i, xe1->xdf2.nrec - i, 0,
|
304
|
+
dest ? dest + size : NULL) < 0)
|
305
|
+
return -1;
|
306
|
+
GITERR_CHECK_ALLOC_ADD(&size, size, copied);
|
307
|
+
|
308
|
+
*out = size;
|
309
|
+
return 0;
|
261
310
|
}
|
262
311
|
|
263
312
|
/*
|
@@ -551,19 +600,24 @@ static int xdl_do_merge(xdfenv_t *xe1, xdchange_t *xscr1,
|
|
551
600
|
/* output */
|
552
601
|
if (result) {
|
553
602
|
int marker_size = xmp->marker_size;
|
554
|
-
|
603
|
+
size_t size;
|
604
|
+
|
605
|
+
if (xdl_fill_merge_buffer(&size, xe1, name1, xe2, name2,
|
555
606
|
ancestor_name,
|
556
607
|
favor, changes, NULL, style,
|
557
|
-
marker_size)
|
608
|
+
marker_size) < 0)
|
609
|
+
return -1;
|
610
|
+
|
558
611
|
result->ptr = xdl_malloc(size);
|
559
612
|
if (!result->ptr) {
|
560
613
|
xdl_cleanup_merge(changes);
|
561
614
|
return -1;
|
562
615
|
}
|
563
616
|
result->size = size;
|
564
|
-
xdl_fill_merge_buffer(xe1, name1, xe2, name2,
|
617
|
+
if (xdl_fill_merge_buffer(&size, xe1, name1, xe2, name2,
|
565
618
|
ancestor_name, favor, changes,
|
566
|
-
result->ptr, style, marker_size)
|
619
|
+
result->ptr, style, marker_size) < 0)
|
620
|
+
return -1;
|
567
621
|
}
|
568
622
|
return xdl_cleanup_merge(changes);
|
569
623
|
}
|