Libify diff-index.
[git/git.git] / diff.h
CommitLineData
be3cfa85
JH
1/*
2 * Copyright (C) 2005 Junio C Hamano
3 */
86436c28
JH
4#ifndef DIFF_H
5#define DIFF_H
6
1b0c7174 7#include "tree-walk.h"
50f9a858 8
91539833 9struct rev_info;
ac1b3d12
LT
10struct diff_options;
11
12typedef void (*change_fn_t)(struct diff_options *options,
13 unsigned old_mode, unsigned new_mode,
14 const unsigned char *old_sha1,
15 const unsigned char *new_sha1,
16 const char *base, const char *path);
17
18typedef void (*add_remove_fn_t)(struct diff_options *options,
19 int addremove, unsigned mode,
20 const unsigned char *sha1,
21 const char *base, const char *path);
22
6b5ee137 23struct diff_options {
6b5ee137
JH
24 const char *filter;
25 const char *orderfile;
26 const char *pickaxe;
ac1b3d12 27 unsigned recursive:1,
86ff1d20 28 with_raw:1,
29353273 29 with_stat:1,
80b1e511 30 tree_in_recursive:1,
6973dcae
JH
31 full_index:1,
32 silent_on_remove:1,
33 find_copies_harder:1;
6b5ee137
JH
34 int break_opt;
35 int detect_rename;
6b5ee137
JH
36 int line_termination;
37 int output_format;
38 int pickaxe_opts;
39 int rename_score;
40 int reverse_diff;
8082d8d3 41 int rename_limit;
6b5ee137 42 int setup;
47dd0d59 43 int abbrev;
ac1b3d12 44
a8baa7b9
JH
45 int nr_paths;
46 const char **paths;
47 int *pathlens;
ac1b3d12
LT
48 change_fn_t change;
49 add_remove_fn_t add_remove;
6b5ee137
JH
50};
51
a8baa7b9
JH
52extern void diff_tree_setup_paths(const char **paths, struct diff_options *);
53extern void diff_tree_release_paths(struct diff_options *);
ac1b3d12
LT
54extern int diff_tree(struct tree_desc *t1, struct tree_desc *t2,
55 const char *base, struct diff_options *opt);
56extern int diff_tree_sha1(const unsigned char *old, const unsigned char *new,
57 const char *base, struct diff_options *opt);
58
ea726d02
JH
59struct combine_diff_path {
60 struct combine_diff_path *next;
61 int len;
62 char *path;
2454c962 63 unsigned int mode;
ea726d02 64 unsigned char sha1[20];
2454c962 65 struct combine_diff_parent {
d416df88 66 char status;
2454c962
JH
67 unsigned int mode;
68 unsigned char sha1[20];
69 } parent[FLEX_ARRAY];
ea726d02 70};
2454c962
JH
71#define combine_diff_path_size(n, l) \
72 (sizeof(struct combine_diff_path) + \
73 sizeof(struct combine_diff_parent) * (n) + (l) + 1)
ea726d02 74
91539833
LT
75extern void show_combined_diff(struct combine_diff_path *elem, int num_parent,
76 int dense, struct rev_info *);
ea726d02 77
91539833 78extern void diff_tree_combined_merge(const unsigned char *sha1, int, struct rev_info *);
af3feefa 79
6b5ee137
JH
80extern void diff_addremove(struct diff_options *,
81 int addremove,
77eb2720
JH
82 unsigned mode,
83 const unsigned char *sha1,
84 const char *base,
85 const char *path);
86
6b5ee137
JH
87extern void diff_change(struct diff_options *,
88 unsigned mode1, unsigned mode2,
89 const unsigned char *sha1,
90 const unsigned char *sha2,
91 const char *base, const char *path);
77eb2720 92
6b5ee137
JH
93extern void diff_unmerge(struct diff_options *,
94 const char *path);
77eb2720 95
57fe64a4
JH
96extern int diff_scoreopt_parse(const char *opt);
97
19feebc8 98#define DIFF_SETUP_REVERSE 1
f0c6b2a2
JH
99#define DIFF_SETUP_USE_CACHE 2
100#define DIFF_SETUP_USE_SIZE_CACHE 4
ce240675 101
9ce392f4 102extern int git_diff_config(const char *var, const char *value);
6b5ee137
JH
103extern void diff_setup(struct diff_options *);
104extern int diff_opt_parse(struct diff_options *, const char **, int);
105extern int diff_setup_done(struct diff_options *);
86436c28 106
6b14d7fa
JH
107#define DIFF_DETECT_RENAME 1
108#define DIFF_DETECT_COPY 2
109
367cec1c 110#define DIFF_PICKAXE_ALL 1
d01d8c67 111#define DIFF_PICKAXE_REGEX 2
f345b0a0 112
6b5ee137 113extern void diffcore_std(struct diff_options *);
f2ce9fde 114
6b5ee137 115extern void diffcore_std_no_resolve(struct diff_options *);
befe8639 116
dda2d79a
JH
117#define COMMON_DIFF_OPTIONS_HELP \
118"\ncommon diff options:\n" \
8082d8d3
JH
119" -z output diff-raw with lines terminated with NUL.\n" \
120" -p output patch format.\n" \
121" -u synonym for -p.\n" \
5c91da25
PB
122" --patch-with-raw\n" \
123" output both a patch and the diff-raw format.\n" \
d75f7952 124" --stat show diffstat instead of patch.\n" \
29353273
JS
125" --patch-with-stat\n" \
126" output a patch and prepend its diffstat.\n" \
8082d8d3 127" --name-only show only names of changed files.\n" \
946f5f7c 128" --name-status show names and status of changed files.\n" \
47dd0d59 129" --full-index show full object name on index lines.\n" \
913419fc 130" --abbrev=<n> abbreviate object names in diff-tree header and diff-raw.\n" \
8082d8d3
JH
131" -R swap input file pairs.\n" \
132" -B detect complete rewrites.\n" \
133" -M detect renames.\n" \
134" -C detect copies.\n" \
dda2d79a 135" --find-copies-harder\n" \
8082d8d3
JH
136" try unchanged files as candidate for copy detection.\n" \
137" -l<n> limit rename attempts up to <n> paths.\n" \
138" -O<file> reorder diffs according to the <file>.\n" \
139" -S<string> find filepair whose only one side contains the string.\n" \
dda2d79a 140" --pickaxe-all\n" \
8082d8d3 141" show all files diff when -S is used and hit is found.\n"
dda2d79a 142
38c6f780
JH
143extern int diff_queue_is_empty(void);
144
e68b6f15 145#define DIFF_FORMAT_RAW 1
19feebc8
JH
146#define DIFF_FORMAT_PATCH 2
147#define DIFF_FORMAT_NO_OUTPUT 3
52f28529 148#define DIFF_FORMAT_NAME 4
946f5f7c 149#define DIFF_FORMAT_NAME_STATUS 5
d75f7952 150#define DIFF_FORMAT_DIFFSTAT 6
19feebc8 151
6b5ee137 152extern void diff_flush(struct diff_options*);
86436c28 153
e7baa4f4 154/* diff-raw status letters */
ca8c9156 155#define DIFF_STATUS_ADDED 'A'
e7baa4f4
JH
156#define DIFF_STATUS_COPIED 'C'
157#define DIFF_STATUS_DELETED 'D'
158#define DIFF_STATUS_MODIFIED 'M'
159#define DIFF_STATUS_RENAMED 'R'
160#define DIFF_STATUS_TYPE_CHANGED 'T'
161#define DIFF_STATUS_UNKNOWN 'X'
162#define DIFF_STATUS_UNMERGED 'U'
163
164/* these are not diff-raw status letters proper, but used by
165 * diffcore-filter insn to specify additional restrictions.
166 */
0b34379a 167#define DIFF_STATUS_FILTER_AON '*'
e7baa4f4
JH
168#define DIFF_STATUS_FILTER_BROKEN 'B'
169
47dd0d59
JH
170extern const char *diff_unique_abbrev(const unsigned char *, int);
171
6973dcae
JH
172extern int run_diff_files(struct rev_info *revs, int silent_on_removed);
173
e09ad6e1
JH
174extern int run_diff_index(struct rev_info *revs, int cached, int match_missing);
175
86436c28 176#endif /* DIFF_H */