Skip to contentSkip to conversation

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

DISCUSSION SZEDER Gábor 2 participants 3 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw

2010/11/2 SZEDER Gábor <[email protected]>:

Quoted 8 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.

Quoted 15 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 [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

#2 lore raw

Hi Pat,

Thanks for your reply.

Quoted 10 lines · Pat Notz

2010/11/2 SZEDER Gábor <[email protected]>:

Quoted 8 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.

Quoted 2 lines

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 ...

Quoted 2 lines

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.

Quoted 3 lines
Quoted 3 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?)