throws ConfigInvalidException {
final StringBuilder name = new StringBuilder();
for (;;) {
int c = in.read();
if (c < 0)
throw new ConfigInvalidException(JGitText.get().unexpectedEndOfConfigFile);
if ('=' == c)
break;
if (' ' == c || '\t' == c) {
for (;;) {
c = in.read();
if (c < 0)
throw new ConfigInvalidException(JGitText.get().unexpectedEndOfConfigFile);
if ('=' == c)
break;
if (';' == c || '#' == c || '\n' == c) {
in.reset();
break;
}
if (' ' == c || '\t' == c)
continue; // Skipped...
throw new ConfigInvalidException(JGitText.get().badEntryDelimiter);
}
break;
}
if (Character.isLetterOrDigit((char) c) || c == '-') {
// From the git-config man page:
// The variable names are case-insensitive and only
// alphanumeric characters and - are allowed.
name.append((char) c);
} else if ('\n' == c) {
in.reset();
name.append((char) c);
break;
} else
throw new ConfigInvalidException(MessageFormat.format(JGitText.get().badEntryName, name));
}
return name.toString();
}