Skip to content

Commit 075f04b

Browse files
authored
Git - Fix GitConfigParser regression (microsoft#167309)
Fix microsoft#166264
1 parent ac084d7 commit 075f04b

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

extensions/git/src/git.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ interface GitConfigSection {
709709
}
710710

711711
class GitConfigParser {
712-
private static readonly _lineSeparator = /\r?\n/g;
712+
private static readonly _lineSeparator = /\r?\n/;
713713

714714
private static readonly _propertyRegex = /^\s*(\w+)\s*=\s*(.*)$/;
715715
private static readonly _sectionRegex = /^\s*\[\s*([^\]]+?)\s*(\"[^"]+\")*\]\s*$/;
@@ -723,13 +723,8 @@ class GitConfigParser {
723723
config.sections.push(section);
724724
};
725725

726-
let position = 0;
727-
let match: RegExpExecArray | null = null;
728-
729-
while (match = GitConfigParser._lineSeparator.exec(raw)) {
730-
const line = raw.substring(position, match.index);
731-
position = match.index + match[0].length;
732-
726+
for (const line of raw.split(GitConfigParser._lineSeparator)) {
727+
// Section
733728
const sectionMatch = line.match(GitConfigParser._sectionRegex);
734729
if (sectionMatch?.length === 3) {
735730
addSection(section);
@@ -738,7 +733,7 @@ class GitConfigParser {
738733
continue;
739734
}
740735

741-
// Properties
736+
// Property
742737
const propertyMatch = line.match(GitConfigParser._propertyRegex);
743738
if (propertyMatch?.length === 3 && !Object.keys(section.properties).includes(propertyMatch[1])) {
744739
section.properties[propertyMatch[1]] = propertyMatch[2];

0 commit comments

Comments
 (0)