Skip to content

Commit 831287d

Browse files
committed
Merge branch 'cw/cherry-pick-allow-empty-message'
"git cherry-pick" by default stops when it sees a commit without any log message. The "--allow-empty-message" option can be used to silently proceed. * cw/cherry-pick-allow-empty-message: cherry-pick: add --allow-empty-message option
2 parents 12d858a + 4bee958 commit 831287d

File tree

5 files changed

+16
-0
lines changed

5 files changed

+16
-0
lines changed

Documentation/git-cherry-pick.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ effect to your index in a row.
118118
previous commit are dropped. To force the inclusion of those commits
119119
use `--keep-redundant-commits`.
120120

121+
--allow-empty-message::
122+
By default, cherry-picking a commit with an empty message will fail.
123+
This option overrides that behaviour, allowing commits with empty
124+
messages to be cherry picked.
125+
121126
--keep-redundant-commits::
122127
If a commit being cherry picked duplicates a commit already in the
123128
current history, it will become empty. By default these

builtin/revert.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,15 @@ static void parse_args(int argc, const char **argv, struct replay_opts *opts)
117117
OPT_END(),
118118
OPT_END(),
119119
OPT_END(),
120+
OPT_END(),
120121
};
121122

122123
if (opts->action == REPLAY_PICK) {
123124
struct option cp_extra[] = {
124125
OPT_BOOLEAN('x', NULL, &opts->record_origin, "append commit name"),
125126
OPT_BOOLEAN(0, "ff", &opts->allow_ff, "allow fast-forward"),
126127
OPT_BOOLEAN(0, "allow-empty", &opts->allow_empty, "preserve initially empty commits"),
128+
OPT_BOOLEAN(0, "allow-empty-message", &opts->allow_empty_message, "allow commits with empty messages"),
127129
OPT_BOOLEAN(0, "keep-redundant-commits", &opts->keep_redundant_commits, "keep redundant, empty commits"),
128130
OPT_END(),
129131
};

sequencer.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,9 @@ static int run_git_commit(const char *defmsg, struct replay_opts *opts,
311311
if (allow_empty)
312312
argv_array_push(&array, "--allow-empty");
313313

314+
if (opts->allow_empty_message)
315+
argv_array_push(&array, "--allow-empty-message");
316+
314317
rc = run_command_v_opt(array.argv, RUN_GIT_CMD);
315318
argv_array_clear(&array);
316319
return rc;

sequencer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ struct replay_opts {
3030
int allow_ff;
3131
int allow_rerere_auto;
3232
int allow_empty;
33+
int allow_empty_message;
3334
int keep_redundant_commits;
3435

3536
int mainline;

t/t3505-cherry-pick-empty.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ test_expect_success 'index lockfile was removed' '
5353
5454
'
5555

56+
test_expect_success 'cherry-pick a commit with an empty message with --allow-empty-message' '
57+
git checkout -f master &&
58+
git cherry-pick --allow-empty-message empty-branch
59+
'
60+
5661
test_expect_success 'cherry pick an empty non-ff commit without --allow-empty' '
5762
git checkout master &&
5863
echo fourth >>file2 &&

0 commit comments

Comments
 (0)