commit d2dfa2ecef800c3522c233c56c05b8a91f859fe0 from: Stefan Sperling date: Wed Oct 07 23:32:36 2020 UTC fix unidiff output header in case both files have only one line commit - ede9a86acbafeb41c2521bc32df592eb913a3f7e commit + d2dfa2ecef800c3522c233c56c05b8a91f859fe0 blob - 715e8c6ecb06cac5859a9514a294598e33a63288 blob + 17ab051ba2a7971ebb60db4df55ab097121d070d --- lib/diff_output_unidiff.c +++ lib/diff_output_unidiff.c @@ -199,7 +199,10 @@ output_unidiff_chunk(struct diff_output_info *outinfo, else right_start = cc->right.start + 1; - if (left_len == 1 && right_len != 1) { + if (left_len == 1 && right_len == 1) { + rc = fprintf(dest, "@@ -%d +%d @@\n", + left_start, right_start); + } else if (left_len == 1 && right_len != 1) { rc = fprintf(dest, "@@ -%d +%d,%d @@\n", left_start, right_start, right_len); } else if (left_len != 1 && right_len == 1) { blob - ac93bcd3ccf2615381907e61aa9e07d216224f59 blob + a6a06181d8406284c36762c8a2f9d252eab1f9db --- test/expect007.diff +++ test/expect007.diff @@ -1,5 +1,5 @@ --- test007.left.txt +++ test007.right.txt -@@ -1,1 +1,1 @@ +@@ -1 +1 @@ -x +abcdx