diff --git a/src/components/GitCommitGraph.tsx b/src/components/GitCommitGraph.tsx index d7d24c2b5..1560e61d7 100644 --- a/src/components/GitCommitGraph.tsx +++ b/src/components/GitCommitGraph.tsx @@ -95,12 +95,19 @@ export class GitCommitGraph extends React.Component { } getHeight(): number { - return ( - this._graphData[this._graphData.length - 1].yOffset + - this.props.getNodeHeight( - this.props.commits[this.props.commits.length - 1].sha - ) - ); + // if this.props.commits.length = 0, just pass 0 + const numCommits = this.props.commits.length; + const lastNodeHeight = + numCommits === 0 + ? 0 + : this.props.getNodeHeight(this.props.commits[numCommits - 1].sha); + + const numGraphNodes = this._graphData.length; + const lastYOffset = + numGraphNodes === 0 + ? 0 + : this._graphData[this._graphData.length - 1].yOffset; + return lastYOffset + lastNodeHeight; } renderRouteNode(svgPathDataAttribute: string, branch: number): JSX.Element { diff --git a/src/model.ts b/src/model.ts index b16478b04..0c658f04d 100644 --- a/src/model.ts +++ b/src/model.ts @@ -919,14 +919,18 @@ export class GitExtension implements IGitExtension { return await this._taskHandler.execute( 'git:fetch:log', async () => { - return await requestAPI( - URLExt.join(path, 'log'), - 'POST', - { - history_count: count, - follow_path: this.selectedHistoryFile?.to - } - ); + try { + return await requestAPI( + URLExt.join(path, 'log'), + 'POST', + { + history_count: count, + follow_path: this.selectedHistoryFile?.to + } + ); + } catch (error) { + return { code: 1 }; + } } ); }