commit - 9dabce8a40d592a5f30843b4cacede063f7e7f56
commit + a5cbcf9c3cc6d3acdf73a4c8a1075b1ebd417fb8
blob - 73727fdb051ba22832e667597be76eb7af2da131
blob + c7fe3adc5f0ce38b80665f0f7703d3d608ba0047
--- lib/diff_output.c
+++ lib/diff_output.c
fprintf(dest, "\n");
}
}
-
-enum diff_rc diff_output_info(FILE *dest, const struct diff_input_info *info)
-{
- fprintf(dest, "--- %s\n+++ %s\n",
- info->left_path ? : "a",
- info->right_path ? : "b");
- return DIFF_RC_OK;
-}
blob - 796c3ee69f83bf338c67c8b310b27c2dea7501f1
blob + d8f61ff77eef405b021f593b8318945d4009d855
--- lib/diff_output_plain.c
+++ lib/diff_output_plain.c
if (result->rc != DIFF_RC_OK)
return result->rc;
- diff_output_info(dest, info);
-
int i;
for (i = 0; i < result->chunks.len; i++) {
struct diff_chunk *c = &result->chunks.head[i];
blob - 372263de595ed3969e52c25db8662df4ad2b69ab
blob + 88af78d02c8b9ea34cd771d45cb8b465fa9982c9
--- lib/diff_output_unidiff.c
+++ lib/diff_output_unidiff.c
ranges_merge(&cc->right, &other->right);
}
-static void diff_output_unidiff_chunk(FILE *dest, bool *info_printed, const struct diff_input_info *info,
+static void diff_output_unidiff_chunk(FILE *dest, bool *header_printed, const struct diff_input_info *info,
const struct diff_result *result, const struct chunk_context *cc)
{
if (range_empty(&cc->left) && range_empty(&cc->right))
return;
- if (!(*info_printed)) {
- diff_output_info(dest, info);
- *info_printed = true;
+ if (!(*header_printed)) {
+ fprintf(dest, "--- %s\n+++ %s\n",
+ info->left_path ? : "a",
+ info->right_path ? : "b");
+ *header_printed = true;
}
fprintf(dest, "@@ -%d,%d +%d,%d @@\n",
return result->rc;
struct chunk_context cc = {};
- bool info_printed = false;
+ bool header_printed = false;
int i;
for (i = 0; i < result->chunks.len; i++) {
* this next one. Print the previous one and start fresh here. */
debug("new chunk to be printed does not touch previous chunk; print left %d-%d right %d-%d\n",
cc.left.start, cc.left.end, cc.right.start, cc.right.end);
- diff_output_unidiff_chunk(dest, &info_printed, info, result, &cc);
+ diff_output_unidiff_chunk(dest, &header_printed, info, result, &cc);
cc = next;
debug("new unprinted chunk is left %d-%d right %d-%d\n",
cc.left.start, cc.left.end, cc.right.start, cc.right.end);
}
if (!chunk_context_empty(&cc))
- diff_output_unidiff_chunk(dest, &info_printed, info, result, &cc);
+ diff_output_unidiff_chunk(dest, &header_printed, info, result, &cc);
return DIFF_RC_OK;
}