threads / discuss / 25616

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

Subject: git commit -C vs. prepare-commit-msg hook

## tl;dr

3 messages between Nov 2, 2010 and Nov 2, 2010.

replies: 2people: 2as markdown or json

SZEDER Gábor· Nov 2, 2010, 14:50 UTC · lore
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· Nov 2, 2010, 20:11 UTC · re: SZEDER Gábor · lore

Re: git commit -C vs. prepare-commit-msg hook

2010/11/2 SZEDER Gábor <szeder@ira.uka.de>:
Show 8 quoted lines
> 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.

Show 15 quoted lines
> 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· Nov 2, 2010, 23:01 UTC · re: Pat Notz · lore

Re: git commit -C vs. prepare-commit-msg hook

Hi Pat,
Thanks for your reply.
On Tue, Nov 02, 2010 at 02:11:33PM -0600, Pat Notz wrote:
Show 12 quoted lines
> 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?)

← back to recent threads