blob: 2d442e296f9821ea4085188602b9ea4a4ba159a6 [file] [log] [blame]
Junio C Hamanobe3cfa82005-04-26 09:25:05 -07001/*
2 * Copyright (C) 2005 Junio C Hamano
3 */
Junio C Hamano86436c22005-04-25 18:22:47 -07004#ifndef DIFF_H
5#define DIFF_H
6
Junio C Hamano1b0c7172006-03-29 22:55:43 -08007#include "tree-walk.h"
Nguyễn Thái Ngọc Duy64acde92013-07-14 15:35:25 +07008#include "pathspec.h"
brian m. carlson1ff57c12015-03-13 23:39:33 +00009#include "object.h"
Linus Torvalds50f9a852006-01-31 14:10:56 -080010
Linus Torvalds91539832006-04-17 11:59:32 -070011struct rev_info;
Linus Torvaldsac1b3d12005-10-20 21:05:05 -070012struct diff_options;
Jeff King04245582006-09-07 02:35:42 -040013struct diff_queue_struct;
Bo Yanga3c158d2010-05-26 15:08:02 +080014struct strbuf;
Axel Bonneta788d7d2010-06-07 17:23:36 +020015struct diff_filespec;
16struct userdiff_driver;
brian m. carlson910650d2017-03-31 01:40:00 +000017struct oid_array;
René Scharfe82889292011-12-17 11:20:07 +010018struct commit;
Kirill Smelkov72441af2014-04-07 01:46:26 +040019struct combine_diff_path;
20
21typedef int (*pathchange_fn_t)(struct diff_options *options,
22 struct combine_diff_path *path);
Linus Torvaldsac1b3d12005-10-20 21:05:05 -070023
24typedef void (*change_fn_t)(struct diff_options *options,
25 unsigned old_mode, unsigned new_mode,
Brandon Williams94a00972017-05-30 10:30:49 -070026 const struct object_id *old_oid,
27 const struct object_id *new_oid,
28 int old_oid_valid, int new_oid_valid,
Jens Lehmanne3d42c42010-01-18 21:26:18 +010029 const char *fullpath,
30 unsigned old_dirty_submodule, unsigned new_dirty_submodule);
Linus Torvaldsac1b3d12005-10-20 21:05:05 -070031
32typedef void (*add_remove_fn_t)(struct diff_options *options,
33 int addremove, unsigned mode,
Brandon Williamsc26022e2017-05-30 10:30:47 -070034 const struct object_id *oid,
35 int oid_valid,
Jens Lehmanne3d42c42010-01-18 21:26:18 +010036 const char *fullpath, unsigned dirty_submodule);
Linus Torvaldsac1b3d12005-10-20 21:05:05 -070037
Jeff King04245582006-09-07 02:35:42 -040038typedef void (*diff_format_fn_t)(struct diff_queue_struct *q,
39 struct diff_options *options, void *data);
40
Bo Yanga3c158d2010-05-26 15:08:02 +080041typedef struct strbuf *(*diff_prefix_fn_t)(struct diff_options *opt, void *data);
42
Timo Hirvonenc6744342006-06-24 20:21:53 +030043#define DIFF_FORMAT_RAW 0x0001
44#define DIFF_FORMAT_DIFFSTAT 0x0002
Junio C Hamano74e2abe2006-10-12 03:01:00 -070045#define DIFF_FORMAT_NUMSTAT 0x0004
46#define DIFF_FORMAT_SUMMARY 0x0008
47#define DIFF_FORMAT_PATCH 0x0010
Nicolas Pitreebd124c2006-12-14 23:15:44 -050048#define DIFF_FORMAT_SHORTSTAT 0x0020
Linus Torvalds7df7c012008-02-12 13:26:31 -080049#define DIFF_FORMAT_DIRSTAT 0x0040
Timo Hirvonenc6744342006-06-24 20:21:53 +030050
51/* These override all above */
Junio C Hamano74e2abe2006-10-12 03:01:00 -070052#define DIFF_FORMAT_NAME 0x0100
53#define DIFF_FORMAT_NAME_STATUS 0x0200
54#define DIFF_FORMAT_CHECKDIFF 0x0400
Timo Hirvonenc6744342006-06-24 20:21:53 +030055
56/* Same as output_format = 0 but we know that -s flag was given
57 * and we should not give default value to output_format.
58 */
Junio C Hamano74e2abe2006-10-12 03:01:00 -070059#define DIFF_FORMAT_NO_OUTPUT 0x0800
Timo Hirvonenc6744342006-06-24 20:21:53 +030060
Junio C Hamano74e2abe2006-10-12 03:01:00 -070061#define DIFF_FORMAT_CALLBACK 0x1000
Jeff King04245582006-09-07 02:35:42 -040062
Pierre Habouzit8f67f8a2007-11-10 20:05:14 +010063#define DIFF_OPT_RECURSIVE (1 << 0)
64#define DIFF_OPT_TREE_IN_RECURSIVE (1 << 1)
65#define DIFF_OPT_BINARY (1 << 2)
66#define DIFF_OPT_TEXT (1 << 3)
67#define DIFF_OPT_FULL_INDEX (1 << 4)
68#define DIFF_OPT_SILENT_ON_REMOVE (1 << 5)
69#define DIFF_OPT_FIND_COPIES_HARDER (1 << 6)
70#define DIFF_OPT_FOLLOW_RENAMES (1 << 7)
Jeff King90d43b02012-03-22 18:52:13 -040071#define DIFF_OPT_RENAME_EMPTY (1 << 8)
Thomas Rast882749a2010-04-14 17:59:06 +020072/* (1 << 9) unused */
Pierre Habouzit8f67f8a2007-11-10 20:05:14 +010073#define DIFF_OPT_HAS_CHANGES (1 << 10)
Junio C Hamano90b19942009-05-23 01:15:35 -070074#define DIFF_OPT_QUICK (1 << 11)
Pierre Habouzit8f67f8a2007-11-10 20:05:14 +010075#define DIFF_OPT_NO_INDEX (1 << 12)
76#define DIFF_OPT_ALLOW_EXTERNAL (1 << 13)
77#define DIFF_OPT_EXIT_WITH_STATUS (1 << 14)
78#define DIFF_OPT_REVERSE_DIFF (1 << 15)
Wincent Colaiuta62c64892007-12-13 21:24:52 +010079#define DIFF_OPT_CHECK_FAILED (1 << 16)
Junio C Hamanocd676a52008-02-12 14:26:02 -080080#define DIFF_OPT_RELATIVE_NAME (1 << 17)
Johannes Schindelin50fd9bd2008-05-14 18:03:31 +010081#define DIFF_OPT_IGNORE_SUBMODULES (1 << 18)
Junio C Hamanof88d2252008-09-02 17:28:59 -070082#define DIFF_OPT_DIRSTAT_CUMULATIVE (1 << 19)
Heikki Orsilafd337772008-09-05 22:27:35 +030083#define DIFF_OPT_DIRSTAT_BY_FILE (1 << 20)
Jeff Kingc7534ef2008-10-26 00:45:55 -040084#define DIFF_OPT_ALLOW_TEXTCONV (1 << 21)
Junio C Hamanof2451942009-05-22 12:45:29 -070085#define DIFF_OPT_DIFF_FROM_CONTENTS (1 << 22)
Jens Lehmann9297f77e62010-03-08 13:53:19 +010086#define DIFF_OPT_DIRTY_SUBMODULES (1 << 24)
Jens Lehmann3bfc4502010-03-13 23:00:27 +010087#define DIFF_OPT_IGNORE_UNTRACKED_IN_SUBMODULES (1 << 25)
Junio C Hamano4af574d2010-06-27 12:07:44 -070088#define DIFF_OPT_IGNORE_DIRTY_SUBMODULES (1 << 26)
Jens Lehmannaee9c7d2010-08-06 00:39:25 +020089#define DIFF_OPT_OVERRIDE_SUBMODULE_CONFIG (1 << 27)
Johan Herland1c57a622011-04-29 11:36:21 +020090#define DIFF_OPT_DIRSTAT_BY_LINE (1 << 28)
René Scharfe14937c22011-10-09 13:36:57 +020091#define DIFF_OPT_FUNCCONTEXT (1 << 29)
Junio C Hamanoaccccde2012-02-21 01:02:46 -080092#define DIFF_OPT_PICKAXE_IGNORE_CASE (1 << 30)
Jeff King9a93c662015-12-29 01:35:46 -050093#define DIFF_OPT_DEFAULT_FOLLOW_RENAMES (1U << 31)
Johannes Schindelin752c0c22009-10-19 14:38:32 +020094
Pierre Habouzit8f67f8a2007-11-10 20:05:14 +010095#define DIFF_OPT_TST(opts, flag) ((opts)->flags & DIFF_OPT_##flag)
Junio C Hamano6c374002013-05-10 17:10:11 +020096#define DIFF_OPT_TOUCHED(opts, flag) ((opts)->touched_flags & DIFF_OPT_##flag)
97#define DIFF_OPT_SET(opts, flag) (((opts)->flags |= DIFF_OPT_##flag),((opts)->touched_flags |= DIFF_OPT_##flag))
98#define DIFF_OPT_CLR(opts, flag) (((opts)->flags &= ~DIFF_OPT_##flag),((opts)->touched_flags |= DIFF_OPT_##flag))
Keith Cascio628d5c22009-02-16 19:26:49 -080099#define DIFF_XDL_TST(opts, flag) ((opts)->xdl_opts & XDF_##flag)
100#define DIFF_XDL_SET(opts, flag) ((opts)->xdl_opts |= XDF_##flag)
101#define DIFF_XDL_CLR(opts, flag) ((opts)->xdl_opts &= ~XDF_##flag)
Pierre Habouzit8f67f8a2007-11-10 20:05:14 +0100102
Junio C Hamano307ab202012-02-19 15:36:55 -0800103#define DIFF_WITH_ALG(opts, flag) (((opts)->xdl_opts & ~XDF_DIFF_ALGORITHM_MASK) | XDF_##flag)
104
Thomas Rast882749a2010-04-14 17:59:06 +0200105enum diff_words_type {
106 DIFF_WORDS_NONE = 0,
107 DIFF_WORDS_PORCELAIN,
108 DIFF_WORDS_PLAIN,
109 DIFF_WORDS_COLOR
110};
111
Jacob Keller61cfbc02016-08-31 16:27:21 -0700112enum diff_submodule_format {
113 DIFF_SUBMODULE_SHORT = 0,
Jacob Kellerfd47ae62016-08-31 16:27:25 -0700114 DIFF_SUBMODULE_LOG,
115 DIFF_SUBMODULE_INLINE_DIFF
Jacob Keller61cfbc02016-08-31 16:27:21 -0700116};
117
Junio C Hamano6b5ee132005-09-21 00:00:47 -0700118struct diff_options {
Junio C Hamano6b5ee132005-09-21 00:00:47 -0700119 const char *orderfile;
120 const char *pickaxe;
Junio C Hamano2f3f8b22006-11-02 00:02:11 -0800121 const char *single_follow;
Johannes Schindelineab9a402007-12-18 19:32:14 +0000122 const char *a_prefix, *b_prefix;
Jacob Keller660e1132016-08-31 16:27:20 -0700123 const char *line_prefix;
124 size_t line_prefix_length;
Pierre Habouzit8f67f8a2007-11-10 20:05:14 +0100125 unsigned flags;
Junio C Hamano6c374002013-05-10 17:10:11 +0200126 unsigned touched_flags;
Junio C Hamano1ecc1cb2013-07-17 15:05:46 -0700127
128 /* diff-filter bits */
129 unsigned int filter;
130
Jeff Kingf1c96262011-08-17 22:03:12 -0700131 int use_color;
Linus Torvaldsee1e5412006-05-13 13:23:48 -0700132 int context;
René Scharfe6d0e6742008-12-28 19:45:32 +0100133 int interhunkcontext;
Junio C Hamano6b5ee132005-09-21 00:00:47 -0700134 int break_opt;
135 int detect_rename;
Junio C Hamano467ddc12011-02-28 16:11:55 -0800136 int irreversible_delete;
Junio C Hamanofb132272007-08-03 13:33:31 -0700137 int skip_stat_unmatch;
Junio C Hamano6b5ee132005-09-21 00:00:47 -0700138 int line_termination;
139 int output_format;
140 int pickaxe_opts;
141 int rename_score;
Junio C Hamano8082d8d2005-09-21 00:18:27 -0700142 int rename_limit;
Jeff Kingbf0ab102011-02-19 05:20:51 -0500143 int needed_rename_limit;
Junio C Hamanof31027c2011-01-06 13:50:06 -0800144 int degraded_cc_to_c;
Jeff King3ac942d2011-02-20 04:51:16 -0500145 int show_rename_progress;
Johan Herland712d2c72011-04-29 11:36:20 +0200146 int dirstat_permille;
Junio C Hamano6b5ee132005-09-21 00:00:47 -0700147 int setup;
Junio C Hamano47dd0d52005-12-13 17:21:41 -0800148 int abbrev;
Nguyễn Thái Ngọc Duy425a28e2016-10-24 17:42:19 +0700149 int ita_invisible_in_index;
Junio C Hamanob8767f72015-05-26 10:11:28 -0700150/* white-space error highlighting */
151#define WSEH_NEW 1
152#define WSEH_CONTEXT 2
153#define WSEH_OLD 4
154 unsigned ws_error_highlight;
Junio C Hamanocd676a52008-02-12 14:26:02 -0800155 const char *prefix;
156 int prefix_length;
Johannes Schindelin698ce6f2006-05-20 15:40:29 +0200157 const char *stat_sep;
Johannes Schindelin0d21efa2006-06-14 17:40:23 +0200158 long xdl_opts;
Linus Torvaldsac1b3d12005-10-20 21:05:05 -0700159
Junio C Hamanoa2540022006-09-26 18:53:02 -0700160 int stat_width;
161 int stat_name_width;
Zbigniew Jędrzejewski-Szmek969fe572012-03-01 13:26:45 +0100162 int stat_graph_width;
Michael J Gruber808e1db2011-05-27 14:36:41 +0200163 int stat_count;
Johannes Schindelin2b6a5412009-01-17 17:29:45 +0100164 const char *word_regex;
Thomas Rast882749a2010-04-14 17:59:06 +0200165 enum diff_words_type word_diff;
Jacob Keller61cfbc02016-08-31 16:27:21 -0700166 enum diff_submodule_format submodule_format;
Junio C Hamanoa2540022006-09-26 18:53:02 -0700167
Johannes Schindelin34a5e1a2007-02-25 23:34:54 +0100168 /* this is set by diffcore for DIFF_FORMAT_PATCH */
169 int found_changes;
170
Junio C Hamano44c48a92010-08-13 12:17:45 -0700171 /* to support internal diff recursion by --follow hack*/
172 int found_follow;
173
Junio C Hamano6c374002013-05-10 17:10:11 +0200174 void (*set_default)(struct diff_options *);
175
Daniel Barkalowc0c77732008-03-09 22:43:39 -0400176 FILE *file;
177 int close_file;
178
Nguyễn Thái Ngọc Duy66f13622010-12-15 22:02:38 +0700179 struct pathspec pathspec;
Kirill Smelkov72441af2014-04-07 01:46:26 +0400180 pathchange_fn_t pathchange;
Linus Torvaldsac1b3d12005-10-20 21:05:05 -0700181 change_fn_t change;
182 add_remove_fn_t add_remove;
Jeff King04245582006-09-07 02:35:42 -0400183 diff_format_fn_t format_callback;
184 void *format_callback_data;
Bo Yanga3c158d2010-05-26 15:08:02 +0800185 diff_prefix_fn_t output_prefix;
186 void *output_prefix_data;
Zoltan Klingeree7fb0b2013-12-06 10:38:46 +1100187
188 int diff_path_counter;
Junio C Hamano6b5ee132005-09-21 00:00:47 -0700189};
190
Jeff Kingce436972006-07-23 05:24:18 -0400191enum color_diff {
192 DIFF_RESET = 0,
Jeff King8dbf3eb2015-05-27 16:48:46 -0400193 DIFF_CONTEXT = 1,
Jeff Kingce436972006-07-23 05:24:18 -0400194 DIFF_METAINFO = 2,
195 DIFF_FRAGINFO = 3,
196 DIFF_FILE_OLD = 4,
197 DIFF_FILE_NEW = 5,
198 DIFF_COMMIT = 6,
Junio C Hamano448c3ef2006-09-22 22:48:39 -0700199 DIFF_WHITESPACE = 7,
Gary V. Vaughan4b055482010-05-14 09:31:35 +0000200 DIFF_FUNCINFO = 8
Jeff Kingce436972006-07-23 05:24:18 -0400201};
202const char *diff_get_color(int diff_use_color, enum color_diff ix);
Pierre Habouzit8f67f8a2007-11-10 20:05:14 +0100203#define diff_get_color_opt(o, ix) \
Jeff Kingf1c96262011-08-17 22:03:12 -0700204 diff_get_color((o)->use_color, ix)
Pierre Habouzit8f67f8a2007-11-10 20:05:14 +0100205
Jeff Kingce436972006-07-23 05:24:18 -0400206
John Keepingf1922232013-02-07 20:15:26 +0000207const char *diff_line_prefix(struct diff_options *);
208
209
Johannes Schindelin698ce6f2006-05-20 15:40:29 +0200210extern const char mime_boundary_leader[];
211
Kirill Smelkov72441af2014-04-07 01:46:26 +0400212extern struct combine_diff_path *diff_tree_paths(
Brandon Williamsfda94b42017-05-30 10:31:06 -0700213 struct combine_diff_path *p, const struct object_id *oid,
214 const struct object_id **parents_oid, int nparent,
Kirill Smelkov72441af2014-04-07 01:46:26 +0400215 struct strbuf *base, struct diff_options *opt);
Brandon Williams66f414f2017-05-30 10:31:03 -0700216extern int diff_tree_oid(const struct object_id *old_oid,
217 const struct object_id *new_oid,
218 const char *base, struct diff_options *opt);
Brandon Williams7b8dea02017-05-30 10:30:57 -0700219extern int diff_root_tree_oid(const struct object_id *new_oid, const char *base,
220 struct diff_options *opt);
Linus Torvaldsac1b3d12005-10-20 21:05:05 -0700221
Junio C Hamanoea726d02006-01-28 00:03:38 -0800222struct combine_diff_path {
223 struct combine_diff_path *next;
Junio C Hamanoea726d02006-01-28 00:03:38 -0800224 char *path;
Junio C Hamano2454c962006-02-06 12:53:07 -0800225 unsigned int mode;
brian m. carlson1ff57c12015-03-13 23:39:33 +0000226 struct object_id oid;
Junio C Hamano2454c962006-02-06 12:53:07 -0800227 struct combine_diff_parent {
Junio C Hamanod416df82006-02-10 02:30:52 -0800228 char status;
Junio C Hamano2454c962006-02-06 12:53:07 -0800229 unsigned int mode;
brian m. carlson1ff57c12015-03-13 23:39:33 +0000230 struct object_id oid;
Junio C Hamano2454c962006-02-06 12:53:07 -0800231 } parent[FLEX_ARRAY];
Junio C Hamanoea726d02006-01-28 00:03:38 -0800232};
Junio C Hamano2454c962006-02-06 12:53:07 -0800233#define combine_diff_path_size(n, l) \
Jeff King5b442c42016-02-19 06:21:30 -0500234 st_add4(sizeof(struct combine_diff_path), (l), 1, \
235 st_mult(sizeof(struct combine_diff_parent), (n)))
Junio C Hamanoea726d02006-01-28 00:03:38 -0800236
Linus Torvalds91539832006-04-17 11:59:32 -0700237extern void show_combined_diff(struct combine_diff_path *elem, int num_parent,
238 int dense, struct rev_info *);
Junio C Hamanoea726d02006-01-28 00:03:38 -0800239
Brandon Williamsb9acf542017-05-30 10:30:55 -0700240extern void diff_tree_combined(const struct object_id *oid, const struct oid_array *parents, int dense, struct rev_info *rev);
Junio C Hamano0fe7c1d2006-04-29 01:24:49 -0700241
René Scharfe82889292011-12-17 11:20:07 +0100242extern void diff_tree_combined_merge(const struct commit *commit, int dense, struct rev_info *rev);
Junio C Hamanoaf3feef2006-01-24 01:22:04 -0800243
Junio C Hamanoa5a818e2008-08-18 20:08:09 -0700244void diff_set_mnemonic_prefix(struct diff_options *options, const char *a, const char *b);
245
Junio C Hamano28b92642011-05-31 09:14:17 -0700246extern int diff_can_quit_early(struct diff_options *);
247
Junio C Hamano6b5ee132005-09-21 00:00:47 -0700248extern void diff_addremove(struct diff_options *,
249 int addremove,
Junio C Hamano77eb2722005-04-27 09:21:00 -0700250 unsigned mode,
Brandon Williamsc26022e2017-05-30 10:30:47 -0700251 const struct object_id *oid,
252 int oid_valid,
Jens Lehmanne3d42c42010-01-18 21:26:18 +0100253 const char *fullpath, unsigned dirty_submodule);
Junio C Hamano77eb2722005-04-27 09:21:00 -0700254
Junio C Hamano6b5ee132005-09-21 00:00:47 -0700255extern void diff_change(struct diff_options *,
256 unsigned mode1, unsigned mode2,
Brandon Williams94a00972017-05-30 10:30:49 -0700257 const struct object_id *old_oid,
258 const struct object_id *new_oid,
259 int old_oid_valid, int new_oid_valid,
Jens Lehmanne3d42c42010-01-18 21:26:18 +0100260 const char *fullpath,
261 unsigned dirty_submodule1, unsigned dirty_submodule2);
Junio C Hamano77eb2722005-04-27 09:21:00 -0700262
Junio C Hamanofa7b2902011-04-22 16:05:58 -0700263extern struct diff_filepair *diff_unmerge(struct diff_options *, const char *path);
Junio C Hamano77eb2722005-04-27 09:21:00 -0700264
Junio C Hamano19feebc2005-05-27 15:54:37 -0700265#define DIFF_SETUP_REVERSE 1
Junio C Hamanof0c6b2a2005-05-27 15:56:38 -0700266#define DIFF_SETUP_USE_CACHE 2
267#define DIFF_SETUP_USE_SIZE_CACHE 4
Junio C Hamanoce240672005-06-03 01:36:43 -0700268
Matthieu Moydea007f2010-08-05 10:22:52 +0200269/*
Nicolas Vigierb0d12fc2013-10-31 12:08:28 +0100270 * Poor man's alternative to parse-option, to allow both stuck form
Matthieu Moydea007f2010-08-05 10:22:52 +0200271 * (--option=value) and separate form (--option value).
272 */
273extern int parse_long_opt(const char *opt, const char **argv,
274 const char **optarg);
275
Johannes Schindelinef90d6d2008-05-14 18:46:53 +0100276extern int git_diff_basic_config(const char *var, const char *value, void *cb);
Michael Haggerty5b162872016-09-05 11:44:53 +0200277extern int git_diff_heuristic_config(const char *var, const char *value, void *cb);
Matthieu Moy5404c112016-02-25 09:59:21 +0100278extern void init_diff_ui_defaults(void);
Johannes Schindelinef90d6d2008-05-14 18:46:53 +0100279extern int git_diff_ui_config(const char *var, const char *value, void *cb);
Junio C Hamano6b5ee132005-09-21 00:00:47 -0700280extern void diff_setup(struct diff_options *);
Duy Nguyena97262c2016-01-21 18:48:44 +0700281extern int diff_opt_parse(struct diff_options *, const char **, int, const char *);
Thomas Rast28452652012-08-03 14:16:24 +0200282extern void diff_setup_done(struct diff_options *);
Junio C Hamano86436c22005-04-25 18:22:47 -0700283
Junio C Hamano6b14d7f2005-05-22 10:04:37 -0700284#define DIFF_DETECT_RENAME 1
285#define DIFF_DETECT_COPY 2
286
Junio C Hamano367cec12005-05-27 15:55:28 -0700287#define DIFF_PICKAXE_ALL 1
Petr Baudisd01d8c62006-03-29 02:16:33 +0200288#define DIFF_PICKAXE_REGEX 2
Junio C Hamanof345b0a2005-05-30 00:08:37 -0700289
Junio C Hamanof506b8e2010-08-23 10:17:03 -0700290#define DIFF_PICKAXE_KIND_S 4 /* traditional plumbing counter */
291#define DIFF_PICKAXE_KIND_G 8 /* grep in the patch */
292
Junio C Hamano6b5ee132005-09-21 00:00:47 -0700293extern void diffcore_std(struct diff_options *);
Junio C Hamano730f7282009-09-20 00:03:39 -0700294extern void diffcore_fix_diff_index(struct diff_options *);
Junio C Hamanof2ce9fd2005-06-11 20:57:13 -0700295
Junio C Hamanodda2d792005-07-13 12:52:35 -0700296#define COMMON_DIFF_OPTIONS_HELP \
297"\ncommon diff options:\n" \
Junio C Hamano8082d8d2005-09-21 00:18:27 -0700298" -z output diff-raw with lines terminated with NUL.\n" \
299" -p output patch format.\n" \
300" -u synonym for -p.\n" \
Petr Baudis5c91da22006-04-11 13:22:17 +0200301" --patch-with-raw\n" \
302" output both a patch and the diff-raw format.\n" \
Johannes Schindelind75f7952006-04-14 00:15:30 +0200303" --stat show diffstat instead of patch.\n" \
Junio C Hamano74e2abe2006-10-12 03:01:00 -0700304" --numstat show numeric diffstat instead of patch.\n" \
Johannes Schindelin29353272006-04-15 13:41:18 +0200305" --patch-with-stat\n" \
306" output a patch and prepend its diffstat.\n" \
Junio C Hamano8082d8d2005-09-21 00:18:27 -0700307" --name-only show only names of changed files.\n" \
Junio C Hamano946f5f72005-09-21 00:20:06 -0700308" --name-status show names and status of changed files.\n" \
Junio C Hamano47dd0d52005-12-13 17:21:41 -0800309" --full-index show full object name on index lines.\n" \
Junio C Hamano913419f2005-12-18 02:03:15 -0800310" --abbrev=<n> abbreviate object names in diff-tree header and diff-raw.\n" \
Junio C Hamano8082d8d2005-09-21 00:18:27 -0700311" -R swap input file pairs.\n" \
312" -B detect complete rewrites.\n" \
313" -M detect renames.\n" \
314" -C detect copies.\n" \
Junio C Hamanodda2d792005-07-13 12:52:35 -0700315" --find-copies-harder\n" \
Junio C Hamano8082d8d2005-09-21 00:18:27 -0700316" try unchanged files as candidate for copy detection.\n" \
317" -l<n> limit rename attempts up to <n> paths.\n" \
318" -O<file> reorder diffs according to the <file>.\n" \
319" -S<string> find filepair whose only one side contains the string.\n" \
Junio C Hamanodda2d792005-07-13 12:52:35 -0700320" --pickaxe-all\n" \
Stephan Federca499202006-07-07 15:57:08 +0200321" show all files diff when -S is used and hit is found.\n" \
322" -a --text treat all files as text.\n"
Junio C Hamanodda2d792005-07-13 12:52:35 -0700323
Junio C Hamano38c6f782005-05-21 19:40:36 -0700324extern int diff_queue_is_empty(void);
Junio C Hamano6b5ee132005-09-21 00:00:47 -0700325extern void diff_flush(struct diff_options*);
Junio C Hamanof31027c2011-01-06 13:50:06 -0800326extern void diff_warn_rename_limit(const char *varname, int needed, int degraded_cc);
Junio C Hamano86436c22005-04-25 18:22:47 -0700327
Junio C Hamanoe7baa4f2005-07-25 13:05:44 -0700328/* diff-raw status letters */
Junio C Hamanoca8c9152005-07-25 14:31:19 -0700329#define DIFF_STATUS_ADDED 'A'
Junio C Hamanoe7baa4f2005-07-25 13:05:44 -0700330#define DIFF_STATUS_COPIED 'C'
331#define DIFF_STATUS_DELETED 'D'
332#define DIFF_STATUS_MODIFIED 'M'
333#define DIFF_STATUS_RENAMED 'R'
334#define DIFF_STATUS_TYPE_CHANGED 'T'
335#define DIFF_STATUS_UNKNOWN 'X'
336#define DIFF_STATUS_UNMERGED 'U'
337
338/* these are not diff-raw status letters proper, but used by
339 * diffcore-filter insn to specify additional restrictions.
340 */
Junio C Hamano0b343792005-10-04 17:44:17 -0700341#define DIFF_STATUS_FILTER_AON '*'
Junio C Hamanoe7baa4f2005-07-25 13:05:44 -0700342#define DIFF_STATUS_FILTER_BROKEN 'B'
343
Jeff Kingd5e3b012016-10-20 02:19:43 -0400344/*
345 * This is different from find_unique_abbrev() in that
346 * it stuffs the result with dots for alignment.
347 */
Jeff Kingd6cece52016-10-20 02:20:07 -0400348extern const char *diff_aligned_abbrev(const struct object_id *sha1, int);
Junio C Hamano47dd0d52005-12-13 17:21:41 -0800349
Junio C Hamano4bd5b7d2007-11-10 00:15:03 -0800350/* do not report anything on removed paths */
351#define DIFF_SILENT_ON_REMOVED 01
Junio C Hamanofb63d7f2007-11-09 18:22:52 -0800352/* report racily-clean paths as modified */
353#define DIFF_RACY_IS_MODIFIED 02
Junio C Hamano4bd5b7d2007-11-10 00:15:03 -0800354extern int run_diff_files(struct rev_info *revs, unsigned int option);
Junio C Hamano5c21ac02006-04-22 03:58:04 -0700355extern int run_diff_index(struct rev_info *revs, int cached);
Junio C Hamanoe09ad6e2006-04-22 02:43:00 -0700356
brian m. carlson944cffb2017-05-06 22:10:35 +0000357extern int do_diff_cache(const struct object_id *, struct diff_options *);
Brandon Williamsbd25f282017-05-30 10:30:54 -0700358extern int diff_flush_patch_id(struct diff_options *, struct object_id *, int);
Johannes Schindelinfcb3d0a2006-06-25 03:51:08 +0200359
Junio C Hamanoda31b352007-12-13 23:40:27 -0800360extern int diff_result_code(struct diff_options *, int);
361
Nguyễn Thái Ngọc Duye5f7a5d2016-01-20 18:06:02 +0700362extern void diff_no_index(struct rev_info *, int, const char **);
Junio C Hamano0569e9b2008-05-23 22:28:56 -0700363
Nguyễn Thái Ngọc Duy018ec3c2016-10-24 17:42:21 +0700364extern int index_differs_from(const char *def, int diff_flags, int ita_invisible_in_index);
Stephan Beyer75f3ff22009-02-10 15:30:35 +0100365
Jeff Kinga64e6a42016-02-22 13:28:54 -0500366/*
367 * Fill the contents of the filespec "df", respecting any textconv defined by
368 * its userdiff driver. The "driver" parameter must come from a
369 * previous call to get_textconv(), and therefore should either be NULL or have
370 * textconv enabled.
371 *
372 * Note that the memory ownership of the resulting buffer depends on whether
373 * the driver field is NULL. If it is, then the memory belongs to the filespec
374 * struct. If it is non-NULL, then "outbuf" points to a newly allocated buffer
375 * that should be freed by the caller.
376 */
Axel Bonneta788d7d2010-06-07 17:23:36 +0200377extern size_t fill_textconv(struct userdiff_driver *driver,
378 struct diff_filespec *df,
379 char **outbuf);
380
Jeff Kinga64e6a42016-02-22 13:28:54 -0500381/*
382 * Look up the userdiff driver for the given filespec, and return it if
383 * and only if it has textconv enabled (otherwise return NULL). The result
384 * can be passed to fill_textconv().
385 */
Axel Bonneta788d7d2010-06-07 17:23:36 +0200386extern struct userdiff_driver *get_textconv(struct diff_filespec *one);
387
Jeff Smith3a35cb22017-05-24 00:15:10 -0500388/*
389 * Prepare diff_filespec and convert it using diff textconv API
390 * if the textconv driver exists.
391 * Return 1 if the conversion succeeds, 0 otherwise.
392 */
393extern int textconv_object(const char *path, unsigned mode, const struct object_id *oid, int oid_valid, char **buf, unsigned long *buf_size);
394
Kevin Ballard10ae7522010-09-27 16:58:25 -0700395extern int parse_rename_score(const char **cp_p);
396
Michal Privoznik07924d42013-01-16 08:51:58 +0100397extern long parse_algorithm_value(const char *value);
398
Nguyễn Thái Ngọc Duy7f814632012-02-01 19:55:07 +0700399extern int print_stat_summary(FILE *fp, int files,
400 int insertions, int deletions);
Nguyễn Thái Ngọc Duy4914c962012-10-26 22:53:52 +0700401extern void setup_diff_pager(struct diff_options *);
Nguyễn Thái Ngọc Duy7f814632012-02-01 19:55:07 +0700402
Junio C Hamano86436c22005-04-25 18:22:47 -0700403#endif /* DIFF_H */