Skip to content

Commit 5b7a547

Browse files
committed
Fixes #1328 - Adds support for reading file history for files which originate from a
symlink
1 parent 48184e7 commit 5b7a547

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/git/gitUri.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict';
22
import * as paths from 'path';
3+
import * as fs from 'fs';
34
import { Uri } from 'vscode';
45
import { UriComparer } from '../comparers';
56
import { DocumentSchemes } from '../constants';
@@ -259,6 +260,15 @@ export class GitUri extends ((Uri as any) as UriEx) {
259260
static async fromUri(uri: Uri): Promise<GitUri> {
260261
if (GitUri.is(uri)) return uri;
261262

263+
const uriPath = uri.fsPath;
264+
const realPath = fs.realpathSync(uriPath);
265+
if (uriPath !== realPath) {
266+
// If we got here, it means the original URI is to a symbolic link, so we create a new one using the real location.
267+
const newUri = Uri.file(realPath);
268+
269+
return this.fromUri(newUri);
270+
}
271+
262272
if (!Container.git.isTrackable(uri)) return new GitUri(uri);
263273

264274
if (uri.scheme === DocumentSchemes.GitLens) return new GitUri(uri);

0 commit comments

Comments
 (0)