forked from nodegit/nodegit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiff.h
More file actions
382 lines (330 loc) · 9.69 KB
/
diff.h
File metadata and controls
382 lines (330 loc) · 9.69 KB
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
#ifndef GITDIFF_H
#define GITDIFF_H
// generated from class_header.h
#include <nan.h>
#include <string>
#include <queue>
extern "C" {
#include <git2.h>
#include <git2/sys/diff.h>
}
#include "../include/blob.h"
#include "../include/diff_options.h"
#include "../include/diff_delta.h"
#include "../include/diff_binary.h"
#include "../include/diff_hunk.h"
#include "../include/diff_line.h"
#include "../include/diff_find_options.h"
#include "../include/diff_perfdata.h"
#include "../include/repository.h"
#include "../include/index.h"
#include "../include/tree.h"
// Forward declaration.
struct git_diff {
};
using namespace node;
using namespace v8;
class GitDiff : public Nan::ObjectWrap {
public:
static Nan::Persistent<Function> constructor_template;
static void InitializeComponent (Local<v8::Object> target);
git_diff *GetValue();
git_diff **GetRefValue();
void ClearValue();
static Local<v8::Value> New(void *raw, bool selfFreeing);
bool selfFreeing;
static int BlobToBuffer_file_cb_cppCallback (
const git_diff_delta * delta
,
float progress
,
void * payload
);
static void BlobToBuffer_file_cb_async(uv_async_t* req, int status);
static void BlobToBuffer_file_cb_setupAsyncPromisePolling(uv_async_t* req);
static void BlobToBuffer_file_cb_asyncPromisePolling(uv_async_t* req, int status);
struct BlobToBuffer_FileCbBaton {
const git_diff_delta * delta;
float progress;
void * payload;
uv_async_t req;
int result;
Nan::Persistent<Object> promise;
bool done;
};
static int BlobToBuffer_binary_cb_cppCallback (
const git_diff_delta * delta
,
const git_diff_binary * binary
,
void * payload
);
static void BlobToBuffer_binary_cb_async(uv_async_t* req, int status);
static void BlobToBuffer_binary_cb_setupAsyncPromisePolling(uv_async_t* req);
static void BlobToBuffer_binary_cb_asyncPromisePolling(uv_async_t* req, int status);
struct BlobToBuffer_BinaryCbBaton {
const git_diff_delta * delta;
const git_diff_binary * binary;
void * payload;
uv_async_t req;
int result;
Nan::Persistent<Object> promise;
bool done;
};
static int BlobToBuffer_hunk_cb_cppCallback (
const git_diff_delta * delta
,
const git_diff_hunk * hunk
,
void * payload
);
static void BlobToBuffer_hunk_cb_async(uv_async_t* req, int status);
static void BlobToBuffer_hunk_cb_setupAsyncPromisePolling(uv_async_t* req);
static void BlobToBuffer_hunk_cb_asyncPromisePolling(uv_async_t* req, int status);
struct BlobToBuffer_HunkCbBaton {
const git_diff_delta * delta;
const git_diff_hunk * hunk;
void * payload;
uv_async_t req;
int result;
Nan::Persistent<Object> promise;
bool done;
};
static int BlobToBuffer_line_cb_cppCallback (
const git_diff_delta * delta
,
const git_diff_hunk * hunk
,
const git_diff_line * line
,
void * payload
);
static void BlobToBuffer_line_cb_async(uv_async_t* req, int status);
static void BlobToBuffer_line_cb_setupAsyncPromisePolling(uv_async_t* req);
static void BlobToBuffer_line_cb_asyncPromisePolling(uv_async_t* req, int status);
struct BlobToBuffer_LineCbBaton {
const git_diff_delta * delta;
const git_diff_hunk * hunk;
const git_diff_line * line;
void * payload;
uv_async_t req;
int result;
Nan::Persistent<Object> promise;
bool done;
};
private:
GitDiff(git_diff *raw, bool selfFreeing);
~GitDiff();
static NAN_METHOD(JSNewFunction);
struct BlobToBufferBaton {
int error_code;
const git_error* error;
const git_blob * old_blob;
const char * old_as_path;
const char * buffer;
size_t buffer_len;
const char * buffer_as_path;
const git_diff_options * options;
git_diff_file_cb file_cb;
git_diff_binary_cb binary_cb;
git_diff_hunk_cb hunk_cb;
git_diff_line_cb line_cb;
void * payload;
};
class BlobToBufferWorker : public Nan::AsyncWorker {
public:
BlobToBufferWorker(
BlobToBufferBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~BlobToBufferWorker() {};
void Execute();
void HandleOKCallback();
private:
BlobToBufferBaton *baton;
};
static NAN_METHOD(BlobToBuffer);
struct FindSimilarBaton {
int error_code;
const git_error* error;
git_diff * diff;
const git_diff_find_options * options;
};
class FindSimilarWorker : public Nan::AsyncWorker {
public:
FindSimilarWorker(
FindSimilarBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~FindSimilarWorker() {};
void Execute();
void HandleOKCallback();
private:
FindSimilarBaton *baton;
};
static NAN_METHOD(FindSimilar);
static NAN_METHOD(GetDelta);
struct GetPerfdataBaton {
int error_code;
const git_error* error;
git_diff_perfdata * out;
const git_diff * diff;
};
class GetPerfdataWorker : public Nan::AsyncWorker {
public:
GetPerfdataWorker(
GetPerfdataBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~GetPerfdataWorker() {};
void Execute();
void HandleOKCallback();
private:
GetPerfdataBaton *baton;
};
static NAN_METHOD(GetPerfdata);
struct IndexToWorkdirBaton {
int error_code;
const git_error* error;
git_diff * diff;
git_repository * repo;
git_index * index;
const git_diff_options * opts;
};
class IndexToWorkdirWorker : public Nan::AsyncWorker {
public:
IndexToWorkdirWorker(
IndexToWorkdirBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~IndexToWorkdirWorker() {};
void Execute();
void HandleOKCallback();
private:
IndexToWorkdirBaton *baton;
};
static NAN_METHOD(IndexToWorkdir);
static NAN_METHOD(NumDeltas);
struct TreeToIndexBaton {
int error_code;
const git_error* error;
git_diff * diff;
git_repository * repo;
git_tree * old_tree;
git_index * index;
const git_diff_options * opts;
};
class TreeToIndexWorker : public Nan::AsyncWorker {
public:
TreeToIndexWorker(
TreeToIndexBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~TreeToIndexWorker() {};
void Execute();
void HandleOKCallback();
private:
TreeToIndexBaton *baton;
};
static NAN_METHOD(TreeToIndex);
struct TreeToTreeBaton {
int error_code;
const git_error* error;
git_diff * diff;
git_repository * repo;
git_tree * old_tree;
git_tree * new_tree;
const git_diff_options * opts;
};
class TreeToTreeWorker : public Nan::AsyncWorker {
public:
TreeToTreeWorker(
TreeToTreeBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~TreeToTreeWorker() {};
void Execute();
void HandleOKCallback();
private:
TreeToTreeBaton *baton;
};
static NAN_METHOD(TreeToTree);
struct TreeToWorkdirBaton {
int error_code;
const git_error* error;
git_diff * diff;
git_repository * repo;
git_tree * old_tree;
const git_diff_options * opts;
};
class TreeToWorkdirWorker : public Nan::AsyncWorker {
public:
TreeToWorkdirWorker(
TreeToWorkdirBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~TreeToWorkdirWorker() {};
void Execute();
void HandleOKCallback();
private:
TreeToWorkdirBaton *baton;
};
static NAN_METHOD(TreeToWorkdir);
struct TreeToWorkdirWithIndexBaton {
int error_code;
const git_error* error;
git_diff * diff;
git_repository * repo;
git_tree * old_tree;
const git_diff_options * opts;
};
class TreeToWorkdirWithIndexWorker : public Nan::AsyncWorker {
public:
TreeToWorkdirWithIndexWorker(
TreeToWorkdirWithIndexBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~TreeToWorkdirWithIndexWorker() {};
void Execute();
void HandleOKCallback();
private:
TreeToWorkdirWithIndexBaton *baton;
};
static NAN_METHOD(TreeToWorkdirWithIndex);
struct BlobToBuffer_globalPayload {
Nan::Callback * file_cb;
Nan::Callback * binary_cb;
Nan::Callback * hunk_cb;
Nan::Callback * line_cb;
BlobToBuffer_globalPayload() {
file_cb = NULL;
binary_cb = NULL;
hunk_cb = NULL;
line_cb = NULL;
}
~BlobToBuffer_globalPayload() {
if (file_cb != NULL) {
delete file_cb;
}
if (binary_cb != NULL) {
delete binary_cb;
}
if (hunk_cb != NULL) {
delete hunk_cb;
}
if (line_cb != NULL) {
delete line_cb;
}
}
};
git_diff *raw;
};
#endif