Merge branch 'ab/commit-m-with-fixup'
authorJunio C Hamano <gitster@pobox.com>
Tue, 23 Jan 2018 21:16:38 +0000 (13:16 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 23 Jan 2018 21:16:38 +0000 (13:16 -0800)
"git commit --fixup" did not allow "-m<message>" option to be used
at the same time; allow it to annotate resulting commit with more
text.

* ab/commit-m-with-fixup:
commit: add support for --fixup <commit> -m"<extra message>"
commit doc: document that -c, -C, -F and --fixup with -m error

1  2 
builtin/commit.c
t/t7500-commit.sh
diff --combined builtin/commit.c
index 1f11e3992db512084b6ad834d69ac6d2de0a8c1c,4e683943919c9200209a3c7247b5d2927ebfbbc7..4610e3d8e3e04a70678a102cc3e0e7472089a3cf
@@@ -701,7 -701,7 +701,7 @@@ static int prepare_to_commit(const cha
                }
        }
  
-       if (have_option_m) {
+       if (have_option_m && !fixup_message) {
                strbuf_addbuf(&sb, &message);
                hook_arg1 = "message";
        } else if (logfile && !strcmp(logfile, "-")) {
                ctx.output_encoding = get_commit_output_encoding();
                format_commit_message(commit, "fixup! %s\n\n",
                                      &sb, &ctx);
+               if (have_option_m)
+                       strbuf_addbuf(&sb, &message);
                hook_arg1 = "message";
        } else if (!stat(git_path_merge_msg(), &statbuf)) {
                /*
@@@ -1197,8 -1199,8 +1199,8 @@@ static int parse_and_validate_options(i
                f++;
        if (f > 1)
                die(_("Only one of -c/-C/-F/--fixup can be used."));
-       if (have_option_m && f > 0)
-               die((_("Option -m cannot be combined with -c/-C/-F/--fixup.")));
+       if (have_option_m && (edit_message || use_message || logfile))
+               die((_("Option -m cannot be combined with -c/-C/-F.")));
        if (f || have_option_m)
                template_file = NULL;
        if (edit_message)
@@@ -1507,7 -1509,7 +1509,7 @@@ static void print_summary(const char *p
        rev.show_root_diff = 1;
        get_commit_format(format.buf, &rev);
        rev.always_show_header = 0;
 -      rev.diffopt.detect_rename = 1;
 +      rev.diffopt.detect_rename = DIFF_DETECT_RENAME;
        rev.diffopt.break_opt = 0;
        diff_setup_done(&rev.diffopt);
  
diff --combined t/t7500-commit.sh
index 1d33c5feb3e23744a5709e2f9bf429d23f49101f,2d95778b74b8fdb3e4d2e00b458d8b5f2beb3576..170b4810e052cc8092cea4ead4f3c098707f0f38
@@@ -130,8 -130,8 +130,8 @@@ EO
  test_expect_success 'commit message from template with whitespace issue' '
        echo "content galore" >>foo &&
        git add foo &&
 -      GIT_EDITOR="$TEST_DIRECTORY"/t7500/add-whitespaced-content git commit \
 -              --template "$TEMPLATE" &&
 +      GIT_EDITOR=\""$TEST_DIRECTORY"\"/t7500/add-whitespaced-content \
 +      git commit --template "$TEMPLATE" &&
        commit_msg_is "commit message"
  '
  
@@@ -272,6 -272,14 +272,14 @@@ test_expect_success 'commit --fixup pro
        commit_msg_is "fixup! target message subject line"
  '
  
+ test_expect_success 'commit --fixup -m"something" -m"extra"' '
+       commit_for_rebase_autosquash_setup &&
+       git commit --fixup HEAD~1 -m"something" -m"extra" &&
+       commit_msg_is "fixup! target message subject linesomething
+ extra"
+ '
  test_expect_success 'commit --squash works with -F' '
        commit_for_rebase_autosquash_setup &&
        echo "log message from file" >msgfile &&
@@@ -325,7 -333,6 +333,6 @@@ test_expect_success 'invalid message op
        test_must_fail git commit --fixup HEAD~1 --squash HEAD~2 &&
        test_must_fail git commit --fixup HEAD~1 -C HEAD~2 &&
        test_must_fail git commit --fixup HEAD~1 -c HEAD~2 &&
-       test_must_fail git commit --fixup HEAD~1 -m "cmdline message" &&
        test_must_fail git commit --fixup HEAD~1 -F log
  '