cherry-pick: add --allow-empty-message option
Scripts such as "git rebase -i" cannot currently cherry-pick commits which have an empty commit message, as git cherry-pick calls git commit without the --allow-empty-message option. Add an --allow-empty-message option to git cherry-pick which is passed through to git commit, so this behaviour can be overridden. Signed-off-by: Chris Webb <chris@arachsys.com> Reviewed-by: Neil Horman <nhorman@tuxdriver.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
3fe4498197
commit
4bee958479
@ -116,6 +116,11 @@ effect to your index in a row.
|
|||||||
previous commit are dropped. To force the inclusion of those commits
|
previous commit are dropped. To force the inclusion of those commits
|
||||||
use `--keep-redundant-commits`.
|
use `--keep-redundant-commits`.
|
||||||
|
|
||||||
|
--allow-empty-message::
|
||||||
|
By default, cherry-picking a commit with an empty message will fail.
|
||||||
|
This option overrides that behaviour, allowing commits with empty
|
||||||
|
messages to be cherry picked.
|
||||||
|
|
||||||
--keep-redundant-commits::
|
--keep-redundant-commits::
|
||||||
If a commit being cherry picked duplicates a commit already in the
|
If a commit being cherry picked duplicates a commit already in the
|
||||||
current history, it will become empty. By default these
|
current history, it will become empty. By default these
|
||||||
|
@ -117,6 +117,7 @@ static void parse_args(int argc, const char **argv, struct replay_opts *opts)
|
|||||||
OPT_END(),
|
OPT_END(),
|
||||||
OPT_END(),
|
OPT_END(),
|
||||||
OPT_END(),
|
OPT_END(),
|
||||||
|
OPT_END(),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (opts->action == REPLAY_PICK) {
|
if (opts->action == REPLAY_PICK) {
|
||||||
@ -124,6 +125,7 @@ static void parse_args(int argc, const char **argv, struct replay_opts *opts)
|
|||||||
OPT_BOOLEAN('x', NULL, &opts->record_origin, "append commit name"),
|
OPT_BOOLEAN('x', NULL, &opts->record_origin, "append commit name"),
|
||||||
OPT_BOOLEAN(0, "ff", &opts->allow_ff, "allow fast-forward"),
|
OPT_BOOLEAN(0, "ff", &opts->allow_ff, "allow fast-forward"),
|
||||||
OPT_BOOLEAN(0, "allow-empty", &opts->allow_empty, "preserve initially empty commits"),
|
OPT_BOOLEAN(0, "allow-empty", &opts->allow_empty, "preserve initially empty commits"),
|
||||||
|
OPT_BOOLEAN(0, "allow-empty-message", &opts->allow_empty_message, "allow commits with empty messages"),
|
||||||
OPT_BOOLEAN(0, "keep-redundant-commits", &opts->keep_redundant_commits, "keep redundant, empty commits"),
|
OPT_BOOLEAN(0, "keep-redundant-commits", &opts->keep_redundant_commits, "keep redundant, empty commits"),
|
||||||
OPT_END(),
|
OPT_END(),
|
||||||
};
|
};
|
||||||
|
@ -311,6 +311,9 @@ static int run_git_commit(const char *defmsg, struct replay_opts *opts,
|
|||||||
if (allow_empty)
|
if (allow_empty)
|
||||||
argv_array_push(&array, "--allow-empty");
|
argv_array_push(&array, "--allow-empty");
|
||||||
|
|
||||||
|
if (opts->allow_empty_message)
|
||||||
|
argv_array_push(&array, "--allow-empty-message");
|
||||||
|
|
||||||
rc = run_command_v_opt(array.argv, RUN_GIT_CMD);
|
rc = run_command_v_opt(array.argv, RUN_GIT_CMD);
|
||||||
argv_array_clear(&array);
|
argv_array_clear(&array);
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -30,6 +30,7 @@ struct replay_opts {
|
|||||||
int allow_ff;
|
int allow_ff;
|
||||||
int allow_rerere_auto;
|
int allow_rerere_auto;
|
||||||
int allow_empty;
|
int allow_empty;
|
||||||
|
int allow_empty_message;
|
||||||
int keep_redundant_commits;
|
int keep_redundant_commits;
|
||||||
|
|
||||||
int mainline;
|
int mainline;
|
||||||
|
@ -53,6 +53,11 @@ test_expect_success 'index lockfile was removed' '
|
|||||||
|
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'cherry-pick a commit with an empty message with --allow-empty-message' '
|
||||||
|
git checkout -f master &&
|
||||||
|
git cherry-pick --allow-empty-message empty-branch
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'cherry pick an empty non-ff commit without --allow-empty' '
|
test_expect_success 'cherry pick an empty non-ff commit without --allow-empty' '
|
||||||
git checkout master &&
|
git checkout master &&
|
||||||
echo fourth >>file2 &&
|
echo fourth >>file2 &&
|
||||||
|
Loading…
Reference in New Issue
Block a user