TL;DR: Why do
git config --get core.commentChar
echo $?
prints 1?
More context:
With either git 2.14.2.windows.3 on Windows 7 and git 2.7.4 on Ubuntu 16.04, when I run git config --get core.commentChar I get the exit error code 1.
I don't understand this behavior because according to the documentation of git config:
1 means that The section or key is invalidcore.commentChar is a config documented on this same page(Also, when I run git config --get core.editor, it correctly prints vim and has exit code 0).
The documentation really should say "invalid or not set/missing". In fact, it does say that:
--get
Get the value for a given key (optionally filtered by a regex matching the value). Returns error code 1 if the key was not found and the last value if multiple key values were found.
Hence, if you have not specifically set core.commentChar to something, git config --get core.commentChar (a) prints nothing and (b) exits nonzero. This is distinct from the case where you set it to an empty string, in which case git config --get would print nothing but exit with status zero.
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