format-patch: teach --range-diff to respect -v/--reroll-count

The --range-diff option announces the embedded range-diff generically
as "Range-diff:", however, we can do better when --reroll-count is
specified by emitting "Range-diff against v{n}:" instead.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Eric Sunshine 2018-07-22 05:57:15 -04:00 committed by Junio C Hamano
parent 2e6fd71a52
commit 4ee9968941
2 changed files with 7 additions and 1 deletions

View File

@ -1092,7 +1092,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
}
if (rev->rdiff1) {
fprintf_ln(rev->diffopt.file, "%s", _("Range-diff:"));
fprintf_ln(rev->diffopt.file, "%s", rev->rdiff_title);
show_range_diff(rev->rdiff1, rev->rdiff2,
rev->creation_factor, 1, &rev->diffopt);
}
@ -1497,6 +1497,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
const char *rdiff_prev = NULL;
struct strbuf rdiff1 = STRBUF_INIT;
struct strbuf rdiff2 = STRBUF_INIT;
struct strbuf rdiff_title = STRBUF_INIT;
const struct option builtin_format_patch_options[] = {
{ OPTION_CALLBACK, 'n', "numbered", &numbered, NULL,
@ -1816,6 +1817,9 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
rev.rdiff1 = rdiff1.buf;
rev.rdiff2 = rdiff2.buf;
rev.creation_factor = RANGE_DIFF_CREATION_FACTOR_DEFAULT;
rev.rdiff_title = diff_title(&rdiff_title, reroll_count,
_("Range-diff:"),
_("Range-diff against v%d:"));
}
if (!signature) {
@ -1943,6 +1947,7 @@ done:
strbuf_release(&idiff_title);
strbuf_release(&rdiff1);
strbuf_release(&rdiff2);
strbuf_release(&rdiff_title);
return 0;
}

View File

@ -222,6 +222,7 @@ struct rev_info {
const char *rdiff1;
const char *rdiff2;
int creation_factor;
const char *rdiff_title;
/* commit counts */
int count_left;