everyday: replace 'prune' and 'repack' with 'gc'
[gitweb.git] / builtin-commit.c
index ad9f9211b39af6cc7d1f319b6a8da7c514a33f12..96410de55ddbc52eb116049b4f6a2792a5386cb4 100644 (file)
@@ -375,6 +375,7 @@ static int prepare_log_message(const char *index_file, const char *prefix)
        if (no_edit) {
                struct rev_info rev;
                unsigned char sha1[40];
+               const char *parent = "HEAD";
 
                fclose(fp);
 
@@ -384,9 +385,12 @@ static int prepare_log_message(const char *index_file, const char *prefix)
                if (get_sha1("HEAD", sha1) != 0)
                        return !!active_nr;
 
+               if (amend)
+                       parent = "HEAD^1";
+
                init_revisions(&rev, "");
                rev.abbrev = 0;
-               setup_revisions(0, NULL, &rev, "HEAD");
+               setup_revisions(0, NULL, &rev, parent);
                DIFF_OPT_SET(&rev.diffopt, QUIET);
                DIFF_OPT_SET(&rev.diffopt, EXIT_WITH_STATUS);
                run_diff_index(&rev, 1 /* cached */);
@@ -537,7 +541,7 @@ static int parse_and_validate_options(int argc, const char *argv[],
                die("Option -m cannot be combined with -c/-C/-F.");
        if (edit_message)
                use_message = edit_message;
-       if (amend)
+       if (amend && !use_message)
                use_message = "HEAD";
        if (use_message) {
                unsigned char sha1[20];
@@ -662,6 +666,10 @@ static void print_summary(const char *prefix, const unsigned char *sha1)
        rev.show_root_diff = 1;
        rev.commit_format = get_commit_format("format:%h: %s");
        rev.always_show_header = 0;
+       rev.diffopt.detect_rename = 1;
+       rev.diffopt.rename_limit = 100;
+       rev.diffopt.break_opt = 0;
+       diff_setup_done(&rev.diffopt);
 
        printf("Created %scommit ", initial_commit ? "initial " : "");