diff options
author | Junio C Hamano <gitster@pobox.com> | 2018-11-13 16:37:27 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-11-13 16:37:27 +0300 |
commit | 39d23dfa409e51844ddda99599927092c8300f12 (patch) | |
tree | f4975a66a1fb9c33a875fe72042e9b7c75519597 /xdiff-interface.h | |
parent | f22838aa7a6dcf308a3307ba17f8afa40989ad3a (diff) | |
parent | 5eade0746e1daf659a9559d804068f9f31614625 (diff) |
Merge branch 'jk/xdiff-interface'
The interface into "xdiff" library used to discover the offset and
size of a generated patch hunk by first formatting it into the
textual hunk header "@@ -n,m +k,l @@" and then parsing the numbers
out. A new interface has been introduced to allow callers a more
direct access to them.
* jk/xdiff-interface:
xdiff-interface: drop parse_hunk_header()
range-diff: use a hunk callback
diff: convert --check to use a hunk callback
combine-diff: use an xdiff hunk callback
diff: use hunk callback for word-diff
diff: discard hunk headers for patch-ids earlier
diff: avoid generating unused hunk header lines
xdiff-interface: provide a separate consume callback for hunks
xdiff: provide a separate emit callback for hunks
Diffstat (limited to 'xdiff-interface.h')
-rw-r--r-- | xdiff-interface.h | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/xdiff-interface.h b/xdiff-interface.h index 135fc05d72..2d41fffd4c 100644 --- a/xdiff-interface.h +++ b/xdiff-interface.h @@ -11,15 +11,18 @@ */ #define MAX_XDIFF_SIZE (1024UL * 1024 * 1023) -typedef void (*xdiff_emit_consume_fn)(void *, char *, unsigned long); +typedef void (*xdiff_emit_line_fn)(void *, char *, unsigned long); +typedef void (*xdiff_emit_hunk_fn)(void *data, + long old_begin, long old_nr, + long new_begin, long new_nr, + const char *func, long funclen); int xdi_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp, xdemitconf_t const *xecfg, xdemitcb_t *ecb); int xdi_diff_outf(mmfile_t *mf1, mmfile_t *mf2, - xdiff_emit_consume_fn fn, void *consume_callback_data, + xdiff_emit_hunk_fn hunk_fn, + xdiff_emit_line_fn line_fn, + void *consume_callback_data, xpparam_t const *xpp, xdemitconf_t const *xecfg); -int parse_hunk_header(char *line, int len, - int *ob, int *on, - int *nb, int *nn); int read_mmfile(mmfile_t *ptr, const char *filename); void read_mmblob(mmfile_t *ptr, const struct object_id *oid); int buffer_is_binary(const char *ptr, unsigned long size); @@ -30,6 +33,14 @@ extern int git_xmerge_config(const char *var, const char *value, void *cb); extern int git_xmerge_style; /* + * Can be used as a no-op hunk_fn for xdi_diff_outf(), since a NULL + * one just sends the hunk line to the line_fn callback). + */ +void discard_hunk_line(void *priv, + long ob, long on, long nb, long nn, + const char *func, long funclen); + +/* * Compare the strings l1 with l2 which are of size s1 and s2 respectively. * Returns 1 if the strings are deemed equal, 0 otherwise. * The `flags` given as XDF_WHITESPACE_FLAGS determine how white spaces |