Commit Diff


commit - 9dabce8a40d592a5f30843b4cacede063f7e7f56
commit + a5cbcf9c3cc6d3acdf73a4c8a1075b1ebd417fb8
blob - 73727fdb051ba22832e667597be76eb7af2da131
blob + c7fe3adc5f0ce38b80665f0f7703d3d608ba0047
--- lib/diff_output.c
+++ lib/diff_output.c
@@ -40,11 +40,3 @@ void diff_output_lines(FILE *dest, const char *prefix,
 		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
@@ -25,8 +25,6 @@ enum diff_rc diff_output_plain(FILE *dest, const struc
 	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
@@ -89,15 +89,17 @@ static void chunk_contexts_merge(struct chunk_context 
 	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",
@@ -143,7 +145,7 @@ enum diff_rc diff_output_unidiff(FILE *dest, const str
 		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++) {
@@ -187,14 +189,14 @@ enum diff_rc diff_output_unidiff(FILE *dest, const str
 		 * 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;
 }