From: Phillip Wood <phillip.wood123@gmail.com>
To: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: [PATCH] revert: optionally refer to commit in the "reference" format
Date: Thu, 26 May 2022 12:17:33 +0100 [thread overview]
Message-ID: <4c8ea23d-1a1d-efd4-6c11-7c08f8728d59@gmail.com> (raw)
In-Reply-To: <xmqqsfp2b30k.fsf@gitster.g>
Hi Junio
On 22/05/2022 05:32, Junio C Hamano wrote:
> A typical "git revert" commit uses the full title of the original
> commit in its title, and starts its body of the message with:
>
> This reverts commit 8fa7f667cf61386257c00d6e954855cc3215ae91.
>
> This does not encourage the best practice of describing not just
> "what" (i.e. "Revert X" on the title says what we did) but "why"
> (i.e. and it does not say why X was undesirable).
>
> We can instead phrase this first line of the body to be more like
>
> This reverts commit 8fa7f667 (do this and that, 2022-04-25)
>
> so that the title does not have to be
>
> Revert "do this and that"
>
> We can instead use the title to describe "why" we are reverting the
> original commit.
>
> Introduce the "--reference" option to "git revert", and also the
> revert.reference configuration variable, which defaults to false, to
> tweak the title and the first line of the draft commit message for
> when creating a "revert" commit.
I think this is a good idea which will hopefully improve project histories.
> diff --git a/builtin/revert.c b/builtin/revert.c
> index 51776abea6..ada51e46b9 100644
> --- a/builtin/revert.c
> +++ b/builtin/revert.c
> @@ -116,6 +116,8 @@ static int run_sequencer(int argc, const char **argv, struct replay_opts *opts)
> N_("option for merge strategy"), option_parse_x),
> { OPTION_STRING, 'S', "gpg-sign", &opts->gpg_sign, N_("key-id"),
> N_("GPG sign commit"), PARSE_OPT_OPTARG, NULL, (intptr_t) "" },
> + OPT_BOOL(0, "reference", &opts->commit_use_reference,
> + N_("use the 'reference' format to refer to commits")),
This option is being added to base_options which applies to cherry-pick
as well as revert. There is a "if" statement just below this hunk which
adds cherry-pick specific options, I think we want to add this new
option in an else block added to that "if" statement.
> static int do_pick_commit(struct repository *r,
> struct todo_item *item,
> struct replay_opts *opts,
> @@ -2167,14 +2184,19 @@ static int do_pick_commit(struct repository *r,
> base_label = msg.label;
> next = parent;
> next_label = msg.parent_label;
> - strbuf_addstr(&msgbuf, "Revert \"");
> - strbuf_addstr(&msgbuf, msg.subject);
> - strbuf_addstr(&msgbuf, "\"\n\nThis reverts commit ");
> - strbuf_addstr(&msgbuf, oid_to_hex(&commit->object.oid));
> + if (!opts->commit_use_reference) {
> + strbuf_addstr(&msgbuf, "Revert \"");
> + strbuf_addstr(&msgbuf, msg.subject);
> + strbuf_addstr(&msgbuf, "\"");
> + } else {
> + strbuf_addstr(&msgbuf, "DESCRIBE WHY WE ARE REVERTING HERE");
In format-patch we add three asterisks to the beginning and end of the
dummy subject and body lines to encourage the user to edit them - is
that worth doing here as well?
Best Wishes
Phillip
next prev parent reply other threads:[~2022-05-26 11:17 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-22 4:32 [PATCH] revert: optionally refer to commit in the "reference" format Junio C Hamano
2022-05-23 13:25 ` Johannes Schindelin
2022-05-23 22:48 ` Junio C Hamano
2022-05-27 6:01 ` [PATCH v3] " Junio C Hamano
2022-05-30 16:40 ` Johannes Schindelin
2022-05-31 14:00 ` Phillip Wood
2022-06-01 4:45 ` Junio C Hamano
2022-06-01 15:03 ` Phillip Wood
2022-06-01 15:14 ` Ævar Arnfjörð Bjarmason
2022-06-01 21:52 ` Junio C Hamano
2022-05-30 16:50 ` Side effects in Git's test suite, was Re: [PATCH] " Johannes Schindelin
2022-05-31 8:03 ` Ævar Arnfjörð Bjarmason
2022-05-23 13:45 ` Ævar Arnfjörð Bjarmason
2022-05-23 22:37 ` Junio C Hamano
2022-05-24 8:12 ` Ævar Arnfjörð Bjarmason
2022-05-24 19:11 ` Junio C Hamano
2022-05-26 11:17 ` Phillip Wood [this message]
2022-05-26 17:29 ` Junio C Hamano
2022-06-26 9:29 ` René Scharfe
2022-06-27 15:38 ` Junio C Hamano
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=4c8ea23d-1a1d-efd4-6c11-7c08f8728d59@gmail.com \
--to=phillip.wood123@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=phillip.wood@dunelm.org.uk \
/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).