diff --git a/src/annotations/gutterChangesAnnotationProvider.ts b/src/annotations/gutterChangesAnnotationProvider.ts index 9db0ecc..dc92eed 100644 --- a/src/annotations/gutterChangesAnnotationProvider.ts +++ b/src/annotations/gutterChangesAnnotationProvider.ts @@ -101,7 +101,7 @@ export class GutterChangesAnnotationProvider extends AnnotationProviderBase(Commands.DiffWith, { repoPath: gitUri.repoPath, diff --git a/src/commands/externalDiff.ts b/src/commands/externalDiff.ts index 37e44cd..e9d0fa3 100644 --- a/src/commands/externalDiff.ts +++ b/src/commands/externalDiff.ts @@ -133,7 +133,7 @@ export class ExternalDiffCommand extends Command { if (!repoPath) return; const uri = editor.document.uri; - const status = await this.container.git.getStatusForFile(repoPath, uri.fsPath); + const status = await this.container.git.getStatusForFile(repoPath, uri); if (status == null) { void window.showInformationMessage("The current file doesn't have any changes"); diff --git a/src/env/node/git/localGitProvider.ts b/src/env/node/git/localGitProvider.ts index b32282d..8d4cd85 100644 --- a/src/env/node/git/localGitProvider.ts +++ b/src/env/node/git/localGitProvider.ts @@ -2661,38 +2661,38 @@ export class LocalGitProvider implements GitProvider, Disposable { // If we have no ref (or staged ref) there is no next commit if (ref == null || ref.length === 0) return undefined; - const fileName = GitUri.relativeTo(uri, repoPath); + const path = this.getRelativePath(uri, repoPath); if (GitRevision.isUncommittedStaged(ref)) { return { - current: GitUri.fromFile(fileName, repoPath, ref), - next: GitUri.fromFile(fileName, repoPath, undefined), + current: GitUri.fromFile(path, repoPath, ref), + next: GitUri.fromFile(path, repoPath, undefined), }; } const next = await this.getNextUri(repoPath, uri, ref, skip); if (next == null) { - const status = await this.getStatusForFile(repoPath, fileName); + const status = await this.getStatusForFile(repoPath, uri); if (status != null) { // If the file is staged, diff with the staged version if (status.indexStatus != null) { return { - current: GitUri.fromFile(fileName, repoPath, ref), - next: GitUri.fromFile(fileName, repoPath, GitRevision.uncommittedStaged), + current: GitUri.fromFile(path, repoPath, ref), + next: GitUri.fromFile(path, repoPath, GitRevision.uncommittedStaged), }; } } return { - current: GitUri.fromFile(fileName, repoPath, ref), - next: GitUri.fromFile(fileName, repoPath, undefined), + current: GitUri.fromFile(path, repoPath, ref), + next: GitUri.fromFile(path, repoPath, undefined), }; } return { current: skip === 0 - ? GitUri.fromFile(fileName, repoPath, ref) + ? GitUri.fromFile(path, repoPath, ref) : (await this.getNextUri(repoPath, uri, ref, skip - 1))!, next: next, }; @@ -2769,7 +2769,7 @@ export class LocalGitProvider implements GitProvider, Disposable { // If we are at the working tree (i.e. no ref), we need to dig deeper to figure out where to go if (!ref) { // First, check the file status to see if there is anything staged - const status = await this.getStatusForFile(repoPath, path); + const status = await this.getStatusForFile(repoPath, uri); if (status != null) { // If the file is staged with working changes, diff working with staged (index) // If the file is staged without working changes, diff staged with HEAD @@ -2861,7 +2861,7 @@ export class LocalGitProvider implements GitProvider, Disposable { // If the document is dirty (unsaved), use the status to determine where to go if (document.isDirty) { // Check the file status to see if there is anything staged - const status = await this.getStatusForFile(repoPath, path); + const status = await this.getStatusForFile(repoPath, uri); if (status != null) { // If the file is staged, diff working with staged (index) // If the file is not staged, diff working with HEAD @@ -2985,7 +2985,7 @@ export class LocalGitProvider implements GitProvider, Disposable { // If the line count is invalid just fallback to the most recent commit if ((ref == null || GitRevision.isUncommittedStaged(ref)) && GitErrors.invalidLineCount.test(msg)) { if (ref == null) { - const status = await this.getStatusForFile(repoPath, path); + const status = await this.getStatusForFile(repoPath, uri); if (status?.indexStatus != null) { return GitUri.fromFile(path, repoPath, GitRevision.uncommittedStaged); } @@ -3123,15 +3123,15 @@ export class LocalGitProvider implements GitProvider, Disposable { } @log() - async getStatusForFile(repoPath: string, path: string): Promise { + async getStatusForFile(repoPath: string, uri: Uri): Promise { const porcelainVersion = (await this.git.isAtLeastVersion('2.11')) ? 2 : 1; - [path, repoPath] = splitPath(path, repoPath); + const [relativePath, root] = splitPath(getBestPath(uri), repoPath); - const data = await this.git.status__file(repoPath, path, porcelainVersion, { + const data = await this.git.status__file(root, relativePath, porcelainVersion, { similarityThreshold: this.container.config.advanced.similarityThreshold, }); - const status = GitStatusParser.parse(data, repoPath, porcelainVersion); + const status = GitStatusParser.parse(data, root, porcelainVersion); if (status == null || !status.files.length) return undefined; return status.files[0]; @@ -3141,12 +3141,12 @@ export class LocalGitProvider implements GitProvider, Disposable { async getStatusForFiles(repoPath: string, pathOrGlob: string): Promise { const porcelainVersion = (await this.git.isAtLeastVersion('2.11')) ? 2 : 1; - [pathOrGlob, repoPath] = splitPath(pathOrGlob, repoPath); + const [relativePath, root] = splitPath(pathOrGlob, repoPath); - const data = await this.git.status__file(repoPath, pathOrGlob, porcelainVersion, { + const data = await this.git.status__file(root, relativePath, porcelainVersion, { similarityThreshold: this.container.config.advanced.similarityThreshold, }); - const status = GitStatusParser.parse(data, repoPath, porcelainVersion); + const status = GitStatusParser.parse(data, root, porcelainVersion); if (status == null || !status.files.length) return []; return status.files; diff --git a/src/git/gitProvider.ts b/src/git/gitProvider.ts index dda935b..f4b4ff2 100644 --- a/src/git/gitProvider.ts +++ b/src/git/gitProvider.ts @@ -337,7 +337,7 @@ export interface GitProvider extends Disposable { ): Promise[]>; getRevisionContent(repoPath: string, path: string, ref: string): Promise; getStash(repoPath: string | undefined): Promise; - getStatusForFile(repoPath: string, path: string): Promise; + getStatusForFile(repoPath: string, uri: Uri): Promise; getStatusForFiles(repoPath: string, pathOrGlob: string): Promise; getStatusForRepo(repoPath: string | undefined): Promise; getTags( diff --git a/src/git/gitProviderService.ts b/src/git/gitProviderService.ts index 509ac45..a42a46d 100644 --- a/src/git/gitProviderService.ts +++ b/src/git/gitProviderService.ts @@ -1707,9 +1707,9 @@ export class GitProviderService implements Disposable { } @log() - async getStatusForFile(repoPath: string | Uri, fileName: string): Promise { + async getStatusForFile(repoPath: string | Uri, uri: Uri): Promise { const { provider, path } = this.getProvider(repoPath); - return provider.getStatusForFile(path, fileName); + return provider.getStatusForFile(path, uri); } @log() diff --git a/src/premium/github/githubGitProvider.ts b/src/premium/github/githubGitProvider.ts index 2a3def7..8520222 100644 --- a/src/premium/github/githubGitProvider.ts +++ b/src/premium/github/githubGitProvider.ts @@ -1757,7 +1757,7 @@ export class GitHubGitProvider implements GitProvider, Disposable { } @log() - async getStatusForFile(_repoPath: string, _path: string): Promise { + async getStatusForFile(_repoPath: string, _uri: Uri): Promise { return undefined; } diff --git a/src/views/nodes/lineHistoryNode.ts b/src/views/nodes/lineHistoryNode.ts index 6fcd4b4..0d99bc5 100644 --- a/src/views/nodes/lineHistoryNode.ts +++ b/src/views/nodes/lineHistoryNode.ts @@ -102,7 +102,7 @@ export class LineHistoryNode selection.active.character, ); - const status = await this.view.container.git.getStatusForFile(this.uri.repoPath!, this.uri.fsPath); + const status = await this.view.container.git.getStatusForFile(this.uri.repoPath!, this.uri); if (status != null) { const file: GitFile = {