tighten trail worktree checkout guards · Entire

tighten trail worktree checkout guards

c3c1410→main·

pfleidi·1w ago·2 files·+140 added/-19 removed

Avoid creating .gitignore when a repo has none, while still appending the managed worktree ignore rule to an existing file.

Verify a registered managed path is still this repo's worktree on the requested branch before reusing it.

Sessions

01KX6X8CDZ55R4ZPFF1EW2Y774View transcript

Changes

2

92 unmodified lines

;...

const worktreeIncludeFile = ".worktreeinclude"

// trailWorktreeMatch describes an existing worktree that has a branch checked
// out; managed means it lives under <root>/.entire/worktrees.
type trailWorktreeMatch struct {
func TestAppendIgnoreRule(t *testing.T) {
t.Parallel()

path := filepath.Join(t.TempDir(), "sub", "exclude")
for range 2 {
if err := appendIgnoreRule(path); err != nil {
path := filepath.Join(t.TempDir(), "gitignore")
if err := os.WriteFile(path, nil, 0o600); err != nil {
t.Fatalf("seed: %v", err)
}...