diff --git a/extensions/git/src/git.ts b/extensions/git/src/git.ts index 7a8c891cf06..6f768d36ea0 100644 --- a/extensions/git/src/git.ts +++ b/extensions/git/src/git.ts @@ -2622,7 +2622,13 @@ export class Repository { } async getCommitCount(range: string): Promise<{ ahead: number; behind: number }> { - const result = await this.exec(['rev-list', '--count', '--left-right', range]); + const args = ['rev-list', '--count', '--left-right', range]; + + if (isWindows) { + args.splice(0, 0, '-c', 'core.longpaths=true'); + } + + const result = await this.exec(args); const [ahead, behind] = result.stdout.trim().split('\t'); return { ahead: Number(ahead) || 0, behind: Number(behind) || 0 }; diff --git a/extensions/git/src/historyProvider.ts b/extensions/git/src/historyProvider.ts index a58b491ce62..a6e97c63763 100644 --- a/extensions/git/src/historyProvider.ts +++ b/extensions/git/src/historyProvider.ts @@ -186,8 +186,14 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec return undefined; } - const commitCount = await this.repository.getCommitCount(`${refId1}...${refId2}`); - return { id: ancestor, ahead: commitCount.ahead, behind: commitCount.behind }; + try { + const commitCount = await this.repository.getCommitCount(`${refId1}...${refId2}`); + return { id: ancestor, ahead: commitCount.ahead, behind: commitCount.behind }; + } catch (err) { + this.logger.error(`Failed to get ahead/behind for '${refId1}...${refId2}': ${err.message}`); + } + + return undefined; } provideFileDecoration(uri: Uri): FileDecoration | undefined {