1

I'm trying to fix a git hook which does modify the commit message. But it assumes one uses # as core.commentchar.

Now I would like to retrieve the core.commentchar. Is there an easy way or do I have to write some logic by my own?

I tried

$ git config --get core.commentchar

This works just fine for custom comment chars but fails to retrieve the default one. Is there any simple command to retrieve the correct comment character? Or am I supposed to check if the above command returns an empty value and know it means it is #?

Bertram Nudelbach
  • 1,783
  • 2
  • 15
  • 27

1 Answers1

0

Yes, if the core.commentchar isn't explicitly defined, then the default one is '#'
(see environment.c)

As I mention in "Start a git commit message with a hashmark (#)", that will be enforce in git 2.1.
The list of default characters considered is in this commit:

# ; @ ! $ % ^ & | :
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Is there any command that hides that logic or do I have to make that check by my own in each script? – Bertram Nudelbach Jul 29 '14 at 07:54
  • @BertramNudelbach not that I know of. The default is '#' [per its documentation](https://github.com/git/git/blob/84c9dc2c5a2d34351a06554af32501d4f99990e9/Documentation/config.txt#L542-L546) – VonC Jul 29 '14 at 07:58
  • thanks for the additional information and the reference to the commits for 2.1! Maybe there is a command and somebody else knows ;-) – Bertram Nudelbach Jul 29 '14 at 08:01
  • 1
    @BertramNudelbach I didn't see it in the source code, though. – VonC Jul 29 '14 at 08:02