diff --git a/src/git/git.ts b/src/git/git.ts index cdcbe0c119fa..ea988c3bd26b 100644 --- a/src/git/git.ts +++ b/src/git/git.ts @@ -990,14 +990,19 @@ export class Git { porcelainVersion: number = 1, { similarityThreshold }: { similarityThreshold?: number } = {} ): Promise { - const porcelain = porcelainVersion >= 2 ? `--porcelain=v${porcelainVersion}` : '--porcelain'; - return git( - { cwd: repoPath, configs: ['-c', 'color.status=false'], env: { GIT_OPTIONAL_LOCKS: '0' } }, + const params = [ 'status', - porcelain, + porcelainVersion >= 2 ? `--porcelain=v${porcelainVersion}` : '--porcelain', '--branch', - '-u', - `-M${similarityThreshold == null ? '' : `${similarityThreshold}%`}`, + '-u' + ]; + if (Git.validateVersion(2, 18)) { + params.push(`--find-renames=${similarityThreshold == null ? '' : `${similarityThreshold}%`}`); + } + + return git( + { cwd: repoPath, configs: ['-c', 'color.status=false'], env: { GIT_OPTIONAL_LOCKS: '0' } }, + ...params, '--' ); } @@ -1010,12 +1015,14 @@ export class Git { ): Promise { const [file, root] = Git.splitPath(fileName, repoPath); - const porcelain = porcelainVersion >= 2 ? `--porcelain=v${porcelainVersion}` : '--porcelain'; + const params = ['status', porcelainVersion >= 2 ? `--porcelain=v${porcelainVersion}` : '--porcelain']; + if (Git.validateVersion(2, 18)) { + params.push(`--find-renames=${similarityThreshold == null ? '' : `${similarityThreshold}%`}`); + } + return git( { cwd: root, configs: ['-c', 'color.status=false'], env: { GIT_OPTIONAL_LOCKS: '0' } }, - 'status', - porcelain, - `-M${similarityThreshold == null ? '' : `${similarityThreshold}%`}`, + ...params, '--', file );