From 413a17865cbdd917c15b235391a6564068e63939 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Fri, 29 Nov 2019 12:31:19 +0100 Subject: [PATCH] git: use getCommit instead of log --- extensions/git/src/git.ts | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/extensions/git/src/git.ts b/extensions/git/src/git.ts index 484bcec0a47ee..af92f83c1a674 100644 --- a/extensions/git/src/git.ts +++ b/extensions/git/src/git.ts @@ -762,10 +762,8 @@ export class Repository { const maxEntries = options && typeof options.maxEntries === 'number' && options.maxEntries > 0 ? options.maxEntries : 32; const args = ['log', '-' + maxEntries, `--pretty=format:${COMMIT_FORMAT}%x00%x00`]; - let gitResult: IExecutionResult; - try { - gitResult = await this.run(args); - } catch (err) { + const gitResult = await this.run(args); + if (gitResult.exitCode) { // An empty repo return []; } @@ -1164,14 +1162,9 @@ export class Repository { }); } + const treeish = await this.getCommit('HEAD').then(() => 'HEAD', () => ''); let mode: string; let add: string = ''; - let treeish: string = ''; - const commits = await this.log({ maxEntries: 1 }); - - if (commits.length > 0) { - treeish = 'HEAD'; - } try { const details = await this.getObjectDetails(treeish, path);