Skip to content

Dashboard ignores main_branch config for diff base detection #97

@mbattifarano

Description

@mbattifarano

Problem

When main_branch is configured to a branch other than the remote's default (e.g., a dev/latest branch that tracks curated stable points on main), the dashboard shows spurious diffs on the main worktree.

Root Cause

get_git_status in src/git/status.rs doesn't use the configured main_branch. Instead, it auto-detects the base via get_default_branch_in, which checks refs/remotes/origin/HEAD and falls back to local main/master:

let base_branch = get_branch_base_in(&branch, Some(worktree_path))
    .ok()
    .or_else(|| get_default_branch_in(Some(worktree_path)).ok())
    .unwrap_or_else(|| "main".to_string());

This means: if you're on dev/latest and origin/HEAD points to master, the dashboard treats the main worktree as a feature branch and diffs master...HEAD.

The same issue applies in load_diff (src/command/dashboard/diff_ops.rs), where the fallback is also hardcoded to "main".

Expected Behavior

The configured main_branch should be used as the base for diff and status calculations, with auto-detection only as a fallback when no config is set.

Workaround

git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/dev/latest

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions