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

Re: Feature request: add a metadata in the commit: the "commited in branch" information

From
Paul Smith <paul@mad-scientist.net>
Date
Dec 30, 2019, 15:15 UTC
Message-ID
<85e17e0628e05279d1dbbe62b877caa90a43ec38.camel@mad-scientist.net>
In-Reply-To
<CAEW0o+gtya5tm6Wb474Srmb2j4E9ocm9p75=aZWjTASbApsb1A@mail.gmail.com>
On Mon, 2019-12-30 at 12:59 +0100, Arnaud Bertrand wrote:
Show 9 quoted lines
> > Why does it need to be the branch name?  You can add your own extra
> > metadata to the git description.
> 
> That's typically my problem.  It is not possible "by default", I mean
> - It is only possible if the developer configure something
> - or if there is an upper layer that guarantee this
> By default, there is no hook embedded with the clone. So, as far as I
> know (and I hope I'm wrong!), you have to use upper layer tools or to
> change environment variables to activate this feature.

In general I have found that trying to mandate what users do in their own repositories on their own systems is a losing proposition.

Instead, we put requirements on what content is pushed to the central repository. Because the central repository is managed by the SCM admin team we always know only properly-constructed commits can appear there, without having to assume that every individual developer's local environment has been set up in a specific way.

This can be done with hooks in the central repository: there are Git hooks that are run before any push is accepted, which can cause the push to be rejected, and hooks that are run after a push is accepted, which can be used for triggering other operations.

So if you have a requirement about contents of Git commit message format, for example, you can enforce that via these hooks. If someone attempts to push commits to the central repository and the commit message has an incorrect format then the push is rejected and they'll have to fix it before they can proceed to push.

In the environments I've been associated with we don't care about branch names; instead everything is based on bug tracker identifiers. Every commit needs to be associated with a valid bug ID (added to the commit message) and the pre-push hook verifies this and rejects the commit if not. Then after the push is accepted, post-push hooks will update the bug tracker with information about the push (SHA, software version, etc.) This ensures that development and management can use the bug tracker as their primary planning tool to know what has been accomplished and what is left to accomplish. Since the commit message is persisted through cherry-picks, etc. it allows us to know which bugs were fixed in which different patch release branches as well.

Previous: Arnaud Bertrand
Message 6 of 6 in “Feature request: add a metadata in the commit: the "commited in branch" information”
  1. Arnaud BertrandDec 23, 2019
  2. Junio C HamanoDec 29, 2019
  3. Arnaud BertrandDec 29, 2019
  4. Theodore Y. Ts'oDec 30, 2019
  5. Arnaud BertrandDec 30, 2019
  6. Paul SmithDec 30, 2019

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.