Sync with 2.13.2
[gitweb.git] / builtin / commit.c
index 8d1cac0629e7079daeef57ac049c0c7d7549e6d0..021070e693e78fe49a168f842f64aeea73de4a8b 100644 (file)
@@ -6,6 +6,7 @@
  */
 
 #include "cache.h"
+#include "config.h"
 #include "lockfile.h"
 #include "cache-tree.h"
 #include "color.h"
@@ -253,7 +254,8 @@ static int list_paths(struct string_list *list, const char *with_tree,
 
        if (with_tree) {
                char *max_prefix = common_prefix(pattern);
-               overlay_tree_on_cache(with_tree, max_prefix ? max_prefix : prefix);
+               overlay_tree_on_index(&the_index, with_tree,
+                                     max_prefix ? max_prefix : prefix);
                free(max_prefix);
        }
 
@@ -313,7 +315,7 @@ static void create_base_index(const struct commit *current_head)
        opts.dst_index = &the_index;
 
        opts.fn = oneway_merge;
-       tree = parse_tree_indirect(current_head->object.oid.hash);
+       tree = parse_tree_indirect(&current_head->object.oid);
        if (!tree)
                die(_("failed to unpack HEAD tree object"));
        parse_tree(tree);
@@ -1263,6 +1265,10 @@ static int parse_status_slot(const char *slot)
                return WT_STATUS_NOBRANCH;
        if (!strcasecmp(slot, "unmerged"))
                return WT_STATUS_UNMERGED;
+       if (!strcasecmp(slot, "localBranch"))
+               return WT_STATUS_LOCAL_BRANCH;
+       if (!strcasecmp(slot, "remoteBranch"))
+               return WT_STATUS_REMOTE_BRANCH;
        return -1;
 }
 
@@ -1430,7 +1436,7 @@ static void print_summary(const char *prefix, const struct object_id *oid,
        struct strbuf author_ident = STRBUF_INIT;
        struct strbuf committer_ident = STRBUF_INIT;
 
-       commit = lookup_commit(oid->hash);
+       commit = lookup_commit(oid);
        if (!commit)
                die(_("couldn't look up newly created commit"));
        if (parse_commit(commit))
@@ -1654,7 +1660,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
        if (get_sha1("HEAD", oid.hash))
                current_head = NULL;
        else {
-               current_head = lookup_commit_or_die(oid.hash, "HEAD");
+               current_head = lookup_commit_or_die(&oid, "HEAD");
                if (parse_commit(current_head))
                        die(_("could not parse HEAD commit"));
        }
@@ -1695,10 +1701,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
                if (!reflog_msg)
                        reflog_msg = "commit (merge)";
                pptr = commit_list_append(current_head, pptr);
-               fp = fopen(git_path_merge_head(), "r");
-               if (fp == NULL)
-                       die_errno(_("could not open '%s' for reading"),
-                                 git_path_merge_head());
+               fp = xfopen(git_path_merge_head(), "r");
                while (strbuf_getline_lf(&m, fp) != EOF) {
                        struct commit *parent;
 
@@ -1758,7 +1761,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
                append_merge_tag_headers(parents, &tail);
        }
 
-       if (commit_tree_extended(sb.buf, sb.len, active_cache_tree->sha1,
+       if (commit_tree_extended(sb.buf, sb.len, active_cache_tree->oid.hash,
                         parents, oid.hash, author_ident.buf, sign_commit, extra)) {
                rollback_index_files();
                die(_("failed to write commit object"));
@@ -1805,7 +1808,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
                cfg = init_copy_notes_for_rewrite("amend");
                if (cfg) {
                        /* we are amending, so current_head is not NULL */
-                       copy_note_for_rewrite(cfg, current_head->object.oid.hash, oid.hash);
+                       copy_note_for_rewrite(cfg, &current_head->object.oid, &oid);
                        finish_copy_notes_for_rewrite(cfg, "Notes added by 'git commit --amend'");
                }
                run_rewrite_hook(&current_head->object.oid, &oid);