@matheusbsbs / matheus-bagliano / commits / 7168624c35
Fork 0

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 <raa.lkml@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Alex Riesen committed Nov 28, 2007 at 22:13 UTC 7168624c3530d8c7ee32f930f8fb2ba302b9801f
1 file changed +22
builtin-commit.c
+22
@@ -367,6 +367,28 @@ static int prepare_log_message(const char *index_file, const char *prefix)
367
368 strbuf_release(&sb);
369
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 +
392 if (in_merge && !no_edit)
393 fprintf(fp,
394 "#\n"