forked from git-for-windows/git
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiff.h
More file actions
Latest commit
359 lines (296 loc) · 11.5 KB
/
Copy pathdiff.h
File metadata and controls
359 lines (296 loc) · 11.5 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
/*
* Copyright (C) 2005 Junio C Hamano
*/
#ifndefDIFF_H
#defineDIFF_H
#include"tree-walk.h"
#include"pathspec.h"
structrev_info;
structdiff_options;
structdiff_queue_struct;
structstrbuf;
structdiff_filespec;
structuserdiff_driver;
structsha1_array;
structcommit;
structcombine_diff_path;
typedefint (*pathchange_fn_t)(structdiff_options*options,
structcombine_diff_path*path);
typedefvoid (*change_fn_t)(structdiff_options*options,
unsignedold_mode, unsignednew_mode,
constunsigned char*old_sha1,
constunsigned char*new_sha1,
intold_sha1_valid, intnew_sha1_valid,
constchar*fullpath,
unsignedold_dirty_submodule, unsignednew_dirty_submodule);
typedefvoid (*add_remove_fn_t)(structdiff_options*options,
intaddremove, unsignedmode,
constunsigned char*sha1,
intsha1_valid,
constchar*fullpath, unsigneddirty_submodule);
typedefvoid (*diff_format_fn_t)(structdiff_queue_struct*q,
structdiff_options*options, void*data);
typedefstructstrbuf*(*diff_prefix_fn_t)(structdiff_options*opt, void*data);
#defineDIFF_FORMAT_RAW 0x0001
#defineDIFF_FORMAT_DIFFSTAT 0x0002
#defineDIFF_FORMAT_NUMSTAT 0x0004
#defineDIFF_FORMAT_SUMMARY 0x0008
#defineDIFF_FORMAT_PATCH 0x0010
#defineDIFF_FORMAT_SHORTSTAT 0x0020
#defineDIFF_FORMAT_DIRSTAT 0x0040
/* These override all above */
#defineDIFF_FORMAT_NAME 0x0100
#defineDIFF_FORMAT_NAME_STATUS 0x0200
#defineDIFF_FORMAT_CHECKDIFF 0x0400
/* Same as output_format = 0 but we know that -s flag was given
* and we should not give default value to output_format.
*/
#defineDIFF_FORMAT_NO_OUTPUT 0x0800
#defineDIFF_FORMAT_CALLBACK 0x1000
#defineDIFF_OPT_RECURSIVE (1 << 0)
#defineDIFF_OPT_TREE_IN_RECURSIVE (1 << 1)
#defineDIFF_OPT_BINARY (1 << 2)
#defineDIFF_OPT_TEXT (1 << 3)
#defineDIFF_OPT_FULL_INDEX (1 << 4)
#defineDIFF_OPT_SILENT_ON_REMOVE (1 << 5)
#defineDIFF_OPT_FIND_COPIES_HARDER (1 << 6)
#defineDIFF_OPT_FOLLOW_RENAMES (1 << 7)
#defineDIFF_OPT_RENAME_EMPTY (1 << 8)
/* (1 << 9) unused */
#defineDIFF_OPT_HAS_CHANGES (1 << 10)
#defineDIFF_OPT_QUICK (1 << 11)
#defineDIFF_OPT_NO_INDEX (1 << 12)
#defineDIFF_OPT_ALLOW_EXTERNAL (1 << 13)
#defineDIFF_OPT_EXIT_WITH_STATUS (1 << 14)
#defineDIFF_OPT_REVERSE_DIFF (1 << 15)
#defineDIFF_OPT_CHECK_FAILED (1 << 16)
#defineDIFF_OPT_RELATIVE_NAME (1 << 17)
#defineDIFF_OPT_IGNORE_SUBMODULES (1 << 18)
#defineDIFF_OPT_DIRSTAT_CUMULATIVE (1 << 19)
#defineDIFF_OPT_DIRSTAT_BY_FILE (1 << 20)
#defineDIFF_OPT_ALLOW_TEXTCONV (1 << 21)
#defineDIFF_OPT_DIFF_FROM_CONTENTS (1 << 22)
#defineDIFF_OPT_SUBMODULE_LOG (1 << 23)
#defineDIFF_OPT_DIRTY_SUBMODULES (1 << 24)
#defineDIFF_OPT_IGNORE_UNTRACKED_IN_SUBMODULES (1 << 25)
#defineDIFF_OPT_IGNORE_DIRTY_SUBMODULES (1 << 26)
#defineDIFF_OPT_OVERRIDE_SUBMODULE_CONFIG (1 << 27)
#defineDIFF_OPT_DIRSTAT_BY_LINE (1 << 28)
#defineDIFF_OPT_FUNCCONTEXT (1 << 29)
#defineDIFF_OPT_PICKAXE_IGNORE_CASE (1 << 30)
#defineDIFF_OPT_TST(opts, flag) ((opts)->flags & DIFF_OPT_##flag)
#defineDIFF_OPT_TOUCHED(opts, flag) ((opts)->touched_flags & DIFF_OPT_##flag)
#defineDIFF_OPT_SET(opts, flag) (((opts)->flags |= DIFF_OPT_##flag),((opts)->touched_flags |= DIFF_OPT_##flag))
#defineDIFF_OPT_CLR(opts, flag) (((opts)->flags &= ~DIFF_OPT_##flag),((opts)->touched_flags |= DIFF_OPT_##flag))
#defineDIFF_XDL_TST(opts, flag) ((opts)->xdl_opts & XDF_##flag)
#defineDIFF_XDL_SET(opts, flag) ((opts)->xdl_opts |= XDF_##flag)
#defineDIFF_XDL_CLR(opts, flag) ((opts)->xdl_opts &= ~XDF_##flag)
#defineDIFF_WITH_ALG(opts, flag) (((opts)->xdl_opts & ~XDF_DIFF_ALGORITHM_MASK) | XDF_##flag)
enumdiff_words_type {
DIFF_WORDS_NONE=0,
DIFF_WORDS_PORCELAIN,
DIFF_WORDS_PLAIN,
DIFF_WORDS_COLOR
};
structdiff_options {
constchar*orderfile;
constchar*pickaxe;
constchar*single_follow;
constchar*a_prefix, *b_prefix;
unsignedflags;
unsignedtouched_flags;
/* diff-filter bits */
unsigned intfilter;
intuse_color;
intcontext;
intinterhunkcontext;
intbreak_opt;
intdetect_rename;
intirreversible_delete;
intskip_stat_unmatch;
intline_termination;
intoutput_format;
intpickaxe_opts;
intrename_score;
intrename_limit;
intneeded_rename_limit;
intdegraded_cc_to_c;
intshow_rename_progress;
intdirstat_permille;
intsetup;
intabbrev;
constchar*prefix;
intprefix_length;
constchar*stat_sep;
longxdl_opts;
intstat_width;
intstat_name_width;
intstat_graph_width;
intstat_count;
constchar*word_regex;
enumdiff_words_typeword_diff;
/* this is set by diffcore for DIFF_FORMAT_PATCH */
intfound_changes;
/* to support internal diff recursion by --follow hack*/
intfound_follow;
void (*set_default)(structdiff_options*);
FILE*file;
intclose_file;
structpathspecpathspec;
pathchange_fn_tpathchange;
change_fn_tchange;
add_remove_fn_tadd_remove;
diff_format_fn_tformat_callback;
void*format_callback_data;
diff_prefix_fn_toutput_prefix;
intoutput_prefix_length;
void*output_prefix_data;
intdiff_path_counter;
};
enumcolor_diff {
DIFF_RESET=0,
DIFF_PLAIN=1,
DIFF_METAINFO=2,
DIFF_FRAGINFO=3,
DIFF_FILE_OLD=4,
DIFF_FILE_NEW=5,
DIFF_COMMIT=6,
DIFF_WHITESPACE=7,
DIFF_FUNCINFO=8
};
constchar*diff_get_color(intdiff_use_color, enumcolor_diffix);
#definediff_get_color_opt(o, ix) \
diff_get_color((o)->use_color, ix)
constchar*diff_line_prefix(structdiff_options*);
externconstcharmime_boundary_leader[];
externstructcombine_diff_path*diff_tree_paths(
structcombine_diff_path*p, constunsigned char*sha1,
constunsigned char**parent_sha1, intnparent,
structstrbuf*base, structdiff_options*opt);
externintdiff_tree_sha1(constunsigned char*old, constunsigned char*new,
constchar*base, structdiff_options*opt);
externintdiff_root_tree_sha1(constunsigned char*new, constchar*base,
structdiff_options*opt);
structcombine_diff_path {
structcombine_diff_path*next;
char*path;
unsigned intmode;
unsigned charsha1[20];
structcombine_diff_parent {
charstatus;
unsigned intmode;
unsigned charsha1[20];
} parent[FLEX_ARRAY];
};
#definecombine_diff_path_size(n, l) \
(sizeof(struct combine_diff_path) + \
sizeof(struct combine_diff_parent) * (n) + (l) + 1)
externvoidshow_combined_diff(structcombine_diff_path*elem, intnum_parent,
intdense, structrev_info*);
externvoiddiff_tree_combined(constunsigned char*sha1, conststructsha1_array*parents, intdense, structrev_info*rev);
externvoiddiff_tree_combined_merge(conststructcommit*commit, intdense, structrev_info*rev);
voiddiff_set_mnemonic_prefix(structdiff_options*options, constchar*a, constchar*b);
externintdiff_can_quit_early(structdiff_options*);
externvoiddiff_addremove(structdiff_options*,
intaddremove,
unsignedmode,
constunsigned char*sha1,
intsha1_valid,
constchar*fullpath, unsigneddirty_submodule);
externvoiddiff_change(structdiff_options*,
unsignedmode1, unsignedmode2,
constunsigned char*sha1,
constunsigned char*sha2,
intsha1_valid,
intsha2_valid,
constchar*fullpath,
unsigneddirty_submodule1, unsigneddirty_submodule2);
externstructdiff_filepair*diff_unmerge(structdiff_options*, constchar*path);
#defineDIFF_SETUP_REVERSE 1
#defineDIFF_SETUP_USE_CACHE 2
#defineDIFF_SETUP_USE_SIZE_CACHE 4
/*
* Poor man's alternative to parse-option, to allow both stuck form
* (--option=value) and separate form (--option value).
*/
externintparse_long_opt(constchar*opt, constchar**argv,
constchar**optarg);
externintgit_diff_basic_config(constchar*var, constchar*value, void*cb);
externintgit_diff_ui_config(constchar*var, constchar*value, void*cb);
externvoiddiff_setup(structdiff_options*);
externintdiff_opt_parse(structdiff_options*, constchar**, int);
externvoiddiff_setup_done(structdiff_options*);
#defineDIFF_DETECT_RENAME 1
#defineDIFF_DETECT_COPY 2
#defineDIFF_PICKAXE_ALL 1
#defineDIFF_PICKAXE_REGEX 2
#defineDIFF_PICKAXE_KIND_S 4 /* traditional plumbing counter */
#defineDIFF_PICKAXE_KIND_G 8 /* grep in the patch */
externvoiddiffcore_std(structdiff_options*);
externvoiddiffcore_fix_diff_index(structdiff_options*);
#defineCOMMON_DIFF_OPTIONS_HELP \
"\ncommon diff options:\n" \
" -z output diff-raw with lines terminated with NUL.\n" \
" -p output patch format.\n" \
" -u synonym for -p.\n" \
" --patch-with-raw\n" \
" output both a patch and the diff-raw format.\n" \
" --stat show diffstat instead of patch.\n" \
" --numstat show numeric diffstat instead of patch.\n" \
" --patch-with-stat\n" \
" output a patch and prepend its diffstat.\n" \
" --name-only show only names of changed files.\n" \
" --name-status show names and status of changed files.\n" \
" --full-index show full object name on index lines.\n" \
" --abbrev=<n> abbreviate object names in diff-tree header and diff-raw.\n" \
" -R swap input file pairs.\n" \
" -B detect complete rewrites.\n" \
" -M detect renames.\n" \
" -C detect copies.\n" \
" --find-copies-harder\n" \
" try unchanged files as candidate for copy detection.\n" \
" -l<n> limit rename attempts up to <n> paths.\n" \
" -O<file> reorder diffs according to the <file>.\n" \
" -S<string> find filepair whose only one side contains the string.\n" \
" --pickaxe-all\n" \
" show all files diff when -S is used and hit is found.\n" \
" -a --text treat all files as text.\n"
externintdiff_queue_is_empty(void);
externvoiddiff_flush(structdiff_options*);
externvoiddiff_warn_rename_limit(constchar*varname, intneeded, intdegraded_cc);
/* diff-raw status letters */
#defineDIFF_STATUS_ADDED 'A'
#defineDIFF_STATUS_COPIED 'C'
#defineDIFF_STATUS_DELETED 'D'
#defineDIFF_STATUS_MODIFIED 'M'
#defineDIFF_STATUS_RENAMED 'R'
#defineDIFF_STATUS_TYPE_CHANGED 'T'
#defineDIFF_STATUS_UNKNOWN 'X'
#defineDIFF_STATUS_UNMERGED 'U'
/* these are not diff-raw status letters proper, but used by
* diffcore-filter insn to specify additional restrictions.
*/
#defineDIFF_STATUS_FILTER_AON '*'
#defineDIFF_STATUS_FILTER_BROKEN 'B'
externconstchar*diff_unique_abbrev(constunsigned char*, int);
/* do not report anything on removed paths */
#defineDIFF_SILENT_ON_REMOVED 01
/* report racily-clean paths as modified */
#defineDIFF_RACY_IS_MODIFIED 02
externintrun_diff_files(structrev_info*revs, unsigned intoption);
externintrun_diff_index(structrev_info*revs, intcached);
externintdo_diff_cache(constunsigned char*, structdiff_options*);
externintdiff_flush_patch_id(structdiff_options*, unsigned char*);
externintdiff_result_code(structdiff_options*, int);
externvoiddiff_no_index(structrev_info*, int, constchar**, constchar*);
externintindex_differs_from(constchar*def, intdiff_flags);
externsize_tfill_textconv(structuserdiff_driver*driver,
structdiff_filespec*df,
char**outbuf);
externstructuserdiff_driver*get_textconv(structdiff_filespec*one);
externintparse_rename_score(constchar**cp_p);
externlongparse_algorithm_value(constchar*value);
externintprint_stat_summary(FILE*fp, intfiles,
intinsertions, intdeletions);
externvoidsetup_diff_pager(structdiff_options*);
#endif/* DIFF_H */