blob: d052608404314880652561e4296e05e9da3f96ca [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"
Linus Torvalds50f9a852006-01-31 14:10:56 -08008
Linus Torvalds91539832006-04-17 11:59:32 -07009struct rev_info;
Linus Torvaldsac1b3d12005-10-20 21:05:05 -070010struct 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
Junio C Hamano6b5ee132005-09-21 00:00:47 -070023struct diff_options {
Junio C Hamano6b5ee132005-09-21 00:00:47 -070024 const char *filter;
25 const char *orderfile;
26 const char *pickaxe;
Linus Torvaldsac1b3d12005-10-20 21:05:05 -070027 unsigned recursive:1,
Junio C Hamano86ff1d22006-04-10 17:36:53 -070028 with_raw:1,
Johannes Schindelin29353272006-04-15 13:41:18 +020029 with_stat:1,
Junio C Hamano80b1e512005-11-14 17:53:22 -080030 tree_in_recursive:1,
Junio C Hamano06606262006-05-05 02:41:53 -070031 binary:1,
Junio C Hamano6973dca2006-04-21 23:57:45 -070032 full_index:1,
33 silent_on_remove:1,
34 find_copies_harder:1;
Junio C Hamano6b5ee132005-09-21 00:00:47 -070035 int break_opt;
36 int detect_rename;
Junio C Hamano6b5ee132005-09-21 00:00:47 -070037 int line_termination;
38 int output_format;
39 int pickaxe_opts;
40 int rename_score;
41 int reverse_diff;
Junio C Hamano8082d8d2005-09-21 00:18:27 -070042 int rename_limit;
Junio C Hamano6b5ee132005-09-21 00:00:47 -070043 int setup;
Junio C Hamano47dd0d52005-12-13 17:21:41 -080044 int abbrev;
Linus Torvaldsac1b3d12005-10-20 21:05:05 -070045
Junio C Hamanoa8baa7b2006-04-10 16:39:11 -070046 int nr_paths;
47 const char **paths;
48 int *pathlens;
Linus Torvaldsac1b3d12005-10-20 21:05:05 -070049 change_fn_t change;
50 add_remove_fn_t add_remove;
Junio C Hamano6b5ee132005-09-21 00:00:47 -070051};
52
Junio C Hamanoa8baa7b2006-04-10 16:39:11 -070053extern void diff_tree_setup_paths(const char **paths, struct diff_options *);
54extern void diff_tree_release_paths(struct diff_options *);
Linus Torvaldsac1b3d12005-10-20 21:05:05 -070055extern int diff_tree(struct tree_desc *t1, struct tree_desc *t2,
56 const char *base, struct diff_options *opt);
57extern int diff_tree_sha1(const unsigned char *old, const unsigned char *new,
58 const char *base, struct diff_options *opt);
59
Junio C Hamanoea726d02006-01-28 00:03:38 -080060struct combine_diff_path {
61 struct combine_diff_path *next;
62 int len;
63 char *path;
Junio C Hamano2454c962006-02-06 12:53:07 -080064 unsigned int mode;
Junio C Hamanoea726d02006-01-28 00:03:38 -080065 unsigned char sha1[20];
Junio C Hamano2454c962006-02-06 12:53:07 -080066 struct combine_diff_parent {
Junio C Hamanod416df82006-02-10 02:30:52 -080067 char status;
Junio C Hamano2454c962006-02-06 12:53:07 -080068 unsigned int mode;
69 unsigned char sha1[20];
70 } parent[FLEX_ARRAY];
Junio C Hamanoea726d02006-01-28 00:03:38 -080071};
Junio C Hamano2454c962006-02-06 12:53:07 -080072#define combine_diff_path_size(n, l) \
73 (sizeof(struct combine_diff_path) + \
74 sizeof(struct combine_diff_parent) * (n) + (l) + 1)
Junio C Hamanoea726d02006-01-28 00:03:38 -080075
Linus Torvalds91539832006-04-17 11:59:32 -070076extern void show_combined_diff(struct combine_diff_path *elem, int num_parent,
77 int dense, struct rev_info *);
Junio C Hamanoea726d02006-01-28 00:03:38 -080078
Junio C Hamano0fe7c1d2006-04-29 01:24:49 -070079extern void diff_tree_combined(const unsigned char *sha1, const unsigned char parent[][20], int num_parent, int dense, struct rev_info *rev);
80
Linus Torvalds91539832006-04-17 11:59:32 -070081extern void diff_tree_combined_merge(const unsigned char *sha1, int, struct rev_info *);
Junio C Hamanoaf3feef2006-01-24 01:22:04 -080082
Junio C Hamano6b5ee132005-09-21 00:00:47 -070083extern void diff_addremove(struct diff_options *,
84 int addremove,
Junio C Hamano77eb2722005-04-27 09:21:00 -070085 unsigned mode,
86 const unsigned char *sha1,
87 const char *base,
88 const char *path);
89
Junio C Hamano6b5ee132005-09-21 00:00:47 -070090extern void diff_change(struct diff_options *,
91 unsigned mode1, unsigned mode2,
92 const unsigned char *sha1,
93 const unsigned char *sha2,
94 const char *base, const char *path);
Junio C Hamano77eb2722005-04-27 09:21:00 -070095
Junio C Hamano6b5ee132005-09-21 00:00:47 -070096extern void diff_unmerge(struct diff_options *,
97 const char *path);
Junio C Hamano77eb2722005-04-27 09:21:00 -070098
Junio C Hamano57fe64a2005-05-19 19:00:36 -070099extern int diff_scoreopt_parse(const char *opt);
100
Junio C Hamano19feebc2005-05-27 15:54:37 -0700101#define DIFF_SETUP_REVERSE 1
Junio C Hamanof0c6b2a2005-05-27 15:56:38 -0700102#define DIFF_SETUP_USE_CACHE 2
103#define DIFF_SETUP_USE_SIZE_CACHE 4
Junio C Hamanoce240672005-06-03 01:36:43 -0700104
Junio C Hamano9ce392f2005-11-21 22:52:37 -0800105extern int git_diff_config(const char *var, const char *value);
Junio C Hamano6b5ee132005-09-21 00:00:47 -0700106extern void diff_setup(struct diff_options *);
107extern int diff_opt_parse(struct diff_options *, const char **, int);
108extern int diff_setup_done(struct diff_options *);
Junio C Hamano86436c22005-04-25 18:22:47 -0700109
Junio C Hamano6b14d7f2005-05-22 10:04:37 -0700110#define DIFF_DETECT_RENAME 1
111#define DIFF_DETECT_COPY 2
112
Junio C Hamano367cec12005-05-27 15:55:28 -0700113#define DIFF_PICKAXE_ALL 1
Petr Baudisd01d8c62006-03-29 02:16:33 +0200114#define DIFF_PICKAXE_REGEX 2
Junio C Hamanof345b0a2005-05-30 00:08:37 -0700115
Junio C Hamano6b5ee132005-09-21 00:00:47 -0700116extern void diffcore_std(struct diff_options *);
Junio C Hamanof2ce9fd2005-06-11 20:57:13 -0700117
Junio C Hamano6b5ee132005-09-21 00:00:47 -0700118extern void diffcore_std_no_resolve(struct diff_options *);
Junio C Hamanobefe8632005-05-29 16:56:13 -0700119
Junio C Hamanodda2d792005-07-13 12:52:35 -0700120#define COMMON_DIFF_OPTIONS_HELP \
121"\ncommon diff options:\n" \
Junio C Hamano8082d8d2005-09-21 00:18:27 -0700122" -z output diff-raw with lines terminated with NUL.\n" \
123" -p output patch format.\n" \
124" -u synonym for -p.\n" \
Petr Baudis5c91da22006-04-11 13:22:17 +0200125" --patch-with-raw\n" \
126" output both a patch and the diff-raw format.\n" \
Johannes Schindelind75f7952006-04-14 00:15:30 +0200127" --stat show diffstat instead of patch.\n" \
Johannes Schindelin29353272006-04-15 13:41:18 +0200128" --patch-with-stat\n" \
129" output a patch and prepend its diffstat.\n" \
Junio C Hamano8082d8d2005-09-21 00:18:27 -0700130" --name-only show only names of changed files.\n" \
Junio C Hamano946f5f72005-09-21 00:20:06 -0700131" --name-status show names and status of changed files.\n" \
Junio C Hamano47dd0d52005-12-13 17:21:41 -0800132" --full-index show full object name on index lines.\n" \
Junio C Hamano913419f2005-12-18 02:03:15 -0800133" --abbrev=<n> abbreviate object names in diff-tree header and diff-raw.\n" \
Junio C Hamano8082d8d2005-09-21 00:18:27 -0700134" -R swap input file pairs.\n" \
135" -B detect complete rewrites.\n" \
136" -M detect renames.\n" \
137" -C detect copies.\n" \
Junio C Hamanodda2d792005-07-13 12:52:35 -0700138" --find-copies-harder\n" \
Junio C Hamano8082d8d2005-09-21 00:18:27 -0700139" try unchanged files as candidate for copy detection.\n" \
140" -l<n> limit rename attempts up to <n> paths.\n" \
141" -O<file> reorder diffs according to the <file>.\n" \
142" -S<string> find filepair whose only one side contains the string.\n" \
Junio C Hamanodda2d792005-07-13 12:52:35 -0700143" --pickaxe-all\n" \
Junio C Hamano8082d8d2005-09-21 00:18:27 -0700144" show all files diff when -S is used and hit is found.\n"
Junio C Hamanodda2d792005-07-13 12:52:35 -0700145
Junio C Hamano38c6f782005-05-21 19:40:36 -0700146extern int diff_queue_is_empty(void);
147
Linus Torvaldse68b6f12005-07-14 17:59:17 -0700148#define DIFF_FORMAT_RAW 1
Junio C Hamano19feebc2005-05-27 15:54:37 -0700149#define DIFF_FORMAT_PATCH 2
150#define DIFF_FORMAT_NO_OUTPUT 3
Junio C Hamano52f28522005-07-13 12:45:51 -0700151#define DIFF_FORMAT_NAME 4
Junio C Hamano946f5f72005-09-21 00:20:06 -0700152#define DIFF_FORMAT_NAME_STATUS 5
Johannes Schindelind75f7952006-04-14 00:15:30 +0200153#define DIFF_FORMAT_DIFFSTAT 6
Junio C Hamano19feebc2005-05-27 15:54:37 -0700154
Junio C Hamano6b5ee132005-09-21 00:00:47 -0700155extern void diff_flush(struct diff_options*);
Junio C Hamano86436c22005-04-25 18:22:47 -0700156
Junio C Hamanoe7baa4f2005-07-25 13:05:44 -0700157/* diff-raw status letters */
Junio C Hamanoca8c9152005-07-25 14:31:19 -0700158#define DIFF_STATUS_ADDED 'A'
Junio C Hamanoe7baa4f2005-07-25 13:05:44 -0700159#define DIFF_STATUS_COPIED 'C'
160#define DIFF_STATUS_DELETED 'D'
161#define DIFF_STATUS_MODIFIED 'M'
162#define DIFF_STATUS_RENAMED 'R'
163#define DIFF_STATUS_TYPE_CHANGED 'T'
164#define DIFF_STATUS_UNKNOWN 'X'
165#define DIFF_STATUS_UNMERGED 'U'
166
167/* these are not diff-raw status letters proper, but used by
168 * diffcore-filter insn to specify additional restrictions.
169 */
Junio C Hamano0b343792005-10-04 17:44:17 -0700170#define DIFF_STATUS_FILTER_AON '*'
Junio C Hamanoe7baa4f2005-07-25 13:05:44 -0700171#define DIFF_STATUS_FILTER_BROKEN 'B'
172
Junio C Hamano47dd0d52005-12-13 17:21:41 -0800173extern const char *diff_unique_abbrev(const unsigned char *, int);
174
Junio C Hamano6973dca2006-04-21 23:57:45 -0700175extern int run_diff_files(struct rev_info *revs, int silent_on_removed);
176
Junio C Hamano5c21ac02006-04-22 03:58:04 -0700177extern int run_diff_index(struct rev_info *revs, int cached);
Junio C Hamanoe09ad6e2006-04-22 02:43:00 -0700178
Junio C Hamano86436c22005-04-25 18:22:47 -0700179#endif /* DIFF_H */