diff.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  1. /*
  2. * Copyright (C) 2005 Junio C Hamano
  3. */
  4. #ifndef DIFF_H
  5. #define DIFF_H
  6. #include "tree-walk.h"
  7. #include "pathspec.h"
  8. #include "object.h"
  9. #include "oidset.h"
  10. /**
  11. * The diff API is for programs that compare two sets of files (e.g. two trees,
  12. * one tree and the index) and present the found difference in various ways.
  13. * The calling program is responsible for feeding the API pairs of files, one
  14. * from the "old" set and the corresponding one from "new" set, that are
  15. * different.
  16. * The library called through this API is called diffcore, and is responsible
  17. * for two things.
  18. *
  19. * - finding total rewrites (`-B`), renames (`-M`) and copies (`-C`), and
  20. * changes that touch a string (`-S`), as specified by the caller.
  21. *
  22. * - outputting the differences in various formats, as specified by the caller.
  23. *
  24. * Calling sequence
  25. * ----------------
  26. *
  27. * - Prepare `struct diff_options` to record the set of diff options, and then
  28. * call `repo_diff_setup()` to initialize this structure. This sets up the
  29. * vanilla default.
  30. *
  31. * - Fill in the options structure to specify desired output format, rename
  32. * detection, etc. `diff_opt_parse()` can be used to parse options given
  33. * from the command line in a way consistent with existing git-diff family
  34. * of programs.
  35. *
  36. * - Call `diff_setup_done()`; this inspects the options set up so far for
  37. * internal consistency and make necessary tweaking to it (e.g. if textual
  38. * patch output was asked, recursive behaviour is turned on); the callback
  39. * set_default in diff_options can be used to tweak this more.
  40. *
  41. * - As you find different pairs of files, call `diff_change()` to feed
  42. * modified files, `diff_addremove()` to feed created or deleted files, or
  43. * `diff_unmerge()` to feed a file whose state is 'unmerged' to the API.
  44. * These are thin wrappers to a lower-level `diff_queue()` function that is
  45. * flexible enough to record any of these kinds of changes.
  46. *
  47. * - Once you finish feeding the pairs of files, call `diffcore_std()`.
  48. * This will tell the diffcore library to go ahead and do its work.
  49. *
  50. * - Calling `diff_flush()` will produce the output.
  51. */
  52. struct combine_diff_path;
  53. struct commit;
  54. struct diff_filespec;
  55. struct diff_options;
  56. struct diff_queue_struct;
  57. struct oid_array;
  58. struct option;
  59. struct repository;
  60. struct rev_info;
  61. struct strbuf;
  62. struct userdiff_driver;
  63. typedef int (*pathchange_fn_t)(struct diff_options *options,
  64. struct combine_diff_path *path);
  65. typedef void (*change_fn_t)(struct diff_options *options,
  66. unsigned old_mode, unsigned new_mode,
  67. const struct object_id *old_oid,
  68. const struct object_id *new_oid,
  69. int old_oid_valid, int new_oid_valid,
  70. const char *fullpath,
  71. unsigned old_dirty_submodule, unsigned new_dirty_submodule);
  72. typedef void (*add_remove_fn_t)(struct diff_options *options,
  73. int addremove, unsigned mode,
  74. const struct object_id *oid,
  75. int oid_valid,
  76. const char *fullpath, unsigned dirty_submodule);
  77. typedef void (*diff_format_fn_t)(struct diff_queue_struct *q,
  78. struct diff_options *options, void *data);
  79. typedef struct strbuf *(*diff_prefix_fn_t)(struct diff_options *opt, void *data);
  80. #define DIFF_FORMAT_RAW 0x0001
  81. #define DIFF_FORMAT_DIFFSTAT 0x0002
  82. #define DIFF_FORMAT_NUMSTAT 0x0004
  83. #define DIFF_FORMAT_SUMMARY 0x0008
  84. #define DIFF_FORMAT_PATCH 0x0010
  85. #define DIFF_FORMAT_SHORTSTAT 0x0020
  86. #define DIFF_FORMAT_DIRSTAT 0x0040
  87. /* These override all above */
  88. #define DIFF_FORMAT_NAME 0x0100
  89. #define DIFF_FORMAT_NAME_STATUS 0x0200
  90. #define DIFF_FORMAT_CHECKDIFF 0x0400
  91. /* Same as output_format = 0 but we know that -s flag was given
  92. * and we should not give default value to output_format.
  93. */
  94. #define DIFF_FORMAT_NO_OUTPUT 0x0800
  95. #define DIFF_FORMAT_CALLBACK 0x1000
  96. #define DIFF_FLAGS_INIT { 0 }
  97. struct diff_flags {
  98. /**
  99. * Tells if tree traversal done by tree-diff should recursively descend
  100. * into a tree object pair that are different in preimage and postimage set.
  101. */
  102. unsigned recursive;
  103. unsigned tree_in_recursive;
  104. /* Affects the way how a file that is seemingly binary is treated. */
  105. unsigned binary;
  106. unsigned text;
  107. /**
  108. * Tells the patch output format not to use abbreviated object names on the
  109. * "index" lines.
  110. */
  111. unsigned full_index;
  112. /* Affects if diff-files shows removed files. */
  113. unsigned silent_on_remove;
  114. /**
  115. * Tells the diffcore library that the caller is feeding unchanged
  116. * filepairs to allow copies from unmodified files be detected.
  117. */
  118. unsigned find_copies_harder;
  119. unsigned follow_renames;
  120. unsigned rename_empty;
  121. /* Internal; used for optimization to see if there is any change. */
  122. unsigned has_changes;
  123. unsigned quick;
  124. /**
  125. * Tells diff-files that the input is not tracked files but files in random
  126. * locations on the filesystem.
  127. */
  128. unsigned no_index;
  129. /**
  130. * Tells output routine that it is Ok to call user specified patch output
  131. * routine. Plumbing disables this to ensure stable output.
  132. */
  133. unsigned allow_external;
  134. /**
  135. * For communication between the calling program and the options parser;
  136. * tell the calling program to signal the presence of difference using
  137. * program exit code.
  138. */
  139. unsigned exit_with_status;
  140. /**
  141. * Tells the library that the calling program is feeding the filepairs
  142. * reversed; `one` is two, and `two` is one.
  143. */
  144. unsigned reverse_diff;
  145. unsigned check_failed;
  146. unsigned relative_name;
  147. unsigned ignore_submodules;
  148. unsigned dirstat_cumulative;
  149. unsigned dirstat_by_file;
  150. unsigned allow_textconv;
  151. unsigned textconv_set_via_cmdline;
  152. unsigned diff_from_contents;
  153. unsigned dirty_submodules;
  154. unsigned ignore_untracked_in_submodules;
  155. unsigned ignore_dirty_submodules;
  156. unsigned override_submodule_config;
  157. unsigned dirstat_by_line;
  158. unsigned funccontext;
  159. unsigned default_follow_renames;
  160. unsigned stat_with_summary;
  161. unsigned suppress_diff_headers;
  162. unsigned dual_color_diffed_diffs;
  163. unsigned suppress_hunk_header_line_count;
  164. };
  165. static inline void diff_flags_or(struct diff_flags *a,
  166. const struct diff_flags *b)
  167. {
  168. char *tmp_a = (char *)a;
  169. const char *tmp_b = (const char *)b;
  170. int i;
  171. for (i = 0; i < sizeof(struct diff_flags); i++)
  172. tmp_a[i] |= tmp_b[i];
  173. }
  174. #define DIFF_XDL_TST(opts, flag) ((opts)->xdl_opts & XDF_##flag)
  175. #define DIFF_XDL_SET(opts, flag) ((opts)->xdl_opts |= XDF_##flag)
  176. #define DIFF_XDL_CLR(opts, flag) ((opts)->xdl_opts &= ~XDF_##flag)
  177. #define DIFF_WITH_ALG(opts, flag) (((opts)->xdl_opts & ~XDF_DIFF_ALGORITHM_MASK) | XDF_##flag)
  178. enum diff_words_type {
  179. DIFF_WORDS_NONE = 0,
  180. DIFF_WORDS_PORCELAIN,
  181. DIFF_WORDS_PLAIN,
  182. DIFF_WORDS_COLOR
  183. };
  184. enum diff_submodule_format {
  185. DIFF_SUBMODULE_SHORT = 0,
  186. DIFF_SUBMODULE_LOG,
  187. DIFF_SUBMODULE_INLINE_DIFF
  188. };
  189. /**
  190. * the set of options the calling program wants to affect the operation of
  191. * diffcore library with.
  192. */
  193. struct diff_options {
  194. const char *orderfile;
  195. /**
  196. * A constant string (can and typically does contain newlines to look for
  197. * a block of text, not just a single line) to filter out the filepairs
  198. * that do not change the number of strings contained in its preimage and
  199. * postimage of the diff_queue.
  200. */
  201. const char *pickaxe;
  202. const char *single_follow;
  203. const char *a_prefix, *b_prefix;
  204. const char *line_prefix;
  205. size_t line_prefix_length;
  206. /**
  207. * collection of boolean options that affects the operation, but some do
  208. * not have anything to do with the diffcore library.
  209. */
  210. struct diff_flags flags;
  211. /* diff-filter bits */
  212. unsigned int filter;
  213. int use_color;
  214. /* Number of context lines to generate in patch output. */
  215. int context;
  216. int interhunkcontext;
  217. /* Affects the way detection logic for complete rewrites, renames and
  218. * copies.
  219. */
  220. int break_opt;
  221. int detect_rename;
  222. int irreversible_delete;
  223. int skip_stat_unmatch;
  224. int line_termination;
  225. /* The output format used when `diff_flush()` is run. */
  226. int output_format;
  227. unsigned pickaxe_opts;
  228. /* Affects the way detection logic for complete rewrites, renames and
  229. * copies.
  230. */
  231. int rename_score;
  232. int rename_limit;
  233. int needed_rename_limit;
  234. int degraded_cc_to_c;
  235. int show_rename_progress;
  236. int dirstat_permille;
  237. int setup;
  238. /* Number of hexdigits to abbreviate raw format output to. */
  239. int abbrev;
  240. /* If non-zero, then stop computing after this many changes. */
  241. int max_changes;
  242. int ita_invisible_in_index;
  243. /* white-space error highlighting */
  244. #define WSEH_NEW (1<<12)
  245. #define WSEH_CONTEXT (1<<13)
  246. #define WSEH_OLD (1<<14)
  247. unsigned ws_error_highlight;
  248. const char *prefix;
  249. int prefix_length;
  250. const char *stat_sep;
  251. int xdl_opts;
  252. /* see Documentation/diff-options.txt */
  253. char **anchors;
  254. size_t anchors_nr, anchors_alloc;
  255. int stat_width;
  256. int stat_name_width;
  257. int stat_graph_width;
  258. int stat_count;
  259. const char *word_regex;
  260. enum diff_words_type word_diff;
  261. enum diff_submodule_format submodule_format;
  262. struct oidset *objfind;
  263. /* this is set by diffcore for DIFF_FORMAT_PATCH */
  264. int found_changes;
  265. /* to support internal diff recursion by --follow hack*/
  266. int found_follow;
  267. /* Callback which allows tweaking the options in diff_setup_done(). */
  268. void (*set_default)(struct diff_options *);
  269. FILE *file;
  270. int close_file;
  271. #define OUTPUT_INDICATOR_NEW 0
  272. #define OUTPUT_INDICATOR_OLD 1
  273. #define OUTPUT_INDICATOR_CONTEXT 2
  274. char output_indicators[3];
  275. struct pathspec pathspec;
  276. pathchange_fn_t pathchange;
  277. change_fn_t change;
  278. add_remove_fn_t add_remove;
  279. void *change_fn_data;
  280. diff_format_fn_t format_callback;
  281. void *format_callback_data;
  282. diff_prefix_fn_t output_prefix;
  283. void *output_prefix_data;
  284. int diff_path_counter;
  285. struct emitted_diff_symbols *emitted_symbols;
  286. enum {
  287. COLOR_MOVED_NO = 0,
  288. COLOR_MOVED_PLAIN = 1,
  289. COLOR_MOVED_BLOCKS = 2,
  290. COLOR_MOVED_ZEBRA = 3,
  291. COLOR_MOVED_ZEBRA_DIM = 4,
  292. } color_moved;
  293. #define COLOR_MOVED_DEFAULT COLOR_MOVED_ZEBRA
  294. #define COLOR_MOVED_MIN_ALNUM_COUNT 20
  295. /* XDF_WHITESPACE_FLAGS regarding block detection are set at 2, 3, 4 */
  296. #define COLOR_MOVED_WS_ALLOW_INDENTATION_CHANGE (1<<5)
  297. #define COLOR_MOVED_WS_ERROR (1<<0)
  298. unsigned color_moved_ws_handling;
  299. struct repository *repo;
  300. struct option *parseopts;
  301. };
  302. unsigned diff_filter_bit(char status);
  303. void diff_emit_submodule_del(struct diff_options *o, const char *line);
  304. void diff_emit_submodule_add(struct diff_options *o, const char *line);
  305. void diff_emit_submodule_untracked(struct diff_options *o, const char *path);
  306. void diff_emit_submodule_modified(struct diff_options *o, const char *path);
  307. void diff_emit_submodule_header(struct diff_options *o, const char *header);
  308. void diff_emit_submodule_error(struct diff_options *o, const char *err);
  309. void diff_emit_submodule_pipethrough(struct diff_options *o,
  310. const char *line, int len);
  311. struct diffstat_t {
  312. int nr;
  313. int alloc;
  314. struct diffstat_file {
  315. char *from_name;
  316. char *name;
  317. char *print_name;
  318. const char *comments;
  319. unsigned is_unmerged:1;
  320. unsigned is_binary:1;
  321. unsigned is_renamed:1;
  322. unsigned is_interesting:1;
  323. uintmax_t added, deleted;
  324. } **files;
  325. };
  326. enum color_diff {
  327. DIFF_RESET = 0,
  328. DIFF_CONTEXT = 1,
  329. DIFF_METAINFO = 2,
  330. DIFF_FRAGINFO = 3,
  331. DIFF_FILE_OLD = 4,
  332. DIFF_FILE_NEW = 5,
  333. DIFF_COMMIT = 6,
  334. DIFF_WHITESPACE = 7,
  335. DIFF_FUNCINFO = 8,
  336. DIFF_FILE_OLD_MOVED = 9,
  337. DIFF_FILE_OLD_MOVED_ALT = 10,
  338. DIFF_FILE_OLD_MOVED_DIM = 11,
  339. DIFF_FILE_OLD_MOVED_ALT_DIM = 12,
  340. DIFF_FILE_NEW_MOVED = 13,
  341. DIFF_FILE_NEW_MOVED_ALT = 14,
  342. DIFF_FILE_NEW_MOVED_DIM = 15,
  343. DIFF_FILE_NEW_MOVED_ALT_DIM = 16,
  344. DIFF_CONTEXT_DIM = 17,
  345. DIFF_FILE_OLD_DIM = 18,
  346. DIFF_FILE_NEW_DIM = 19,
  347. DIFF_CONTEXT_BOLD = 20,
  348. DIFF_FILE_OLD_BOLD = 21,
  349. DIFF_FILE_NEW_BOLD = 22,
  350. };
  351. const char *diff_get_color(int diff_use_color, enum color_diff ix);
  352. #define diff_get_color_opt(o, ix) \
  353. diff_get_color((o)->use_color, ix)
  354. const char *diff_line_prefix(struct diff_options *);
  355. extern const char mime_boundary_leader[];
  356. struct combine_diff_path *diff_tree_paths(
  357. struct combine_diff_path *p, const struct object_id *oid,
  358. const struct object_id **parents_oid, int nparent,
  359. struct strbuf *base, struct diff_options *opt);
  360. void diff_tree_oid(const struct object_id *old_oid,
  361. const struct object_id *new_oid,
  362. const char *base, struct diff_options *opt);
  363. void diff_root_tree_oid(const struct object_id *new_oid, const char *base,
  364. struct diff_options *opt);
  365. struct combine_diff_path {
  366. struct combine_diff_path *next;
  367. char *path;
  368. unsigned int mode;
  369. struct object_id oid;
  370. struct combine_diff_parent {
  371. char status;
  372. unsigned int mode;
  373. struct object_id oid;
  374. struct strbuf path;
  375. } parent[FLEX_ARRAY];
  376. };
  377. #define combine_diff_path_size(n, l) \
  378. st_add4(sizeof(struct combine_diff_path), (l), 1, \
  379. st_mult(sizeof(struct combine_diff_parent), (n)))
  380. void show_combined_diff(struct combine_diff_path *elem, int num_parent,
  381. struct rev_info *);
  382. void diff_tree_combined(const struct object_id *oid, const struct oid_array *parents, struct rev_info *rev);
  383. void diff_tree_combined_merge(const struct commit *commit, struct rev_info *rev);
  384. void diff_set_mnemonic_prefix(struct diff_options *options, const char *a, const char *b);
  385. int diff_can_quit_early(struct diff_options *);
  386. void diff_addremove(struct diff_options *,
  387. int addremove,
  388. unsigned mode,
  389. const struct object_id *oid,
  390. int oid_valid,
  391. const char *fullpath, unsigned dirty_submodule);
  392. void diff_change(struct diff_options *,
  393. unsigned mode1, unsigned mode2,
  394. const struct object_id *old_oid,
  395. const struct object_id *new_oid,
  396. int old_oid_valid, int new_oid_valid,
  397. const char *fullpath,
  398. unsigned dirty_submodule1, unsigned dirty_submodule2);
  399. struct diff_filepair *diff_unmerge(struct diff_options *, const char *path);
  400. void compute_diffstat(struct diff_options *options, struct diffstat_t *diffstat,
  401. struct diff_queue_struct *q);
  402. void free_diffstat_info(struct diffstat_t *diffstat);
  403. #define DIFF_SETUP_REVERSE 1
  404. #define DIFF_SETUP_USE_SIZE_CACHE 4
  405. /*
  406. * Poor man's alternative to parse-option, to allow both stuck form
  407. * (--option=value) and separate form (--option value).
  408. */
  409. int parse_long_opt(const char *opt, const char **argv,
  410. const char **optarg);
  411. int git_diff_basic_config(const char *var, const char *value, void *cb);
  412. int git_diff_heuristic_config(const char *var, const char *value, void *cb);
  413. void init_diff_ui_defaults(void);
  414. int git_diff_ui_config(const char *var, const char *value, void *cb);
  415. #ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
  416. #define diff_setup(diffopts) repo_diff_setup(the_repository, diffopts)
  417. #endif
  418. void repo_diff_setup(struct repository *, struct diff_options *);
  419. int diff_opt_parse(struct diff_options *, const char **, int, const char *);
  420. void diff_setup_done(struct diff_options *);
  421. int git_config_rename(const char *var, const char *value);
  422. #define DIFF_DETECT_RENAME 1
  423. #define DIFF_DETECT_COPY 2
  424. #define DIFF_PICKAXE_ALL 1
  425. #define DIFF_PICKAXE_REGEX 2
  426. #define DIFF_PICKAXE_KIND_S 4 /* traditional plumbing counter */
  427. #define DIFF_PICKAXE_KIND_G 8 /* grep in the patch */
  428. #define DIFF_PICKAXE_KIND_OBJFIND 16 /* specific object IDs */
  429. #define DIFF_PICKAXE_KINDS_MASK (DIFF_PICKAXE_KIND_S | \
  430. DIFF_PICKAXE_KIND_G | \
  431. DIFF_PICKAXE_KIND_OBJFIND)
  432. #define DIFF_PICKAXE_IGNORE_CASE 32
  433. void diffcore_std(struct diff_options *);
  434. void diffcore_fix_diff_index(void);
  435. #define COMMON_DIFF_OPTIONS_HELP \
  436. "\ncommon diff options:\n" \
  437. " -z output diff-raw with lines terminated with NUL.\n" \
  438. " -p output patch format.\n" \
  439. " -u synonym for -p.\n" \
  440. " --patch-with-raw\n" \
  441. " output both a patch and the diff-raw format.\n" \
  442. " --stat show diffstat instead of patch.\n" \
  443. " --numstat show numeric diffstat instead of patch.\n" \
  444. " --patch-with-stat\n" \
  445. " output a patch and prepend its diffstat.\n" \
  446. " --name-only show only names of changed files.\n" \
  447. " --name-status show names and status of changed files.\n" \
  448. " --full-index show full object name on index lines.\n" \
  449. " --abbrev=<n> abbreviate object names in diff-tree header and diff-raw.\n" \
  450. " -R swap input file pairs.\n" \
  451. " -B detect complete rewrites.\n" \
  452. " -M detect renames.\n" \
  453. " -C detect copies.\n" \
  454. " --find-copies-harder\n" \
  455. " try unchanged files as candidate for copy detection.\n" \
  456. " -l<n> limit rename attempts up to <n> paths.\n" \
  457. " -O<file> reorder diffs according to the <file>.\n" \
  458. " -S<string> find filepair whose only one side contains the string.\n" \
  459. " --pickaxe-all\n" \
  460. " show all files diff when -S is used and hit is found.\n" \
  461. " -a --text treat all files as text.\n"
  462. int diff_queue_is_empty(void);
  463. void diff_flush(struct diff_options*);
  464. void diff_warn_rename_limit(const char *varname, int needed, int degraded_cc);
  465. /* diff-raw status letters */
  466. #define DIFF_STATUS_ADDED 'A'
  467. #define DIFF_STATUS_COPIED 'C'
  468. #define DIFF_STATUS_DELETED 'D'
  469. #define DIFF_STATUS_MODIFIED 'M'
  470. #define DIFF_STATUS_RENAMED 'R'
  471. #define DIFF_STATUS_TYPE_CHANGED 'T'
  472. #define DIFF_STATUS_UNKNOWN 'X'
  473. #define DIFF_STATUS_UNMERGED 'U'
  474. /* these are not diff-raw status letters proper, but used by
  475. * diffcore-filter insn to specify additional restrictions.
  476. */
  477. #define DIFF_STATUS_FILTER_AON '*'
  478. #define DIFF_STATUS_FILTER_BROKEN 'B'
  479. /*
  480. * This is different from find_unique_abbrev() in that
  481. * it stuffs the result with dots for alignment.
  482. */
  483. const char *diff_aligned_abbrev(const struct object_id *sha1, int);
  484. /* do not report anything on removed paths */
  485. #define DIFF_SILENT_ON_REMOVED 01
  486. /* report racily-clean paths as modified */
  487. #define DIFF_RACY_IS_MODIFIED 02
  488. int run_diff_files(struct rev_info *revs, unsigned int option);
  489. int run_diff_index(struct rev_info *revs, int cached);
  490. int do_diff_cache(const struct object_id *, struct diff_options *);
  491. int diff_flush_patch_id(struct diff_options *, struct object_id *, int, int);
  492. void flush_one_hunk(struct object_id *result, git_hash_ctx *ctx);
  493. int diff_result_code(struct diff_options *, int);
  494. int diff_no_index(struct rev_info *,
  495. int implicit_no_index, int, const char **);
  496. int index_differs_from(struct repository *r, const char *def,
  497. const struct diff_flags *flags,
  498. int ita_invisible_in_index);
  499. /*
  500. * Emit an interdiff of two object ID's to 'diff_options.file' optionally
  501. * indented by 'indent' spaces.
  502. */
  503. void show_interdiff(const struct object_id *, const struct object_id *,
  504. int indent, struct diff_options *);
  505. /*
  506. * Fill the contents of the filespec "df", respecting any textconv defined by
  507. * its userdiff driver. The "driver" parameter must come from a
  508. * previous call to get_textconv(), and therefore should either be NULL or have
  509. * textconv enabled.
  510. *
  511. * Note that the memory ownership of the resulting buffer depends on whether
  512. * the driver field is NULL. If it is, then the memory belongs to the filespec
  513. * struct. If it is non-NULL, then "outbuf" points to a newly allocated buffer
  514. * that should be freed by the caller.
  515. */
  516. size_t fill_textconv(struct repository *r,
  517. struct userdiff_driver *driver,
  518. struct diff_filespec *df,
  519. char **outbuf);
  520. /*
  521. * Look up the userdiff driver for the given filespec, and return it if
  522. * and only if it has textconv enabled (otherwise return NULL). The result
  523. * can be passed to fill_textconv().
  524. */
  525. struct userdiff_driver *get_textconv(struct repository *r,
  526. struct diff_filespec *one);
  527. /*
  528. * Prepare diff_filespec and convert it using diff textconv API
  529. * if the textconv driver exists.
  530. * Return 1 if the conversion succeeds, 0 otherwise.
  531. */
  532. int textconv_object(struct repository *repo,
  533. const char *path,
  534. unsigned mode,
  535. const struct object_id *oid, int oid_valid,
  536. char **buf, unsigned long *buf_size);
  537. int parse_rename_score(const char **cp_p);
  538. long parse_algorithm_value(const char *value);
  539. void print_stat_summary(FILE *fp, int files,
  540. int insertions, int deletions);
  541. void setup_diff_pager(struct diff_options *);
  542. #endif /* DIFF_H */