# git commit -C vs. prepare-commit-msg hook

3 messages from 2010-11-02 to 2010-11-02. Participants: SZEDER Gábor, Pat Notz.
Thread: https://gitlist.dev/t/25616

## SZEDER Gábor, 2010-11-02 14:50

Subject: git commit -C vs. prepare-commit-msg hook
Message-ID: <20101102145059.GB2116@neumann>
URL: https://gitlist.dev/e/20101102145059.GB2116%40neumann

```
Hi,

Just noticed (read: got bitten by ;) that 'git commit' runs the
prepare-commit-msg hook even if it was invoked with the -C option.
This seems contradictory to me, because 'git commit -C' is to reuse an
already existing log message (and author info) as is, whereas
prepare-commit-msg is there to automatically edit the commit message.

Is this desired and I'm missing something, or is this a bug?  (or just
accidental, but we can't do anything about it anyway because of
backward compatibility?)

Thanks.


Best,
Gábor

```

## Pat Notz, 2010-11-02 20:11

Subject: Re: git commit -C vs. prepare-commit-msg hook
Message-ID: <AANLkTimdjAc1ZKNkWAO_KU8CqorShMv0TNDvsy5qmSDw@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTimdjAc1ZKNkWAO_KU8CqorShMv0TNDvsy5qmSDw%40mail.gmail.com
In-Reply-To: <20101102145059.GB2116@neumann>

```
2010/11/2 SZEDER Gábor <szeder@ira.uka.de>:
> Hi,
>
> Just noticed (read: got bitten by ;) that 'git commit' runs the
> prepare-commit-msg hook even if it was invoked with the -C option.
> This seems contradictory to me, because 'git commit -C' is to reuse an
> already existing log message (and author info) as is, whereas
> prepare-commit-msg is there to automatically edit the commit message.
>

Can your hook look for the presence of the third command line argument
to catch this case?  Granted, you won't be able to tell the difference
between -C and -c or --amend.

> Is this desired and I'm missing something, or is this a bug?  (or just
> accidental, but we can't do anything about it anyway because of
> backward compatibility?)
>
> Thanks.
>
>
> Best,
> Gábor
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

```

## SZEDER Gábor, 2010-11-02 23:01

Subject: Re: git commit -C vs. prepare-commit-msg hook
Message-ID: <20101102230112.GC2116@neumann>
URL: https://gitlist.dev/e/20101102230112.GC2116%40neumann
In-Reply-To: <AANLkTimdjAc1ZKNkWAO_KU8CqorShMv0TNDvsy5qmSDw@mail.gmail.com>

```
Hi Pat,


Thanks for your reply.

On Tue, Nov 02, 2010 at 02:11:33PM -0600, Pat Notz wrote:
> 2010/11/2 SZEDER Gábor <szeder@ira.uka.de>:
> > Hi,
> >
> > Just noticed (read: got bitten by ;) that 'git commit' runs the
> > prepare-commit-msg hook even if it was invoked with the -C option.
> > This seems contradictory to me, because 'git commit -C' is to reuse an
> > already existing log message (and author info) as is, whereas
> > prepare-commit-msg is there to automatically edit the commit message.
> >
> 
> Can your hook look for the presence of the third command line argument
> to catch this case?

Yeah, this is what I tried as workaround ...

> Granted, you won't be able to tell the difference between -C and -c
> or --amend.

... and this is why it didn't work out, i.e. I needed to differentiate
-C from -c or --amend.

> > Is this desired and I'm missing something, or is this a bug?  (or just
> > accidental, but we can't do anything about it anyway because of
> > backward compatibility?)

```
