The following Git statement
cd periodtest/
git init
git config user.name "Test."
# verify that user.name is 'Test.'
git config user.name
touch README
git add README
git commit -a -m "period test"
Results in the following checkout
# check user name after commit
git log
And the resulting commit w/out the period was:
commit 9b7e4960fd8129059b5759d1bb937b60241fd70b
Author: Test <[email protected]>
Date: Wed Oct 1 20:28:28 2014 -0700
period test
Is there a way to get that period to stay in the username?
No, your user.name does not matter.
This behaviour is hardcoded into git.
Edit: As it stands this is still true for git version 2.25.1 (27. February 2020).
To create the author string during a commit git removes crud (as git calls it) from the beginning and the end of the string. For this it uses the strbuf_addstr_without_crud
function defined in ident.c
- see ident.c line 426 version 2.25.1.
Take a look at the function header:
/*
* Copy over a string to the destination, but avoid special
* characters ('\n', '<' and '>') and remove crud at the end
*/
static void strbuf_addstr_without_crud(struct strbuf *sb, const char *src)
See ident.c lines 225-262 version 2.25.1.
Git determines crud via another function which checks for specific characters.
static int crud(unsigned char c)
{
return c <= 32 ||
c == '.' ||
c == ',' ||
c == ':' ||
c == ';' ||
c == '<' ||
c == '>' ||
c == '"' ||
c == '\\' ||
c == '\'';
}
See ident.c lines 198-210 version 2.25.1.
As you can see a period is considered crud by git and will be removed, at the moment there is no flag or option you can set to avoid this behaviour.
This means you have two options.
You fork git and change the way git creates the author string.
Or you append another character after the trailing period, for example a Zero-width space (which often won't be printed properly on a console)
Alternatively you can always submit a feature request on the git mailing list, but in this case I wouldn't raise my hopes too high.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With