Skip to content

fix(git): compute diff stats including uncommitted changes for dirty branches#391

Open
proboscis wants to merge 1 commit intomainfrom
issue/orch-401/run-20260201-104839
Open

fix(git): compute diff stats including uncommitted changes for dirty branches#391
proboscis wants to merge 1 commit intomainfrom
issue/orch-401/run-20260201-104839

Conversation

@proboscis
Copy link
Owner

Summary

  • Adds getWorkingTreeDiffStats function that computes diff from base branch to working tree (including uncommitted changes)
  • Updates GetWorktreeStatus to use this function when the branch is dirty
  • Adds unit tests to verify diff stats are properly computed for dirty branches

Problem

In orch-monitor TUI, the +/- columns showed - even when the branch column showed dirty. This happened because:

  • getDiffStatsFast computed git diff --numstat origin/main...HEAD (only committed changes)
  • When there are ONLY uncommitted changes, this shows 0/0, resulting in - in the TUI

Solution

When the branch is dirty, compute diff stats using git diff --numstat origin/main (without ...HEAD), which compares the base branch directly to the working tree and includes both committed AND uncommitted changes.

Evidence

Before fix (dirty branch with only uncommitted changes):

WorkingTreeDiff - Additions: 0, Deletions: 0

After fix:

WorkingTreeDiff - Additions: 18, Deletions: 1

Test output:

=== RUN   TestGetWorktreeStatus_DirtyWithDiffStats
--- PASS: TestGetWorktreeStatus_DirtyWithDiffStats (0.24s)
=== RUN   TestGetWorktreeStatus_DirtyWithBothCommittedAndUncommitted
--- PASS: TestGetWorktreeStatus_DirtyWithBothCommittedAndUncommitted (0.30s)
PASS

Files Changed

  • internal/git/gogit.go: Added getWorkingTreeDiffStats, updated dirty branch handling
  • internal/git/gogit_test.go: New tests for dirty worktree diff stats

Fixes: orch-401

…branches

When a branch is dirty, the daemon now computes diff stats that include
both committed and uncommitted changes (working tree vs base branch)
instead of only committed changes (HEAD vs base branch).

This ensures the +/- columns in orch-monitor TUI show actual values
when the branch state shows 'dirty' instead of showing '-'.

Fixes: orch-401
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant