interplane.Get Omega
Read in your language

interplane-forge

INTERPLANE Forge

Brought by drakestapleton

branch main Branches Tags History

interplane-forge / browse / c3_blame.om

396 lines · 6892 bytes Raw Blame History
1note browse/c3_blame.om: /blame/<ref>/<path> from git blame --porcelain, and the in-repo code
2note search /search?q= (git grep, fixed string, case-insensitive, capped) (ForgeBrowse).
3global gbbk ulong 4096
4global gbba ulong 4096
5global gbbal ulong 4096
6global gbbt ulong 4096
7global gbbs ulong 4096
8global gbbsl ulong 4096
9global gbbo ulong 4096
10global gbbn ulong 1
11global gbbc ulong 1
12global gbbp ulong 1
13global gbq uchar 256
14global gbql ulong 1
15const BRBLMX ulong 4096
16const BRHITS ulong 200
17text tbporc "--porcelain"
18text tbkauth "author "
19text tbkatim "author-time "
20text tbksumm "summary "
21text tbtblm "Blame"
22text tbtsrch "Search"
23text tbbl1 "<table class=\"code blame\"><tbody>\n"
24text tbbl2 "\"><td class=\"bl\">"
25text tbbl3 "</td><td class=\"ln\"><a href=\"#L"
26text tbbl4 "<a class=\"mono\" href=\""
27text tbbl5 "</a> <span class=\"meta\">"
28text tbbl6 "</span> "
29text tbbl7 "<tr class=\"bs\" id=\"L"
30text tbblcut "<p class=\"muted\">Blame output was cut.</p>\n"
31text tbgrep "grep"
32text tbgz "-z"
33text tbgn "-n"
34text tbgi "-I"
35text tbgii "-i"
36text tbgf "-F"
37text tbgmc "--max-count=5"
38text tbge "-e"
39text tbsf1 "<h2>Search</h2>\n<form class=\"inline\" method=\"get\" action=\""
40text tbsf2 "/search\"><input type=\"search\" name=\"q\" maxlength=\"256\" value=\""
41text tbsf3 "\" aria-label=\"Search this repository\"> <button type=\"submit\">Search</button></form>\n"
42text tbsf4 "<p class=\"meta\">Fixed-string, case-insensitive search of the default branch <code>"
43text tbsf5 "</code>; at most 5 lines per file and 200 lines in total.</p>\n"
44text tbsh1 "<div class=\"box\"><p><a href=\""
45text tbsh2 "</a></p>\n"
46text tbsh3 "<p class=\"hit\"><a class=\"mono\" href=\""
47text tbsh4 "</a> <code>"
48text tbsh5 "</code></p>\n"
49text tbsnone "<p class=\"muted\">No matches.</p>\n"
50text tbsmore "<p class=\"muted\">Only the first 200 matching lines are shown.</p>\n"
51text tbsbad "<p class=\"err\">The search text may not contain control characters.</p>\n"
52text tbq1 "q"
53note ---- blame
54fn brblamepg to long
55if not brres
56ret brerr 404
57end
58if eq get gbpl 0 0
59ret brerr 404
60end
61k = brotype
62if eq k 0
63ret brerr 404
64end
65if eq k 1
66brloc tbtree
67ret 302
68end
69fksource
70fka tbblame
71fka tbporc
72fkopen
73brksha
74fka tbdd
75fkopen
76brkp
77st = fexec BRTMO
78if ne st 0
79ret brerr 404
80end
81brti tbtblm
82frepohd 0
83brrefbar
84brcrumb
85brblame
86ret 200
87end
88note brbkey: the first 16 hex of the sha at fxo[a] as a number
89fn brbkey a ulong to ulong
90v = ulong 0
91for i ulong 16
92v = add shl v 4 brhexv get fxo add a i
93end
94ret v
95end
96fn brbfind key ulong to ulong
97n = get gbbn 0
98for i ulong n bound 4096
99if eq get gbbk i key
100ret i
101end
102end
103ret n
104end
105note brbishdr: fxo[s, e) starts with 40 lowercase hex and a space
106fn brbishdr s ulong e ulong to bool
107if lt sub e s 41
108ret false
109end
110for i ulong 40
111if not brlhex get fxo add s i
112ret false
113end
114end
115ret eq get fxo add s 40 32
116end
117note brblame: walk the porcelain: header "<sha> <orig> <final>[ <n>]", key lines, then "\t<line>"
118fn brblame to void
119put gbbn 0 0
120put gbbc 0 0
121put gbbp 0 0
122n = get fxol 0
123cur = ulong 0
124ln = ulong 0
125fput tbbl1
126s = ulong 0
127while lt s n bound BRBIG
128e = brxfind s n 10
129c = uchar 10
130if lt s e
131c = get fxo s
132end
133if eq c 9
134brbline cur ln add s 1 e
135end
136if brbishdr s e
137cur = brbhdr s e
138ln = brbfin s e
139else
140if ne c 9
141brbkv cur s e
142end
143end
144s = add e 1
145end
146fput tbtab2
147if ne get fxotr 0 0
148fput tbblcut
149end
150end
151note brbhdr: the table index for the header's sha (a new entry when unseen; BRBLMX when full)
152fn brbhdr s ulong e ulong to ulong
153key = brbkey s
154i = brbfind key
155n = get gbbn 0
156if lt i n
157ret i
158end
159if ge n BRBLMX
160ret BRBLMX
161end
162put gbbk n key
163put gbbo n s
164put gbbal n 0
165put gbbsl n 0
166put gbbt n 0
167put gbbn 0 add n 1
168ret n
169end
170note brbfin: the final line number (third field of the header)
171fn brbfin s ulong e ulong to ulong
172a = brxfind add s 41 e 32
173ret brxdec add a 1 e
174end
175fn brbkv cur ulong s ulong e ulong to void
176if ge cur BRBLMX
177ret
178end
179if brxat s e tbkatim
180put gbbt cur brxdec add s len tbkatim e
181ret
182end
183if brxat s e tbkauth
184put gbba cur add s len tbkauth
185put gbbal cur sub e add s len tbkauth
186ret
187end
188if brxat s e tbksumm
189put gbbs cur add s len tbksumm
190put gbbsl cur sub e add s len tbksumm
191end
192end
193note brbline: one content row; the first row of each run of one commit carries its info
194fn brbline cur ulong ln ulong a ulong e ulong to void
195key = ulong 0
196if lt cur BRBLMX
197key = get gbbk cur
198end
199first = or ne key get gbbp 0 eq get gbbc 0 0
200put gbbp 0 key
201put gbbc 0 add get gbbc 0 1
202if first
203fput tbbl7
204else
205fput tbcd2
206end
207fnum ln
208fput tbbl2
209if and first lt cur BRBLMX
210brbcinfo cur
211end
212fput tbbl3
213fnum ln
214fput tbaq
215fnum ln
216fput tbcd4
217fxesc a sub e a
218fput tbcd5
219end
220fn brbcinfo cur ulong to void
221o = get gbbo cur
222fput tbbl4
223brucmt o 40
224fput tbaq
225fxput o 7
226fput tbbl5
227brdate get gbbt cur
228fput tbbl6
229fxesc get gbba cur get gbbal cur
230fputc 58
231fputc 32
232m = get gbbsl cur
233if gt m 80
234m = 80
235end
236fxesc get gbbs cur m
237end
238note ---- /search?q=
239fn brsrchpg to long
240if gt get gbrl 0 0
241ret brerr 404
242end
243q = fqget tbq1
244put gbql 0 0
245bad = false
246if gt q 256
247ret brerr 400
248end
249if gt q 0
250bad = not brsq ulong q
251end
252brdefref
253if not brres
254ret brerr 404
255end
256brti tbtsrch
257frepohd 0
258brsform
259if bad
260fput tbsbad
261ret 400
262end
263if gt get gbql 0 0
264brsrun
265end
266ret 200
267end
268note brsq: copy fval[0, n) into gbq; false on a control byte
269fn brsq n ulong to bool
270for i ulong n bound 256
271c = get fval i
272if or lt c 32 eq c 127
273put gbql 0 0
274ret false
275end
276put gbq i c
277end
278put gbql 0 n
279ret true
280end
281fn brsform to void
282fput tbsf1
283brurepo
284fput tbsf2
285for i ulong get gbql 0
286fescc get gbq i
287end
288fput tbsf3
289fput tbsf4
290brrefesc
291fput tbsf5
292end
293fn brsrun to void
294fksource
295fka tbgrep
296fka tbgz
297fka tbgn
298fka tbgi
299fka tbgii
300fka tbgf
301fka tbnocol
302fka tbgmc
303fka tbge
304fkopen
305for i ulong get gbql 0
306fkc get gbq i
307end
308fkopen
309brksha
310st = fexec BRTMO
311n = get fxol 0
312if or ne st 0 eq n 0
313fput tbsnone
314ret
315end
316brshits n
317end
318note brshits: lines "<sha>:<path>\0<line>\0<text>", grouped by file
319fn brshits n ulong to void
320s = ulong 0
321c = ulong 0
322pa = ulong 0
323pl = ulong 0
324while lt s n bound BRBIG
325e = brxfind s n 10
326a = add s 41
327z = brxfind a e 0
328if and lt a z lt z e
329if not brxsame pa pl a sub z a
330if gt pl 0
331fput tbdive
332end
333brshead a sub z a
334pa = a
335pl = sub z a
336end
337brshit a sub z a add z 1 e
338c = add c 1
339end
340if ge c BRHITS
341if lt add e 1 n
342fput tbdive
343fput tbsmore
344ret
345end
346end
347s = add e 1
348end
349if gt pl 0
350fput tbdive
351end
352end
353fn brxsame a ulong l ulong b ulong m ulong to bool
354if ne l m
355ret false
356end
357for i ulong l bound BRBIG
358if ne get fxo add a i get fxo add b i
359ret false
360end
361end
362ret true
363end
364fn brsblob a ulong l ulong to void
365bruact tbblob
366fputc 47
367bruxo a l
368end
369fn brshead a ulong l ulong to void
370fput tbsh1
371brsblob a l
372fput tbaq
373fxesc a l
374fput tbsh2
375end
376fn brshit a ulong l ulong b ulong e ulong to void
377y = brxfind b e 0
378fput tbsh3
379brsblob a l
380fputc 35
381fputc 76
382fxput b sub y b
383fput tbaq
384fxput b sub y b
385fput tbsh4
386t = add y 1
387m = ulong 0
388if lt t e
389m = sub e t
390end
391if gt m 300
392m = 300
393end
394fxesc t m
395fput tbsh5
396end