svn commit: r368736 - head/tools/tools/git/hooks

Ed Maste emaste at freebsd.org
Mon Dec 28 22:29:29 UTC 2020


On Mon, 28 Dec 2020 at 14:34, Alan Somers <asomers at freebsd.org> wrote:
>
> On Thu, Dec 17, 2020 at 12:58 PM Ed Maste <emaste at freebsd.org> wrote:
>>
>> Author: emaste
>> Date: Thu Dec 17 19:58:29 2020
>> New Revision: 368736
>> URL: https://svnweb.freebsd.org/changeset/base/368736
>>
>> Log:
>>   Add initial version of git commit message preparation hook
>>
> Thanks!  But how can we use it?  Is there a "git config" incantation that will use this file?

Just copy it into .git/hooks/. Can also fetch the latest version
directly from cgit; lwhsu added this to
https://github.com/bsdimp/freebsd-git-docs/blob/main/URLs.md:

fetch https://cgit.freebsd.org/src/plain/tools/tools/git/hooks/prepare-commit-msg
-o .git/hooks
chmod 755 .git/hooks/prepare-commit-msg

I'd like us to end up with a setup-repo.sh or such that will offer to
take care of all of these things.

>Also, this seems too complicated.  Git already has a "config.template" configuration variable.   Could we just use that instead, or does it not work for some reason?

It does work, although it's a bit awkward. For one thing, the provided
template is placed at the top of the message, followed by the default
message, but our addition is really commented-out information and fits
best in the middle of the existing text - after the "Please enter
the..." and before the list of changes and such. With config.template
we'd end up with something like:

====

# PR:           <If and which Problem Report is related.>
# ...
# Differential Revision:        <https://reviews.freebsd.org/D###>
#
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# ...
====

Additionally we might want to make some more programmatic changes in
the default message (depending on the resolution of some open
questions). For example we could strip the "MFC after" line that's
copied from the original commit, when preparing the commit message for
a MFC/cherry-pick.


More information about the svn-src-head mailing list