git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] sequencer: beautify subject of reverts of reverts

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 28, 2023, 14:02 UTC
Message-ID
<xmqqtty5ht2x.fsf@gitster.g>
In-Reply-To
<20230323162234.995465-1-oswald.buddenhagen@gmx.de>
Oswald Buddenhagen <oswald.buddenhagen@gmx.de> writes:
Show 14 quoted lines
> diff --git a/sequencer.c b/sequencer.c
> index 3be23d7ca2..853b4ed334 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -2234,6 +2234,9 @@ static int do_pick_commit(struct repository *r,
>  		if (opts->commit_use_reference) {
>  			strbuf_addstr(&msgbuf,
>  				"# *** SAY WHY WE ARE REVERTING ON THE TITLE LINE ***");
> +		} else if (starts_with(msg.subject, "Revert \"")) {
> +			strbuf_addstr(&msgbuf, "Reapply ");
> +			strbuf_addstr(&msgbuf, msg.subject + 7);
>  		} else {
>  			strbuf_addstr(&msgbuf, "Revert \"");
>  			strbuf_addstr(&msgbuf, msg.subject);
Two and half comments:
 * The hard-coded +7 looks fragile.  Perhaps use skip_prefix?
 * During transition to introduce a new version of Git with this
   feature, when reverting an existing revert of a revert, care must
   be taken.  Such a commit would begin as
	Revert "Revert ...
   and turning it to
	Reapply "Revert ...
   may not be a good way to label such a reversion of a double
   revert without end-user confusion.  As it is very likely that
   such a reversion commit was created by existing versions of Git,
   the easiest and least confusing way out would be to notice and
   refrain from touching such a commit.
 * The change lacks tests.
Removal of hardcoded +7 (i.e. the first point) may look like this.
 sequencer.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git i/sequencer.c w/sequencer.c
index 853b4ed334..520113ec63 100644
--- i/sequencer.c
+++ w/sequencer.c
@@ -2227,6 +2227,8 @@ static int do_pick_commit(struct repository *r,
 	 */
 
 	if (command == TODO_REVERT) {
+		const char *original_title;
+
 		base = commit;
 		base_label = msg.label;
 		next = parent;
@@ -2234,9 +2236,9 @@ static int do_pick_commit(struct repository *r,
 		if (opts->commit_use_reference) {
 			strbuf_addstr(&msgbuf,
 				"# *** SAY WHY WE ARE REVERTING ON THE TITLE LINE ***");
-		} else if (starts_with(msg.subject, "Revert \"")) {
+		} else if (skip_prefix(msg.subject, "Revert \"", &original_title)) {
-			strbuf_addstr(&msgbuf, "Reapply ");
+			strbuf_addstr(&msgbuf, "Reapply \"");
-			strbuf_addstr(&msgbuf, msg.subject + 7);
+			strbuf_addstr(&msgbuf, original_title);
 		} else {
 			strbuf_addstr(&msgbuf, "Revert \"");
 			strbuf_addstr(&msgbuf, msg.subject);
Previous: Junio C Hamano
Message 8 of 8 in “sequencer: beautify subject of reverts of reverts”
  1. sequencer: beautify subject of reverts of revertsOswald Buddenhagen, Mar 23, 2023
  2. Kristoffer HaugsbakkMar 25, 2023
  3. Junio C HamanoMar 27, 2023
  4. Kristoffer HaugsbakkMar 28, 2023
  5. Oswald BuddenhagenMar 28, 2023
  6. Kristoffer HaugsbakkMar 28, 2023
  7. Junio C HamanoMar 28, 2023
  8. Junio C HamanoMar 28, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.