Commit
aef843026b710be32af1b22128868e49843f11c0
commit: clarify FROM_REBASE_PICK and is_from_rebase() names
Commit 430b75f7209c (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_NOW_EMPTY` to use `is_from_rebase_now_empty(whence)`. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Elijah Newren <newren@gmail.com> · 2026-09-01 22:24 UTC · committed by Junio C Hamano
3 files changed,
+11
−11
modified builtin/commit.c
| @@ -520,7 +520,7 @@ static const char *prepare_index(const char **argv, const char *prefix, | |||
| 520 | 520 | die(_("cannot do a partial commit during a merge.")); | |
| 521 | 521 | else if (is_from_cherry_pick(whence)) | |
| 522 | 522 | die(_("cannot do a partial commit during a cherry-pick.")); | |
| 523 | - | else if (is_from_rebase(whence)) | |
| 523 | + | else if (is_from_rebase_now_empty(whence)) | |
| 524 | 524 | die(_("cannot do a partial commit during a rebase.")); | |
| 525 | 525 | } | |
| 526 | 526 | ||
| @@ -893,7 +893,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix, | |||
| 893 | 893 | */ | |
| 894 | 894 | else if (whence == FROM_MERGE) | |
| 895 | 895 | hook_arg1 = "merge"; | |
| 896 | - | else if (is_from_cherry_pick(whence) || whence == FROM_REBASE_PICK) { | |
| 896 | + | else if (is_from_cherry_pick(whence) || is_from_rebase_now_empty(whence)) { | |
| 897 | 897 | hook_arg1 = "commit"; | |
| 898 | 898 | hook_arg2 = "CHERRY_PICK_HEAD"; | |
| 899 | 899 | } | |
| @@ -1086,7 +1086,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix, | |||
| 1086 | 1086 | if (amend) | |
| 1087 | 1087 | fputs(_(empty_amend_advice), stderr); | |
| 1088 | 1088 | else if (is_from_cherry_pick(whence) || | |
| 1089 | - | whence == FROM_REBASE_PICK) { | |
| 1089 | + | is_from_rebase_now_empty(whence)) { | |
| 1090 | 1090 | fputs(_(empty_cherry_pick_advice), stderr); | |
| 1091 | 1091 | if (whence == FROM_CHERRY_PICK_SINGLE) | |
| 1092 | 1092 | fputs(_(empty_cherry_pick_advice_single), stderr); | |
| @@ -1333,7 +1333,7 @@ static int parse_and_validate_options(int argc, const char *argv[], | |||
| 1333 | 1333 | die(_("You are in the middle of a merge -- cannot amend.")); | |
| 1334 | 1334 | else if (is_from_cherry_pick(whence)) | |
| 1335 | 1335 | die(_("You are in the middle of a cherry-pick -- cannot amend.")); | |
| 1336 | - | else if (whence == FROM_REBASE_PICK) | |
| 1336 | + | else if (is_from_rebase_now_empty(whence)) | |
| 1337 | 1337 | die(_("You are in the middle of a rebase -- cannot amend.")); | |
| 1338 | 1338 | } | |
| 1339 | 1339 | if (fixup_message && squash_message) | |
| @@ -1353,7 +1353,7 @@ static int parse_and_validate_options(int argc, const char *argv[], | |||
| 1353 | 1353 | if (amend && !use_message && !fixup_message) | |
| 1354 | 1354 | use_message = "HEAD"; | |
| 1355 | 1355 | if (!use_message && !is_from_cherry_pick(whence) && | |
| 1356 | - | !is_from_rebase(whence) && renew_authorship) | |
| 1356 | + | !is_from_rebase_now_empty(whence) && renew_authorship) | |
| 1357 | 1357 | die(_("--reset-author can be used only with -C, -c or --amend.")); | |
| 1358 | 1358 | if (use_message) { | |
| 1359 | 1359 | use_message_buffer = read_commit_message(use_message); | |
| @@ -1362,7 +1362,7 @@ static int parse_and_validate_options(int argc, const char *argv[], | |||
| 1362 | 1362 | author_message_buffer = use_message_buffer; | |
| 1363 | 1363 | } | |
| 1364 | 1364 | } | |
| 1365 | - | if ((is_from_cherry_pick(whence) || whence == FROM_REBASE_PICK) && | |
| 1365 | + | if ((is_from_cherry_pick(whence) || is_from_rebase_now_empty(whence)) && | |
| 1366 | 1366 | !renew_authorship) { | |
| 1367 | 1367 | author_message = "CHERRY_PICK_HEAD"; | |
| 1368 | 1368 | author_message_buffer = read_commit_message(author_message); | |
| @@ -1887,7 +1887,7 @@ int cmd_commit(int argc, | |||
| 1887 | 1887 | if (!reflog_msg) | |
| 1888 | 1888 | reflog_msg = is_from_cherry_pick(whence) | |
| 1889 | 1889 | ? "commit (cherry-pick)" | |
| 1890 | - | : is_from_rebase(whence) | |
| 1890 | + | : is_from_rebase_now_empty(whence) | |
| 1891 | 1891 | ? "commit (rebase)" | |
| 1892 | 1892 | : "commit"; | |
| 1893 | 1893 | commit_list_insert(current_head, &parents); | |
modified sequencer.c
| @@ -6855,7 +6855,7 @@ int sequencer_determine_whence(struct repository *r, enum commit_whence *whence) | |||
| 6855 | 6855 | !repo_get_oid(r, "REBASE_HEAD", &rebase_head) && | |
| 6856 | 6856 | !repo_get_oid(r, "CHERRY_PICK_HEAD", &cherry_pick_head) && | |
| 6857 | 6857 | oideq(&rebase_head, &cherry_pick_head)) | |
| 6858 | - | *whence = FROM_REBASE_PICK; | |
| 6858 | + | *whence = FROM_REBASE_NOW_EMPTY; | |
| 6859 | 6859 | else | |
| 6860 | 6860 | *whence = FROM_CHERRY_PICK_SINGLE; | |
| 6861 | 6861 | ||
modified wt-status.h
| @@ -41,7 +41,7 @@ enum commit_whence { | |||
| 41 | 41 | FROM_MERGE, /* commit came from merge */ | |
| 42 | 42 | FROM_CHERRY_PICK_SINGLE, /* commit came from cherry-pick */ | |
| 43 | 43 | FROM_CHERRY_PICK_MULTI, /* commit came from a sequence of cherry-picks */ | |
| 44 | - | FROM_REBASE_PICK /* commit came from a pick/reword/edit */ | |
| 44 | + | FROM_REBASE_NOW_EMPTY /* rebase applied a pick that became empty */ | |
| 45 | 45 | }; | |
| 46 | 46 | ||
| 47 | 47 | 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) | |||
| 50 | 50 | whence == FROM_CHERRY_PICK_MULTI; | |
| 51 | 51 | } | |
| 52 | 52 | ||
| 53 | - | static inline int is_from_rebase(enum commit_whence whence) | |
| 53 | + | static inline int is_from_rebase_now_empty(enum commit_whence whence) | |
| 54 | 54 | { | |
| 55 | - | return whence == FROM_REBASE_PICK; | |
| 55 | + | return whence == FROM_REBASE_NOW_EMPTY; | |
| 56 | 56 | } | |
| 57 | 57 | ||
| 58 | 58 | struct wt_status_change_data { | |