Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 268 lines (225 sloc) 8.726 kB
be3cfa8 [PATCH] Diff-tree-helper take two.
Junio C Hamano authored
1 /*
2 * Copyright (C) 2005 Junio C Hamano
3 */
86436c2 [PATCH] Split external diff command interface to a separate file.
Junio C Hamano authored
4 #ifndef DIFF_H
5 #define DIFF_H
6
1b0c717 tree/diff header cleanup.
Junio C Hamano authored
7 #include "tree-walk.h"
50f9a85 Make the "struct tree_desc" operations available to others
Linus Torvalds authored
8
9153983 Log message printout cleanups
Linus Torvalds authored
9 struct rev_info;
ac1b3d1 Split up tree diff functions into tree-diff.c library
Linus Torvalds authored
10 struct diff_options;
0424558 @peff diff: support custom callbacks for output
peff authored
11 struct diff_queue_struct;
ac1b3d1 Split up tree diff functions into tree-diff.c library
Linus Torvalds authored
12
13 typedef void (*change_fn_t)(struct diff_options *options,
14 unsigned old_mode, unsigned new_mode,
15 const unsigned char *old_sha1,
16 const unsigned char *new_sha1,
fd55a19 @dmpot Fix buffer overflow in git diff
dmpot authored
17 const char *fullpath);
ac1b3d1 Split up tree diff functions into tree-diff.c library
Linus Torvalds authored
18
19 typedef void (*add_remove_fn_t)(struct diff_options *options,
20 int addremove, unsigned mode,
21 const unsigned char *sha1,
fd55a19 @dmpot Fix buffer overflow in git diff
dmpot authored
22 const char *fullpath);
ac1b3d1 Split up tree diff functions into tree-diff.c library
Linus Torvalds authored
23
0424558 @peff diff: support custom callbacks for output
peff authored
24 typedef void (*diff_format_fn_t)(struct diff_queue_struct *q,
25 struct diff_options *options, void *data);
26
c674434 @tihirvon Merge with_raw, with_stat and summary variables to output_format
tihirvon authored
27 #define DIFF_FORMAT_RAW 0x0001
28 #define DIFF_FORMAT_DIFFSTAT 0x0002
74e2abe diff --numstat
Junio C Hamano authored
29 #define DIFF_FORMAT_NUMSTAT 0x0004
30 #define DIFF_FORMAT_SUMMARY 0x0008
31 #define DIFF_FORMAT_PATCH 0x0010
ebd124c make commit message a little more consistent and conforting
Nicolas Pitre authored
32 #define DIFF_FORMAT_SHORTSTAT 0x0020
7df7c01 @torvalds Add "--dirstat" for some directory statistics
torvalds authored
33 #define DIFF_FORMAT_DIRSTAT 0x0040
c674434 @tihirvon Merge with_raw, with_stat and summary variables to output_format
tihirvon authored
34
35 /* These override all above */
74e2abe diff --numstat
Junio C Hamano authored
36 #define DIFF_FORMAT_NAME 0x0100
37 #define DIFF_FORMAT_NAME_STATUS 0x0200
38 #define DIFF_FORMAT_CHECKDIFF 0x0400
c674434 @tihirvon Merge with_raw, with_stat and summary variables to output_format
tihirvon authored
39
40 /* Same as output_format = 0 but we know that -s flag was given
41 * and we should not give default value to output_format.
42 */
74e2abe diff --numstat
Junio C Hamano authored
43 #define DIFF_FORMAT_NO_OUTPUT 0x0800
c674434 @tihirvon Merge with_raw, with_stat and summary variables to output_format
tihirvon authored
44
74e2abe diff --numstat
Junio C Hamano authored
45 #define DIFF_FORMAT_CALLBACK 0x1000
0424558 @peff diff: support custom callbacks for output
peff authored
46
8f67f8a @MadCoder Make the diff_options bitfields be an unsigned with explicit masks.
MadCoder authored
47 #define DIFF_OPT_RECURSIVE (1 << 0)
48 #define DIFF_OPT_TREE_IN_RECURSIVE (1 << 1)
49 #define DIFF_OPT_BINARY (1 << 2)
50 #define DIFF_OPT_TEXT (1 << 3)
51 #define DIFF_OPT_FULL_INDEX (1 << 4)
52 #define DIFF_OPT_SILENT_ON_REMOVE (1 << 5)
53 #define DIFF_OPT_FIND_COPIES_HARDER (1 << 6)
54 #define DIFF_OPT_FOLLOW_RENAMES (1 << 7)
55 #define DIFF_OPT_COLOR_DIFF (1 << 8)
56 #define DIFF_OPT_COLOR_DIFF_WORDS (1 << 9)
57 #define DIFF_OPT_HAS_CHANGES (1 << 10)
58 #define DIFF_OPT_QUIET (1 << 11)
59 #define DIFF_OPT_NO_INDEX (1 << 12)
60 #define DIFF_OPT_ALLOW_EXTERNAL (1 << 13)
61 #define DIFF_OPT_EXIT_WITH_STATUS (1 << 14)
62 #define DIFF_OPT_REVERSE_DIFF (1 << 15)
62c6489 @wincent "diff --check" should affect exit status
wincent authored
63 #define DIFF_OPT_CHECK_FAILED (1 << 16)
cd676a5 @gitster diff --relative: output paths as relative to the current subdirectory
gitster authored
64 #define DIFF_OPT_RELATIVE_NAME (1 << 17)
50fd9bd @dscho diff options: Introduce --ignore-submodules
dscho authored
65 #define DIFF_OPT_IGNORE_SUBMODULES (1 << 18)
f88d225 @gitster diff --cumulative is a sub-option of --dirstat
gitster authored
66 #define DIFF_OPT_DIRSTAT_CUMULATIVE (1 << 19)
fd33777 @heikkiorsila diff --dirstat-by-file: count changed files, not lines
heikkiorsila authored
67 #define DIFF_OPT_DIRSTAT_BY_FILE (1 << 20)
c7534ef @peff userdiff: require explicitly allowing textconv
peff authored
68 #define DIFF_OPT_ALLOW_TEXTCONV (1 << 21)
8f67f8a @MadCoder Make the diff_options bitfields be an unsigned with explicit masks.
MadCoder authored
69 #define DIFF_OPT_TST(opts, flag) ((opts)->flags & DIFF_OPT_##flag)
70 #define DIFF_OPT_SET(opts, flag) ((opts)->flags |= DIFF_OPT_##flag)
71 #define DIFF_OPT_CLR(opts, flag) ((opts)->flags &= ~DIFF_OPT_##flag)
72
6b5ee13 Diff clean-up.
Junio C Hamano authored
73 struct diff_options {
74 const char *filter;
75 const char *orderfile;
76 const char *pickaxe;
2f3f8b2 git-pickaxe: rename detection optimization
Junio C Hamano authored
77 const char *single_follow;
eab9a40 @dscho Teach diff machinery to display other prefixes than "a/" and "b/"
dscho authored
78 const char *a_prefix, *b_prefix;
8f67f8a @MadCoder Make the diff_options bitfields be an unsigned with explicit masks.
MadCoder authored
79 unsigned flags;
ee1e541 git diff: support "-U" and "--unified" options properly
Linus Torvalds authored
80 int context;
6d0e674 diff: add option to show context between close hunks
René Scharfe authored
81 int interhunkcontext;
6b5ee13 Diff clean-up.
Junio C Hamano authored
82 int break_opt;
83 int detect_rename;
fb13227 @gitster git-diff: squelch "empty" diffs
gitster authored
84 int skip_stat_unmatch;
6b5ee13 Diff clean-up.
Junio C Hamano authored
85 int line_termination;
86 int output_format;
87 int pickaxe_opts;
88 int rename_score;
8082d8d Diff: -l<num> to limit rename/copy detection.
Junio C Hamano authored
89 int rename_limit;
b8960bb @peff diff: make "too many files" rename warning optional
peff authored
90 int warn_on_too_large_rename;
7df7c01 @torvalds Add "--dirstat" for some directory statistics
torvalds authored
91 int dirstat_percent;
6b5ee13 Diff clean-up.
Junio C Hamano authored
92 int setup;
47dd0d5 diff: --abbrev option
Junio C Hamano authored
93 int abbrev;
cd676a5 @gitster diff --relative: output paths as relative to the current subdirectory
gitster authored
94 const char *prefix;
95 int prefix_length;
698ce6f @dscho fmt-patch: Support --attach
dscho authored
96 const char *stat_sep;
0d21efa @dscho Teach diff about -b and -w flags
dscho authored
97 long xdl_opts;
ac1b3d1 Split up tree diff functions into tree-diff.c library
Linus Torvalds authored
98
a254002 diff --stat: allow custom diffstat output width.
Junio C Hamano authored
99 int stat_width;
100 int stat_name_width;
101
34a5e1a @dscho diff --no-index: also imitate the exit status of diff(1)
dscho authored
102 /* this is set by diffcore for DIFF_FORMAT_PATCH */
103 int found_changes;
104
c0c7773 Write diff output to a file in struct diff_options
Daniel Barkalow authored
105 FILE *file;
106 int close_file;
107
a8baa7b tree-diff: do not assume we use only one pathspec
Junio C Hamano authored
108 int nr_paths;
109 const char **paths;
110 int *pathlens;
ac1b3d1 Split up tree diff functions into tree-diff.c library
Linus Torvalds authored
111 change_fn_t change;
112 add_remove_fn_t add_remove;
0424558 @peff diff: support custom callbacks for output
peff authored
113 diff_format_fn_t format_callback;
114 void *format_callback_data;
6b5ee13 Diff clean-up.
Junio C Hamano authored
115 };
116
ce43697 @peff Colorize 'commit' lines in log ui
peff authored
117 enum color_diff {
118 DIFF_RESET = 0,
119 DIFF_PLAIN = 1,
120 DIFF_METAINFO = 2,
121 DIFF_FRAGINFO = 3,
122 DIFF_FILE_OLD = 4,
123 DIFF_FILE_NEW = 5,
124 DIFF_COMMIT = 6,
448c3ef diff.c: second war on whitespace.
Junio C Hamano authored
125 DIFF_WHITESPACE = 7,
ce43697 @peff Colorize 'commit' lines in log ui
peff authored
126 };
127 const char *diff_get_color(int diff_use_color, enum color_diff ix);
8f67f8a @MadCoder Make the diff_options bitfields be an unsigned with explicit masks.
MadCoder authored
128 #define diff_get_color_opt(o, ix) \
129 diff_get_color(DIFF_OPT_TST((o), COLOR_DIFF), ix)
130
ce43697 @peff Colorize 'commit' lines in log ui
peff authored
131
698ce6f @dscho fmt-patch: Support --attach
dscho authored
132 extern const char mime_boundary_leader[];
133
a8baa7b tree-diff: do not assume we use only one pathspec
Junio C Hamano authored
134 extern void diff_tree_setup_paths(const char **paths, struct diff_options *);
135 extern void diff_tree_release_paths(struct diff_options *);
ac1b3d1 Split up tree diff functions into tree-diff.c library
Linus Torvalds authored
136 extern int diff_tree(struct tree_desc *t1, struct tree_desc *t2,
137 const char *base, struct diff_options *opt);
138 extern int diff_tree_sha1(const unsigned char *old, const unsigned char *new,
139 const char *base, struct diff_options *opt);
2b60356 Make git-cherry handle root trees
Rene Scharfe authored
140 extern int diff_root_tree_sha1(const unsigned char *new, const char *base,
141 struct diff_options *opt);
ac1b3d1 Split up tree diff functions into tree-diff.c library
Linus Torvalds authored
142
ea726d0 diff-files: -c and --cc options.
Junio C Hamano authored
143 struct combine_diff_path {
144 struct combine_diff_path *next;
145 int len;
146 char *path;
2454c96 combine-diff: show mode changes as well.
Junio C Hamano authored
147 unsigned int mode;
ea726d0 diff-files: -c and --cc options.
Junio C Hamano authored
148 unsigned char sha1[20];
2454c96 combine-diff: show mode changes as well.
Junio C Hamano authored
149 struct combine_diff_parent {
d416df8 combine-diff: Record diff status a bit more faithfully
Junio C Hamano authored
150 char status;
2454c96 combine-diff: show mode changes as well.
Junio C Hamano authored
151 unsigned int mode;
152 unsigned char sha1[20];
153 } parent[FLEX_ARRAY];
ea726d0 diff-files: -c and --cc options.
Junio C Hamano authored
154 };
2454c96 combine-diff: show mode changes as well.
Junio C Hamano authored
155 #define combine_diff_path_size(n, l) \
156 (sizeof(struct combine_diff_path) + \
157 sizeof(struct combine_diff_parent) * (n) + (l) + 1)
ea726d0 diff-files: -c and --cc options.
Junio C Hamano authored
158
9153983 Log message printout cleanups
Linus Torvalds authored
159 extern void show_combined_diff(struct combine_diff_path *elem, int num_parent,
160 int dense, struct rev_info *);
ea726d0 diff-files: -c and --cc options.
Junio C Hamano authored
161
0fe7c1d built-in diff: assorted updates.
Junio C Hamano authored
162 extern void diff_tree_combined(const unsigned char *sha1, const unsigned char parent[][20], int num_parent, int dense, struct rev_info *rev);
163
9153983 Log message printout cleanups
Linus Torvalds authored
164 extern void diff_tree_combined_merge(const unsigned char *sha1, int, struct rev_info *);
af3feef diff-tree -c: show a merge commit a bit more sensibly.
Junio C Hamano authored
165
a5a818e @gitster diff: vary default prefix depending on what are compared
gitster authored
166 void diff_set_mnemonic_prefix(struct diff_options *options, const char *a, const char *b);
167
6b5ee13 Diff clean-up.
Junio C Hamano authored
168 extern void diff_addremove(struct diff_options *,
169 int addremove,
77eb272 [PATCH] Reworked external diff interface.
Junio C Hamano authored
170 unsigned mode,
171 const unsigned char *sha1,
fd55a19 @dmpot Fix buffer overflow in git diff
dmpot authored
172 const char *fullpath);
77eb272 [PATCH] Reworked external diff interface.
Junio C Hamano authored
173
6b5ee13 Diff clean-up.
Junio C Hamano authored
174 extern void diff_change(struct diff_options *,
175 unsigned mode1, unsigned mode2,
176 const unsigned char *sha1,
177 const unsigned char *sha2,
fd55a19 @dmpot Fix buffer overflow in git diff
dmpot authored
178 const char *fullpath);
77eb272 [PATCH] Reworked external diff interface.
Junio C Hamano authored
179
6b5ee13 Diff clean-up.
Junio C Hamano authored
180 extern void diff_unmerge(struct diff_options *,
e9c8409 diff-index --cached --raw: show tree entry on the LHS for unmerged en…
Junio C Hamano authored
181 const char *path,
182 unsigned mode,
183 const unsigned char *sha1);
77eb272 [PATCH] Reworked external diff interface.
Junio C Hamano authored
184
19feebc [PATCH] Clean up diff_setup() to make it more extensible.
Junio C Hamano authored
185 #define DIFF_SETUP_REVERSE 1
f0c6b2a [PATCH] Optimize diff-tree -[CM] --stdin
Junio C Hamano authored
186 #define DIFF_SETUP_USE_CACHE 2
187 #define DIFF_SETUP_USE_SIZE_CACHE 4
ce24067 [PATCH] diff: Fix docs and add -O to diff-helper.
Junio C Hamano authored
188
ef90d6d @dscho Provide git_config with a callback-data parameter
dscho authored
189 extern int git_diff_basic_config(const char *var, const char *value, void *cb);
190 extern int git_diff_ui_config(const char *var, const char *value, void *cb);
6b2f2d9 @matthiask Add color.ui variable which globally enables colorization if set
matthiask authored
191 extern int diff_use_color_default;
6b5ee13 Diff clean-up.
Junio C Hamano authored
192 extern void diff_setup(struct diff_options *);
193 extern int diff_opt_parse(struct diff_options *, const char **, int);
194 extern int diff_setup_done(struct diff_options *);
86436c2 [PATCH] Split external diff command interface to a separate file.
Junio C Hamano authored
195
6b14d7f [PATCH] Diffcore updates.
Junio C Hamano authored
196 #define DIFF_DETECT_RENAME 1
197 #define DIFF_DETECT_COPY 2
198
367cec1 [PATCH] Add --pickaxe-all to diff-* brothers.
Junio C Hamano authored
199 #define DIFF_PICKAXE_ALL 1
d01d8c6 Support for pickaxe matching regular expressions
Petr Baudis authored
200 #define DIFF_PICKAXE_REGEX 2
f345b0a [PATCH] Add -B flag to diff-* brothers.
Junio C Hamano authored
201
6b5ee13 Diff clean-up.
Junio C Hamano authored
202 extern void diffcore_std(struct diff_options *);
f2ce9fd [PATCH] Add --diff-filter= output restriction to diff-* family.
Junio C Hamano authored
203
dda2d79 [PATCH] Clean up diff option descriptions.
Junio C Hamano authored
204 #define COMMON_DIFF_OPTIONS_HELP \
205 "\ncommon diff options:\n" \
8082d8d Diff: -l<num> to limit rename/copy detection.
Junio C Hamano authored
206 " -z output diff-raw with lines terminated with NUL.\n" \
207 " -p output patch format.\n" \
208 " -u synonym for -p.\n" \
5c91da2 Document --patch-with-raw
Petr Baudis authored
209 " --patch-with-raw\n" \
210 " output both a patch and the diff-raw format.\n" \
d75f795 @dscho diff-options: add --stat (take 2)
dscho authored
211 " --stat show diffstat instead of patch.\n" \
74e2abe diff --numstat
Junio C Hamano authored
212 " --numstat show numeric diffstat instead of patch.\n" \
2935327 @dscho diff-options: add --patch-with-stat
dscho authored
213 " --patch-with-stat\n" \
214 " output a patch and prepend its diffstat.\n" \
8082d8d Diff: -l<num> to limit rename/copy detection.
Junio C Hamano authored
215 " --name-only show only names of changed files.\n" \
946f5f7 Diff: --name-status output format.
Junio C Hamano authored
216 " --name-status show names and status of changed files.\n" \
47dd0d5 diff: --abbrev option
Junio C Hamano authored
217 " --full-index show full object name on index lines.\n" \
913419f diff --abbrev: document --abbrev=<n> form.
Junio C Hamano authored
218 " --abbrev=<n> abbreviate object names in diff-tree header and diff-raw.\n" \
8082d8d Diff: -l<num> to limit rename/copy detection.
Junio C Hamano authored
219 " -R swap input file pairs.\n" \
220 " -B detect complete rewrites.\n" \
221 " -M detect renames.\n" \
222 " -C detect copies.\n" \
dda2d79 [PATCH] Clean up diff option descriptions.
Junio C Hamano authored
223 " --find-copies-harder\n" \
8082d8d Diff: -l<num> to limit rename/copy detection.
Junio C Hamano authored
224 " try unchanged files as candidate for copy detection.\n" \
225 " -l<n> limit rename attempts up to <n> paths.\n" \
226 " -O<file> reorder diffs according to the <file>.\n" \
227 " -S<string> find filepair whose only one side contains the string.\n" \
dda2d79 [PATCH] Clean up diff option descriptions.
Junio C Hamano authored
228 " --pickaxe-all\n" \
ca49920 Add -a and --text to common diff options help
Stephan Feder authored
229 " show all files diff when -S is used and hit is found.\n" \
230 " -a --text treat all files as text.\n"
dda2d79 [PATCH] Clean up diff option descriptions.
Junio C Hamano authored
231
38c6f78 [PATCH] Prepare diffcore interface for diff-tree header supression.
Junio C Hamano authored
232 extern int diff_queue_is_empty(void);
6b5ee13 Diff clean-up.
Junio C Hamano authored
233 extern void diff_flush(struct diff_options*);
86436c2 [PATCH] Split external diff command interface to a separate file.
Junio C Hamano authored
234
e7baa4f Use symbolic constants for diff-raw status indicators.
Junio C Hamano authored
235 /* diff-raw status letters */
ca8c915 diff-raw: Use 'A' instead of 'N' for added files.
Junio C Hamano authored
236 #define DIFF_STATUS_ADDED 'A'
e7baa4f Use symbolic constants for diff-raw status indicators.
Junio C Hamano authored
237 #define DIFF_STATUS_COPIED 'C'
238 #define DIFF_STATUS_DELETED 'D'
239 #define DIFF_STATUS_MODIFIED 'M'
240 #define DIFF_STATUS_RENAMED 'R'
241 #define DIFF_STATUS_TYPE_CHANGED 'T'
242 #define DIFF_STATUS_UNKNOWN 'X'
243 #define DIFF_STATUS_UNMERGED 'U'
244
245 /* these are not diff-raw status letters proper, but used by
246 * diffcore-filter insn to specify additional restrictions.
247 */
0b34379 Fix diff-filter All-Or-None mark.
Junio C Hamano authored
248 #define DIFF_STATUS_FILTER_AON '*'
e7baa4f Use symbolic constants for diff-raw status indicators.
Junio C Hamano authored
249 #define DIFF_STATUS_FILTER_BROKEN 'B'
250
47dd0d5 diff: --abbrev option
Junio C Hamano authored
251 extern const char *diff_unique_abbrev(const unsigned char *, int);
252
4bd5b7d @gitster ce_match_stat, run_diff_files: use symbolic constants for readability
gitster authored
253 /* do not report anything on removed paths */
254 #define DIFF_SILENT_ON_REMOVED 01
fb63d7f @gitster git-add: make the entry stat-clean after re-adding the same contents
gitster authored
255 /* report racily-clean paths as modified */
256 #define DIFF_RACY_IS_MODIFIED 02
4bd5b7d @gitster ce_match_stat, run_diff_files: use symbolic constants for readability
gitster authored
257 extern int run_diff_files(struct rev_info *revs, unsigned int option);
5c21ac0 Libified diff-index: backward compatibility fix.
Junio C Hamano authored
258 extern int run_diff_index(struct rev_info *revs, int cached);
e09ad6e Libify diff-index.
Junio C Hamano authored
259
1cfe773 git-blame: no rev means start from the working tree file.
Junio C Hamano authored
260 extern int do_diff_cache(const unsigned char *, struct diff_options *);
fcb3d0a @dscho add diff_flush_patch_id() to calculate the patch id
dscho authored
261 extern int diff_flush_patch_id(struct diff_options *, unsigned char *);
262
da31b35 @gitster diff --check: minor fixups
gitster authored
263 extern int diff_result_code(struct diff_options *, int);
264
0569e9b @gitster "git diff": do not ignore index without --no-index
gitster authored
265 extern void diff_no_index(struct rev_info *, int, const char **, int, const char *);
266
86436c2 [PATCH] Split external diff command interface to a separate file.
Junio C Hamano authored
267 #endif /* DIFF_H */
Something went wrong with that request. Please try again.