Skip to content

fix: correctly detect clean worktrees when checking for uncommitted changes#13

Merged
malaporte merged 1 commit intomainfrom
uncommitted-changes-warning
Apr 2, 2026
Merged

fix: correctly detect clean worktrees when checking for uncommitted changes#13
malaporte merged 1 commit intomainfrom
uncommitted-changes-warning

Conversation

@malaporte
Copy link
Copy Markdown
Owner

Summary

getWorktreeStatus was always warning about uncommitted changes for clean worktrees. The bug was a falsy check on the output of git status --porcelain — an empty string (returned for a clean worktree) is falsy in JavaScript, causing the ternary to fall through to the true default instead of correctly evaluating "".trim().length > 0 === false.

Changes

  • Fix hasUncommittedChanges check in getWorktreeStatus to use !== null instead of a truthiness check, so an empty string from a clean worktree correctly resolves to false

Testing

The fix handles all three cases correctly:

  • "" (clean worktree) → false
  • "M foo.ts\n" (dirty worktree) → true
  • null (git command failed) → true (safe fallback)

Reviewer Notes

Single-character change in packages/treebeard/src/bun/services/git.ts:145. The safe fallback behaviour on command failure (null → true) is preserved intentionally.

@malaporte malaporte marked this pull request as ready for review April 2, 2026 06:45
@malaporte malaporte merged commit 10b2664 into main Apr 2, 2026
2 checks passed
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 2, 2026

🎉 This PR is included in version 2.7.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant