On Mon, Apr 28, 2014 at 11:01 AM, Jeremy Morton <ad...@game-point.net> wrote:
> On 28/04/2014 07:45, Christian Couder wrote:
>> Yes, it's possible. Yesterday, I sent the following patch:
>> [RFC/PATCH 2/2] trailer: add examples to the documentation
>> and it shows a commit-msg hook to do something like that:
>> $ cat>.git/hooks/commit-msg<<EOF
>> #!/bin/sh
>> git interpret-trailers --trim-empty --trailer "git-version: \$(git
>> describe)" "\$1">  "\$1.new"
>> mv "\$1.new" "\$1"
>> EOF
>> $ chmod +x .git/hooks/commit-msg
>> I think you just need to use the following if you want the branch
>> instead of the git version:
>> git interpret-trailers --trim-empty --trailer "git-branch: \$(git name-rev
>> --name-only HEAD)" "\$1">  "\$1.new"
>> It could even be simpler if there was an option (which has already
>> been discussed) that made it possible to modify the file in
>> place. This way one would not need the 'mv "\$1.new" "\$1"' command.
> This is certainly going in the right direction, but it's still implemented
> as a hook on a per-repo basis.  Do you foresee a point in the future where
> these trailers could be added through simple one-liners in someone's global
> .gitconfig file?  That's where I'd really like to get to.

It's a hack, but it works surprisingly well in practice (assuming that
you and your co-workers all agree that this is an acceptable

 1. Write the hook script and add it to your project (in a git-hooks
subdir or something)

 2. Add a post-checkout hook to install the first hook and the
post-checkout hook itself into the user's .git/hooks/ dir.

 3. Tell your co-workers to run the post-checkout hook script manually
the first time. After that, the script should take care of updating
itself and any hooks that you add to the project.


Johan Herland, <jo...@herland.net>
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to