From 85e87ff0eb1f452de903874e3aba1fb6a6daa4b6 Mon Sep 17 00:00:00 2001 From: phaedrus Date: Tue, 1 Sep 2026 18:00:53 -0500 Subject: [PATCH] fix(get): force literal tree lookup --- internal/kernel/read.go | 2 +- internal/kernel/read_refresh_test.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/kernel/read.go b/internal/kernel/read.go index 2d175bb..602c670 100644 --- a/internal/kernel/read.go +++ b/internal/kernel/read.go @@ -40,7 +40,7 @@ func (s readSnapshot) read(path string) ([]byte, error) { if s.sha != "" { raw, err := git(s.repo, "show", s.sha+":"+path) if err != nil { - if tree, treeErr := git(s.repo, "ls-tree", "-z", s.sha, "--", path); treeErr == nil && tree == "" { + if tree, treeErr := git(s.repo, "ls-tree", "-z", s.sha, "--", ":(literal)"+path); treeErr == nil && tree == "" { return nil, fs.ErrNotExist } return nil, err diff --git a/internal/kernel/read_refresh_test.go b/internal/kernel/read_refresh_test.go index b6958de..1490679 100644 --- a/internal/kernel/read_refresh_test.go +++ b/internal/kernel/read_refresh_test.go @@ -114,6 +114,10 @@ func TestGetClassifiesMissingCommittedPath(t *testing.T) { if got != nil || conf == nil || conf.Code != "not_found" || conf.Path != "notes/missing.md" { t.Fatalf("got=%+v conflict=%#v", got, conf) } + got, conf = Get(f.cs, "hosta", ":(literal)README.md") + if got != nil || conf == nil || conf.Code != "not_found" { + t.Fatalf("pathspec magic result=%+v conflict=%#v", got, conf) + } if _, err := (readSnapshot{repo: mustEffectiveRoot(&f.cs[0]), sha: "missing-commit"}).read("README.md"); errors.Is(err, fs.ErrNotExist) { t.Fatalf("invalid snapshot classified as missing path: %v", err) }