git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* How do I control the automated commit message on a merge?
@ 2008-06-03 21:55 Marvin Fraeman
  2008-06-03 22:51 ` Johannes Schindelin
  0 siblings, 1 reply; 4+ messages in thread
From: Marvin Fraeman @ 2008-06-03 21:55 UTC (permalink / raw)
  To: git

I am using git-svn. The SVN repository I'm dealing with has a standard
comment convention I must follow. It is a simple static string of
information that must appear on the first line of the commit message.
Everything else can be free-form.

I figured out how to add a commit template to my gitconfig file. So
for regular commits, I think I'm fine. But when Git does a merge (no
conflicts), it auto-generates a commit message like:

        Merge branch 'master' of  /path/to/other/repo

How can I change this so my required string gets written at the
beginning of the commit message. I played with the commit-msg and
prepare-commit-msg hooks, but it didn't seem to get triggered in the
merge case.

Also, having the prepare-commit-msg hook add text had the side-effect
that in my normal commits, the message was always accepted, even when
I wanted to abort (vi using :q!). In case I ever do need to use
prepare-commit-msg, is there a way I can use it where abort still can
work?


Thank you

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How do I control the automated commit message on a merge?
  2008-06-03 21:55 How do I control the automated commit message on a merge? Marvin Fraeman
@ 2008-06-03 22:51 ` Johannes Schindelin
  2008-06-04  0:05   ` Marvin Fraeman
  0 siblings, 1 reply; 4+ messages in thread
From: Johannes Schindelin @ 2008-06-03 22:51 UTC (permalink / raw)
  To: Marvin Fraeman; +Cc: git

Hi,

On Tue, 3 Jun 2008, Marvin Fraeman wrote:

> when Git does a merge (no conflicts), it auto-generates a commit message 
> like:
> 
>         Merge branch 'master' of  /path/to/other/repo
> 
> How can I change this so my required string gets written at the
> beginning of the commit message.

s/./?/

You might be happy with a post-merge hook amending the commit with a 
completely different message.

Hth,
Dscho

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How do I control the automated commit message on a merge?
  2008-06-03 22:51 ` Johannes Schindelin
@ 2008-06-04  0:05   ` Marvin Fraeman
  2008-06-04  7:33     ` Stephan Beyer
  0 siblings, 1 reply; 4+ messages in thread
From: Marvin Fraeman @ 2008-06-04  0:05 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git

On Tue, Jun 3, 2008 at 3:51 PM, Johannes Schindelin
<Johannes.Schindelin@gmx.de> wrote:
> Hi,
>
> On Tue, 3 Jun 2008, Marvin Fraeman wrote:
>
>> when Git does a merge (no conflicts), it auto-generates a commit message
>> like:
>>
>>         Merge branch 'master' of  /path/to/other/repo
>>
>> How can I change this so my required string gets written at the
>> beginning of the commit message.
>
> s/./?/

Where do I do the substitution in this case? I don't know where this
default commit message is coming from and where to intercept it. Are
you saying this is part of the post-merge hook or is that an
alternative solution?

Thank you

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How do I control the automated commit message on a merge?
  2008-06-04  0:05   ` Marvin Fraeman
@ 2008-06-04  7:33     ` Stephan Beyer
  0 siblings, 0 replies; 4+ messages in thread
From: Stephan Beyer @ 2008-06-04  7:33 UTC (permalink / raw)
  To: Marvin Fraeman; +Cc: git

[-- Attachment #1: Type: text/plain, Size: 1566 bytes --]

Hi,

> >> when Git does a merge (no conflicts), it auto-generates a commit message
> >> like:
> >>
> >>         Merge branch 'master' of  /path/to/other/repo
> >>
> >> How can I change this so my required string gets written at the
> >> beginning of the commit message.
> >
> > s/./?/
> 
> Where do I do the substitution in this case?

In the question that you sent to the list ;-)
(But something like s/\./?/ makes more sense.)

The real answer of Johannes to your question was only:
> You might be happy with a post-merge hook amending the commit with a
> completely different message.

Meaning, you should put something like
 #!/bin/sh
 git commit -m "This is my new commit message." --amend
or better:
 #!/bin/sh
 git commit --amend -m "$(git cat-file commit HEAD |
 	sed -e '1,/^$/d;s/^/YOUR SIMPLE STATIC STRING HERE\n\n/')"
into .git/hooks/post-merge (and make it executable).
YOUR SIMPLE STATIC STRING HERE is the new first line.
Replace the \n\n by a space to get someting like
"YOUR SIMPLE STATIC STRING HERE Merge foo into HEAD."

> Also, having the prepare-commit-msg hook add text had the side-effect
> that in my normal commits, the message was always accepted, even when
> I wanted to abort (vi using :q!).

Let the commit-msg hook add the text afterwards.

Or remove the prepared commit message in vi and then press :x (or :wq),
because commit aborts on an *empty* commit message and not on 
an unchanged commit message.

Regards,
  Stephan

-- 
Stephan Beyer <s-beyer@gmx.net>, PGP 0x6EDDD207FCC5040F

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-06-04  7:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-03 21:55 How do I control the automated commit message on a merge? Marvin Fraeman
2008-06-03 22:51 ` Johannes Schindelin
2008-06-04  0:05   ` Marvin Fraeman
2008-06-04  7:33     ` Stephan Beyer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).