blob: 135fc05d72e8f066a63902785d12485a656efa97 [file] [log] [blame]
Junio C Hamanod9ea73e2006-04-05 02:03:58 -07001#ifndef XDIFF_INTERFACE_H
2#define XDIFF_INTERFACE_H
3
brian m. carlsond4493472016-09-05 20:08:02 +00004#include "cache.h"
Junio C Hamanod9ea73e2006-04-05 02:03:58 -07005#include "xdiff/xdiff.h"
Junio C Hamanod9ea73e2006-04-05 02:03:58 -07006
Jeff Kingdcd17422015-09-24 19:12:45 -04007/*
8 * xdiff isn't equipped to handle content over a gigabyte;
9 * we make the cutoff 1GB - 1MB to give some breathing
10 * room for constant-sized additions (e.g., merge markers)
11 */
12#define MAX_XDIFF_SIZE (1024UL * 1024 * 1023)
13
Junio C Hamanod9ea73e2006-04-05 02:03:58 -070014typedef void (*xdiff_emit_consume_fn)(void *, char *, unsigned long);
15
Junio C Hamanoc279d7e2007-12-13 13:25:07 -080016int xdi_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp, xdemitconf_t const *xecfg, xdemitcb_t *ecb);
Brian Downingc99db9d22008-08-14 00:36:50 -050017int xdi_diff_outf(mmfile_t *mf1, mmfile_t *mf2,
Junio C Hamano8a3f5242008-08-13 23:18:22 -070018 xdiff_emit_consume_fn fn, void *consume_callback_data,
René Scharfedfea7902010-05-04 22:41:34 +020019 xpparam_t const *xpp, xdemitconf_t const *xecfg);
Junio C Hamanoc1e335a2006-04-05 12:22:35 -070020int parse_hunk_header(char *line, int len,
Junio C Hamanoa0fd3142006-04-06 22:29:55 -070021 int *ob, int *on,
22 int *nb, int *nn);
Johannes Schindelin7cab5882006-12-20 17:37:07 +010023int read_mmfile(mmfile_t *ptr, const char *filename);
brian m. carlsond4493472016-09-05 20:08:02 +000024void read_mmblob(mmfile_t *ptr, const struct object_id *oid);
Johannes Schindelin6bfce932007-06-05 03:36:11 +010025int buffer_is_binary(const char *ptr, unsigned long size);
Junio C Hamanod9ea73e2006-04-05 02:03:58 -070026
Brandon Caseya0135852008-09-18 17:42:48 -050027extern void xdiff_set_find_func(xdemitconf_t *xecfg, const char *line, int cflags);
René Scharfe8cfe5f12009-07-02 00:01:43 +020028extern void xdiff_clear_find_func(xdemitconf_t *xecfg);
Junio C Hamanob5412482008-08-29 10:49:56 -070029extern int git_xmerge_config(const char *var, const char *value, void *cb);
30extern int git_xmerge_style;
Junio C Hamanof2584752007-07-06 00:45:10 -070031
Stefan Beller5ec82742017-10-25 11:49:11 -070032/*
33 * Compare the strings l1 with l2 which are of size s1 and s2 respectively.
34 * Returns 1 if the strings are deemed equal, 0 otherwise.
35 * The `flags` given as XDF_WHITESPACE_FLAGS determine how white spaces
36 * are treated for the comparision.
37 */
38extern int xdiff_compare_lines(const char *l1, long s1,
39 const char *l2, long s2, long flags);
40
41/*
42 * Returns a hash of the string s of length len.
43 * The `flags` given as XDF_WHITESPACE_FLAGS determine how white spaces
44 * are treated for the hash.
45 */
46extern unsigned long xdiff_hash_string(const char *s, size_t len, long flags);
47
Junio C Hamanod9ea73e2006-04-05 02:03:58 -070048#endif