summaryrefslogtreecommitdiff
path: root/tests-clar/diff/diff_helpers.c
diff options
context:
space:
mode:
authorVicent Martí <vicent@github.com>2013-11-04 08:05:55 -0800
committerVicent Martí <vicent@github.com>2013-11-04 08:05:55 -0800
commit5a0b88036f612ce7e9cdc24517c9b9eb6100a3d7 (patch)
tree835825d113deeceef856702bfd7b427648579b4d /tests-clar/diff/diff_helpers.c
parentbecb13c0f04c4ba54cf27303136293dbf8abfd73 (diff)
parent3e57069e821ecf966c3de9c79923cd77657e923b (diff)
downloadlibgit2-5a0b88036f612ce7e9cdc24517c9b9eb6100a3d7.tar.gz
Merge pull request #1929 from libgit2/rb/misc-diff-fixes
Fix some observed problems with incorrect diffs
Diffstat (limited to 'tests-clar/diff/diff_helpers.c')
-rw-r--r--tests-clar/diff/diff_helpers.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/tests-clar/diff/diff_helpers.c b/tests-clar/diff/diff_helpers.c
index 466d0ef54..33bb561f6 100644
--- a/tests-clar/diff/diff_helpers.c
+++ b/tests-clar/diff/diff_helpers.c
@@ -221,11 +221,15 @@ static int diff_print_cb(
const git_diff_line *line,
void *payload)
{
- GIT_UNUSED(payload);
- GIT_UNUSED(delta);
- GIT_UNUSED(hunk);
- fprintf((FILE *)payload, "%c%.*s",
- line->origin, (int)line->content_len, line->content);
+ FILE *fp = payload;
+
+ GIT_UNUSED(delta); GIT_UNUSED(hunk);
+
+ if (line->origin == GIT_DIFF_LINE_CONTEXT ||
+ line->origin == GIT_DIFF_LINE_ADDITION ||
+ line->origin == GIT_DIFF_LINE_DELETION)
+ fputc(line->origin, fp);
+ fwrite(line->content, 1, line->content_len, fp);
return 0;
}