aboutsummaryrefslogtreecommitdiffstats
path: root/xdiff-interface.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2018-11-02 02:37:18 -0400
committerJunio C Hamano <gitster@pobox.com>2018-11-05 13:14:35 +0900
commit7c61e25fbf1a4a65208be1197940a383f220a1b7 (patch)
tree71ec85c998587ae798a4b30f5c154225a5041ec0 /xdiff-interface.c
parentb135739125e9dc49fafc42d4a8a1956c46329ff1 (diff)
downloadgit-7c61e25fbf1a4a65208be1197940a383f220a1b7.tar.gz
diff: use hunk callback for word-diff
Our word-diff does not look at the -/+ lines generated by xdiff at all (because they are not real lines to show the user, but just the tokenized words split into lines). Instead we use the line numbers from the hunk headers to index our own data structure. As a result, our xdi_diff_outf() callback throws away all lines except hunk headers. We can instead use a hunk callback, which has two benefits: 1. We don't have to re-parse the generated hunk header line, but can use the passed parameters directly. 2. By setting our line callback to NULL, we can tell xdiff-interface that it does not even need to bother generating the other lines, saving a small amount of work. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'xdiff-interface.c')
-rw-r--r--xdiff-interface.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/xdiff-interface.c b/xdiff-interface.c
index b99a57825f..a23adb3c45 100644
--- a/xdiff-interface.c
+++ b/xdiff-interface.c
@@ -95,6 +95,9 @@ static int xdiff_outf(void *priv_, mmbuffer_t *mb, int nbuf)
struct xdiff_emit_state *priv = priv_;
int i;
+ if (!priv->line_fn)
+ return 0;
+
for (i = 0; i < nbuf; i++) {
if (mb[i].ptr[mb[i].size-1] != '\n') {
/* Incomplete line */