diff options
Diffstat (limited to 'diff.c')
-rw-r--r-- | diff.c | 20 |
1 files changed, 15 insertions, 5 deletions
@@ -561,6 +561,7 @@ static void emit_line(struct diff_options *o, const char *set, const char *reset } enum diff_symbol { + DIFF_SYMBOL_BINARY_FILES, DIFF_SYMBOL_HEADER, DIFF_SYMBOL_FILEPAIR_PLUS, DIFF_SYMBOL_FILEPAIR_MINUS, @@ -690,6 +691,7 @@ static void emit_diff_symbol(struct diff_options *o, enum diff_symbol s, line, reset, strchr(line, ' ') ? "\t" : ""); break; + case DIFF_SYMBOL_BINARY_FILES: case DIFF_SYMBOL_HEADER: fprintf(o->file, "%s", line); break; @@ -2542,6 +2544,7 @@ static void builtin_diff(const char *name_a, } else if (!DIFF_OPT_TST(o, TEXT) && ( (!textconv_one && diff_filespec_is_binary(one)) || (!textconv_two && diff_filespec_is_binary(two)) )) { + struct strbuf sb = STRBUF_INIT; if (!one->data && !two->data && S_ISREG(one->mode) && S_ISREG(two->mode) && !DIFF_OPT_TST(o, BINARY)) { @@ -2554,8 +2557,11 @@ static void builtin_diff(const char *name_a, } emit_diff_symbol(o, DIFF_SYMBOL_HEADER, header.buf, header.len, 0); - fprintf(o->file, "%sBinary files %s and %s differ\n", - line_prefix, lbl[0], lbl[1]); + strbuf_addf(&sb, "%sBinary files %s and %s differ\n", + diff_line_prefix(o), lbl[0], lbl[1]); + emit_diff_symbol(o, DIFF_SYMBOL_BINARY_FILES, + sb.buf, sb.len, 0); + strbuf_release(&sb); goto free_ab_and_return; } if (fill_mmfile(&mf1, one) < 0 || fill_mmfile(&mf2, two) < 0) @@ -2572,9 +2578,13 @@ static void builtin_diff(const char *name_a, strbuf_reset(&header); if (DIFF_OPT_TST(o, BINARY)) emit_binary_diff(o->file, &mf1, &mf2, line_prefix); - else - fprintf(o->file, "%sBinary files %s and %s differ\n", - line_prefix, lbl[0], lbl[1]); + else { + strbuf_addf(&sb, "%sBinary files %s and %s differ\n", + diff_line_prefix(o), lbl[0], lbl[1]); + emit_diff_symbol(o, DIFF_SYMBOL_BINARY_FILES, + sb.buf, sb.len, 0); + strbuf_release(&sb); + } o->found_changes = 1; } else { /* Crazy xdl interfaces.. */ |