Git - handle submodule HEAD file (#240357)

* Git - handle submodule HEAD file

* 💄

* Better fix
This commit is contained in:
Ladislau Szomoru
2025-02-11 12:28:56 +01:00
committed by GitHub
parent d5c18cf9e0
commit afa8e16e50
2 changed files with 9 additions and 4 deletions

View File

@@ -18,7 +18,7 @@ interface CacheRow {
const THREE_MINUTES = 1000 * 60 * 3;
const FIVE_MINUTES = 1000 * 60 * 5;
function sanitizeRef(ref: string, path: string, repository: Repository): string {
function sanitizeRef(ref: string, path: string, submoduleOf: string | undefined, repository: Repository): string {
if (ref === '~') {
const fileUri = Uri.file(path);
const uriString = fileUri.toString();
@@ -30,6 +30,11 @@ function sanitizeRef(ref: string, path: string, repository: Repository): string
return `:${ref[1]}`;
}
// Submodule HEAD
if (submoduleOf && (ref === 'index' || ref === 'wt')) {
return 'HEAD';
}
return ref;
}
@@ -141,7 +146,7 @@ export class GitFileSystemProvider implements FileSystemProvider {
}
try {
const details = await repository.getObjectDetails(sanitizeRef(ref, path, repository), path);
const details = await repository.getObjectDetails(sanitizeRef(ref, path, submoduleOf, repository), path);
return { type: FileType.File, size: details.size, mtime: this.mtime, ctime: 0 };
} catch {
// Empty tree
@@ -198,7 +203,7 @@ export class GitFileSystemProvider implements FileSystemProvider {
this.cache.set(uri.toString(), cacheValue);
try {
return await repository.buffer(sanitizeRef(ref, path, repository), path);
return await repository.buffer(sanitizeRef(ref, path, submoduleOf, repository), path);
} catch {
// Empty tree
if (ref === await repository.getEmptyTree()) {