From: Junio C Hamano Date: Tue, 20 Dec 2011 21:24:12 +0000 (-0800) Subject: Merge branch 'jc/pull-signed-tag' X-Git-Tag: v1.7.9-rc0~38 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/4d466b69fe4695ffff1de1f494dada67074d2b50?ds=inline;hp=-c Merge branch 'jc/pull-signed-tag' * jc/pull-signed-tag: commit: do not lose mergetag header when not amending --- 4d466b69fe4695ffff1de1f494dada67074d2b50 diff --combined builtin/commit.c index d0f27f931a,0c64c880d5..626036a179 --- a/builtin/commit.c +++ b/builtin/commit.c @@@ -81,8 -81,7 +81,8 @@@ static const char *template_file static const char *author_message, *author_message_buffer; static char *edit_message, *use_message; static char *fixup_message, *squash_message; -static int all, edit_flag, also, interactive, patch_interactive, only, amend, signoff; +static int all, also, interactive, patch_interactive, only, amend, signoff; +static int edit_flag = -1; /* unspecified */ static int quiet, verbose, no_verify, allow_empty, dry_run, renew_authorship; static int no_post_rewrite, allow_empty_message; static char *untracked_files_arg, *force_date, *ignore_submodule_arg; @@@ -142,7 -141,7 +142,7 @@@ static struct option builtin_commit_opt 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_BOOLEAN('e', "edit", &edit_flag, "force edit of commit"), + OPT_BOOL('e', "edit", &edit_flag, "force edit of commit"), OPT_STRING(0, "cleanup", &cleanup_arg, "default", "how to strip spaces and #comments from message"), OPT_BOOLEAN(0, "status", &include_status, "include status in commit message template"), /* end commit message options */ @@@ -395,7 -394,6 +395,7 @@@ static char *prepare_index(int argc, co fd = hold_locked_index(&index_lock, 1); add_files_to_cache(also ? prefix : NULL, pathspec, 0); refresh_cache_or_die(refresh_flags); + update_main_cache_tree(1); if (write_cache(fd, active_cache, active_nr) || close_lock_file(&index_lock)) die(_("unable to write new_index file")); @@@ -416,7 -414,6 +416,7 @@@ fd = hold_locked_index(&index_lock, 1); refresh_cache_or_die(refresh_flags); if (active_cache_changed) { + update_main_cache_tree(1); if (write_cache(fd, active_cache, active_nr) || commit_locked_index(&index_lock)) die(_("unable to write new_index file")); @@@ -865,7 -862,10 +865,7 @@@ static int prepare_to_commit(const cha */ discard_cache(); read_cache_from(index_file); - if (!active_cache_tree) - active_cache_tree = cache_tree(); - if (cache_tree_update(active_cache_tree, - active_cache, active_nr, 0, 0) < 0) { + if (update_main_cache_tree(0)) { error(_("Error building trees")); return 0; } @@@ -1020,8 -1020,8 +1020,8 @@@ static int parse_and_validate_options(i if (logfile || message.len || use_message || fixup_message) use_editor = 0; - if (edit_flag) - use_editor = 1; + if (0 <= edit_flag) + use_editor = edit_flag; if (!use_editor) setenv("GIT_EDITOR", ":", 1); @@@ -1259,7 -1259,7 +1259,7 @@@ static void print_summary(const char *p struct commit *commit; struct strbuf format = STRBUF_INIT; unsigned char junk_sha1[20]; - const char *head = resolve_ref("HEAD", junk_sha1, 0, NULL); + const char *head; struct pretty_print_context pctx = {0}; struct strbuf author_ident = STRBUF_INIT; struct strbuf committer_ident = STRBUF_INIT; @@@ -1304,7 -1304,6 +1304,7 @@@ rev.diffopt.break_opt = 0; diff_setup_done(&rev.diffopt); + head = resolve_ref_unsafe("HEAD", junk_sha1, 0, NULL); printf("[%s%s ", !prefixcmp(head, "refs/heads/") ? head + 11 : @@@ -1485,8 -1484,12 +1485,12 @@@ int cmd_commit(int argc, const char **a 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, author_ident.buf, extra)) { @@@ -1520,7 -1523,6 +1524,7 @@@ } unlink(git_path("CHERRY_PICK_HEAD")); + unlink(git_path("REVERT_HEAD")); unlink(git_path("MERGE_HEAD")); unlink(git_path("MERGE_MSG")); unlink(git_path("MERGE_MODE"));