Merge branch 'jn/merge-custom-no-trivial'
authorJunio C Hamano <gitster@pobox.com>
Fri, 3 Sep 2010 16:43:43 +0000 (09:43 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 3 Sep 2010 16:43:43 +0000 (09:43 -0700)
* jn/merge-custom-no-trivial:
t7606: Avoid using head as a file name
merge: let custom strategies intervene in trivial merges
t7606 (merge-theirs): modernize style

1  2 
builtin/merge.c
diff --combined builtin/merge.c
index 576e81f14578661461d71230c896436fab3023f9,e48e90bb696e0aed31707f43199bfc8d8d070894..4e4ec898e6cd8bed9f43e2cb8d8958cd6160e766
@@@ -54,7 -54,6 +54,7 @@@ static size_t use_strategies_nr, use_st
  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;
  
@@@ -132,6 -131,7 +132,7 @@@ static struct strategy *get_strategy(co
  
        ret = xcalloc(1, sizeof(struct strategy));
        ret->name = xstrdup(name);
+       ret->attr = NO_TRIVIAL;
        return ret;
  }
  
@@@ -438,7 -438,7 +439,7 @@@ static void merge_name(const char *remo
                strbuf_addstr(&truname, "refs/heads/");
                strbuf_addstr(&truname, remote);
                strbuf_setlen(&truname, truname.len - len);
 -              if (resolve_ref(truname.buf, buf_sha, 0, NULL)) {
 +              if (resolve_ref(truname.buf, buf_sha, 1, NULL)) {
                        strbuf_addf(msg,
                                    "%s\t\tbranch '%s'%s of .\n",
                                    sha1_to_hex(remote_head->sha1),
@@@ -487,8 -487,7 +488,8 @@@ static int git_merge_config(const char 
                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++;
                return git_config_string(&pull_octopus, k, v);
        else if (!strcmp(k, "merge.log") || !strcmp(k, "merge.summary"))
                option_log = git_config_bool(k, v);
 +      else if (!strcmp(k, "merge.renormalize"))
 +              option_renormalize = git_config_bool(k, v);
        return git_diff_ui_config(k, v, cb);
  }
  
@@@ -628,11 -625,6 +629,11 @@@ static int try_merge_strategy(const cha
                if (!strcmp(strategy, "subtree"))
                        o.subtree_shift = "";
  
 +              o.renormalize = option_renormalize;
 +
 +              /*
 +               * NEEDSWORK: merge with table in builtin/merge-recursive
 +               */
                for (x = 0; x < xopts_nr; x++) {
                        if (!strcmp(xopts[x], "ours"))
                                o.recursive_variant = MERGE_RECURSIVE_OURS;
                                o.subtree_shift = "";
                        else if (!prefixcmp(xopts[x], "subtree="))
                                o.subtree_shift = xopts[x]+8;
 +                      else if (!strcmp(xopts[x], "renormalize"))
 +                              o.renormalize = 1;
 +                      else if (!strcmp(xopts[x], "no-renormalize"))
 +                              o.renormalize = 0;
                        else
                                die("Unknown option for merge-recursive: -X%s", xopts[x]);
                }
@@@ -717,8 -705,7 +718,8 @@@ int checkout_fast_forward(const unsigne
        opts.verbose_update = 1;
        opts.merge = 1;
        opts.fn = twoway_merge;
 -      opts.msgs = get_porcelain_error_msgs();
 +      opts.show_all_errors = 1;
 +      set_porcelain_error_msgs(opts.msgs, "merge");
  
        trees[nr_trees] = parse_tree_indirect(head);
        if (!trees[nr_trees++])
@@@ -830,7 -817,7 +831,7 @@@ static int finish_automerge(struct comm
        return 0;
  }
  
 -static int suggest_conflicts(void)
 +static int suggest_conflicts(int renormalizing)
  {
        FILE *fp;
        int pos;
@@@ -1315,5 -1302,5 +1316,5 @@@ int cmd_merge(int argc, const char **ar
                        "stopped before committing as requested\n");
                return 0;
        } else
 -              return suggest_conflicts();
 +              return suggest_conflicts(option_renormalize);
  }