@matheusbsbs / matheus-bagliano / commits / 0424558190
Fork 0

diff: support custom callbacks for output

Users can request the DIFF_FORMAT_CALLBACK output format to get a callback consisting of the whole diff_queue_struct. Signed-off-by: Junio C Hamano <junkio@cox.net>

Jeff King committed Sep 7, 2006 at 02:35 UTC 0424558190fb85e6702e7c64cd2b11bc31d7be85
2 files changed +11
diff.c
+3
@@ -2587,6 +2587,9 @@ void diff_flush(struct diff_options *options)
2587 }
2588 }
2589
2590 + if (output_format & DIFF_FORMAT_CALLBACK)
2591 + options->format_callback(q, options, options->format_callback_data);
2592 +
2593 for (i = 0; i < q->nr; i++)
2594 diff_free_filepair(q->queue[i]);
2595 free_queue:
diff.h
+8
@@ -8,6 +8,7 @@
8
9 struct rev_info;
10 struct diff_options;
11 +struct diff_queue_struct;
12
13 typedef void (*change_fn_t)(struct diff_options *options,
14 unsigned old_mode, unsigned new_mode,
@@ -20,6 +21,9 @@ typedef void (*add_remove_fn_t)(struct diff_options *options,
21 const unsigned char *sha1,
22 const char *base, const char *path);
23
24 +typedef void (*diff_format_fn_t)(struct diff_queue_struct *q,
25 + struct diff_options *options, void *data);
26 +
27 #define DIFF_FORMAT_RAW 0x0001
28 #define DIFF_FORMAT_DIFFSTAT 0x0002
29 #define DIFF_FORMAT_SUMMARY 0x0004
@@ -35,6 +39,8 @@ typedef void (*add_remove_fn_t)(struct diff_options *options,
39 */
40 #define DIFF_FORMAT_NO_OUTPUT 0x0080
41
42 +#define DIFF_FORMAT_CALLBACK 0x0100
43 +
44 struct diff_options {
45 const char *filter;
46 const char *orderfile;
@@ -68,6 +74,8 @@ struct diff_options {
74 int *pathlens;
75 change_fn_t change;
76 add_remove_fn_t add_remove;
77 + diff_format_fn_t format_callback;
78 + void *format_callback_data;
79 };
80
81 enum color_diff {