diff options
| author | Junio C Hamano <gitster@pobox.com> | 2021-07-13 16:52:50 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2021-07-13 16:52:50 -0700 |
| commit | 4da281e84d87b099ba8d0a255534dc1251be968e (patch) | |
| tree | 5919bdb367772fbbbe822f72f33ea2256b94d33a /xdiff-interface.h | |
| parent | Merge branch 'hn/prep-tests-for-reftable' (diff) | |
| parent | xdiff-interface: replace discard_hunk_line() with a flag (diff) | |
| download | git-4da281e84d87b099ba8d0a255534dc1251be968e.tar.gz git-4da281e84d87b099ba8d0a255534dc1251be968e.zip | |
Merge branch 'ab/pickaxe-pcre2'
Rewrite the backend for "diff -G/-S" to use pcre2 engine when
available.
* ab/pickaxe-pcre2: (22 commits)
xdiff-interface: replace discard_hunk_line() with a flag
xdiff users: use designated initializers for out_line
pickaxe -G: don't special-case create/delete
pickaxe -G: terminate early on matching lines
xdiff-interface: allow early return from xdiff_emit_line_fn
xdiff-interface: prepare for allowing early return
pickaxe -S: slightly optimize contains()
pickaxe: rename variables in has_changes() for brevity
pickaxe -S: support content with NULs under --pickaxe-regex
pickaxe: assert that we must have a needle under -G or -S
pickaxe: refactor function selection in diffcore-pickaxe()
perf: add performance test for pickaxe
pickaxe/style: consolidate declarations and assignments
diff.h: move pickaxe fields together again
pickaxe: die when --find-object and --pickaxe-all are combined
pickaxe: die when -G and --pickaxe-regex are combined
pickaxe tests: add missing test for --no-pickaxe-regex being an error
pickaxe tests: test for -G, -S and --find-object incompatibility
pickaxe tests: add test for "log -S" not being a regex
pickaxe tests: add test for diffgrep_consume() internals
...
Diffstat (limited to 'xdiff-interface.h')
| -rw-r--r-- | xdiff-interface.h | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/xdiff-interface.h b/xdiff-interface.h index 93df26900c..4301a7eef2 100644 --- a/xdiff-interface.h +++ b/xdiff-interface.h @@ -11,7 +11,28 @@ */ #define MAX_XDIFF_SIZE (1024UL * 1024 * 1023) -typedef void (*xdiff_emit_line_fn)(void *, char *, unsigned long); +/** + * The `xdiff_emit_line_fn` function can return 1 to abort early, or 0 + * to continue processing. Note that doing so is an all-or-nothing + * affair, as returning 1 will return all the way to the top-level, + * e.g. the xdi_diff_outf() call to generate the diff. + * + * Thus returning 1 means you won't be getting any more diff lines. If + * you need something in-between those two options you'll to use + * `xdl_emit_hunk_consume_func_t` and implement your own version of + * xdl_emit_diff(). + * + * We may extend the interface in the future to understand other more + * granular return values. While you should return 1 to exit early, + * doing so will currently make your early return indistinguishable + * from an error internal to xdiff, xdiff itself will see that + * non-zero return and translate it to -1. + * + * See "diff_grep" in diffcore-pickaxe.c for a trick to work around + * this, i.e. using the "consume_callback_data" to note the desired + * early return. + */ +typedef int (*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, @@ -33,14 +54,6 @@ 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 |
