Git - fix bug with opening the first commit from the timeline view (#239111)

This commit is contained in:
Ladislau Szomoru
2025-01-29 17:03:52 +01:00
committed by GitHub
parent a29a921f0a
commit 2ae3d5ae35
2 changed files with 15 additions and 1 deletions

View File

@@ -144,6 +144,12 @@ export class GitFileSystemProvider implements FileSystemProvider {
const details = await repository.getObjectDetails(sanitizeRef(ref, path, repository), path);
return { type: FileType.File, size: details.size, mtime: this.mtime, ctime: 0 };
} catch {
// Empty tree
if (ref === await repository.getEmptyTree()) {
this.logger.warn(`[GitFileSystemProvider][stat] Empty tree - ${uri.toString()}`);
return { type: FileType.File, size: 0, mtime: this.mtime, ctime: 0 };
}
// File does not exist in git. This could be because the file is untracked or ignored
this.logger.warn(`[GitFileSystemProvider][stat] File not found - ${uri.toString()}`);
throw FileSystemError.FileNotFound();
@@ -194,6 +200,12 @@ export class GitFileSystemProvider implements FileSystemProvider {
try {
return await repository.buffer(sanitizeRef(ref, path, repository), path);
} catch {
// Empty tree
if (ref === await repository.getEmptyTree()) {
this.logger.warn(`[GitFileSystemProvider][readFile] Empty tree - ${uri.toString()}`);
return new Uint8Array(0);
}
// File does not exist in git. This could be because the file is untracked or ignored
this.logger.warn(`[GitFileSystemProvider][readFile] File not found - ${uri.toString()}`);
throw FileSystemError.FileNotFound();