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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

Signed-off-by: Junio C Hamano <junkio@xxxxxxx>
---
 diff.c |    7 +++++++
 diff.h |    1 +
 2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/diff.c b/diff.c
index d8f9242..3cdb47a 100644
--- a/diff.c
+++ b/diff.c
@@ -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 --git a/diff.h b/diff.h
index a0d2ce1..2fc86eb 100644
--- a/diff.h
+++ b/diff.h
@@ -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,
-- 
1.5.1.777.gd14d3


-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]