Code

clone: factor out checkout code
[git.git] / builtin / commit.c
index d0f27f931aae51555083ed6192474eaeb8b1694c..5891e95758a0d2530b325bd5fd346e15702e3017 100644 (file)
@@ -104,7 +104,7 @@ static enum commit_whence whence;
 static int use_editor = 1, include_status = 1;
 static int show_ignored_in_status;
 static const char *only_include_assumed;
-static struct strbuf message;
+static struct strbuf message = STRBUF_INIT;
 
 static int null_termination;
 static enum {
@@ -139,7 +139,7 @@ static struct option builtin_commit_options[] = {
        OPT_STRING('C', "reuse-message", &use_message, "commit", "reuse message from specified commit"),
        OPT_STRING(0, "fixup", &fixup_message, "commit", "use autosquash formatted message to fixup specified commit"),
        OPT_STRING(0, "squash", &squash_message, "commit", "use autosquash formatted message to squash specified commit"),
-       OPT_BOOLEAN(0, "reset-author", &renew_authorship, "the commit is authored by me now (used with -C-c/--amend)"),
+       OPT_BOOLEAN(0, "reset-author", &renew_authorship, "the commit is authored by me now (used with -C/-c/--amend)"),
        OPT_BOOLEAN('s', "signoff", &signoff, "add Signed-off-by:"),
        OPT_FILENAME('t', "template", &template_file, "use specified template file"),
        OPT_BOOL('e', "edit", &edit_flag, "force edit of commit"),
@@ -1485,10 +1485,14 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
                exit(1);
        }
 
-       if (amend)
+       if (amend) {
                extra = read_commit_extra_headers(current_head);
+       } else {
+               struct commit_extra_header **tail = &extra;
+               append_merge_tag_headers(parents, &tail);
+       }
 
-       if (commit_tree_extended(sb.buf, active_cache_tree->sha1, parents, sha1,
+       if (commit_tree_extended(&sb, active_cache_tree->sha1, parents, sha1,
                                 author_ident.buf, extra)) {
                rollback_index_files();
                die(_("failed to write commit object"));