]> git.ipfire.org Git - thirdparty/git.git/commit
revert: optionally refer to commit in the "reference" format
authorJunio C Hamano <gitster@pobox.com>
Fri, 27 May 2022 06:01:39 +0000 (23:01 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 27 May 2022 06:05:03 +0000 (23:05 -0700)
commit43966ab3156a082067bf9930351e96e9488da735
tree540a2bf2af1738c6084a68b58ad4018bbbab2386
parent6cd33dceed60949e2dbc32e3f0f5e67c4c882e1e
revert: optionally refer to commit in the "reference" format

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.

When this option is in use, the first line of the pre-filled editor
buffer becomes a comment line that tells the user to say _why_.  If
the user exits the editor without touching this line by mistake,
what we prepare to become the first line of the body, i.e. "This
reverts commit 8fa7f667 (do this and that, 2022-04-25)", ends up to
be the title of the resulting commit.  This behaviour is designed to
help such a user to identify such a revert in "git log --oneline"
easily so that it can be further reworded with "git rebase -i" later.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/config/revert.txt [new file with mode: 0644]
Documentation/git-revert.txt
builtin/revert.c
sequencer.c
sequencer.h
t/t3501-revert-cherry-pick.sh