Skip to content

Commit d942d1e

Browse files
committed
Git - enable copy-on-write to worktree include files when the file system supports it
1 parent 8ba0844 commit d942d1e

File tree

1 file changed

+17
-27
lines changed

1 file changed

+17
-27
lines changed

extensions/git/src/repository.ts

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,36 +1928,26 @@ export class Repository implements Disposable {
19281928

19291929
try {
19301930
// Copy files
1931-
let copiedFiles = 0;
1932-
const results = await window.withProgress({
1933-
location: ProgressLocation.Notification,
1934-
title: l10n.t('Copying additional files to the worktree'),
1935-
cancellable: false
1936-
}, async (progress) => {
1937-
const limiter = new Limiter<void>(10);
1938-
const files = Array.from(ignoredFiles);
1939-
1940-
return Promise.allSettled(files.map(sourceFile =>
1941-
limiter.queue(async () => {
1942-
const targetFile = path.join(worktreePath, relativePath(this.root, sourceFile));
1943-
await fsPromises.mkdir(path.dirname(targetFile), { recursive: true });
1944-
await fsPromises.cp(sourceFile, targetFile, {
1945-
force: true,
1946-
recursive: false,
1947-
verbatimSymlinks: true
1948-
});
1949-
1950-
copiedFiles++;
1951-
progress.report({
1952-
increment: 100 / ignoredFiles.size,
1953-
message: l10n.t('({0}/{1})', copiedFiles, ignoredFiles.size)
1954-
});
1955-
})
1956-
));
1957-
});
1931+
const startTime = Date.now();
1932+
const limiter = new Limiter<void>(15);
1933+
const files = Array.from(ignoredFiles);
1934+
1935+
const results = await Promise.allSettled(files.map(sourceFile =>
1936+
limiter.queue(async () => {
1937+
const targetFile = path.join(worktreePath, relativePath(this.root, sourceFile));
1938+
await fsPromises.mkdir(path.dirname(targetFile), { recursive: true });
1939+
await fsPromises.cp(sourceFile, targetFile, {
1940+
force: true,
1941+
mode: fs.constants.COPYFILE_FICLONE,
1942+
recursive: false,
1943+
verbatimSymlinks: true
1944+
});
1945+
})
1946+
));
19581947

19591948
// Log any failed operations
19601949
const failedOperations = results.filter(r => r.status === 'rejected');
1950+
this.logger.info(`[Repository][_copyWorktreeIncludeFiles] Copied ${files.length - failedOperations.length} files to worktree. Failed to copy ${failedOperations.length} files. [${Date.now() - startTime}ms]`);
19611951

19621952
if (failedOperations.length > 0) {
19631953
window.showWarningMessage(l10n.t('Failed to copy {0} files to the worktree.', failedOperations.length));

0 commit comments

Comments
 (0)