Skip to content

Commit 06c1b71

Browse files
fixes #248369: Fix discarding untracked files on Windows subst drives
1 parent 5b9a753 commit 06c1b71

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

extensions/git/src/repository.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1399,7 +1399,20 @@ export class Repository implements Disposable {
13991399
if (discardUntrackedChangesToTrash) {
14001400
const limiter = new Limiter<void>(5);
14011401
await Promise.all(toClean.map(fsPath => limiter.queue(
1402-
async () => await workspace.fs.delete(Uri.file(fsPath), { useTrash: true }))));
1402+
async () => {
1403+
// Use fs path from the rootRealPath if it exists (for handling subst drive paths)
1404+
const realPath = this.rootRealPath && fsPath.startsWith(this.root)
1405+
? path.join(this.rootRealPath, fsPath.substring(this.root.length))
1406+
: fsPath;
1407+
1408+
try {
1409+
await workspace.fs.delete(Uri.file(realPath), { useTrash: true });
1410+
} catch (err) {
1411+
this.logger.warn(`[Repository][clean] Failed to delete file '${fsPath}' using realPath '${realPath}': ${err.message}`);
1412+
// Fall back to direct Git clean if file system delete fails
1413+
await this.repository.clean([fsPath]);
1414+
}
1415+
})));
14031416
} else {
14041417
await this.repository.clean(toClean);
14051418
}

0 commit comments

Comments
 (0)