mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-01 22:12:26 +01:00
[Git] Migrate to git autostash when pulling for better performance (#187850)
* git: migrate to git autostash when pulling (better performance) * should be implemented correctly! * refactor other op * Pull request feedback --------- Co-authored-by: Ladislau Szomoru <3372902+lszomoru@users.noreply.github.com>
This commit is contained in:
@@ -1798,6 +1798,7 @@ export class Repository implements Disposable {
|
||||
await this.run(Operation.Pull, async () => {
|
||||
await this.maybeAutoStash(async () => {
|
||||
const config = workspace.getConfiguration('git', Uri.file(this.root));
|
||||
const autoStash = config.get<boolean>('autoStash');
|
||||
const fetchOnPull = config.get<boolean>('fetchOnPull');
|
||||
const tags = config.get<boolean>('pullTags');
|
||||
|
||||
@@ -1807,7 +1808,7 @@ export class Repository implements Disposable {
|
||||
}
|
||||
|
||||
if (await this.checkIfMaybeRebased(this.HEAD?.name)) {
|
||||
await this._pullAndHandleTagConflict(rebase, remote, branch, { unshallow, tags });
|
||||
await this._pullAndHandleTagConflict(rebase, remote, branch, { unshallow, tags, autoStash });
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1881,6 +1882,7 @@ export class Repository implements Disposable {
|
||||
await this.run(Operation.Sync, async () => {
|
||||
await this.maybeAutoStash(async () => {
|
||||
const config = workspace.getConfiguration('git', Uri.file(this.root));
|
||||
const autoStash = config.get<boolean>('autoStash');
|
||||
const fetchOnPull = config.get<boolean>('fetchOnPull');
|
||||
const tags = config.get<boolean>('pullTags');
|
||||
const followTags = config.get<boolean>('followTagsWhenSync');
|
||||
@@ -1893,7 +1895,7 @@ export class Repository implements Disposable {
|
||||
}
|
||||
|
||||
if (await this.checkIfMaybeRebased(this.HEAD?.name)) {
|
||||
await this._pullAndHandleTagConflict(rebase, remoteName, pullBranch, { tags, cancellationToken });
|
||||
await this._pullAndHandleTagConflict(rebase, remoteName, pullBranch, { tags, cancellationToken, autoStash });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2530,6 +2532,7 @@ export class Repository implements Disposable {
|
||||
private async maybeAutoStash<T>(runOperation: () => Promise<T>): Promise<T> {
|
||||
const config = workspace.getConfiguration('git', Uri.file(this.root));
|
||||
const shouldAutoStash = config.get<boolean>('autoStash')
|
||||
&& this.repository.git.compareGitVersionTo('2.27.0') < 0
|
||||
&& (this.indexGroup.resourceStates.length > 0
|
||||
|| this.workingTreeGroup.resourceStates.some(
|
||||
r => r.type !== Status.UNTRACKED && r.type !== Status.IGNORED));
|
||||
|
||||
Reference in New Issue
Block a user