fixed checkout branch with no commits

This commit is contained in:
Austin Fulbright 2024-07-24 07:13:10 -04:00
parent ebd4da95cd
commit 5460bc0a0c

View File

@ -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 (id === undefined || !id) {
head = null;
} else {
head = commits.get(id) ?? null;
}
if (commits.get(id) === undefined) {
throw new Error('Branch ' + branch + ' has no commits');
}
head = commits.get(id) ?? null;
}
};