diff --git a/pkg/commands/git_commands/repo_paths_test.go b/pkg/commands/git_commands/repo_paths_test.go index 6533b733d..1bee52ec5 100644 --- a/pkg/commands/git_commands/repo_paths_test.go +++ b/pkg/commands/git_commands/repo_paths_test.go @@ -55,6 +55,24 @@ func TestGetRepoPathsAux(t *testing.T) { }, Err: nil, }, + { + Name: "worktree with trailing separator in path", + BeforeFunc: func(fs afero.Fs) { + // setup for linked worktree + _ = fs.MkdirAll("/path/to/repo/.git/worktrees/worktree1", 0o755) + _ = afero.WriteFile(fs, "/path/to/repo/worktree1/.git", []byte("gitdir: /path/to/repo/.git/worktrees/worktree1/"), 0o644) + }, + Path: "/path/to/repo/worktree1", + Expected: &RepoPaths{ + currentPath: "/path/to/repo/worktree1", + worktreePath: "/path/to/repo/worktree1", + worktreeGitDirPath: "/path/to/repo/.git/worktrees/worktree1", + repoPath: "/path/to/repo", + repoGitDirPath: "/path/to/repo/.git", + repoName: "repo", + }, + Err: nil, + }, { Name: "worktree .git file missing gitdir directive", BeforeFunc: func(fs afero.Fs) {