Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Clone

Read only, no credentials:

https://rodent.software/git/vole.git

Write over SSH with a registered key:

git clone ssh://git@0.0.0.0:2222/vole.git

A free and open-source forge that lives in your Git repo.

Read a change's file list without its patch, and never cut a diff

f64c77e4950c1759f336d3bc1849ead86e8b8ebf · Keenan Nemetz · 8d ago · parent 11720250

Read a change's file list without its patch, and never cut a diff

The review tree, the file count and the landing summary were all parsed out of
one `git diff` capped at 512 KiB. When a change carries a large file the cut
lands inside it, and every file named after the cut is missing from the tree:
reviewing #143, a 546 KB deletion hid the 296 files that came after it while
the tab still said "6 changed". The cap existed to stop a page rendering every
hunk, but the pages it guarded already render one file at a time.

The inventory and the patch are separate reads now. DiffInventory runs
`git diff --raw --numstat -z`, which names every file with its status and line
counts in one walk of the trees and generates no hunks; the changed-file tree,
the counts and the landing summary read that. The Files tab then asks for the
one file it shows with DiffPaths, and the commit page keeps its per-file
ShowPatchPath. Nothing is capped by bytes: a page is as large as the file it
shows, and the inventory is the whole change however large it is.

Compare still renders every file of a range at once, and is uncapped too, so a
large comparison is one large page. Making that per-file is the next step if it
turns out to matter.

TestDiffInventoryCountsEveryFile covers the statuses, counts, renames and binary
files the inventory has to report; TestRequestFilesListsEveryChangedFile is the
regression for the tree that lost its files, and the commit page test now
asserts the end of a large patch instead of its cut.

server/web/diff_test.go +4−3

@@ -169,10 +169,11 @@ index aaa..bbb 100644
169 169 }
170 170 }
171 171
172 func TestParseDiffToleratesATruncatedPatch(t *testing.T) {
172 func TestParseDiffToleratesAPatchThatEndsMidHunk(t *testing.T) {
173 173 t.Parallel()
174 // A cut patch ends mid-hunk: it must render what it has, not panic or claim
175 // the missing lines were unchanged.
174 // A patch can end mid-hunk, whether git was interrupted or a caller handed
175 // the parser an excerpt: it must render what it has, not panic or claim the
176 // missing lines were unchanged.
176 177 files := parseDiff(`diff --git a/big.txt b/big.txt
177 178 --- a/big.txt
178 179 +++ b/big.txt