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

Re: Referring to commits in commit messages

From
Jacob Keller <jacob.keller@gmail.com>
Date
Dec 24, 2018, 00:01 UTC
Message-ID
<CA+P7+xoL2jEV68bkndoLmRBaTY0vNs=gBAWdpw=U4g=XO-Eapg@mail.gmail.com>
In-Reply-To
<20181219221401.GC228469@google.com>
On Wed, Dec 19, 2018 at 2:36 PM Jonathan Nieder <jrnieder@gmail.com> wrote:
Show 23 quoted lines
> In Linux kernel land, Documentation/process/submitting-patches.rst
> contains the following:
>
> -- >8 --
> If your patch fixes a bug in a specific commit, e.g. you found an issue using
> ``git bisect``, please use the 'Fixes:' tag with the first 12 characters of
> the SHA-1 ID, and the one line summary.  For example::
>
>         Fixes: e21d2170f366 ("video: remove unnecessary platform_set_drvdata()")
>
> The following ``git config`` settings can be used to add a pretty format for
> outputting the above style in the ``git log`` or ``git show`` commands::
>
>         [core]
>                 abbrev = 12
>         [pretty]
>                 fixes = Fixes: %h (\"%s\")
> -- 8< --
>
> I like it because (1) the semantics are clear, (2) it's very concrete
> (e.g. "first 12 characters", (3) it goes in a trailer, where other
> bits intended for machine consumption already go.
>

For what it's worth, Linux's checkpatch.pl script also checks for and enforces that commit references have this format.

I personally like having the date information, and have attempted to get checkpatch.pl to stop complaining about the date when it's included. (see https://patchwork.ozlabs.org/patch/821543/ for the patch that I've had up, we've been trying to get the maintainer of checkpatch.pl to notice and pull it in, but not very much success as of yet).

I'd prefer to keep the format as seen on this list fairly often which is the something like

show --pretty=%h (\"%s\", %ad) --date=short
or
show --pretty=%h (\"%s\", %cd) --date=short

I like the date since it gives a quick approximation of how long ago the commit was made, and helps in the rare case of disambiguation. Personally I also like the quotes since it makes it more obvious where the subject begins and ends. They aren't strictly necessary but aid readability to me.

Thanks, Jake

Previous: Ævar Arnfjörð BjarmasonNext: SZEDER Gábor
Message 10 of 17 in “stripspace: allow -s/-c outside git repository”
  1. stripspace: allow -s/-c outside git repositoryJonathan Nieder, Dec 17, 2018
  2. Martin ÅgrenDec 18, 2018
  3. Johannes SchindelinDec 18, 2018
  4. Martin ÅgrenDec 19, 2018
  5. Johannes SchindelinDec 18, 2018
  6. Referring to commits in commit messagesÆvar Arnfjörð Bjarmason, Dec 19, 2018
  7. Duy NguyenDec 19, 2018
  8. Jonathan NiederDec 19, 2018
  9. Ævar Arnfjörð BjarmasonDec 20, 2018
  10. Jacob KellerDec 24, 2018
  11. SZEDER GáborDec 19, 2018
  12. Jeff KingDec 19, 2018
  13. Jonathan NiederDec 19, 2018
  14. Jeff KingDec 19, 2018
  15. Jonathan NiederDec 19, 2018
  16. Jeff KingDec 20, 2018
  17. Ævar Arnfjörð BjarmasonDec 19, 2018

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.