Stricter config entry name validation

As an alternative to libgit2/libgit2#1287 this implements the core git rules for config section and key validation with new code that is based on what already existed in libgit2.

The rules, for reference, that are implemented are:

* The top-level section name (i.e. before the first period) and the trailing key name (i.e. after the last period) must consist entirely of alphanumeric characters and dashes, the first character cannot be a dash, and all the letters will be mapped to lower case. Also, these parts cannot be missing.
* Any middle section name, if it exists, must not contain newlines.

These rules are enforced both when you go to set a value in a config file and when you attempt to rename a section of config file.

This PR includes a new test that @nulltoken wrote which I copy-pasted from the above mentioned PR.