🌐 AI搜索 & 代理 主页
blob: f783baef14604678d1e638cc766bffdbdc43f691 [file] [log] [blame]
Junio C Hamanobe3cfa82005-04-26 16:25:051/*
2 * Copyright (C) 2005 Junio C Hamano
3 */
Junio C Hamano86436c22005-04-26 01:22:474#ifndef DIFF_H
5#define DIFF_H
6
Junio C Hamano1b0c7172006-03-30 06:55:437#include "tree-walk.h"
Linus Torvalds50f9a852006-01-31 22:10:568
Linus Torvaldsac1b3d12005-10-21 04:05:059struct diff_options;
10
11typedef void (*change_fn_t)(struct diff_options *options,
12 unsigned old_mode, unsigned new_mode,
13 const unsigned char *old_sha1,
14 const unsigned char *new_sha1,
15 const char *base, const char *path);
16
17typedef void (*add_remove_fn_t)(struct diff_options *options,
18 int addremove, unsigned mode,
19 const unsigned char *sha1,
20 const char *base, const char *path);
21
Junio C Hamano6b5ee132005-09-21 07:00:4722struct diff_options {
Junio C Hamano6b5ee132005-09-21 07:00:4723 const char *filter;
24 const char *orderfile;
25 const char *pickaxe;
Linus Torvaldsac1b3d12005-10-21 04:05:0526 unsigned recursive:1,
Junio C Hamano86ff1d22006-04-11 00:36:5327 with_raw:1,
Johannes Schindelin29353272006-04-15 11:41:1828 with_stat:1,
Junio C Hamano80b1e512005-11-15 01:53:2229 tree_in_recursive:1,
30 full_index:1;
Junio C Hamano6b5ee132005-09-21 07:00:4731 int break_opt;
32 int detect_rename;
33 int find_copies_harder;
34 int line_termination;
35 int output_format;
36 int pickaxe_opts;
37 int rename_score;
38 int reverse_diff;
Junio C Hamano8082d8d2005-09-21 07:18:2739 int rename_limit;
Junio C Hamano6b5ee132005-09-21 07:00:4740 int setup;
Junio C Hamano47dd0d52005-12-14 01:21:4141 int abbrev;
Linus Torvaldsac1b3d12005-10-21 04:05:0542
Junio C Hamanoa8baa7b2006-04-10 23:39:1143 int nr_paths;
44 const char **paths;
45 int *pathlens;
Linus Torvaldsac1b3d12005-10-21 04:05:0546 change_fn_t change;
47 add_remove_fn_t add_remove;
Junio C Hamano6b5ee132005-09-21 07:00:4748};
49
Junio C Hamanoa8baa7b2006-04-10 23:39:1150extern void diff_tree_setup_paths(const char **paths, struct diff_options *);
51extern void diff_tree_release_paths(struct diff_options *);
Linus Torvaldsac1b3d12005-10-21 04:05:0552extern int diff_tree(struct tree_desc *t1, struct tree_desc *t2,
53 const char *base, struct diff_options *opt);
54extern int diff_tree_sha1(const unsigned char *old, const unsigned char *new,
55 const char *base, struct diff_options *opt);
56
Junio C Hamanoea726d02006-01-28 08:03:3857struct combine_diff_path {
58 struct combine_diff_path *next;
59 int len;
60 char *path;
Junio C Hamano2454c962006-02-06 20:53:0761 unsigned int mode;
Junio C Hamanoea726d02006-01-28 08:03:3862 unsigned char sha1[20];
Junio C Hamano2454c962006-02-06 20:53:0763 struct combine_diff_parent {
Junio C Hamanod416df82006-02-10 10:30:5264 char status;
Junio C Hamano2454c962006-02-06 20:53:0765 unsigned int mode;
66 unsigned char sha1[20];
67 } parent[FLEX_ARRAY];
Junio C Hamanoea726d02006-01-28 08:03:3868};
Junio C Hamano2454c962006-02-06 20:53:0769#define combine_diff_path_size(n, l) \
70 (sizeof(struct combine_diff_path) + \
71 sizeof(struct combine_diff_parent) * (n) + (l) + 1)
Junio C Hamanoea726d02006-01-28 08:03:3872
Linus Torvaldsee638022006-02-09 18:30:2873extern int show_combined_diff(struct combine_diff_path *elem, int num_parent,
Junio C Hamano0a798072006-02-09 23:23:0674 int dense, const char *header,
75 struct diff_options *);
Junio C Hamanoea726d02006-01-28 08:03:3876
Linus Torvaldsee638022006-02-09 18:30:2877extern const char *diff_tree_combined_merge(const unsigned char *sha1, const char *, int, struct diff_options *opt);
Junio C Hamanoaf3feef2006-01-24 09:22:0478
Junio C Hamano6b5ee132005-09-21 07:00:4779extern void diff_addremove(struct diff_options *,
80 int addremove,
Junio C Hamano77eb2722005-04-27 16:21:0081 unsigned mode,
82 const unsigned char *sha1,
83 const char *base,
84 const char *path);
85
Junio C Hamano6b5ee132005-09-21 07:00:4786extern void diff_change(struct diff_options *,
87 unsigned mode1, unsigned mode2,
88 const unsigned char *sha1,
89 const unsigned char *sha2,
90 const char *base, const char *path);
Junio C Hamano77eb2722005-04-27 16:21:0091
Junio C Hamano6b5ee132005-09-21 07:00:4792extern void diff_unmerge(struct diff_options *,
93 const char *path);
Junio C Hamano77eb2722005-04-27 16:21:0094
Junio C Hamano57fe64a2005-05-20 02:00:3695extern int diff_scoreopt_parse(const char *opt);
96
Junio C Hamano19feebc2005-05-27 22:54:3797#define DIFF_SETUP_REVERSE 1
Junio C Hamanof0c6b2a2005-05-27 22:56:3898#define DIFF_SETUP_USE_CACHE 2
99#define DIFF_SETUP_USE_SIZE_CACHE 4
Junio C Hamanoce240672005-06-03 08:36:43100
Junio C Hamano9ce392f2005-11-22 06:52:37101extern int git_diff_config(const char *var, const char *value);
Junio C Hamano6b5ee132005-09-21 07:00:47102extern void diff_setup(struct diff_options *);
103extern int diff_opt_parse(struct diff_options *, const char **, int);
104extern int diff_setup_done(struct diff_options *);
Junio C Hamano86436c22005-04-26 01:22:47105
Junio C Hamano6b14d7f2005-05-22 17:04:37106#define DIFF_DETECT_RENAME 1
107#define DIFF_DETECT_COPY 2
108
Junio C Hamano367cec12005-05-27 22:55:28109#define DIFF_PICKAXE_ALL 1
Petr Baudisd01d8c62006-03-29 00:16:33110#define DIFF_PICKAXE_REGEX 2
Junio C Hamanof345b0a2005-05-30 07:08:37111
Junio C Hamano6b5ee132005-09-21 07:00:47112extern void diffcore_std(struct diff_options *);
Junio C Hamanof2ce9fd2005-06-12 03:57:13113
Junio C Hamano6b5ee132005-09-21 07:00:47114extern void diffcore_std_no_resolve(struct diff_options *);
Junio C Hamanobefe8632005-05-29 23:56:13115
Junio C Hamanodda2d792005-07-13 19:52:35116#define COMMON_DIFF_OPTIONS_HELP \
117"\ncommon diff options:\n" \
Junio C Hamano8082d8d2005-09-21 07:18:27118" -z output diff-raw with lines terminated with NUL.\n" \
119" -p output patch format.\n" \
120" -u synonym for -p.\n" \
Petr Baudis5c91da22006-04-11 11:22:17121" --patch-with-raw\n" \
122" output both a patch and the diff-raw format.\n" \
Johannes Schindelind75f7952006-04-13 22:15:30123" --stat show diffstat instead of patch.\n" \
Johannes Schindelin29353272006-04-15 11:41:18124" --patch-with-stat\n" \
125" output a patch and prepend its diffstat.\n" \
Junio C Hamano8082d8d2005-09-21 07:18:27126" --name-only show only names of changed files.\n" \
Junio C Hamano946f5f72005-09-21 07:20:06127" --name-status show names and status of changed files.\n" \
Junio C Hamano47dd0d52005-12-14 01:21:41128" --full-index show full object name on index lines.\n" \
Junio C Hamano913419f2005-12-18 10:03:15129" --abbrev=<n> abbreviate object names in diff-tree header and diff-raw.\n" \
Junio C Hamano8082d8d2005-09-21 07:18:27130" -R swap input file pairs.\n" \
131" -B detect complete rewrites.\n" \
132" -M detect renames.\n" \
133" -C detect copies.\n" \
Junio C Hamanodda2d792005-07-13 19:52:35134" --find-copies-harder\n" \
Junio C Hamano8082d8d2005-09-21 07:18:27135" try unchanged files as candidate for copy detection.\n" \
136" -l<n> limit rename attempts up to <n> paths.\n" \
137" -O<file> reorder diffs according to the <file>.\n" \
138" -S<string> find filepair whose only one side contains the string.\n" \
Junio C Hamanodda2d792005-07-13 19:52:35139" --pickaxe-all\n" \
Junio C Hamano8082d8d2005-09-21 07:18:27140" show all files diff when -S is used and hit is found.\n"
Junio C Hamanodda2d792005-07-13 19:52:35141
Junio C Hamano38c6f782005-05-22 02:40:36142extern int diff_queue_is_empty(void);
143
Linus Torvaldse68b6f12005-07-15 00:59:17144#define DIFF_FORMAT_RAW 1
Junio C Hamano19feebc2005-05-27 22:54:37145#define DIFF_FORMAT_PATCH 2
146#define DIFF_FORMAT_NO_OUTPUT 3
Junio C Hamano52f28522005-07-13 19:45:51147#define DIFF_FORMAT_NAME 4
Junio C Hamano946f5f72005-09-21 07:20:06148#define DIFF_FORMAT_NAME_STATUS 5
Johannes Schindelind75f7952006-04-13 22:15:30149#define DIFF_FORMAT_DIFFSTAT 6
Junio C Hamano19feebc2005-05-27 22:54:37150
Junio C Hamano6b5ee132005-09-21 07:00:47151extern void diff_flush(struct diff_options*);
Junio C Hamano86436c22005-04-26 01:22:47152
Junio C Hamanoe7baa4f2005-07-25 20:05:44153/* diff-raw status letters */
Junio C Hamanoca8c9152005-07-25 21:31:19154#define DIFF_STATUS_ADDED 'A'
Junio C Hamanoe7baa4f2005-07-25 20:05:44155#define DIFF_STATUS_COPIED 'C'
156#define DIFF_STATUS_DELETED 'D'
157#define DIFF_STATUS_MODIFIED 'M'
158#define DIFF_STATUS_RENAMED 'R'
159#define DIFF_STATUS_TYPE_CHANGED 'T'
160#define DIFF_STATUS_UNKNOWN 'X'
161#define DIFF_STATUS_UNMERGED 'U'
162
163/* these are not diff-raw status letters proper, but used by
164 * diffcore-filter insn to specify additional restrictions.
165 */
Junio C Hamano0b343792005-10-05 00:44:17166#define DIFF_STATUS_FILTER_AON '*'
Junio C Hamanoe7baa4f2005-07-25 20:05:44167#define DIFF_STATUS_FILTER_BROKEN 'B'
168
Junio C Hamano47dd0d52005-12-14 01:21:41169extern const char *diff_unique_abbrev(const unsigned char *, int);
170
Junio C Hamano86436c22005-04-26 01:22:47171#endif /* DIFF_H */