Skip to content

Commit 7168624

Browse files
raalkmlgitster
authored andcommitted
Do not generate full commit log message if it is not going to be used
Like when it is already specified through -C, -F or -m to git-commit. Signed-off-by: Alex Riesen <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e475fe1 commit 7168624

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

builtin-commit.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,28 @@ static int prepare_log_message(const char *index_file, const char *prefix)
367367

368368
strbuf_release(&sb);
369369

370+
if (no_edit) {
371+
struct rev_info rev;
372+
unsigned char sha1[40];
373+
374+
fclose(fp);
375+
376+
if (!active_nr && read_cache() < 0)
377+
die("Cannot read index");
378+
379+
if (get_sha1("HEAD", sha1) != 0)
380+
return !!active_nr;
381+
382+
init_revisions(&rev, "");
383+
rev.abbrev = 0;
384+
setup_revisions(0, NULL, &rev, "HEAD");
385+
DIFF_OPT_SET(&rev.diffopt, QUIET);
386+
DIFF_OPT_SET(&rev.diffopt, EXIT_WITH_STATUS);
387+
run_diff_index(&rev, 1 /* cached */);
388+
389+
return !!DIFF_OPT_TST(&rev.diffopt, HAS_CHANGES);
390+
}
391+
370392
if (in_merge && !no_edit)
371393
fprintf(fp,
372394
"#\n"

0 commit comments

Comments
 (0)