-
Notifications
You must be signed in to change notification settings - Fork 4
/
git-2.45.0.patch
237 lines (218 loc) · 6.45 KB
/
git-2.45.0.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
diff --git a/git-xdiff.h b/git-xdiff.h
new file mode 100644
index 0000000..4091d22
--- /dev/null
+++ b/git-xdiff.h
@@ -0,0 +1,79 @@
+/*
+ * This file provides the necessary indirection between xdiff and
+ * the calling application. Callers can use this file to avoid modifying
+ * xdiff itself with application-specific code, while still using their
+ * bespoke runtime. For example: callers may wish to use a specific
+ * `malloc` function, and can do so by defining `xdl_malloc` in this
+ * file.
+ */
+
+#ifndef __GIT_XDIFF_H__
+#define __GIT_XDIFF_H__
+
+#include <ctype.h>
+#include <limits.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+
+/* Work around C90-conformance issues */
+#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)
+# if defined(_MSC_VER)
+# define inline __inline
+# elif defined(__GNUC__)
+# define inline __inline__
+# else
+# define inline
+# endif
+#endif
+
+#if defined(__GNUC__) && defined(__GNUC_MINOR__) && \
+ ((__GNUC__ << 16) + __GNUC_MINOR__ >= (4 << 16) + 5)
+# define XDL_UNUSED __attribute__((unused)) \
+ __attribute__((deprecated ("parameter declared as UNUSED")))
+#elif defined(__GNUC__)
+# define XDL_UNUSED __attribute__((unused)) \
+ __attribute__((deprecated))
+#else
+# define XDL_UNUSED
+#endif
+
+#define xdl_malloc(x) malloc(x)
+#define xdl_calloc(n, sz) calloc(n, sz)
+#define xdl_free(ptr) free(ptr)
+#define xdl_realloc(ptr, x) realloc(ptr, x)
+
+#define XDL_BUG(msg) do { fprintf(stderr, "fatal: %s\n", msg); exit(128); } while(0)
+
+#if defined(_MSC_VER) && !defined(XDL_REGEX)
+
+# define xdl_regex_t void *
+# define xdl_regmatch_t void *
+
+inline int xdl_regexec_buf(
+ const xdl_regex_t *preg, const char *buf, size_t size,
+ size_t nmatch, xdl_regmatch_t pmatch[], int eflags)
+{
+ return 15; /* REG_ASSERT */
+}
+
+#else
+# include <regex.h>
+
+# define xdl_regex_t regex_t
+# define xdl_regmatch_t regmatch_t
+
+inline int xdl_regexec_buf(
+ const xdl_regex_t *preg, const char *buf, size_t size,
+ size_t nmatch, xdl_regmatch_t pmatch[], int eflags)
+{
+ pmatch[0].rm_so = 0;
+ pmatch[0].rm_eo = size;
+
+ return regexec(preg, buf, nmatch, pmatch, eflags | REG_STARTEND);
+}
+
+#endif /* XDL_NO_REGEX */
+
+#endif
diff --git a/xdiff.h b/xdiff.h
index bb56b23..fb47f63 100644
--- a/xdiff.h
+++ b/xdiff.h
@@ -27,6 +27,8 @@
extern "C" {
#endif /* #ifdef __cplusplus */
+#include "git-xdiff.h"
+
/* xpparm_t.flags */
#define XDF_NEED_MINIMAL (1 << 0)
@@ -82,7 +84,7 @@ typedef struct s_xpparam {
unsigned long flags;
/* -I<regex> */
- regex_t **ignore_regex;
+ xdl_regex_t **ignore_regex;
size_t ignore_regex_nr;
/* See Documentation/diff-options.txt. */
@@ -119,11 +121,6 @@ typedef struct s_bdiffparam {
} bdiffparam_t;
-#define xdl_malloc(x) xmalloc(x)
-#define xdl_calloc(n, sz) xcalloc(n, sz)
-#define xdl_free(ptr) free(ptr)
-#define xdl_realloc(ptr,x) xrealloc(ptr,x)
-
void *xdl_mmfile_first(mmfile_t *mmf, long *size);
long xdl_mmfile_size(mmfile_t *mmf);
diff --git a/xdiffi.c b/xdiffi.c
index 344c2df..ea36143 100644
--- a/xdiffi.c
+++ b/xdiffi.c
@@ -833,7 +833,7 @@ int xdl_change_compact(xdfile_t *xdf, xdfile_t *xdfo, long flags) {
/* Shift the group backward as much as possible: */
while (!group_slide_up(xdf, &g))
if (group_previous(xdfo, &go))
- BUG("group sync broken sliding up");
+ XDL_BUG("group sync broken sliding up");
/*
* This is this highest that this group can be shifted.
@@ -849,7 +849,7 @@ int xdl_change_compact(xdfile_t *xdf, xdfile_t *xdfo, long flags) {
if (group_slide_down(xdf, &g))
break;
if (group_next(xdfo, &go))
- BUG("group sync broken sliding down");
+ XDL_BUG("group sync broken sliding down");
if (go.end > go.start)
end_matching_other = g.end;
@@ -874,9 +874,9 @@ int xdl_change_compact(xdfile_t *xdf, xdfile_t *xdfo, long flags) {
*/
while (go.end == go.start) {
if (group_slide_up(xdf, &g))
- BUG("match disappeared");
+ XDL_BUG("match disappeared");
if (group_previous(xdfo, &go))
- BUG("group sync broken sliding to match");
+ XDL_BUG("group sync broken sliding to match");
}
} else if (flags & XDF_INDENT_HEURISTIC) {
/*
@@ -917,9 +917,9 @@ int xdl_change_compact(xdfile_t *xdf, xdfile_t *xdfo, long flags) {
while (g.end > best_shift) {
if (group_slide_up(xdf, &g))
- BUG("best shift unreached");
+ XDL_BUG("best shift unreached");
if (group_previous(xdfo, &go))
- BUG("group sync broken sliding to blank line");
+ XDL_BUG("group sync broken sliding to blank line");
}
}
@@ -928,11 +928,11 @@ int xdl_change_compact(xdfile_t *xdf, xdfile_t *xdfo, long flags) {
if (group_next(xdf, &g))
break;
if (group_next(xdfo, &go))
- BUG("group sync broken moving to next group");
+ XDL_BUG("group sync broken moving to next group");
}
if (!group_next(xdfo, &go))
- BUG("group sync broken at end of file");
+ XDL_BUG("group sync broken at end of file");
return 0;
}
@@ -973,7 +973,7 @@ void xdl_free_script(xdchange_t *xscr) {
}
}
-static int xdl_call_hunk_func(xdfenv_t *xe UNUSED, xdchange_t *xscr, xdemitcb_t *ecb,
+static int xdl_call_hunk_func(xdfenv_t *xe XDL_UNUSED, xdchange_t *xscr, xdemitcb_t *ecb,
xdemitconf_t const *xecfg)
{
xdchange_t *xch, *xche;
@@ -1012,11 +1012,11 @@ static void xdl_mark_ignorable_lines(xdchange_t *xscr, xdfenv_t *xe, long flags)
}
static int record_matches_regex(xrecord_t *rec, xpparam_t const *xpp) {
- regmatch_t regmatch;
+ xdl_regmatch_t regmatch;
int i;
for (i = 0; i < xpp->ignore_regex_nr; i++)
- if (!regexec_buf(xpp->ignore_regex[i], rec->ptr, rec->size, 1,
+ if (!xdl_regexec_buf(xpp->ignore_regex[i], rec->ptr, rec->size, 1,
®match, 0))
return 1;
diff --git a/xinclude.h b/xinclude.h
index a4285ac..75db1d8 100644
--- a/xinclude.h
+++ b/xinclude.h
@@ -23,7 +23,7 @@
#if !defined(XINCLUDE_H)
#define XINCLUDE_H
-#include "git-compat-util.h"
+#include "git-xdiff.h"
#include "xmacros.h"
#include "xdiff.h"
#include "xtypes.h"
diff --git a/xmerge.c b/xmerge.c
index af40c88..6ebf73a 100644
--- a/xmerge.c
+++ b/xmerge.c
@@ -88,7 +88,7 @@ static int xdl_cleanup_merge(xdmerge_t *c)
if (c->mode == 0)
count++;
next_c = c->next;
- free(c);
+ xdl_free(c);
}
return count;
}
@@ -456,7 +456,7 @@ static void xdl_merge_two_conflicts(xdmerge_t *m)
m->chg1 = next_m->i1 + next_m->chg1 - m->i1;
m->chg2 = next_m->i2 + next_m->chg2 - m->i2;
m->next = next_m->next;
- free(next_m);
+ xdl_free(next_m);
}
/*