Merge branch 'jc/pull-signed-tag'
authorJunio C Hamano <gitster@pobox.com>
Tue, 20 Dec 2011 21:24:12 +0000 (13:24 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 20 Dec 2011 21:24:12 +0000 (13:24 -0800)
* jc/pull-signed-tag:
commit: do not lose mergetag header when not amending

1  2 
builtin/commit.c
diff --combined builtin/commit.c
index d0f27f931aae51555083ed6192474eaeb8b1694c,0c64c880d5fe7106e391e677f6a32dd46e73b36b..626036a179e1476ee28a9f2ff32fedc5b97dc5d0
@@@ -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"));
                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;
        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)) {
        }
  
        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"));