vole
Site
Clone
Read only, no credentials:
https://rodent.software/vole.git
Write over SSH with a registered key:
git clone ssh://git@rodent.software/vole.git
Self-hosted forge that lives in your Git repo.
Enforce path gates on the names git stores
617cda58a98595daf8a0a42758d383f8e40c3fd2 · Keenan Nemetz · 13d ago · parent 87bab8e1
Enforce path gates on the names git stores DiffStatusPaths parsed git diff-tree's tab-separated output. Git C-quotes non-ASCII, tab, newline, quote, and space-edged names by default, so the map was keyed by the escaped spelling. A lock on Content/Héros/Épée.uasset was stored, listed, and never matched against a push; protected scopes, CI path filters, and the index refresh read the same map. Use -z and NUL records so the key is always the path git stores. Pass --no-renames so a rename reports its source as a deletion and its destination as an addition: a lock or protected path on either side stays visible. The old tests neutralized the problem with core.quotePath=false. The new tests use the filenames that trigger quoting and tab-separated ambiguity.
core/git/diff_test.go +84
| @@ -0,0 +1,84 @@ | |||
| 1 | package git | ||
| 2 | |||
| 3 | // The diff is the input to every path gate: locks, protected scopes, CI path | ||
| 4 | // filters, the index refresh. A path that comes back in a different spelling | ||
| 5 | // than the one git stores is a gate that silently does not fire, so these tests | ||
| 6 | // use the filenames that make git quote and the ones that make tab-separated | ||
| 7 | // parsing ambiguous. | ||
| 8 | |||
| 9 | import "testing" | ||
| 10 | |||
| 11 | func TestDiffStatusKeepsPathsGitWouldQuote(t *testing.T) { | ||
| 12 | g, rev := changeRepo(t) | ||
| 13 | // changeRepo's second commit modifies readme, adds docs/guide.md, deletes | ||
| 14 | // keep.txt and renames a path with a space and a non-ASCII byte. | ||
| 15 | old, err := g.RevParse(rev + "^") | ||
| 16 | if err != nil { | ||
| 17 | t.Fatal(err) | ||
| 18 | } | ||
| 19 | next, err := g.RevParse(rev) | ||
| 20 | if err != nil { | ||
| 21 | t.Fatal(err) | ||
| 22 | } | ||
| 23 | status, err := g.DiffStatus(old, next) | ||
| 24 | if err != nil { | ||
| 25 | t.Fatal(err) | ||
| 26 | } | ||
| 27 | want := map[string]string{ | ||
| 28 | "readme.md": "M", | ||
| 29 | "docs/guide.md": "A", | ||
| 30 | "keep.txt": "D", | ||
| 31 | "old name.txt": "D", | ||
| 32 | "nëw name.txt": "A", | ||
| 33 | } | ||
| 34 | for path, code := range want { | ||
| 35 | if status[path] != code { | ||
| 36 | t.Errorf("DiffStatus[%q] = %q, want %q (got %v)", path, status[path], code, status) | ||
| 37 | } | ||
| 38 | } | ||
| 39 | for path := range status { | ||
| 40 | if path == "" { | ||
| 41 | t.Errorf("DiffStatus has an empty path: %v", status) | ||
| 42 | continue | ||
| 43 | } | ||
| 44 | if path[0] == '"' { | ||
| 45 | t.Errorf("DiffStatus kept git's quoted spelling %s: %v", path, status) | ||
| 46 | } | ||
| 47 | } | ||
| 48 | } | ||
| 49 | |||
| 50 | func TestDiffStatusPreservesAwkwardFileNames(t *testing.T) { | ||
| 51 | files := map[string][]byte{ | ||
| 52 | "plain.txt": []byte("one\n"), | ||
| 53 | "with\ttab.txt": []byte("one\n"), | ||
| 54 | " leading.txt": []byte("one\n"), | ||
| 55 | "trailing.txt ": []byte("one\n"), | ||
| 56 | "café.txt": []byte("one\n"), | ||
| 57 | } | ||
| 58 | g := blobRepo(t, files) | ||
| 59 | old, err := g.RevParse("refs/heads/main") | ||
| 60 | if err != nil { | ||
| 61 | t.Fatal(err) | ||
| 62 | } | ||
| 63 | if _, err := CommitFiles(g, "refs/heads/main", func(dst map[string][]byte) error { | ||
| 64 | for name := range files { | ||
| 65 | dst[name] = []byte("two\n") | ||
| 66 | } | ||
| 67 | return nil | ||
| 68 | }, "edit every awkward name", "test"); err != nil { | ||
| 69 | t.Fatal(err) | ||
| 70 | } | ||
| 71 | next, err := g.RevParse("refs/heads/main") | ||
| 72 | if err != nil { | ||
| 73 | t.Fatal(err) | ||
| 74 | } | ||
| 75 | status, err := g.DiffStatus(old, next) | ||
| 76 | if err != nil { | ||
| 77 | t.Fatal(err) | ||
| 78 | } | ||
| 79 | for name := range files { | ||
| 80 | if status[name] != "M" { | ||
| 81 | t.Errorf("DiffStatus[%q] = %q, want M (got %v)", name, status[name], status) | ||
| 82 | } | ||
| 83 | } | ||
| 84 | } | ||