Code

vcs-svn: Check for errors from open()
[git.git] / builtin / merge.c
index 9e4733d25f94a4185acb99cbc53255cee2654c1b..10f091b51960cd6ae913b1c4d2ab9e6931862351 100644 (file)
@@ -54,6 +54,7 @@ static size_t use_strategies_nr, use_strategies_alloc;
 static const char **xopts;
 static size_t xopts_nr, xopts_alloc;
 static const char *branch;
+static int option_renormalize;
 static int verbosity;
 static int allow_rerere_auto;
 
@@ -131,6 +132,7 @@ static struct strategy *get_strategy(const char *name)
 
        ret = xcalloc(1, sizeof(struct strategy));
        ret->name = xstrdup(name);
+       ret->attr = NO_TRIVIAL;
        return ret;
 }
 
@@ -487,7 +489,8 @@ static int git_merge_config(const char *k, const char *v, void *cb)
                buf = xstrdup(v);
                argc = split_cmdline(buf, &argv);
                if (argc < 0)
-                       die("Bad branch.%s.mergeoptions string", branch);
+                       die("Bad branch.%s.mergeoptions string: %s", branch,
+                           split_cmdline_strerror(argc));
                argv = xrealloc(argv, sizeof(*argv) * (argc + 2));
                memmove(argv + 1, argv, sizeof(*argv) * (argc + 1));
                argc++;
@@ -502,8 +505,15 @@ static int git_merge_config(const char *k, const char *v, void *cb)
                return git_config_string(&pull_twohead, k, v);
        else if (!strcmp(k, "pull.octopus"))
                return git_config_string(&pull_octopus, k, v);
+       else if (!strcmp(k, "merge.renormalize"))
+               option_renormalize = git_config_bool(k, v);
        else if (!strcmp(k, "merge.log") || !strcmp(k, "merge.summary")) {
-               shortlog_len = git_config_bool(k, v) ? DEFAULT_MERGE_LOG_LEN : 0;
+               int is_bool;
+               shortlog_len = git_config_bool_or_int(k, v, &is_bool);
+               if (!is_bool && shortlog_len < 0)
+                       return error("%s: negative length %s", k, v);
+               if (is_bool && shortlog_len)
+                       shortlog_len = DEFAULT_MERGE_LOG_LEN;
                return 0;
        }
        return git_diff_ui_config(k, v, cb);
@@ -627,18 +637,11 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
                if (!strcmp(strategy, "subtree"))
                        o.subtree_shift = "";
 
-               for (x = 0; x < xopts_nr; x++) {
-                       if (!strcmp(xopts[x], "ours"))
-                               o.recursive_variant = MERGE_RECURSIVE_OURS;
-                       else if (!strcmp(xopts[x], "theirs"))
-                               o.recursive_variant = MERGE_RECURSIVE_THEIRS;
-                       else if (!strcmp(xopts[x], "subtree"))
-                               o.subtree_shift = "";
-                       else if (!prefixcmp(xopts[x], "subtree="))
-                               o.subtree_shift = xopts[x]+8;
-                       else
+               o.renormalize = option_renormalize;
+
+               for (x = 0; x < xopts_nr; x++)
+                       if (parse_merge_opt(&o, xopts[x]))
                                die("Unknown option for merge-recursive: -X%s", xopts[x]);
-               }
 
                o.branch1 = head_arg;
                o.branch2 = remoteheads->item->util;
@@ -707,7 +710,7 @@ int checkout_fast_forward(const unsigned char *head, const unsigned char *remote
        opts.verbose_update = 1;
        opts.merge = 1;
        opts.fn = twoway_merge;
-       opts.msgs = get_porcelain_error_msgs();
+       setup_unpack_trees_porcelain(&opts, "merge");
 
        trees[nr_trees] = parse_tree_indirect(head);
        if (!trees[nr_trees++])
@@ -819,7 +822,7 @@ static int finish_automerge(struct commit_list *common,
        return 0;
 }
 
-static int suggest_conflicts(void)
+static int suggest_conflicts(int renormalizing)
 {
        FILE *fp;
        int pos;
@@ -1302,5 +1305,5 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
                        "stopped before committing as requested\n");
                return 0;
        } else
-               return suggest_conflicts();
+               return suggest_conflicts(option_renormalize);
 }