From: Junio C Hamano <gitster@pobox.com>
To: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] sequencer: beautify subject of reverts of reverts
Date: Tue, 28 Mar 2023 07:02:46 -0700 [thread overview]
Message-ID: <xmqqtty5ht2x.fsf@gitster.g> (raw)
In-Reply-To: 20230323162234.995465-1-oswald.buddenhagen@gmx.de
Oswald Buddenhagen <oswald.buddenhagen@gmx.de> writes:
> 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);
prev parent reply other threads:[~2023-03-28 14:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-23 16:22 [PATCH] sequencer: beautify subject of reverts of reverts Oswald Buddenhagen
2023-03-25 10:39 ` Kristoffer Haugsbakk
2023-03-27 22:25 ` Junio C Hamano
2023-03-28 6:04 ` Kristoffer Haugsbakk
2023-03-28 13:23 ` Oswald Buddenhagen
2023-03-28 13:43 ` Kristoffer Haugsbakk
2023-03-28 14:00 ` Junio C Hamano
2023-03-28 14:02 ` Junio C Hamano [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqtty5ht2x.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=oswald.buddenhagen@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).