зеркало из https://github.com/microsoft/git.git
add -p (built-in): imitate `xdl_format_hunk_hdr()` generating hunk headers
In libxdiff, imitating GNU diff, the hunk headers only show the line count if it is different from 1. When splitting hunks, the Perl version of `git add -p` already imitates this. Let's do the same in the built-in version of said command. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
cb581b16ef
Коммит
decc9ee4ea
11
add-patch.c
11
add-patch.c
|
@ -661,9 +661,14 @@ static void render_hunk(struct add_p_state *s, struct hunk *hunk,
|
||||||
else
|
else
|
||||||
new_offset += delta;
|
new_offset += delta;
|
||||||
|
|
||||||
strbuf_addf(out, "@@ -%lu,%lu +%lu,%lu @@",
|
strbuf_addf(out, "@@ -%lu", old_offset);
|
||||||
old_offset, header->old_count,
|
if (header->old_count != 1)
|
||||||
new_offset, header->new_count);
|
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)
|
if (len)
|
||||||
strbuf_add(out, p, len);
|
strbuf_add(out, p, len);
|
||||||
else if (colored)
|
else if (colored)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче