Skip to content

Commit d477351

Browse files
authored
Git - Get HEAD details in parallel (microsoft#163756)
1 parent b879d03 commit d477351

File tree

2 files changed

+29
-17
lines changed

2 files changed

+29
-17
lines changed

extensions/git/src/git.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1995,6 +1995,26 @@ export class Repository {
19951995
});
19961996
}
19971997

1998+
async getHEADBranch(): Promise<Branch | undefined> {
1999+
let HEAD: Branch | undefined;
2000+
2001+
try {
2002+
HEAD = await this.getHEAD();
2003+
2004+
if (HEAD.name) {
2005+
try {
2006+
HEAD = await this.getBranch(HEAD.name);
2007+
} catch (err) {
2008+
// noop
2009+
}
2010+
}
2011+
} catch (err) {
2012+
// noop
2013+
}
2014+
2015+
return HEAD;
2016+
}
2017+
19982018
async getHEAD(): Promise<Ref> {
19992019
try {
20002020
// Attempt to parse the HEAD file

extensions/git/src/repository.ts

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2017,27 +2017,19 @@ export class Repository implements Disposable {
20172017
this.telemetryReporter.sendTelemetryEvent('statusSlow', { ignoreSubmodules: String(ignoreSubmodules), didHitLimit: String(didHitLimit), didWarnAboutLimit: String(this.didWarnAboutLimit) }, { statusLength, totalTime });
20182018
}
20192019

2020-
let HEAD: Branch | undefined;
2021-
2022-
try {
2023-
HEAD = await this.repository.getHEAD();
2024-
2025-
if (HEAD.name) {
2026-
try {
2027-
HEAD = await this.repository.getBranch(HEAD.name);
2028-
} catch (err) {
2029-
// noop
2030-
}
2031-
}
2032-
} catch (err) {
2033-
// noop
2034-
}
2035-
20362020
let sort = config.get<'alphabetically' | 'committerdate'>('branchSortOrder') || 'alphabetically';
20372021
if (sort !== 'alphabetically' && sort !== 'committerdate') {
20382022
sort = 'alphabetically';
20392023
}
2040-
const [refs, remotes, submodules, rebaseCommit, mergeInProgress, commitTemplate] = await Promise.all([this.repository.getRefs({ sort }), this.repository.getRemotes(), this.repository.getSubmodules(), this.getRebaseCommit(), this.isMergeInProgress(), this.getInputTemplate()]);
2024+
const [HEAD, refs, remotes, submodules, rebaseCommit, mergeInProgress, commitTemplate] =
2025+
await Promise.all([
2026+
this.repository.getHEADBranch(),
2027+
this.repository.getRefs({ sort }),
2028+
this.repository.getRemotes(),
2029+
this.repository.getSubmodules(),
2030+
this.getRebaseCommit(),
2031+
this.isMergeInProgress(),
2032+
this.getInputTemplate()]);
20412033

20422034
this._HEAD = HEAD;
20432035
this._refs = refs!;

0 commit comments

Comments
 (0)