diff --git a/extensions/git/src/git.ts b/extensions/git/src/git.ts index cf2a7224f71..4adc617a3eb 100644 --- a/extensions/git/src/git.ts +++ b/extensions/git/src/git.ts @@ -171,6 +171,9 @@ async function exec(child: cp.ChildProcess, options: any = {}): Promise ee.removeListener(name, fn))); }; + let encoding = options.encoding || 'utf8'; + encoding = iconv.encodingExists(encoding) ? encoding : 'utf8'; + const [exitCode, stdout, stderr] = await Promise.all([ new Promise((c, e) => { once(child, 'error', e); @@ -179,7 +182,7 @@ async function exec(child: cp.ChildProcess, options: any = {}): Promise(c => { const buffers: Buffer[] = []; on(child.stdout, 'data', b => buffers.push(b)); - once(child.stdout, 'close', () => c(iconv.decode(Buffer.concat(buffers), options.encoding || 'utf8'))); + once(child.stdout, 'close', () => c(iconv.decode(Buffer.concat(buffers), encoding))); }), new Promise(c => { const buffers: Buffer[] = [];