From 3b5f795446601868d52d09ebac70ae3b7aee157a Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Mon, 21 Oct 2013 13:42:42 -0700 Subject: Create git_diff_line and extend git_diff_hunk Instead of having functions with so very many parameters to pass hunk and line data, this takes the existing git_diff_hunk struct and extends it with more hunk data, plus adds a git_diff_line. Those structs are used to pass back hunk and line data instead of the old APIs that took tons of parameters. Some work that was previously only being done for git_diff_patch creation (scanning the diff content for exact line counts) is now done for all callbacks, but the performance difference should not be noticable. --- examples/log.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'examples/log.c') diff --git a/examples/log.c b/examples/log.c index 30de16ae9..4c2df07c9 100644 --- a/examples/log.c +++ b/examples/log.c @@ -184,14 +184,18 @@ static void print_commit(git_commit *commit) static int print_diff( const git_diff_delta *delta, - const git_diff_hunk *range, - char usage, - const char *line, - size_t line_len, + const git_diff_hunk *hunk, + const git_diff_line *line, void *data) { - (void)delta; (void)range; (void)usage; (void)line_len; (void)data; - fputs(line, stdout); + (void)delta; (void)hunk; (void)data; + + if (line->origin == GIT_DIFF_LINE_CONTEXT || + line->origin == GIT_DIFF_LINE_ADDITION || + line->origin == GIT_DIFF_LINE_DELETION) + fputc(line->origin, stdout); + + fwrite(line->content, 1, line->content_len, stdout); return 0; } -- cgit v1.2.1