summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--add-patch.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/add-patch.c b/add-patch.c
index bd94bd3a7c..55bd9d4f37 100644
--- a/add-patch.c
+++ b/add-patch.c
@@ -661,9 +661,14 @@ static void render_hunk(struct add_p_state *s, struct hunk *hunk,
else
new_offset += delta;
- strbuf_addf(out, "@@ -%lu,%lu +%lu,%lu @@",
- old_offset, header->old_count,
- new_offset, header->new_count);
+ strbuf_addf(out, "@@ -%lu", old_offset);
+ if (header->old_count != 1)
+ strbuf_addf(out, ",%lu", header->old_count);
+ strbuf_addf(out, " +%lu", new_offset);
+ if (header->new_count != 1)
+ strbuf_addf(out, ",%lu", header->new_count);
+ strbuf_addstr(out, " @@");
+
if (len)
strbuf_add(out, p, len);
else if (colored)