checkedOutBranches method
Every branch some working tree of this repository has checked out: the main working tree's (unless the repository is bare) and each linked worktree's.
Implementation
Set<String> checkedOutBranches() {
final branches = <String>{};
if (_hasMainWorktree()) {
final main = _branchOf(File(p.join(commonDir, 'HEAD')));
if (main != null) branches.add(main);
}
final worktrees = Directory(p.join(commonDir, 'worktrees'));
if (worktrees.existsSync()) {
for (final dir in worktrees.listSync().whereType<Directory>()) {
final branch = _branchOf(File(p.join(dir.path, 'HEAD')));
if (branch != null) branches.add(branch);
}
}
return branches;
}