From 7a4179e00bcbce61813bdc2598c88a20f8f8e396 Mon Sep 17 00:00:00 2001 From: Shahar Weiss Date: Sun, 17 Jan 2021 12:38:09 +0200 Subject: [PATCH] Fixes #1328 - Adds support for reading file history for files which originate from a symlink --- src/git/gitUri.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/git/gitUri.ts b/src/git/gitUri.ts index 07491650d6010..dd274fb4a548a 100644 --- a/src/git/gitUri.ts +++ b/src/git/gitUri.ts @@ -1,4 +1,5 @@ 'use strict'; +import * as fs from 'fs'; import * as paths from 'path'; import { Uri } from 'vscode'; import { UriComparer } from '../comparers'; @@ -259,6 +260,15 @@ export class GitUri extends ((Uri as any) as UriEx) { static async fromUri(uri: Uri): Promise { if (GitUri.is(uri)) return uri; + const uriPath = uri.fsPath; + const realPath = fs.realpathSync(uriPath); + if (uriPath !== realPath) { + // If we got here, it means the original URI is to a symbolic link, so we create a new one using the real location. + const newUri = Uri.file(realPath); + + return this.fromUri(newUri); + } + if (!Container.git.isTrackable(uri)) return new GitUri(uri); if (uri.scheme === DocumentSchemes.GitLens) return new GitUri(uri);