From a0ecf511fdde8a33e46688374ab0fbef201403f5 Mon Sep 17 00:00:00 2001 From: Ladislau Szomoru <3372902+lszomoru@users.noreply.github.com> Date: Tue, 21 Jan 2025 15:38:47 +0100 Subject: [PATCH] Git - pass the similarityThreshold to git diff-tree (#238367) --- extensions/git/src/git.ts | 10 ++++++++-- extensions/git/src/repository.ts | 5 ++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/extensions/git/src/git.ts b/extensions/git/src/git.ts index 4072e4ae706..d235b926b16 100644 --- a/extensions/git/src/git.ts +++ b/extensions/git/src/git.ts @@ -1592,8 +1592,14 @@ export class Repository { return parseGitChanges(this.repositoryRoot, gitResult.stdout); } - async diffTrees(treeish1: string, treeish2?: string): Promise { - const args = ['diff-tree', '-r', '--name-status', '-z', '--diff-filter=ADMR', treeish1]; + async diffTrees(treeish1: string, treeish2?: string, options?: { similarityThreshold?: number }): Promise { + const args = ['diff-tree', '-r', '--name-status', '-z', '--diff-filter=ADMR']; + + if (options?.similarityThreshold) { + args.push(`--find-renames=${options.similarityThreshold}%`); + } + + args.push(treeish1); if (treeish2) { args.push(treeish2); diff --git a/extensions/git/src/repository.ts b/extensions/git/src/repository.ts index 79b8379426e..20fb28e8e58 100644 --- a/extensions/git/src/repository.ts +++ b/extensions/git/src/repository.ts @@ -1166,7 +1166,10 @@ export class Repository implements Disposable { } diffTrees(treeish1: string, treeish2?: string): Promise { - return this.run(Operation.Diff, () => this.repository.diffTrees(treeish1, treeish2)); + const scopedConfig = workspace.getConfiguration('git', Uri.file(this.root)); + const similarityThreshold = scopedConfig.get('similarityThreshold', 50); + + return this.run(Operation.Diff, () => this.repository.diffTrees(treeish1, treeish2, { similarityThreshold })); } getMergeBase(ref1: string, ref2: string, ...refs: string[]): Promise {