Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions addons/isl/src/dag/dag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,13 @@ export class Dag extends SelfUpdate<CommitDagRecord> {
return [...sorted];
}
const hashes = arrayFromHashes(set === undefined ? this.all() : set);
return hashes.sort((a, b) => {
const aIdx = index.get(a);
const bIdx = index.get(b);
if (aIdx == null || bIdx == null) {
throw new Error(`Commit ${a} or ${b} is not in the dag.`);
}
// Filter out hashes not present in the dag to avoid errors when the set
// contains commits that are not in the dag (e.g. during drag-and-drop
// rebase previews where commits may reference hashes not yet in the dag).
const presentHashes = hashes.filter(h => index.has(h));
return presentHashes.sort((a, b) => {
const aIdx = index.get(a) as number;
const bIdx = index.get(b) as number;
return aIdx - bIdx;
});
}
Expand Down