diff options
author | Jeff King <peff@peff.net> | 2018-11-02 02:35:01 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-11-02 20:43:02 +0900 |
commit | 611e42a5980a3a9f8bb3b1b49c1abde63c7a191e (patch) | |
tree | 3c3e5ca8edb25cbb1ff14478c3e869d687b5a19e /builtin | |
parent | Git 2.19.1 (diff) | |
download | tgif-611e42a5980a3a9f8bb3b1b49c1abde63c7a191e.tar.xz |
xdiff: provide a separate emit callback for hunks
The xdiff library always emits hunk header lines to our callbacks as
formatted strings like "@@ -a,b +c,d @@\n". This is convenient if we're
going to output a diff, but less so if we actually need to compute using
those numbers, which requires re-parsing the line.
In preparation for moving away from this, let's teach xdiff a new
callback function which gets the broken-out hunk information. To help
callers that don't want to use this new callback, if it's NULL we'll
continue to format the hunk header into a string.
Note that this function renames the "outf" callback to "out_line", as
well. This isn't strictly necessary, but helps in two ways:
1. Now that there are two callbacks, it's nice to use more descriptive
names.
2. Many callers did not zero the emit_callback_data struct, and needed
to be modified to set ecb.out_hunk to NULL. By changing the name of
the existing struct member, that guarantees that any new callers
from in-flight topics will break the build and be examined
manually.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/merge-tree.c | 3 | ||||
-rw-r--r-- | builtin/rerere.c | 3 |
2 files changed, 4 insertions, 2 deletions
diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c index f8023bae1e..e7771a1012 100644 --- a/builtin/merge-tree.c +++ b/builtin/merge-tree.c @@ -110,7 +110,8 @@ static void show_diff(struct merge_list *entry) xpp.flags = 0; memset(&xecfg, 0, sizeof(xecfg)); xecfg.ctxlen = 3; - ecb.outf = show_outf; + ecb.out_hunk = NULL; + ecb.out_line = show_outf; ecb.priv = NULL; src.ptr = origin(entry, &size); diff --git a/builtin/rerere.c b/builtin/rerere.c index 0bc40298c2..ea409e80cb 100644 --- a/builtin/rerere.c +++ b/builtin/rerere.c @@ -41,7 +41,8 @@ static int diff_two(const char *file1, const char *label1, xpp.flags = 0; memset(&xecfg, 0, sizeof(xecfg)); xecfg.ctxlen = 3; - ecb.outf = outf; + ecb.out_hunk = NULL; + ecb.out_line = outf; ret = xdi_diff(&minus, &plus, &xpp, &xecfg, &ecb); free(minus.ptr); |