Skip to content

Commit

Permalink
fixed checkout branch with no commits
Browse files Browse the repository at this point in the history
  • Loading branch information
Austin Fulbright authored and Austin Fulbright committed Jul 24, 2024
1 parent ebd4da9 commit 5460bc0
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions packages/mermaid/src/diagrams/git/gitGraphAst.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,14 +399,11 @@ export const checkout = function (branch: string) {
} else {
curBranch = branch;
const id = branches.get(curBranch);

if (id === null || id === undefined) {
throw new Error('Branch ' + branch + ' has no commits');
}
if (commits.get(id) === undefined) {
throw new Error('Branch ' + branch + ' has no commits');
if (id === undefined || !id) {
head = null;
} else {
head = commits.get(id) ?? null;
}
head = commits.get(id) ?? null;
}
};

Expand Down

0 comments on commit 5460bc0

Please sign in to comment.