From: Bo Yang <struggleyb.nku@gmail.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, trast@student.ethz.ch
Subject: [PATCH 1/7] Add a prefix output callback to diff output.
Date: Sat, 15 May 2010 04:02:05 -0700 [thread overview]
Message-ID: <1273921331-32702-2-git-send-email-struggleyb.nku@gmail.com> (raw)
In-Reply-To: <1273921331-32702-1-git-send-email-struggleyb.nku@gmail.com>
The callback allow to output some prefix string for
each line of diff output.
Signed-off-by: Bo Yang <struggleyb.nku@gmail.com>
---
diff.c | 11 ++++++++---
diff.h | 5 +++++
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/diff.c b/diff.c
index e49f14a..2a38bef 100644
--- a/diff.c
+++ b/diff.c
@@ -282,11 +282,16 @@ static void check_blank_at_eof(mmfile_t *mf1, mmfile_t *mf2,
ecbdata->blank_at_eof_in_postimage = (at - l2) + 1;
}
-static void emit_line_0(FILE *file, const char *set, const char *reset,
+static void emit_line_0(struct diff_options *o, const char *set, const char *reset,
int first, const char *line, int len)
{
int has_trailing_newline, has_trailing_carriage_return;
int nofirst;
+ FILE *file = o->file;
+
+ if (o->output_prefix) {
+ o->output_prefix(file, 1, o->output_prefix_data);
+ }
if (len == 0) {
has_trailing_newline = (first == '\n');
@@ -316,10 +321,10 @@ static void emit_line_0(FILE *file, const char *set, const char *reset,
fputc('\n', file);
}
-static void emit_line(FILE *file, const char *set, const char *reset,
+static void emit_line(struct diff_options *o, const char *set, const char *reset,
const char *line, int len)
{
- emit_line_0(file, set, reset, line[0], line+1, len-1);
+ emit_line_0(o, set, reset, line[0], line+1, len-1);
}
static int new_blank_line_at_eof(struct emit_callback *ecbdata, const char *line, int len)
diff --git a/diff.h b/diff.h
index 6a71013..0031dd8 100644
--- a/diff.h
+++ b/diff.h
@@ -9,6 +9,7 @@
struct rev_info;
struct diff_options;
struct diff_queue_struct;
+struct strbuf;
typedef void (*change_fn_t)(struct diff_options *options,
unsigned old_mode, unsigned new_mode,
@@ -25,6 +26,8 @@ typedef void (*add_remove_fn_t)(struct diff_options *options,
typedef void (*diff_format_fn_t)(struct diff_queue_struct *q,
struct diff_options *options, void *data);
+typedef struct strbuf *(*diff_prefix_fn_t)(FILE *file, int print, void *data);
+
#define DIFF_FORMAT_RAW 0x0001
#define DIFF_FORMAT_DIFFSTAT 0x0002
#define DIFF_FORMAT_NUMSTAT 0x0004
@@ -122,6 +125,8 @@ struct diff_options {
add_remove_fn_t add_remove;
diff_format_fn_t format_callback;
void *format_callback_data;
+ diff_prefix_fn_t output_prefix;
+ void *output_prefix_data;
};
enum color_diff {
--
1.7.1.94.gc3269
next prev parent reply other threads:[~2010-05-15 11:02 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-15 11:02 [PATCH 0/7] Make git log --graph looks better with -p and other diff options Bo Yang
2010-05-15 11:02 ` Bo Yang [this message]
2010-05-15 11:02 ` [PATCH 2/7] Change to call the new emit_line Bo Yang
2010-05-15 11:02 ` [PATCH 3/7] Output the graph columns at the end of the commit message Bo Yang
2010-05-15 11:02 ` [PATCH 4/7] diff.c: Output the text graph padding before each diff line Bo Yang
2010-05-15 11:02 ` [PATCH 5/7] Emit a whole line once a time Bo Yang
2010-05-15 11:02 ` [PATCH 6/7] Register a callback for graph output Bo Yang
2010-05-15 11:02 ` [PATCH 7/7] Make --color-words work well with --graph Bo Yang
2010-05-17 6:59 ` Thomas Rast
2010-05-17 6:57 ` [PATCH 6/7] Register a callback for graph output Thomas Rast
2010-05-17 6:52 ` [PATCH 4/7] diff.c: Output the text graph padding before each diff line Thomas Rast
2010-05-17 6:45 ` [PATCH 2/7] Change to call the new emit_line Thomas Rast
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1273921331-32702-2-git-send-email-struggleyb.nku@gmail.com \
--to=struggleyb.nku@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=trast@student.ethz.ch \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).