Skip to content

Wrongful error on \b character in git config #1397

@CEbbinghaus

Description

@CEbbinghaus

Error

C:\Program Files\dotnet\sdk\8.0.114\Sdks\Microsoft.Build.Tasks.Git\build\Microsoft.Build.Tasks.Git.targets(25,5): error : Error reading git repository information: Error parsing config line 13 in file '[Path To Repo]\.git\config': Unexpected character U+005c.

Breakdown

This error originiates from the following switch case which wrongfully throws on the \b escaped character despite that being explicitly mentioned by the git config documentation.

switch (reader.Peek())
{
case '\r':
case '\n':
ReadToLineEnd(reader);
continue;
case 'n':
reader.Read();
builder.Append('\n');
// escaped \n is not considered trailing whitespace:
lengthIgnoringTrailingWhitespace = builder.Length;
continue;
case 't':
reader.Read();
builder.Append('\t');
// escaped \t is not considered trailing whitespace:
lengthIgnoringTrailingWhitespace = builder.Length;
continue;
case '\\':
case '"':
builder.Append((char)reader.Read());
lengthIgnoringTrailingWhitespace = builder.Length;
continue;
default:
reader.UnexpectedCharacter(c);
break;
}

source

The following escape sequences (beside " and \) are recognized: \n for newline character (NL), \t for horizontal tabulation (HT, TAB) and \b for backspace (BS). Other char escape sequences (including octal escape sequences) are invalid.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions