From: Jeremy Morton Date: Mon, 28 Apr 2014 09:01:20 GMT Subject: Re: Recording the current branch on each commit? Message-ID: <535E18E0.3010507@game-point.net> In-Reply-To: <20140428.084543.1615507400056684596.chriscool@tuxfamily.org> 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< #!/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)