| Junio C Hamano | be3cfa8 | 2005-04-26 16:25:05 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2005 Junio C Hamano |
| 3 | */ |
| Junio C Hamano | 86436c2 | 2005-04-26 01:22:47 | [diff] [blame] | 4 | #ifndef DIFF_H |
| 5 | #define DIFF_H |
| 6 | |
| Junio C Hamano | 1b0c717 | 2006-03-30 06:55:43 | [diff] [blame] | 7 | #include "tree-walk.h" |
| Linus Torvalds | 50f9a85 | 2006-01-31 22:10:56 | [diff] [blame] | 8 | |
| Linus Torvalds | ac1b3d1 | 2005-10-21 04:05:05 | [diff] [blame] | 9 | struct diff_options; |
| 10 | |
| 11 | typedef 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 | |
| 17 | typedef 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 Hamano | 6b5ee13 | 2005-09-21 07:00:47 | [diff] [blame] | 22 | struct diff_options { |
| Junio C Hamano | 6b5ee13 | 2005-09-21 07:00:47 | [diff] [blame] | 23 | const char *filter; |
| 24 | const char *orderfile; |
| 25 | const char *pickaxe; |
| Linus Torvalds | ac1b3d1 | 2005-10-21 04:05:05 | [diff] [blame] | 26 | unsigned recursive:1, |
| Junio C Hamano | 86ff1d2 | 2006-04-11 00:36:53 | [diff] [blame] | 27 | with_raw:1, |
| Johannes Schindelin | 2935327 | 2006-04-15 11:41:18 | [diff] [blame] | 28 | with_stat:1, |
| Junio C Hamano | 80b1e51 | 2005-11-15 01:53:22 | [diff] [blame] | 29 | tree_in_recursive:1, |
| 30 | full_index:1; |
| Junio C Hamano | 6b5ee13 | 2005-09-21 07:00:47 | [diff] [blame] | 31 | 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 Hamano | 8082d8d | 2005-09-21 07:18:27 | [diff] [blame] | 39 | int rename_limit; |
| Junio C Hamano | 6b5ee13 | 2005-09-21 07:00:47 | [diff] [blame] | 40 | int setup; |
| Junio C Hamano | 47dd0d5 | 2005-12-14 01:21:41 | [diff] [blame] | 41 | int abbrev; |
| Linus Torvalds | ac1b3d1 | 2005-10-21 04:05:05 | [diff] [blame] | 42 | |
| Junio C Hamano | a8baa7b | 2006-04-10 23:39:11 | [diff] [blame] | 43 | int nr_paths; |
| 44 | const char **paths; |
| 45 | int *pathlens; |
| Linus Torvalds | ac1b3d1 | 2005-10-21 04:05:05 | [diff] [blame] | 46 | change_fn_t change; |
| 47 | add_remove_fn_t add_remove; |
| Junio C Hamano | 6b5ee13 | 2005-09-21 07:00:47 | [diff] [blame] | 48 | }; |
| 49 | |
| Junio C Hamano | a8baa7b | 2006-04-10 23:39:11 | [diff] [blame] | 50 | extern void diff_tree_setup_paths(const char **paths, struct diff_options *); |
| 51 | extern void diff_tree_release_paths(struct diff_options *); |
| Linus Torvalds | ac1b3d1 | 2005-10-21 04:05:05 | [diff] [blame] | 52 | extern int diff_tree(struct tree_desc *t1, struct tree_desc *t2, |
| 53 | const char *base, struct diff_options *opt); |
| 54 | extern int diff_tree_sha1(const unsigned char *old, const unsigned char *new, |
| 55 | const char *base, struct diff_options *opt); |
| 56 | |
| Junio C Hamano | ea726d0 | 2006-01-28 08:03:38 | [diff] [blame] | 57 | struct combine_diff_path { |
| 58 | struct combine_diff_path *next; |
| 59 | int len; |
| 60 | char *path; |
| Junio C Hamano | 2454c96 | 2006-02-06 20:53:07 | [diff] [blame] | 61 | unsigned int mode; |
| Junio C Hamano | ea726d0 | 2006-01-28 08:03:38 | [diff] [blame] | 62 | unsigned char sha1[20]; |
| Junio C Hamano | 2454c96 | 2006-02-06 20:53:07 | [diff] [blame] | 63 | struct combine_diff_parent { |
| Junio C Hamano | d416df8 | 2006-02-10 10:30:52 | [diff] [blame] | 64 | char status; |
| Junio C Hamano | 2454c96 | 2006-02-06 20:53:07 | [diff] [blame] | 65 | unsigned int mode; |
| 66 | unsigned char sha1[20]; |
| 67 | } parent[FLEX_ARRAY]; |
| Junio C Hamano | ea726d0 | 2006-01-28 08:03:38 | [diff] [blame] | 68 | }; |
| Junio C Hamano | 2454c96 | 2006-02-06 20:53:07 | [diff] [blame] | 69 | #define combine_diff_path_size(n, l) \ |
| 70 | (sizeof(struct combine_diff_path) + \ |
| 71 | sizeof(struct combine_diff_parent) * (n) + (l) + 1) |
| Junio C Hamano | ea726d0 | 2006-01-28 08:03:38 | [diff] [blame] | 72 | |
| Linus Torvalds | ee63802 | 2006-02-09 18:30:28 | [diff] [blame] | 73 | extern int show_combined_diff(struct combine_diff_path *elem, int num_parent, |
| Junio C Hamano | 0a79807 | 2006-02-09 23:23:06 | [diff] [blame] | 74 | int dense, const char *header, |
| 75 | struct diff_options *); |
| Junio C Hamano | ea726d0 | 2006-01-28 08:03:38 | [diff] [blame] | 76 | |
| Linus Torvalds | ee63802 | 2006-02-09 18:30:28 | [diff] [blame] | 77 | extern const char *diff_tree_combined_merge(const unsigned char *sha1, const char *, int, struct diff_options *opt); |
| Junio C Hamano | af3feef | 2006-01-24 09:22:04 | [diff] [blame] | 78 | |
| Junio C Hamano | 6b5ee13 | 2005-09-21 07:00:47 | [diff] [blame] | 79 | extern void diff_addremove(struct diff_options *, |
| 80 | int addremove, |
| Junio C Hamano | 77eb272 | 2005-04-27 16:21:00 | [diff] [blame] | 81 | unsigned mode, |
| 82 | const unsigned char *sha1, |
| 83 | const char *base, |
| 84 | const char *path); |
| 85 | |
| Junio C Hamano | 6b5ee13 | 2005-09-21 07:00:47 | [diff] [blame] | 86 | extern 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 Hamano | 77eb272 | 2005-04-27 16:21:00 | [diff] [blame] | 91 | |
| Junio C Hamano | 6b5ee13 | 2005-09-21 07:00:47 | [diff] [blame] | 92 | extern void diff_unmerge(struct diff_options *, |
| 93 | const char *path); |
| Junio C Hamano | 77eb272 | 2005-04-27 16:21:00 | [diff] [blame] | 94 | |
| Junio C Hamano | 57fe64a | 2005-05-20 02:00:36 | [diff] [blame] | 95 | extern int diff_scoreopt_parse(const char *opt); |
| 96 | |
| Junio C Hamano | 19feebc | 2005-05-27 22:54:37 | [diff] [blame] | 97 | #define DIFF_SETUP_REVERSE 1 |
| Junio C Hamano | f0c6b2a | 2005-05-27 22:56:38 | [diff] [blame] | 98 | #define DIFF_SETUP_USE_CACHE 2 |
| 99 | #define DIFF_SETUP_USE_SIZE_CACHE 4 |
| Junio C Hamano | ce24067 | 2005-06-03 08:36:43 | [diff] [blame] | 100 | |
| Junio C Hamano | 9ce392f | 2005-11-22 06:52:37 | [diff] [blame] | 101 | extern int git_diff_config(const char *var, const char *value); |
| Junio C Hamano | 6b5ee13 | 2005-09-21 07:00:47 | [diff] [blame] | 102 | extern void diff_setup(struct diff_options *); |
| 103 | extern int diff_opt_parse(struct diff_options *, const char **, int); |
| 104 | extern int diff_setup_done(struct diff_options *); |
| Junio C Hamano | 86436c2 | 2005-04-26 01:22:47 | [diff] [blame] | 105 | |
| Junio C Hamano | 6b14d7f | 2005-05-22 17:04:37 | [diff] [blame] | 106 | #define DIFF_DETECT_RENAME 1 |
| 107 | #define DIFF_DETECT_COPY 2 |
| 108 | |
| Junio C Hamano | 367cec1 | 2005-05-27 22:55:28 | [diff] [blame] | 109 | #define DIFF_PICKAXE_ALL 1 |
| Petr Baudis | d01d8c6 | 2006-03-29 00:16:33 | [diff] [blame] | 110 | #define DIFF_PICKAXE_REGEX 2 |
| Junio C Hamano | f345b0a | 2005-05-30 07:08:37 | [diff] [blame] | 111 | |
| Junio C Hamano | 6b5ee13 | 2005-09-21 07:00:47 | [diff] [blame] | 112 | extern void diffcore_std(struct diff_options *); |
| Junio C Hamano | f2ce9fd | 2005-06-12 03:57:13 | [diff] [blame] | 113 | |
| Junio C Hamano | 6b5ee13 | 2005-09-21 07:00:47 | [diff] [blame] | 114 | extern void diffcore_std_no_resolve(struct diff_options *); |
| Junio C Hamano | befe863 | 2005-05-29 23:56:13 | [diff] [blame] | 115 | |
| Junio C Hamano | dda2d79 | 2005-07-13 19:52:35 | [diff] [blame] | 116 | #define COMMON_DIFF_OPTIONS_HELP \ |
| 117 | "\ncommon diff options:\n" \ |
| Junio C Hamano | 8082d8d | 2005-09-21 07:18:27 | [diff] [blame] | 118 | " -z output diff-raw with lines terminated with NUL.\n" \ |
| 119 | " -p output patch format.\n" \ |
| 120 | " -u synonym for -p.\n" \ |
| Petr Baudis | 5c91da2 | 2006-04-11 11:22:17 | [diff] [blame] | 121 | " --patch-with-raw\n" \ |
| 122 | " output both a patch and the diff-raw format.\n" \ |
| Johannes Schindelin | d75f795 | 2006-04-13 22:15:30 | [diff] [blame] | 123 | " --stat show diffstat instead of patch.\n" \ |
| Johannes Schindelin | 2935327 | 2006-04-15 11:41:18 | [diff] [blame] | 124 | " --patch-with-stat\n" \ |
| 125 | " output a patch and prepend its diffstat.\n" \ |
| Junio C Hamano | 8082d8d | 2005-09-21 07:18:27 | [diff] [blame] | 126 | " --name-only show only names of changed files.\n" \ |
| Junio C Hamano | 946f5f7 | 2005-09-21 07:20:06 | [diff] [blame] | 127 | " --name-status show names and status of changed files.\n" \ |
| Junio C Hamano | 47dd0d5 | 2005-12-14 01:21:41 | [diff] [blame] | 128 | " --full-index show full object name on index lines.\n" \ |
| Junio C Hamano | 913419f | 2005-12-18 10:03:15 | [diff] [blame] | 129 | " --abbrev=<n> abbreviate object names in diff-tree header and diff-raw.\n" \ |
| Junio C Hamano | 8082d8d | 2005-09-21 07:18:27 | [diff] [blame] | 130 | " -R swap input file pairs.\n" \ |
| 131 | " -B detect complete rewrites.\n" \ |
| 132 | " -M detect renames.\n" \ |
| 133 | " -C detect copies.\n" \ |
| Junio C Hamano | dda2d79 | 2005-07-13 19:52:35 | [diff] [blame] | 134 | " --find-copies-harder\n" \ |
| Junio C Hamano | 8082d8d | 2005-09-21 07:18:27 | [diff] [blame] | 135 | " 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 Hamano | dda2d79 | 2005-07-13 19:52:35 | [diff] [blame] | 139 | " --pickaxe-all\n" \ |
| Junio C Hamano | 8082d8d | 2005-09-21 07:18:27 | [diff] [blame] | 140 | " show all files diff when -S is used and hit is found.\n" |
| Junio C Hamano | dda2d79 | 2005-07-13 19:52:35 | [diff] [blame] | 141 | |
| Junio C Hamano | 38c6f78 | 2005-05-22 02:40:36 | [diff] [blame] | 142 | extern int diff_queue_is_empty(void); |
| 143 | |
| Linus Torvalds | e68b6f1 | 2005-07-15 00:59:17 | [diff] [blame] | 144 | #define DIFF_FORMAT_RAW 1 |
| Junio C Hamano | 19feebc | 2005-05-27 22:54:37 | [diff] [blame] | 145 | #define DIFF_FORMAT_PATCH 2 |
| 146 | #define DIFF_FORMAT_NO_OUTPUT 3 |
| Junio C Hamano | 52f2852 | 2005-07-13 19:45:51 | [diff] [blame] | 147 | #define DIFF_FORMAT_NAME 4 |
| Junio C Hamano | 946f5f7 | 2005-09-21 07:20:06 | [diff] [blame] | 148 | #define DIFF_FORMAT_NAME_STATUS 5 |
| Johannes Schindelin | d75f795 | 2006-04-13 22:15:30 | [diff] [blame] | 149 | #define DIFF_FORMAT_DIFFSTAT 6 |
| Junio C Hamano | 19feebc | 2005-05-27 22:54:37 | [diff] [blame] | 150 | |
| Junio C Hamano | 6b5ee13 | 2005-09-21 07:00:47 | [diff] [blame] | 151 | extern void diff_flush(struct diff_options*); |
| Junio C Hamano | 86436c2 | 2005-04-26 01:22:47 | [diff] [blame] | 152 | |
| Junio C Hamano | e7baa4f | 2005-07-25 20:05:44 | [diff] [blame] | 153 | /* diff-raw status letters */ |
| Junio C Hamano | ca8c915 | 2005-07-25 21:31:19 | [diff] [blame] | 154 | #define DIFF_STATUS_ADDED 'A' |
| Junio C Hamano | e7baa4f | 2005-07-25 20:05:44 | [diff] [blame] | 155 | #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 Hamano | 0b34379 | 2005-10-05 00:44:17 | [diff] [blame] | 166 | #define DIFF_STATUS_FILTER_AON '*' |
| Junio C Hamano | e7baa4f | 2005-07-25 20:05:44 | [diff] [blame] | 167 | #define DIFF_STATUS_FILTER_BROKEN 'B' |
| 168 | |
| Junio C Hamano | 47dd0d5 | 2005-12-14 01:21:41 | [diff] [blame] | 169 | extern const char *diff_unique_abbrev(const unsigned char *, int); |
| 170 | |
| Junio C Hamano | 86436c2 | 2005-04-26 01:22:47 | [diff] [blame] | 171 | #endif /* DIFF_H */ |