Skip to contentSkip to conversation

diff: allow showing a warning message before the diff.

PATCH In review Junio C Hamano 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 diff: allow showing a warning message before the diff.

This allows the caller to add an informational message at the beginning of the diff, when output is produced by diff_flush(). It (ab)uses the WHITESPACE color; we should probably have named that as WARNING color instead, as the existing use is already about warnings.

Nobody uses this yet, but the next one does.

---
 diff.c |    7 +++++++
 diff.h |    1 +
 2 files changed, 8 insertions(+), 0 deletions(-)
diff.c +7 -0
index d8f9242..3cdb47a 100644
@@ -2796,6 +2796,13 @@ void diff_flush(struct diff_options *options)
 	if (!q->nr)
 		goto free_queue;
 
+	if (options->warning) {
+		const char *reset, *set;
+		set = diff_get_color(options->color_diff, DIFF_WHITESPACE);
+		reset = diff_get_color(options->color_diff, DIFF_RESET);
+		printf("%s%s%s\n", set, options->warning, reset);
+	}
+
 	if (output_format & (DIFF_FORMAT_RAW |
 			     DIFF_FORMAT_NAME |
 			     DIFF_FORMAT_NAME_STATUS |
diff.h +1 -0
index a0d2ce1..2fc86eb 100644
@@ -48,6 +48,7 @@ struct diff_options {
 	const char *orderfile;
 	const char *pickaxe;
 	const char *single_follow;
+	const char *warning;
 	unsigned recursive:1,
 		 tree_in_recursive:1,
 		 binary:1,
Signature · 1 line
1.5.1.777.gd14d3