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/templates/diff.html +2−2

@@ -5,13 +5,13 @@
5 5 needs no separate summary line above it; the total line is for the multi-file
6 6 diff a compare renders. */}}
7 7 {{define "diff"}}
8 {{if ne (len .Files) 1}}<div class="diffsum muted">{{len .Files}} file{{if ne (len .Files) 1}}s{{end}} changed{{if .Added}} · <span class="adds">+{{.Added}}</span>{{end}}{{if .Removed}} · <span class="dels">−{{.Removed}}</span>{{end}}{{if .Truncated}} · showing the first 512 KiB{{end}}</div>{{end}}
8 {{if ne (len .Files) 1}}<div class="diffsum muted">{{len .Files}} file{{if ne (len .Files) 1}}s{{end}} changed{{if .Added}} · <span class="adds">+{{.Added}}</span>{{end}}{{if .Removed}} · <span class="dels">−{{.Removed}}</span>{{end}}</div>{{end}}
9 9 {{range .Files}}
10 10 {{$file := .}}
11 11 <section class="diff"{{if .Language}} data-highlight="{{.Language}}"{{end}}>
12 12 <h3>
13 13 <span class="path">{{if and .OldPath (ne .OldPath .NewPath)}}{{.OldPath}} → {{end}}{{.Label}}</span>{{if .Binary}}<span class="label">binary</span>{{end}}
14 <span class="diffstat">{{if and $.Truncated (eq (len $.Files) 1)}}<span class="muted">showing the first 512 KiB</span>{{end}}{{if .Added}}<span class="adds">+{{.Added}}</span>{{end}}{{if .Removed}}<span class="dels">−{{.Removed}}</span>{{end}}</span>
14 <span class="diffstat">{{if .Added}}<span class="adds">+{{.Added}}</span>{{end}}{{if .Removed}}<span class="dels">−{{.Removed}}</span>{{end}}</span>
15 15 </h3>
16 16 {{if .Binary}}
17 17 <p class="binary">Binary file: no line diff to show. Use <code>git show</code> to inspect it.</p>