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

Re: [RFC PATCH] hooks: add some defaults to support sane workflow to pre-commit

From
Heiko Voigt <git-list@hvoigt.net>
Date
Feb 23, 2009, 18:41 UTC
Message-ID
<49A2EDD3.5080307@hvoigt.net>
In-Reply-To
<49A00215.9070106@hvoigt.net>
Heiko Voigt schrieb:
Show 11 quoted lines
> How about combining my first approach with the second idea? Teach git
> different default sets of hooks. So something like:
> 
>    git init --workflow="topic-branches"
> 
> would initialize and install a certain set of hooks.
> 
> Implement the possibility to propagate this setting to the server, by
> using a config variable or similar. This way only secure hooks will
> automatically be inherited and the user has the benefit of a more
> specific workflow support.

So I have been thinking about an actual implementation lately and here are some more specifics of a possible implementation:

Add a new configuration file .gitconfig tracked in the working copy next to .gitignore and such. The order would then be:

/etc/gitconfig ~/.gitconfig $project/.gitconfig $project/.git/config

Do not allow all options in such a file but use a specific namespace for whitelisting them e.g.: project.workflow

Add hooks that are activated by default and use these configuration variables to tune their behaviour. Example:

[ "$(git config project.workflow)" = "topic-branches" ] && topic_branches=1
# if we are in topic mode work should always be done on a feature branch
if topic_branches && git branch | grep "^* master" > /dev/null; then
    echo "No commits on master, please !"
    exit 1
fi

Such distributable options could also transport other values like the description for gitweb.

What do you think?
cheers Heiko
Previous: Heiko VoigtNext: Junio C Hamano
Message 8 of 10 in “hooks: add some defaults to support sane workflow to pre-commit”
  1. hooks: add some defaults to support sane workflow to pre-commitHeiko Voigt, Feb 20, 2009
  2. Wincent ColaiutaFeb 20, 2009
  3. Heiko VoigtFeb 21, 2009
  4. Thomas RastFeb 21, 2009
  5. Heiko VoigtFeb 21, 2009
  6. Jakub NarebskiFeb 21, 2009
  7. Heiko VoigtFeb 21, 2009
  8. Heiko VoigtFeb 23, 2009
  9. Junio C HamanoOct 19, 2009
  10. Heiko VoigtOct 20, 2009

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.