fix: canonicalize path case on macOS for git worktree operations (GH#880)
bd sync fails with exit status 128 when the daemon is started from a terminal with different path casing than what git has stored. This happens on macOS case-insensitive filesystem when directory names are renamed (e.g., MyProject to myproject) but terminal sessions retain the old casing. The fix uses realpath(1) on macOS to get the true filesystem case when canonicalizing paths: - CanonicalizePath() now calls realpath on macOS - git.GetRepoRoot() canonicalizes repoRoot via canonicalizeCase() - syncbranch.GetRepoRoot() uses utils.CanonicalizePath() This ensures git worktree paths match exactly, preventing the exit status 128 errors from git operations. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Executed-By: beads/crew/dave Rig: beads Role: crew
This commit is contained in:
committed by
Steve Yegge
parent
fbc93e3de2
commit
7b90678afe
@@ -327,6 +327,35 @@ func TestNormalizePathForComparison(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestCanonicalizePathCase(t *testing.T) {
|
||||
if runtime.GOOS != "darwin" {
|
||||
t.Skip("case canonicalization test only runs on macOS")
|
||||
}
|
||||
|
||||
// Create a directory with mixed case
|
||||
tmpDir := t.TempDir()
|
||||
mixedCaseDir := filepath.Join(tmpDir, "TestCase")
|
||||
if err := os.MkdirAll(mixedCaseDir, 0755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Access via wrong case (lowercase)
|
||||
wrongCasePath := filepath.Join(tmpDir, "testcase")
|
||||
|
||||
// Verify the wrong case path exists (macOS case-insensitive)
|
||||
if _, err := os.Stat(wrongCasePath); err != nil {
|
||||
t.Fatalf("wrong case path should exist on macOS: %v", err)
|
||||
}
|
||||
|
||||
// CanonicalizePath should return the correct case
|
||||
result := CanonicalizePath(wrongCasePath)
|
||||
|
||||
// The result should have the correct case "TestCase", not "testcase"
|
||||
if !strings.HasSuffix(result, "TestCase") {
|
||||
t.Errorf("CanonicalizePath(%q) = %q, want path ending in 'TestCase'", wrongCasePath, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPathsEqual(t *testing.T) {
|
||||
t.Run("identical paths", func(t *testing.T) {
|
||||
tmpDir := t.TempDir()
|
||||
|
||||
Reference in New Issue
Block a user