Skip to content

Commit 3482b42

Browse files
Mroikgitster
authored andcommitted
format-patch: refactor generate_commit_list_cover
Refactor for readability and remove unnecessary initialization. Signed-off-by: Mirko Faina <mroik@delayed.space> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 60cb27e commit 3482b42

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

builtin/log.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,12 +1376,11 @@ static void generate_commit_list_cover(FILE *cover_file, const char *format,
13761376
struct pretty_print_context ctx = {0};
13771377
struct rev_info rev = REV_INFO_INIT;
13781378

1379-
strbuf_init(&commit_line, 0);
13801379
rev.total = n;
13811380
ctx.rev = &rev;
1382-
for (int i = n - 1; i >= 0; i--) {
1383-
rev.nr = n - i;
1384-
repo_format_commit_message(the_repository, list[i], format,
1381+
for (int i = 1; i <= n; i++) {
1382+
rev.nr = i;
1383+
repo_format_commit_message(the_repository, list[n - i], format,
13851384
&commit_line, &ctx);
13861385
fprintf(cover_file, "%s\n", commit_line.buf);
13871386
strbuf_reset(&commit_line);

0 commit comments

Comments
 (0)