use -z --stdin when running check-ignore, qualified guess for #37857

This commit is contained in:
Johannes Rieken
2017-11-10 10:05:01 +01:00
parent 6933e2eb3c
commit 5ca4bab8fc

View File

@@ -756,15 +756,17 @@ export class Repository implements Disposable {
return Promise.resolve(new Set<string>());
}
const child = this.repository.stream(['check-ignore', ...filePaths]);
// https://git-scm.com/docs/git-check-ignore#git-check-ignore--z
const child = this.repository.stream(['check-ignore', '-z', '--stdin'], { stdio: [null, null, null] });
child.stdin.end(filePaths.join('\0'), 'utf8');
const onExit = (exitCode: number) => {
if (exitCode === 1) {
// nothing ignored
resolve(new Set<string>());
} else if (exitCode === 0) {
// each line is something ignored
resolve(new Set<string>(data.split('\n')));
// paths are separated by the null-character
resolve(new Set<string>(data.split('\0')));
} else {
reject(new GitError({ stdout: data, stderr, exitCode }));
}