Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/git/gitUri.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
'use strict';
import * as fs from 'fs';
import * as paths from 'path';
import { Uri } from 'vscode';
import { decodeUtf8Hex, encodeUtf8Hex } from '@env/hex';
import { UriComparer } from '../comparers';
Expand Down Expand Up @@ -248,6 +251,16 @@ export class GitUri extends (Uri as any as UriEx) {
})
static async fromUri(uri: Uri): Promise<GitUri> {
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.instance.git.isTrackable(uri)) return new GitUri(uri);
if (uri.scheme === Schemes.GitLens) return new GitUri(uri);

Expand Down