From: Junio C Hamano Date: Thu, 22 Mar 2018 21:24:09 +0000 (-0700) Subject: Merge branch 'nd/diff-flush-before-warning' into maint X-Git-Tag: v2.16.3~32 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/b32221935e82d74d653212339442606d98aa7594 Merge branch 'nd/diff-flush-before-warning' into maint Avoid showing a warning message in the middle of a line of "git diff" output. * nd/diff-flush-before-warning: diff.c: flush stdout before printing rename warnings --- b32221935e82d74d653212339442606d98aa7594 diff --cc diff.c index db4696fdf5,bfd1bd2410..e9d0e38123 --- a/diff.c +++ b/diff.c @@@ -5454,59 -4623,15 +5454,60 @@@ N_("you may want to set your %s variabl void diff_warn_rename_limit(const char *varname, int needed, int degraded_cc) { + fflush(stdout); if (degraded_cc) - warning(degrade_cc_to_c_warning); + warning(_(degrade_cc_to_c_warning)); else if (needed) - warning(rename_limit_warning); + warning(_(rename_limit_warning)); else return; - if (0 < needed && needed < 32767) - warning(rename_limit_advice, varname, needed); + if (0 < needed) + warning(_(rename_limit_advice), varname, needed); +} + +static void diff_flush_patch_all_file_pairs(struct diff_options *o) +{ + int i; + static struct emitted_diff_symbols esm = EMITTED_DIFF_SYMBOLS_INIT; + struct diff_queue_struct *q = &diff_queued_diff; + + if (WSEH_NEW & WS_RULE_MASK) + die("BUG: WS rules bit mask overlaps with diff symbol flags"); + + if (o->color_moved) + o->emitted_symbols = &esm; + + for (i = 0; i < q->nr; i++) { + struct diff_filepair *p = q->queue[i]; + if (check_pair_status(p)) + diff_flush_patch(p, o); + } + + if (o->emitted_symbols) { + if (o->color_moved) { + struct hashmap add_lines, del_lines; + + hashmap_init(&del_lines, + (hashmap_cmp_fn)moved_entry_cmp, o, 0); + hashmap_init(&add_lines, + (hashmap_cmp_fn)moved_entry_cmp, o, 0); + + add_lines_to_move_detection(o, &add_lines, &del_lines); + mark_color_as_moved(o, &add_lines, &del_lines); + if (o->color_moved == COLOR_MOVED_ZEBRA_DIM) + dim_moved_lines(o); + + hashmap_free(&add_lines, 0); + hashmap_free(&del_lines, 0); + } + + for (i = 0; i < esm.nr; i++) + emit_diff_symbol_from_struct(o, &esm.buf[i]); + + for (i = 0; i < esm.nr; i++) + free((void *)esm.buf[i].line); + } + esm.nr = 0; } void diff_flush(struct diff_options *options)