Merge branch 'ab/commit-m-with-fixup' into maint
"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
This commit is contained in:
@ -144,6 +144,8 @@ OPTIONS
|
|||||||
Use the given <msg> as the commit message.
|
Use the given <msg> as the commit message.
|
||||||
If multiple `-m` options are given, their values are
|
If multiple `-m` options are given, their values are
|
||||||
concatenated as separate paragraphs.
|
concatenated as separate paragraphs.
|
||||||
|
+
|
||||||
|
The `-m` option is mutually exclusive with `-c`, `-C`, and `-F`.
|
||||||
|
|
||||||
-t <file>::
|
-t <file>::
|
||||||
--template=<file>::
|
--template=<file>::
|
||||||
|
@ -701,7 +701,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (have_option_m) {
|
if (have_option_m && !fixup_message) {
|
||||||
strbuf_addbuf(&sb, &message);
|
strbuf_addbuf(&sb, &message);
|
||||||
hook_arg1 = "message";
|
hook_arg1 = "message";
|
||||||
} else if (logfile && !strcmp(logfile, "-")) {
|
} else if (logfile && !strcmp(logfile, "-")) {
|
||||||
@ -731,6 +731,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
|
|||||||
ctx.output_encoding = get_commit_output_encoding();
|
ctx.output_encoding = get_commit_output_encoding();
|
||||||
format_commit_message(commit, "fixup! %s\n\n",
|
format_commit_message(commit, "fixup! %s\n\n",
|
||||||
&sb, &ctx);
|
&sb, &ctx);
|
||||||
|
if (have_option_m)
|
||||||
|
strbuf_addbuf(&sb, &message);
|
||||||
hook_arg1 = "message";
|
hook_arg1 = "message";
|
||||||
} else if (!stat(git_path_merge_msg(), &statbuf)) {
|
} else if (!stat(git_path_merge_msg(), &statbuf)) {
|
||||||
/*
|
/*
|
||||||
@ -1197,8 +1199,8 @@ static int parse_and_validate_options(int argc, const char *argv[],
|
|||||||
f++;
|
f++;
|
||||||
if (f > 1)
|
if (f > 1)
|
||||||
die(_("Only one of -c/-C/-F/--fixup can be used."));
|
die(_("Only one of -c/-C/-F/--fixup can be used."));
|
||||||
if (have_option_m && f > 0)
|
if (have_option_m && (edit_message || use_message || logfile))
|
||||||
die((_("Option -m cannot be combined with -c/-C/-F/--fixup.")));
|
die((_("Option -m cannot be combined with -c/-C/-F.")));
|
||||||
if (f || have_option_m)
|
if (f || have_option_m)
|
||||||
template_file = NULL;
|
template_file = NULL;
|
||||||
if (edit_message)
|
if (edit_message)
|
||||||
|
@ -272,6 +272,14 @@ test_expect_success 'commit --fixup provides correct one-line commit message' '
|
|||||||
commit_msg_is "fixup! target message subject line"
|
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' '
|
test_expect_success 'commit --squash works with -F' '
|
||||||
commit_for_rebase_autosquash_setup &&
|
commit_for_rebase_autosquash_setup &&
|
||||||
echo "log message from file" >msgfile &&
|
echo "log message from file" >msgfile &&
|
||||||
@ -325,7 +333,6 @@ test_expect_success 'invalid message options when using --fixup' '
|
|||||||
test_must_fail git commit --fixup HEAD~1 --squash HEAD~2 &&
|
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 -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
|
test_must_fail git commit --fixup HEAD~1 -F log
|
||||||
'
|
'
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user