Thread (28 messages) flat view 28 messages, 8 authors, 2016-06-15

Re: Recording the current branch on each commit?

From: Jeremy Morton <hidden>
Date: 2016-06-15 23:00:51

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.

Best,
Christian.
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.

-- 
Best regards,
Jeremy Morton (Jez)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help