Merge branch 'jn/update-contrib-example-merge'
authorJunio C Hamano <gitster@pobox.com>
Fri, 3 Sep 2010 16:43:42 +0000 (09:43 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 3 Sep 2010 16:43:42 +0000 (09:43 -0700)
* jn/update-contrib-example-merge: (24 commits)
merge script: learn --[no-]rerere-autoupdate
merge script: notice @{-1} shorthand
merge script: handle --no-ff --no-commit correctly
merge script: --ff-only to disallow true merge
merge script: handle many-way octopus
merge script: handle -m --log correctly
merge script: forbid merge -s index
merge script: allow custom strategies
merge script: merge -X<option>
merge script: improve log message subject
merge script: refuse to merge during merge
merge script: tweak unmerged files message to match builtin
merge script: --squash, --ff from unborn branch are errors
fmt-merge-msg -m to override merge title
merge-base --independent to print reduced parent list in a merge
merge-base --octopus to mimic show-branch --merge-base
Documentation: add a SEE ALSO section for merge-base
t6200 (fmt-merge-msg): style nitpicks
t6010 (merge-base): modernize style
t7600 (merge): test merge from branch yet to be born
...

1  2 
builtin/fmt-merge-msg.c
builtin/merge.c
diff --combined builtin/fmt-merge-msg.c
index a76cd4e9d131eb76edb8a88f675dc14d4b3f597e,937d5a717ba3dd71e908f59297a5085e31b48c07..e7e12eea250691a2c0d70964d1fffea0923dd292
@@@ -7,7 -7,7 +7,7 @@@
  #include "string-list.h"
  
  static const char * const fmt_merge_msg_usage[] = {
-       "git fmt-merge-msg [--log|--no-log] [--file <file>]",
+       "git fmt-merge-msg [-m <message>] [--log|--no-log] [--file <file>]",
        NULL
  };
  
@@@ -38,8 -38,8 +38,8 @@@ void init_src_data(struct src_data *dat
        data->generic.strdup_strings = 1;
  }
  
 -static struct string_list srcs = { NULL, 0, 0, 1 };
 -static struct string_list origins = { NULL, 0, 0, 1 };
 +static struct string_list srcs = STRING_LIST_INIT_DUP;
 +static struct string_list origins = STRING_LIST_INIT_DUP;
  
  static int handle_line(char *line)
  {
@@@ -146,7 -146,7 +146,7 @@@ static void shortlog(const char *name, 
        int i, count = 0;
        struct commit *commit;
        struct object *branch;
 -      struct string_list subjects = { NULL, 0, 0, 1 };
 +      struct string_list subjects = STRING_LIST_INIT_DUP;
        int flags = UNINTERESTING | TREESAME | SEEN | SHOWN | ADDED;
        struct strbuf sb = STRBUF_INIT;
  
@@@ -319,11 -319,14 +319,14 @@@ int fmt_merge_msg_shortlog(struct strbu
  int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
  {
        const char *inpath = NULL;
+       const char *message = NULL;
        struct option options[] = {
                OPT_BOOLEAN(0, "log",     &merge_summary, "populate log with the shortlog"),
                { OPTION_BOOLEAN, 0, "summary", &merge_summary, NULL,
                  "alias for --log (deprecated)",
                  PARSE_OPT_NOARG | PARSE_OPT_HIDDEN },
+               OPT_STRING('m', "message", &message, "text",
+                       "use <text> as start of message"),
                OPT_FILENAME('F', "file", &inpath, "file to read from"),
                OPT_END()
        };
                             0);
        if (argc > 0)
                usage_with_options(fmt_merge_msg_usage, options);
+       if (message && !merge_summary) {
+               char nl = '\n';
+               write_in_full(STDOUT_FILENO, message, strlen(message));
+               write_in_full(STDOUT_FILENO, &nl, 1);
+               return 0;
+       }
  
        if (inpath && strcmp(inpath, "-")) {
                in = fopen(inpath, "r");
  
        if (strbuf_read(&input, fileno(in), 0) < 0)
                die_errno("could not read input file");
-       ret = fmt_merge_msg(merge_summary, &input, &output);
+       if (message) {
+               strbuf_addstr(&output, message);
+               ret = fmt_merge_msg_shortlog(&input, &output);
+       } else {
+               ret = fmt_merge_msg(merge_summary, &input, &output);
+       }
        if (ret)
                return ret;
        write_in_full(STDOUT_FILENO, output.buf, output.len);
diff --combined builtin/merge.c
index da26cd629a4ba16f95f9c27d28f67573dcf21c1e,2207f79969975225077ff16c7c368c4652548862..576e81f14578661461d71230c896436fab3023f9
@@@ -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;
  
@@@ -438,7 -437,7 +438,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 -486,7 +487,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 -624,6 +628,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 -704,7 +717,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 -816,7 +830,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 -1301,5 +1315,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);
  }