Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
diff.c: emit_diff_symbol learns DIFF_SYMBOL_HEADER
author
Stefan Beller
<sbeller@google.com>
Fri, 30 Jun 2017 00:06:57 +0000
(17:06 -0700)
committer
Junio C Hamano
<gitster@pobox.com>
Fri, 30 Jun 2017 20:13:01 +0000
(13:13 -0700)
The header is constructed lazily including line breaks, so just emit
the raw string as is.
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
3ee8b7b
)
diff --git
a/diff.c
b/diff.c
index 49b45fef29143b4e21e185e255247320ea2c4b90..78f7c6f82fd44f528809b02576fdb1f4405d55bc 100644
(file)
--- a/
diff.c
+++ b/
diff.c
@@
-561,6
+561,7
@@
static void emit_line(struct diff_options *o, const char *set, const char *reset
}
enum diff_symbol {
}
enum diff_symbol {
+ DIFF_SYMBOL_HEADER,
DIFF_SYMBOL_FILEPAIR_PLUS,
DIFF_SYMBOL_FILEPAIR_MINUS,
DIFF_SYMBOL_WORDS_PORCELAIN,
DIFF_SYMBOL_FILEPAIR_PLUS,
DIFF_SYMBOL_FILEPAIR_MINUS,
DIFF_SYMBOL_WORDS_PORCELAIN,
@@
-689,6
+690,9
@@
static void emit_diff_symbol(struct diff_options *o, enum diff_symbol s,
line, reset,
strchr(line, ' ') ? "\t" : "");
break;
line, reset,
strchr(line, ' ') ? "\t" : "");
break;
+ case DIFF_SYMBOL_HEADER:
+ fprintf(o->file, "%s", line);
+ break;
default:
die("BUG: unknown diff symbol");
}
default:
die("BUG: unknown diff symbol");
}
@@
-1385,7
+1389,8
@@
static void fn_out_consume(void *priv, char *line, unsigned long len)
o->found_changes = 1;
if (ecbdata->header) {
o->found_changes = 1;
if (ecbdata->header) {
- fprintf(o->file, "%s", ecbdata->header->buf);
+ emit_diff_symbol(o, DIFF_SYMBOL_HEADER,
+ ecbdata->header->buf, ecbdata->header->len, 0);
strbuf_reset(ecbdata->header);
ecbdata->header = NULL;
}
strbuf_reset(ecbdata->header);
ecbdata->header = NULL;
}
@@
-2519,7
+2524,8
@@
static void builtin_diff(const char *name_a,
if (complete_rewrite &&
(textconv_one || !diff_filespec_is_binary(one)) &&
(textconv_two || !diff_filespec_is_binary(two))) {
if (complete_rewrite &&
(textconv_one || !diff_filespec_is_binary(one)) &&
(textconv_two || !diff_filespec_is_binary(two))) {
- fprintf(o->file, "%s", header.buf);
+ emit_diff_symbol(o, DIFF_SYMBOL_HEADER,
+ header.buf, header.len, 0);
strbuf_reset(&header);
emit_rewrite_diff(name_a, name_b, one, two,
textconv_one, textconv_two, o);
strbuf_reset(&header);
emit_rewrite_diff(name_a, name_b, one, two,
textconv_one, textconv_two, o);
@@
-2529,7
+2535,8
@@
static void builtin_diff(const char *name_a,
}
if (o->irreversible_delete && lbl[1][0] == '/') {
}
if (o->irreversible_delete && lbl[1][0] == '/') {
- fprintf(o->file, "%s", header.buf);
+ emit_diff_symbol(o, DIFF_SYMBOL_HEADER, header.buf,
+ header.len, 0);
strbuf_reset(&header);
goto free_ab_and_return;
} else if (!DIFF_OPT_TST(o, TEXT) &&
strbuf_reset(&header);
goto free_ab_and_return;
} else if (!DIFF_OPT_TST(o, TEXT) &&
@@
-2540,10
+2547,13
@@
static void builtin_diff(const char *name_a,
!DIFF_OPT_TST(o, BINARY)) {
if (!oidcmp(&one->oid, &two->oid)) {
if (must_show_header)
!DIFF_OPT_TST(o, BINARY)) {
if (!oidcmp(&one->oid, &two->oid)) {
if (must_show_header)
- fprintf(o->file, "%s", header.buf);
+ emit_diff_symbol(o, DIFF_SYMBOL_HEADER,
+ header.buf, header.len,
+ 0);
goto free_ab_and_return;
}
goto free_ab_and_return;
}
- fprintf(o->file, "%s", header.buf);
+ 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]);
goto free_ab_and_return;
fprintf(o->file, "%sBinary files %s and %s differ\n",
line_prefix, lbl[0], lbl[1]);
goto free_ab_and_return;
@@
-2554,10
+2564,11
@@
static void builtin_diff(const char *name_a,
if (mf1.size == mf2.size &&
!memcmp(mf1.ptr, mf2.ptr, mf1.size)) {
if (must_show_header)
if (mf1.size == mf2.size &&
!memcmp(mf1.ptr, mf2.ptr, mf1.size)) {
if (must_show_header)
- fprintf(o->file, "%s", header.buf);
+ emit_diff_symbol(o, DIFF_SYMBOL_HEADER,
+ header.buf, header.len, 0);
goto free_ab_and_return;
}
goto free_ab_and_return;
}
-
fprintf(o->file, "%s", header.buf
);
+
emit_diff_symbol(o, DIFF_SYMBOL_HEADER, header.buf, header.len, 0
);
strbuf_reset(&header);
if (DIFF_OPT_TST(o, BINARY))
emit_binary_diff(o->file, &mf1, &mf2, line_prefix);
strbuf_reset(&header);
if (DIFF_OPT_TST(o, BINARY))
emit_binary_diff(o->file, &mf1, &mf2, line_prefix);
@@
-2575,7
+2586,8
@@
static void builtin_diff(const char *name_a,
const struct userdiff_funcname *pe;
if (must_show_header) {
const struct userdiff_funcname *pe;
if (must_show_header) {
- fprintf(o->file, "%s", header.buf);
+ emit_diff_symbol(o, DIFF_SYMBOL_HEADER,
+ header.buf, header.len, 0);
strbuf_reset(&header);
}
strbuf_reset(&header);
}