From: Johan Herland <jo...@herland.net>
Subject: Re: Recording the current branch on each commit?
Date: Mon, 28 Apr 2014 01:39:26 +0200
> On Sun, Apr 27, 2014 at 10:55 PM, Jeremy Morton <ad...@game-point.net> wrote:
>> On 27/04/2014 20:33, Johan Herland wrote:
>>> On Sun, Apr 27, 2014 at 7:38 PM, Jeremy Morton<ad...@game-point.net>
>>>> On 27/04/2014 10:09, Johan Herland wrote:
>>>> As far as I can tell from that discussion, the general opposition to
>>>> encoding the branch name as a structural part of the commit object is
>>>> for some people's workflows, it would be unhelpful and/or misleading.
>>>> fair enough then - why don't we make it a setting that is off by default,
>>>> and can easily be switched on? That way the people for whom tagging the
>>>> branch name would be useful have a very easy way to switch it on.
>>> Therefore, the most pragmatic and constructive thing to do at this
>>> point, is IMHO to work within the confines of the existing commit
>>> object structure. I actually believe using commit message trailers
>>> like "Made-on-branch: frotz" in addition to some helpful
>>> infrastructure (hooks, templates, git-interpret-trailers, etc.) should
>>> get you pretty much exactly what you want. And if this feature turns
>>> out to be extremely useful for a lot of users, we can certainly
>>> consider changing the commit object format in the future.
>> OK, fair enough. So I guess what I'd like to see, then, is good built-in
>> functionality in Git for these commit message trailers, so that they are
>> very easy to turn on. I'd like to be able to tell co-developers to add a
>> one-liner to their git config file rather than some post-commit script.
> I think this is what the interpret-trailers effort is about.
> Unfortunately I have not followed it closely enough to say if your use
> case is already covered by Christian's (CCed) work. Christian: With
> your current patch series, is it possible for Jeremy to configure
> interpret-trailers to automatically append a "Made-on-branch:
> <current_branch>" trailer whenever he creates a commit?
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
git interpret-trailers --trim-empty --trailer "git-version: \$(git describe)"
"\$1" > "\$1.new"
mv "\$1.new" "\$1"
$ 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.
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