Thread (43 messages) flat view 43 messages, 4 authors, 3d ago

Re: [PATCH v4 1/5] commit: clarify FROM_REBASE_PICK and is_from_rebase() names

From: Phillip Wood <hidden>
Date: 2026-09-02 15:39:12

Hi Elijah

On 01/09/2026 23:24, Elijah Newren via GitGitGadget wrote:
From: Elijah Newren <redacted>

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)`.
This looks good, the new names are much clearer

Thanks

Phillip
quoted hunk ↗ jump to hunk
Signed-off-by: Elijah Newren <redacted>
---
  builtin/commit.c | 14 +++++++-------
  sequencer.c      |  2 +-
  wt-status.h      |  6 +++---
  3 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/builtin/commit.c b/builtin/commit.c
index 28f6174503..17cc27e53e 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -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_now_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_now_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_now_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_now_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_now_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_now_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_now_empty(whence)
  					? "commit (rebase)"
  					: "commit";
  		commit_list_insert(current_head, &parents);
diff --git a/sequencer.c b/sequencer.c
index 65afd100d9..d336c309ca 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -6956,7 +6956,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_NOW_EMPTY;
  		else
  			*whence = FROM_CHERRY_PICK_SINGLE;
  
diff --git a/wt-status.h b/wt-status.h
index e9fe32e98c..2143f50b49 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -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_NOW_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_now_empty(enum commit_whence whence)
  {
-	return whence == FROM_REBASE_PICK;
+	return whence == FROM_REBASE_NOW_EMPTY;
  }
  
  struct wt_status_change_data {
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help