Commit Diff


commit - 8993f42562696079866fc2dec7191877b6cc1f18
commit + 1edd9c2b609adfa7ed93dbd839b7d683e695feaa
blob - 304efb917050acadd79aae06eec9473ae5fdc797
blob + e2f352bf17421cfdc1dd349b9740f53d91599b2e
--- include/diff_output.h
+++ include/diff_output.h
@@ -53,7 +53,8 @@ struct diff_chunk_context {
 
 int diff_output_plain(struct diff_output_info **output_info, FILE *dest,
 			const struct diff_input_info *info,
-			const struct diff_result *result);
+			const struct diff_result *result,
+			int hunk_headers_only);
 int diff_output_unidiff(struct diff_output_info **output_info,
 			FILE *dest, const struct diff_input_info *info,
 			const struct diff_result *result,
blob - 60533bd949aeec8ada84abec88bf7e58e93f5ff5
blob + 7b0082bd1b84c999c55bbf418266fd4a41017a0c
--- lib/diff_output_plain.c
+++ lib/diff_output_plain.c
@@ -31,7 +31,7 @@ static int
 output_plain_chunk(struct diff_output_info *outinfo,
     FILE *dest, const struct diff_input_info *info,
     const struct diff_result *result,
-    struct diff_chunk_context *cc, off_t *outoff)
+    struct diff_chunk_context *cc, off_t *outoff, bool headers_only)
 {
 	off_t *offp;
 	int left_start, left_len, right_start, right_len;
@@ -113,7 +113,8 @@ output_plain_chunk(struct diff_output_info *outinfo,
 	 * additions and deletions when this happens.
 	 */
 	int c_idx;
-	for (c_idx = cc->chunk.start; c_idx < cc->chunk.end; c_idx++) {
+	for (c_idx = cc->chunk.start; !headers_only && c_idx < cc->chunk.end;
+	    c_idx++) {
 		const struct diff_chunk *c = &result->chunks.head[c_idx];
 		if (c->left_count && !c->right_count)
 			rc = diff_output_lines(outinfo, dest,
@@ -152,7 +153,7 @@ output_plain_chunk(struct diff_output_info *outinfo,
 int
 diff_output_plain(struct diff_output_info **output_info,
     FILE *dest, const struct diff_input_info *info,
-    const struct diff_result *result)
+    const struct diff_result *result, int hunk_headers_only)
 {
 	struct diff_output_info *outinfo = NULL;
 	struct diff_chunk_context cc = {};
@@ -233,13 +234,13 @@ diff_output_plain(struct diff_output_info **output_inf
 			continue;
 		}
 		rc = output_plain_chunk(outinfo, dest, info, result, &cc,
-		    &outoff);
+		    &outoff, hunk_headers_only);
 		if (rc != DIFF_RC_OK)
 			return rc;
 		cc = next;
 	}
 	if (!diff_chunk_context_empty(&cc))
 		return output_plain_chunk(outinfo, dest, info, result, &cc,
-		    &outoff);
+		    &outoff, hunk_headers_only);
 	return DIFF_RC_OK;
 }