Git fork
1/*
2 * Copyright (C) 2005 Junio C Hamano
3 */
4#ifndef DIFF_H
5#define DIFF_H
6
7#include "hash.h"
8#include "pathspec.h"
9#include "strbuf.h"
10#include "color.h"
11
12struct oidset;
13
14/**
15 * The diff API is for programs that compare two sets of files (e.g. two trees,
16 * one tree and the index) and present the found difference in various ways.
17 * The calling program is responsible for feeding the API pairs of files, one
18 * from the "old" set and the corresponding one from "new" set, that are
19 * different.
20 * The library called through this API is called diffcore, and is responsible
21 * for two things.
22 *
23 * - finding total rewrites (`-B`), renames (`-M`) and copies (`-C`), and
24 * changes that touch a string (`-S`), as specified by the caller.
25 *
26 * - outputting the differences in various formats, as specified by the caller.
27 *
28 * Calling sequence
29 * ----------------
30 *
31 * - Prepare `struct diff_options` to record the set of diff options, and then
32 * call `repo_diff_setup()` to initialize this structure. This sets up the
33 * vanilla default.
34 *
35 * - Fill in the options structure to specify desired output format, rename
36 * detection, etc. `diff_opt_parse()` can be used to parse options given
37 * from the command line in a way consistent with existing git-diff family
38 * of programs.
39 *
40 * - Call `diff_setup_done()`; this inspects the options set up so far for
41 * internal consistency and make necessary tweaking to it (e.g. if textual
42 * patch output was asked, recursive behaviour is turned on); the callback
43 * set_default in diff_options can be used to tweak this more.
44 *
45 * - As you find different pairs of files, call `diff_change()` to feed
46 * modified files, `diff_addremove()` to feed created or deleted files, or
47 * `diff_unmerge()` to feed a file whose state is 'unmerged' to the API.
48 * These are thin wrappers to a lower-level `diff_queue()` function that is
49 * flexible enough to record any of these kinds of changes.
50 *
51 * - Once you finish feeding the pairs of files, call `diffcore_std()`.
52 * This will tell the diffcore library to go ahead and do its work.
53 *
54 * - Calling `diff_flush()` will produce the output, it will call
55 * `diff_free()` to free any resources, e.g. those allocated in
56 * `diff_opt_parse()`.
57 *
58 * - Set `.no_free = 1` before calling `diff_flush()` to defer the
59 * freeing of allocated memory in diff_options. This is useful when
60 * `diff_flush()` is being called in a loop, rather than as a
61 * one-off. When setting `.no_free = 1` you must ensure that
62 * `diff_free()` is called at the end, either by flipping the flag
63 * before the last `diff_flush()` call, or by flipping it before
64 * calling `diff_free()` yourself.
65 */
66
67struct combine_diff_path;
68struct commit;
69struct diff_filespec;
70struct diff_options;
71struct diff_queue_struct;
72struct oid_array;
73struct option;
74struct repository;
75struct rev_info;
76struct userdiff_driver;
77
78typedef int (*pathchange_fn_t)(struct diff_options *options,
79 struct combine_diff_path *path);
80
81typedef void (*change_fn_t)(struct diff_options *options,
82 unsigned old_mode, unsigned new_mode,
83 const struct object_id *old_oid,
84 const struct object_id *new_oid,
85 int old_oid_valid, int new_oid_valid,
86 const char *fullpath,
87 unsigned old_dirty_submodule, unsigned new_dirty_submodule);
88
89typedef void (*add_remove_fn_t)(struct diff_options *options,
90 int addremove, unsigned mode,
91 const struct object_id *oid,
92 int oid_valid,
93 const char *fullpath, unsigned dirty_submodule);
94
95typedef void (*diff_format_fn_t)(struct diff_queue_struct *q,
96 struct diff_options *options, void *data);
97
98typedef const char *(*diff_prefix_fn_t)(struct diff_options *opt, void *data);
99
100#define DIFF_FORMAT_RAW 0x0001
101#define DIFF_FORMAT_DIFFSTAT 0x0002
102#define DIFF_FORMAT_NUMSTAT 0x0004
103#define DIFF_FORMAT_SUMMARY 0x0008
104#define DIFF_FORMAT_PATCH 0x0010
105#define DIFF_FORMAT_SHORTSTAT 0x0020
106#define DIFF_FORMAT_DIRSTAT 0x0040
107
108/* These override all above */
109#define DIFF_FORMAT_NAME 0x0100
110#define DIFF_FORMAT_NAME_STATUS 0x0200
111#define DIFF_FORMAT_CHECKDIFF 0x0400
112
113/* Same as output_format = 0 but we know that -s flag was given
114 * and we should not give default value to output_format.
115 */
116#define DIFF_FORMAT_NO_OUTPUT 0x0800
117
118#define DIFF_FORMAT_CALLBACK 0x1000
119
120#define DIFF_FLAGS_INIT { 0 }
121struct diff_flags {
122
123 /**
124 * Tells if tree traversal done by tree-diff should recursively descend
125 * into a tree object pair that are different in preimage and postimage set.
126 */
127 unsigned recursive;
128 unsigned tree_in_recursive;
129
130 /*
131 * Historically diff_tree_combined() overrides recursive to 1. To
132 * suppress this behavior, set the flag below.
133 * It has no effect if recursive is already set to 1.
134 */
135 unsigned no_recursive_diff_tree_combined;
136
137 /* Affects the way how a file that is seemingly binary is treated. */
138 unsigned binary;
139 unsigned text;
140
141 /**
142 * Tells the patch output format not to use abbreviated object names on the
143 * "index" lines.
144 */
145 unsigned full_index;
146
147 /* Affects if diff-files shows removed files. */
148 unsigned silent_on_remove;
149
150 /**
151 * Tells the diffcore library that the caller is feeding unchanged
152 * filepairs to allow copies from unmodified files be detected.
153 */
154 unsigned find_copies_harder;
155
156 unsigned follow_renames;
157 unsigned rename_empty;
158
159 /* Internal; used for optimization to see if there is any change. */
160 unsigned has_changes;
161
162 unsigned quick;
163
164 /**
165 * Tells diff-files that the input is not tracked files but files in random
166 * locations on the filesystem.
167 */
168 unsigned no_index;
169
170 /**
171 * Tells output routine that it is Ok to call user specified patch output
172 * routine. Plumbing disables this to ensure stable output.
173 */
174 unsigned allow_external;
175
176 /**
177 * For communication between the calling program and the options parser;
178 * tell the calling program to signal the presence of difference using
179 * program exit code.
180 */
181 unsigned exit_with_status;
182
183 /**
184 * Tells the library that the calling program is feeding the filepairs
185 * reversed; `one` is two, and `two` is one.
186 */
187 unsigned reverse_diff;
188
189 unsigned check_failed;
190 unsigned relative_name;
191 unsigned ignore_submodules;
192 unsigned dirstat_cumulative;
193 unsigned dirstat_by_file;
194 unsigned allow_textconv;
195 unsigned textconv_set_via_cmdline;
196 unsigned diff_from_contents;
197 unsigned dirty_submodules;
198 unsigned ignore_untracked_in_submodules;
199 unsigned ignore_submodule_set;
200 unsigned ignore_dirty_submodules;
201 unsigned override_submodule_config;
202 unsigned dirstat_by_line;
203 unsigned funccontext;
204 unsigned default_follow_renames;
205 unsigned stat_with_summary;
206 unsigned suppress_diff_headers;
207 unsigned dual_color_diffed_diffs;
208 unsigned suppress_hunk_header_line_count;
209};
210
211static inline void diff_flags_or(struct diff_flags *a,
212 const struct diff_flags *b)
213{
214 char *tmp_a = (char *)a;
215 const char *tmp_b = (const char *)b;
216
217 for (size_t i = 0; i < sizeof(struct diff_flags); i++)
218 tmp_a[i] |= tmp_b[i];
219}
220
221#define DIFF_XDL_TST(opts, flag) ((opts)->xdl_opts & XDF_##flag)
222#define DIFF_XDL_SET(opts, flag) ((opts)->xdl_opts |= XDF_##flag)
223#define DIFF_XDL_CLR(opts, flag) ((opts)->xdl_opts &= ~XDF_##flag)
224
225#define DIFF_WITH_ALG(opts, flag) (((opts)->xdl_opts & ~XDF_DIFF_ALGORITHM_MASK) | XDF_##flag)
226
227enum diff_words_type {
228 DIFF_WORDS_NONE = 0,
229 DIFF_WORDS_PORCELAIN,
230 DIFF_WORDS_PLAIN,
231 DIFF_WORDS_COLOR
232};
233
234enum diff_submodule_format {
235 DIFF_SUBMODULE_SHORT = 0,
236 DIFF_SUBMODULE_LOG,
237 DIFF_SUBMODULE_INLINE_DIFF
238};
239
240/**
241 * the set of options the calling program wants to affect the operation of
242 * diffcore library with.
243 */
244struct diff_options {
245 char *orderfile;
246
247 /*
248 * "--rotate-to=<file>" would start showing at <file> and when
249 * the output reaches the end, wrap around by default.
250 * Setting skip_instead_of_rotate to true stops the output at the
251 * end, effectively discarding the earlier part of the output
252 * before <file>'s diff (this is used to implement the
253 * "--skip-to=<file>" option).
254 *
255 * When rotate_to_strict is set, it is an error if there is no
256 * <file> in the diff. Otherwise, the output starts at the
257 * path that is the same as, or first path that sorts after,
258 * <file>. Because it is unreasonable to require the exact
259 * match for "git log -p --rotate-to=<file>" (i.e. not all
260 * commit would touch that single <file>), "git log" sets it
261 * to false. "git diff" sets it to true to detect an error
262 * in the command line option.
263 */
264 const char *rotate_to;
265 int skip_instead_of_rotate;
266 int rotate_to_strict;
267
268 /**
269 * A constant string (can and typically does contain newlines to look for
270 * a block of text, not just a single line) to filter out the filepairs
271 * that do not change the number of strings contained in its preimage and
272 * postimage of the diff_queue.
273 */
274 const char *pickaxe;
275 unsigned pickaxe_opts;
276
277 /* -I<regex> */
278 regex_t **ignore_regex;
279 size_t ignore_regex_nr, ignore_regex_alloc;
280
281 const char *single_follow;
282 const char *a_prefix, *b_prefix;
283 const char *line_prefix;
284
285 /**
286 * collection of boolean options that affects the operation, but some do
287 * not have anything to do with the diffcore library.
288 */
289 struct diff_flags flags;
290
291 /* diff-filter bits */
292 unsigned int filter, filter_not;
293
294 enum git_colorbool use_color;
295
296 /* Number of context lines to generate in patch output. */
297 int context;
298
299 int interhunkcontext;
300
301 /* Affects the way detection logic for complete rewrites, renames and
302 * copies.
303 */
304 int break_opt;
305 int detect_rename;
306
307 int irreversible_delete;
308 int skip_stat_unmatch;
309 int line_termination;
310
311 /* The output format used when `diff_flush()` is run. */
312 int output_format;
313
314 /* Affects the way detection logic for complete rewrites, renames and
315 * copies.
316 */
317 int rename_score;
318 int rename_limit;
319
320 int needed_rename_limit;
321 int degraded_cc_to_c;
322 int show_rename_progress;
323 int dirstat_permille;
324 int setup;
325
326 /* Number of hexdigits to abbreviate raw format output to. */
327 int abbrev;
328
329 /* If non-zero, then stop computing after this many changes. */
330 int max_changes;
331
332 int ita_invisible_in_index;
333/* white-space error highlighting */
334#define WSEH_NEW (1<<12)
335#define WSEH_CONTEXT (1<<13)
336#define WSEH_OLD (1<<14)
337 unsigned ws_error_highlight;
338 const char *prefix;
339 int prefix_length;
340 const char *stat_sep;
341 int xdl_opts;
342 int ignore_driver_algorithm;
343
344 /* see Documentation/diff-options.adoc */
345 char **anchors;
346 size_t anchors_nr, anchors_alloc;
347
348 int stat_width;
349 int stat_name_width;
350 int stat_graph_width;
351 int stat_count;
352 const char *word_regex;
353 enum diff_words_type word_diff;
354 enum diff_submodule_format submodule_format;
355
356 struct oidset *objfind;
357
358 /* this is set by diffcore for DIFF_FORMAT_PATCH */
359 int found_changes;
360
361 /* to support internal diff recursion by --follow hack*/
362 int found_follow;
363
364 /*
365 * By default, diffcore_std() resolves the statuses for queued diff file
366 * pairs by calling diff_resolve_rename_copy(). If status information
367 * has already been manually set, this option prevents diffcore_std()
368 * from resetting statuses.
369 */
370 int skip_resolving_statuses;
371
372 /* Callback which allows tweaking the options in diff_setup_done(). */
373 void (*set_default)(struct diff_options *);
374
375 FILE *file;
376 int close_file;
377
378#define OUTPUT_INDICATOR_NEW 0
379#define OUTPUT_INDICATOR_OLD 1
380#define OUTPUT_INDICATOR_CONTEXT 2
381 char output_indicators[3];
382
383 struct pathspec pathspec;
384 pathchange_fn_t pathchange;
385 change_fn_t change;
386 add_remove_fn_t add_remove;
387 void *change_fn_data;
388 diff_format_fn_t format_callback;
389 void *format_callback_data;
390 diff_prefix_fn_t output_prefix;
391 void *output_prefix_data;
392
393 int diff_path_counter;
394
395 struct emitted_diff_symbols *emitted_symbols;
396 enum {
397 COLOR_MOVED_NO = 0,
398 COLOR_MOVED_PLAIN = 1,
399 COLOR_MOVED_BLOCKS = 2,
400 COLOR_MOVED_ZEBRA = 3,
401 COLOR_MOVED_ZEBRA_DIM = 4,
402 } color_moved;
403 #define COLOR_MOVED_DEFAULT COLOR_MOVED_ZEBRA
404 #define COLOR_MOVED_MIN_ALNUM_COUNT 20
405
406 /* XDF_WHITESPACE_FLAGS regarding block detection are set at 2, 3, 4 */
407 #define COLOR_MOVED_WS_ALLOW_INDENTATION_CHANGE (1<<5)
408 #define COLOR_MOVED_WS_ERROR (1<<0)
409 unsigned color_moved_ws_handling;
410
411 bool dry_run;
412
413 struct repository *repo;
414 struct strmap *additional_path_headers;
415
416 int no_free;
417
418 /*
419 * The value '0' is a valid max-depth (for no recursion), and value '-1'
420 * also (for unlimited recursion), so the extra "valid" flag is used to
421 * determined whether the user specified option --max-depth.
422 */
423 int max_depth;
424 int max_depth_valid;
425};
426
427unsigned diff_filter_bit(char status);
428
429void diff_emit_submodule_del(struct diff_options *o, const char *line);
430void diff_emit_submodule_add(struct diff_options *o, const char *line);
431void diff_emit_submodule_untracked(struct diff_options *o, const char *path);
432void diff_emit_submodule_modified(struct diff_options *o, const char *path);
433void diff_emit_submodule_header(struct diff_options *o, const char *header);
434void diff_emit_submodule_error(struct diff_options *o, const char *err);
435void diff_emit_submodule_pipethrough(struct diff_options *o,
436 const char *line, int len);
437
438struct diffstat_t {
439 int nr;
440 int alloc;
441 struct diffstat_file {
442 char *from_name;
443 char *name;
444 char *print_name;
445 const char *comments;
446 unsigned is_unmerged:1;
447 unsigned is_binary:1;
448 unsigned is_renamed:1;
449 unsigned is_interesting:1;
450 uintmax_t added, deleted;
451 } **files;
452};
453
454enum color_diff {
455 DIFF_RESET = 0,
456 DIFF_CONTEXT = 1,
457 DIFF_METAINFO = 2,
458 DIFF_FRAGINFO = 3,
459 DIFF_FILE_OLD = 4,
460 DIFF_FILE_NEW = 5,
461 DIFF_COMMIT = 6,
462 DIFF_WHITESPACE = 7,
463 DIFF_FUNCINFO = 8,
464 DIFF_FILE_OLD_MOVED = 9,
465 DIFF_FILE_OLD_MOVED_ALT = 10,
466 DIFF_FILE_OLD_MOVED_DIM = 11,
467 DIFF_FILE_OLD_MOVED_ALT_DIM = 12,
468 DIFF_FILE_NEW_MOVED = 13,
469 DIFF_FILE_NEW_MOVED_ALT = 14,
470 DIFF_FILE_NEW_MOVED_DIM = 15,
471 DIFF_FILE_NEW_MOVED_ALT_DIM = 16,
472 DIFF_CONTEXT_DIM = 17,
473 DIFF_FILE_OLD_DIM = 18,
474 DIFF_FILE_NEW_DIM = 19,
475 DIFF_CONTEXT_BOLD = 20,
476 DIFF_FILE_OLD_BOLD = 21,
477 DIFF_FILE_NEW_BOLD = 22,
478};
479
480const char *diff_get_color(enum git_colorbool diff_use_color, enum color_diff ix);
481#define diff_get_color_opt(o, ix) \
482 diff_get_color((o)->use_color, ix)
483
484
485const char *diff_line_prefix(struct diff_options *);
486
487
488extern const char mime_boundary_leader[];
489
490struct combine_diff_path *diff_tree_paths(
491 const struct object_id *oid,
492 const struct object_id **parents_oid, int nparent,
493 struct strbuf *base, struct diff_options *opt);
494void diff_tree_oid(const struct object_id *old_oid,
495 const struct object_id *new_oid,
496 const char *base, struct diff_options *opt);
497void diff_root_tree_oid(const struct object_id *new_oid, const char *base,
498 struct diff_options *opt);
499
500struct combine_diff_path {
501 struct combine_diff_path *next;
502 char *path;
503 unsigned int mode;
504 struct object_id oid;
505 struct combine_diff_parent {
506 char status;
507 unsigned int mode;
508 struct object_id oid;
509 /*
510 * This per-parent path is filled only when doing a combined
511 * diff with revs.combined_all_paths set, and only if the path
512 * differs from the post-image (e.g., a rename or copy).
513 * Otherwise it is left NULL.
514 */
515 char *path;
516 } parent[FLEX_ARRAY];
517};
518struct combine_diff_path *combine_diff_path_new(const char *path,
519 size_t path_len,
520 unsigned int mode,
521 const struct object_id *oid,
522 size_t num_parents);
523
524void show_combined_diff(struct combine_diff_path *elem, int num_parent,
525 struct rev_info *);
526
527void diff_tree_combined(const struct object_id *oid, const struct oid_array *parents, struct rev_info *rev);
528
529void diff_tree_combined_merge(const struct commit *commit, struct rev_info *rev);
530
531void diff_set_mnemonic_prefix(struct diff_options *options, const char *a, const char *b);
532void diff_set_noprefix(struct diff_options *options);
533void diff_set_default_prefix(struct diff_options *options);
534
535int diff_can_quit_early(struct diff_options *);
536
537/*
538 * Stages changes in the provided diff queue for file additions and deletions.
539 * If a file pair gets queued, it is returned.
540 */
541struct diff_filepair *diff_queue_addremove(struct diff_queue_struct *queue,
542 struct diff_options *,
543 int addremove, unsigned mode,
544 const struct object_id *oid,
545 int oid_valid, const char *fullpath,
546 unsigned dirty_submodule);
547
548/*
549 * Stages changes in the provided diff queue for file modifications.
550 * If a file pair gets queued, it is returned.
551 */
552struct diff_filepair *diff_queue_change(struct diff_queue_struct *queue,
553 struct diff_options *,
554 unsigned mode1, unsigned mode2,
555 const struct object_id *old_oid,
556 const struct object_id *new_oid,
557 int old_oid_valid, int new_oid_valid,
558 const char *fullpath,
559 unsigned dirty_submodule1,
560 unsigned dirty_submodule2);
561
562void diff_addremove(struct diff_options *,
563 int addremove,
564 unsigned mode,
565 const struct object_id *oid,
566 int oid_valid,
567 const char *fullpath, unsigned dirty_submodule);
568
569void diff_change(struct diff_options *,
570 unsigned mode1, unsigned mode2,
571 const struct object_id *old_oid,
572 const struct object_id *new_oid,
573 int old_oid_valid, int new_oid_valid,
574 const char *fullpath,
575 unsigned dirty_submodule1, unsigned dirty_submodule2);
576
577struct diff_filepair *diff_unmerge(struct diff_options *, const char *path);
578
579void compute_diffstat(struct diff_options *options, struct diffstat_t *diffstat,
580 struct diff_queue_struct *q);
581void free_diffstat_info(struct diffstat_t *diffstat);
582
583#define DIFF_SETUP_REVERSE 1
584#define DIFF_SETUP_USE_SIZE_CACHE 4
585
586/*
587 * Poor man's alternative to parse-option, to allow both stuck form
588 * (--option=value) and separate form (--option value).
589 */
590int parse_long_opt(const char *opt, const char **argv,
591 const char **optarg);
592
593struct config_context;
594int git_diff_basic_config(const char *var, const char *value,
595 const struct config_context *ctx, void *cb);
596int git_diff_heuristic_config(const char *var, const char *value, void *cb);
597void init_diff_ui_defaults(void);
598int git_diff_ui_config(const char *var, const char *value,
599 const struct config_context *ctx, void *cb);
600void repo_diff_setup(struct repository *, struct diff_options *);
601struct option *add_diff_options(const struct option *, struct diff_options *);
602int diff_opt_parse(struct diff_options *, const char **, int, const char *);
603void diff_setup_done(struct diff_options *);
604
605/*
606 * Returns true if the pathspec can work with --follow mode. If die_on_error is
607 * set, die() with a specific error message rather than returning false.
608 */
609int diff_check_follow_pathspec(struct pathspec *ps, int die_on_error);
610
611int git_config_rename(const char *var, const char *value);
612
613#define DIFF_DETECT_RENAME 1
614#define DIFF_DETECT_COPY 2
615
616#define DIFF_PICKAXE_ALL 1
617#define DIFF_PICKAXE_REGEX 2
618
619#define DIFF_PICKAXE_KIND_S 4 /* traditional plumbing counter */
620#define DIFF_PICKAXE_KIND_G 8 /* grep in the patch */
621#define DIFF_PICKAXE_KIND_OBJFIND 16 /* specific object IDs */
622
623#define DIFF_PICKAXE_KINDS_MASK (DIFF_PICKAXE_KIND_S | \
624 DIFF_PICKAXE_KIND_G | \
625 DIFF_PICKAXE_KIND_OBJFIND)
626#define DIFF_PICKAXE_KINDS_G_REGEX_MASK (DIFF_PICKAXE_KIND_G | \
627 DIFF_PICKAXE_REGEX)
628#define DIFF_PICKAXE_KINDS_ALL_OBJFIND_MASK (DIFF_PICKAXE_ALL | \
629 DIFF_PICKAXE_KIND_OBJFIND)
630
631#define DIFF_PICKAXE_IGNORE_CASE 32
632
633void init_diffstat_widths(struct diff_options *);
634void diffcore_std(struct diff_options *);
635void diffcore_fix_diff_index(void);
636
637#define COMMON_DIFF_OPTIONS_HELP \
638"\ncommon diff options:\n" \
639" -z output diff-raw with lines terminated with NUL.\n" \
640" -p output patch format.\n" \
641" -u synonym for -p.\n" \
642" --patch-with-raw\n" \
643" output both a patch and the diff-raw format.\n" \
644" --stat show diffstat instead of patch.\n" \
645" --numstat show numeric diffstat instead of patch.\n" \
646" --patch-with-stat\n" \
647" output a patch and prepend its diffstat.\n" \
648" --name-only show only names of changed files.\n" \
649" --name-status show names and status of changed files.\n" \
650" --full-index show full object name on index lines.\n" \
651" --abbrev=<n> abbreviate object names in diff-tree header and diff-raw.\n" \
652" -R swap input file pairs.\n" \
653" -B detect complete rewrites.\n" \
654" -M detect renames.\n" \
655" -C detect copies.\n" \
656" --find-copies-harder\n" \
657" try unchanged files as candidate for copy detection.\n" \
658" -l<n> limit rename attempts up to <n> paths.\n" \
659" -O<file> reorder diffs according to the <file>.\n" \
660" -S<string> find filepair whose only one side contains the string.\n" \
661" --pickaxe-all\n" \
662" show all files diff when -S is used and hit is found.\n" \
663" -a --text treat all files as text.\n"
664
665int diff_queue_is_empty(struct diff_options *o);
666void diff_flush(struct diff_options*);
667void diff_free(struct diff_options*);
668void diff_warn_rename_limit(const char *varname, int needed, int degraded_cc);
669
670/* diff-raw status letters */
671#define DIFF_STATUS_ADDED 'A'
672#define DIFF_STATUS_COPIED 'C'
673#define DIFF_STATUS_DELETED 'D'
674#define DIFF_STATUS_MODIFIED 'M'
675#define DIFF_STATUS_RENAMED 'R'
676#define DIFF_STATUS_TYPE_CHANGED 'T'
677#define DIFF_STATUS_UNKNOWN 'X'
678#define DIFF_STATUS_UNMERGED 'U'
679
680/* these are not diff-raw status letters proper, but used by
681 * diffcore-filter insn to specify additional restrictions.
682 */
683#define DIFF_STATUS_FILTER_AON '*'
684#define DIFF_STATUS_FILTER_BROKEN 'B'
685
686/*
687 * This is different from repo_find_unique_abbrev() in that
688 * it stuffs the result with dots for alignment.
689 */
690const char *diff_aligned_abbrev(const struct object_id *sha1, int);
691
692void diff_get_merge_base(const struct rev_info *revs, struct object_id *mb);
693
694/* do not report anything on removed paths */
695#define DIFF_SILENT_ON_REMOVED 01
696/* report racily-clean paths as modified */
697#define DIFF_RACY_IS_MODIFIED 02
698void run_diff_files(struct rev_info *revs, unsigned int option);
699
700#define DIFF_INDEX_CACHED 01
701#define DIFF_INDEX_MERGE_BASE 02
702void run_diff_index(struct rev_info *revs, unsigned int option);
703
704int do_diff_cache(const struct object_id *, struct diff_options *);
705int diff_flush_patch_id(struct diff_options *, struct object_id *, int);
706void flush_one_hunk(struct object_id *result, struct git_hash_ctx *ctx);
707
708int diff_result_code(struct rev_info *);
709
710int diff_no_index(struct rev_info *, const struct git_hash_algo *algop,
711 int implicit_no_index, int, const char **);
712
713int index_differs_from(struct repository *r, const char *def,
714 const struct diff_flags *flags,
715 int ita_invisible_in_index);
716
717/*
718 * Emit an interdiff of two object ID's to 'diff_options.file' optionally
719 * indented by 'indent' spaces.
720 */
721void show_interdiff(const struct object_id *, const struct object_id *,
722 int indent, struct diff_options *);
723
724/*
725 * Fill the contents of the filespec "df", respecting any textconv defined by
726 * its userdiff driver. The "driver" parameter must come from a
727 * previous call to get_textconv(), and therefore should either be NULL or have
728 * textconv enabled.
729 *
730 * Note that the memory ownership of the resulting buffer depends on whether
731 * the driver field is NULL. If it is, then the memory belongs to the filespec
732 * struct. If it is non-NULL, then "outbuf" points to a newly allocated buffer
733 * that should be freed by the caller.
734 */
735size_t fill_textconv(struct repository *r,
736 struct userdiff_driver *driver,
737 struct diff_filespec *df,
738 char **outbuf);
739
740/*
741 * Look up the userdiff driver for the given filespec, and return it if
742 * and only if it has textconv enabled (otherwise return NULL). The result
743 * can be passed to fill_textconv().
744 */
745struct userdiff_driver *get_textconv(struct repository *r,
746 struct diff_filespec *one);
747
748/*
749 * Prepare diff_filespec and convert it using diff textconv API
750 * if the textconv driver exists.
751 * Return 1 if the conversion succeeds, 0 otherwise.
752 */
753int textconv_object(struct repository *repo,
754 const char *path,
755 unsigned mode,
756 const struct object_id *oid, int oid_valid,
757 char **buf, unsigned long *buf_size);
758
759int parse_rename_score(const char **cp_p);
760
761long parse_algorithm_value(const char *value);
762
763void print_stat_summary(FILE *fp, int files,
764 int insertions, int deletions);
765void setup_diff_pager(struct diff_options *);
766
767extern int diff_auto_refresh_index;
768
769#endif /* DIFF_H */