commit: clarify FROM_REBASE_PICK and is_from_rebase() names

Commit 430b75f720 (commit: give correct advice for empty commit during
a rebase, 2019-12-06) introduced a FROM_REBASE_PICK enum value and an
is_from_rebase() function.  Those names failed to convey that they were
specifically about hitting a commit that becomes empty when rebasing.
Clarify their names now.

While at it, change `whence == FROM_REBASE_EMPTY` to use
`is_from_rebase_empty(whence)`.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
jch^2
Elijah Newren 2026-08-28 07:44:41 +00:00 committed by Junio C Hamano
parent e9019fcafe
commit ad3a039c31
3 changed files with 11 additions and 11 deletions

View File

@ -520,7 +520,7 @@ static const char *prepare_index(const char **argv, const char *prefix,
die(_("cannot do a partial commit during a merge."));
else if (is_from_cherry_pick(whence))
die(_("cannot do a partial commit during a cherry-pick."));
else if (is_from_rebase(whence))
else if (is_from_rebase_empty(whence))
die(_("cannot do a partial commit during a rebase."));
}

@ -893,7 +893,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
*/
else if (whence == FROM_MERGE)
hook_arg1 = "merge";
else if (is_from_cherry_pick(whence) || whence == FROM_REBASE_PICK) {
else if (is_from_cherry_pick(whence) || is_from_rebase_empty(whence)) {
hook_arg1 = "commit";
hook_arg2 = "CHERRY_PICK_HEAD";
}
@ -1086,7 +1086,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
if (amend)
fputs(_(empty_amend_advice), stderr);
else if (is_from_cherry_pick(whence) ||
whence == FROM_REBASE_PICK) {
is_from_rebase_empty(whence)) {
fputs(_(empty_cherry_pick_advice), stderr);
if (whence == FROM_CHERRY_PICK_SINGLE)
fputs(_(empty_cherry_pick_advice_single), stderr);
@ -1333,7 +1333,7 @@ static int parse_and_validate_options(int argc, const char *argv[],
die(_("You are in the middle of a merge -- cannot amend."));
else if (is_from_cherry_pick(whence))
die(_("You are in the middle of a cherry-pick -- cannot amend."));
else if (whence == FROM_REBASE_PICK)
else if (is_from_rebase_empty(whence))
die(_("You are in the middle of a rebase -- cannot amend."));
}
if (fixup_message && squash_message)
@ -1353,7 +1353,7 @@ static int parse_and_validate_options(int argc, const char *argv[],
if (amend && !use_message && !fixup_message)
use_message = "HEAD";
if (!use_message && !is_from_cherry_pick(whence) &&
!is_from_rebase(whence) && renew_authorship)
!is_from_rebase_empty(whence) && renew_authorship)
die(_("--reset-author can be used only with -C, -c or --amend."));
if (use_message) {
use_message_buffer = read_commit_message(use_message);
@ -1362,7 +1362,7 @@ static int parse_and_validate_options(int argc, const char *argv[],
author_message_buffer = use_message_buffer;
}
}
if ((is_from_cherry_pick(whence) || whence == FROM_REBASE_PICK) &&
if ((is_from_cherry_pick(whence) || is_from_rebase_empty(whence)) &&
!renew_authorship) {
author_message = "CHERRY_PICK_HEAD";
author_message_buffer = read_commit_message(author_message);
@ -1887,7 +1887,7 @@ int cmd_commit(int argc,
if (!reflog_msg)
reflog_msg = is_from_cherry_pick(whence)
? "commit (cherry-pick)"
: is_from_rebase(whence)
: is_from_rebase_empty(whence)
? "commit (rebase)"
: "commit";
commit_list_insert(current_head, &parents);

View File

@ -6855,7 +6855,7 @@ int sequencer_determine_whence(struct repository *r, enum commit_whence *whence)
!repo_get_oid(r, "REBASE_HEAD", &rebase_head) &&
!repo_get_oid(r, "CHERRY_PICK_HEAD", &cherry_pick_head) &&
oideq(&rebase_head, &cherry_pick_head))
*whence = FROM_REBASE_PICK;
*whence = FROM_REBASE_EMPTY;
else
*whence = FROM_CHERRY_PICK_SINGLE;


View File

@ -41,7 +41,7 @@ enum commit_whence {
FROM_MERGE, /* commit came from merge */
FROM_CHERRY_PICK_SINGLE, /* commit came from cherry-pick */
FROM_CHERRY_PICK_MULTI, /* commit came from a sequence of cherry-picks */
FROM_REBASE_PICK /* commit came from a pick/reword/edit */
FROM_REBASE_EMPTY /* rebase applied a pick that became empty */
};

static inline int is_from_cherry_pick(enum commit_whence whence)
@ -50,9 +50,9 @@ static inline int is_from_cherry_pick(enum commit_whence whence)
whence == FROM_CHERRY_PICK_MULTI;
}

static inline int is_from_rebase(enum commit_whence whence)
static inline int is_from_rebase_empty(enum commit_whence whence)
{
return whence == FROM_REBASE_PICK;
return whence == FROM_REBASE_EMPTY;
}

struct wt_status_change_data {