Merge branch 'lg/merge-signoff'
authorJunio C Hamano <gitster@pobox.com>
Thu, 24 Aug 2017 17:20:01 +0000 (10:20 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 24 Aug 2017 17:20:02 +0000 (10:20 -0700)
"git merge" learned a "--signoff" option to add the Signed-off-by:
trailer with the committer's name.

* lg/merge-signoff:
merge: add a --signoff flag

1  2 
builtin/merge.c
diff --combined builtin/merge.c
index 328945d6093aae40410b0c437a21c588ac6d6692,78c36e9bf353b53a1a0dad38a4804e6f3b2de980..cc570529932344d3c3477281576ab5642818e3aa
@@@ -70,6 -70,7 +70,7 @@@ static int continue_current_merge
  static int allow_unrelated_histories;
  static int show_progress = -1;
  static int default_to_upstream = 1;
+ static int signoff;
  static const char *sign_commit;
  
  static struct strategy all_strategy[] = {
@@@ -233,6 -234,7 +234,7 @@@ static struct option builtin_merge_opti
        { OPTION_STRING, 'S', "gpg-sign", &sign_commit, N_("key-id"),
          N_("GPG sign commit"), PARSE_OPT_OPTARG, NULL, (intptr_t) "" },
        OPT_BOOL(0, "overwrite-ignore", &overwrite_ignore, N_("update ignored files (default)")),
+       OPT_BOOL(0, "signoff", &signoff, N_("add Signed-off-by:")),
        OPT_END()
  };
  
@@@ -537,7 -539,7 +539,7 @@@ static void parse_branch_merge_options(
                die(_("Bad branch.%s.mergeoptions string: %s"), branch,
                    split_cmdline_strerror(argc));
        REALLOC_ARRAY(argv, argc + 2);
 -      memmove(argv + 1, argv, sizeof(*argv) * (argc + 1));
 +      MOVE_ARRAY(argv + 1, argv, argc + 1);
        argc++;
        argv[0] = "branch.*.mergeoptions";
        parse_options(argc, argv, NULL, builtin_merge_options,
@@@ -566,7 -568,7 +568,7 @@@ static int git_merge_config(const char 
        else if (!strcmp(k, "merge.renormalize"))
                option_renormalize = git_config_bool(k, v);
        else if (!strcmp(k, "merge.ff")) {
 -              int boolval = git_config_maybe_bool(k, v);
 +              int boolval = git_parse_maybe_bool(v);
                if (0 <= boolval) {
                        fast_forward = boolval ? FF_ALLOW : FF_NO;
                } else if (v && !strcmp(v, "only")) {
@@@ -763,6 -765,8 +765,8 @@@ static void prepare_to_commit(struct co
        strbuf_addch(&msg, '\n');
        if (0 < option_edit)
                strbuf_commented_addf(&msg, _(merge_editor_comment), comment_line_char);
+       if (signoff)
+               append_signoff(&msg, ignore_non_trailer(msg.buf, msg.len), 0);
        write_file_buf(git_path_merge_msg(), msg.buf, msg.len);
        if (run_commit_hook(0 < option_edit, get_index_file(), "prepare-commit-msg",
                            git_path_merge_msg(), "merge", NULL))
@@@ -940,7 -944,7 +944,7 @@@ static int default_edit_option(void
                return 0;
  
        if (e) {
 -              int v = git_config_maybe_bool(name, e);
 +              int v = git_parse_maybe_bool(e);
                if (v < 0)
                        die(_("Bad value '%s' in environment '%s'"), e, name);
                return v;
@@@ -1117,8 -1121,8 +1121,8 @@@ int cmd_merge(int argc, const char **ar
         * current branch.
         */
        branch = branch_to_free = resolve_refdup("HEAD", 0, head_oid.hash, NULL);
 -      if (branch && starts_with(branch, "refs/heads/"))
 -              branch += 11;
 +      if (branch)
 +              skip_prefix(branch, "refs/heads/", &branch);
        if (!branch || is_null_oid(&head_oid))
                head_commit = NULL;
        else