From: Junio C Hamano Date: Fri, 21 May 2010 11:02:17 +0000 (-0700) Subject: Merge branch 'tr/word-diff' X-Git-Tag: v1.7.2-rc0~124 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=1bdd46cd3a2fe1e0aeb965fb0edb493064e24495;p=git.git Merge branch 'tr/word-diff' * tr/word-diff: diff: add --word-diff option that generalizes --color-words Conflicts: diff.c --- 1bdd46cd3a2fe1e0aeb965fb0edb493064e24495 diff --cc diff.c index 43a313deb,d81a57a3c..502b30167 --- a/diff.c +++ b/diff.c @@@ -683,7 -748,9 +736,8 @@@ static void diff_words_show(struct diff { xpparam_t xpp; xdemitconf_t xecfg; - xdemitcb_t ecb; mmfile_t minus, plus; + struct diff_words_style *style = diff_words->style; /* special case: only removal */ if (!diff_words->plus.text.size) { @@@ -1759,10 -1838,23 +1823,23 @@@ static void builtin_diff(const char *na die ("Invalid regular expression: %s", o->word_regex); } + for (i = 0; i < ARRAY_SIZE(diff_words_styles); i++) { + if (o->word_diff == diff_words_styles[i].type) { + ecbdata.diff_words->style = + &diff_words_styles[i]; + break; + } + } + if (DIFF_OPT_TST(o, COLOR_DIFF)) { + struct diff_words_style *st = ecbdata.diff_words->style; + st->old.color = diff_get_color_opt(o, DIFF_FILE_OLD); + st->new.color = diff_get_color_opt(o, DIFF_FILE_NEW); + st->ctx.color = diff_get_color_opt(o, DIFF_PLAIN); + } } xdi_diff_outf(&mf1, &mf2, fn_out_consume, &ecbdata, - &xpp, &xecfg, &ecb); + &xpp, &xecfg); - if (DIFF_OPT_TST(o, COLOR_DIFF_WORDS)) + if (o->word_diff) free_diff_words_data(&ecbdata); if (textconv_one) free(mf1.ptr);