interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / apps / interplane-forge / browse / c2_hist.om

1210 lines · 20389 bytes Raw Blame History
1note browse/c2_hist.om: /commits, /commit/<sha>[.patch|.diff], the diff renderer, /branches,
2note /tags and /compare (ForgeBrowse).
3global gbdo ulong 1
4global gbdn ulong 1
5global gbdi ulong 1
6global gbdt ulong 1
7global gbdh ulong 1
8global gbdc ulong 1
9global gbca uchar 256
10global gbcal ulong 1
11global gbcb uchar 256
12global gbcbl ulong 1
13global gbdef uchar 256
14global gbdefl ulong 1
15note /branches and /tags pages (brrefs): 0 rows read, 1 rows of this page written, 2 mode (0 HTML
16note branches, 1 HTML tags, 2 JSON branches, 3 JSON tags), 3 page, 4 JSON rows written
17global gbrpg ulong 8
18const BRPG ulong 2000
19text tbpgof "<p class=\"meta\">Rows "
20text tbpgto " to "
21text tbpgof2 " of "
22text tbpgdot ".</p>\n"
23const BRDMAX ulong 4194304
24const BRDLN ulong 30000
25text tbshow "show"
26text tbsfmt "-s"
27text tbfmtk "--format=%H%x1f%P%x1f%an%x1f%at%x1f%cn%x1f%ct%x1f%B"
28text tbfmt0 "--format="
29text tbnums "--numstat"
30text tbpp "-p"
31text tbmm "-M"
32text tbnocol "--no-color"
33text tbnoext "--no-ext-diff"
34text tbdmfp "--diff-merges=first-parent"
35text tbdiff "diff"
36text tbfmtp "format-patch"
37text tbstdo "--stdout"
38text tbx1 "-1"
39text tbn31 "31"
40text tbn251 "251"
41text tbsort "--sort=-committerdate"
42text tbsortt "--sort=-creatordate"
43text tbfmtb "--format=%(refname)%1f%(objectname)%1f%(committerdate:unix)%1f%(contents:subject)"
44text tbfmtt "--format=%(refname)%1f%(objectname)%1f%(*objectname)%1f%(creatordate:unix)%1f%(contents:subject)"
45text tbdgit "diff --git "
46text tbdat "@@"
47text tbdb " b/"
48text tbdnew "new file mode"
49text tbddel "deleted file mode"
50text tbdrf "rename from"
51text tbdrt "rename to"
52text tbdbin "Binary files"
53text tbdmd "old mode"
54text tbdmn "new mode"
55text tbxpatch ".patch"
56text tbxdiff ".diff"
57text tbtcmts "Commits"
58text tbtcmt "Commit"
59text tbtbr "Branches"
60text tbttag "Tags"
61text tbtcmp "Compare"
62text tbch1 "<h2>Commits on <code>"
63text tbch2 "</code>"
64text tbch3 " for <code>"
65text tbul1 "<ul class=\"commits\">\n"
66text tbul2 "</ul>\n"
67text tbli1 "<li><a href=\""
68text tbli2 "</a><p class=\"meta\"><a class=\"mono\" href=\""
69text tbli3 "</a> &#183; "
70text tbli4 " &#183; "
71text tbli5 " &#183; <a href=\""
72text tbli6 "\">Browse</a></p></li>\n"
73text tbnone "<p class=\"muted\">No commits.</p>\n"
74text tbpg1 "<p class=\"pager\">"
75text tbpg2 "?page="
76text tbpgn "\">Newer</a> "
77text tbpgo "\">Older</a>"
78text tbcm1 "<div class=\"box commit\"><h2>"
79text tbcm2 "<pre class=\"msg\">"
80text tbcm3 "</pre>\n"
81text tbcm4 "<p class=\"meta\">"
82text tbcm5 " authored "
83text tbcm6 " &#183; "
84text tbcm7 " committed "
85text tbcm8 "<p class=\"meta\">commit <span class=\"mono\">"
86text tbcm9 "</span> &#183; parent "
87text tbcm10 " &#183; <a href=\""
88text tbcm11 "\">Browse files</a> &#183; <a href=\""
89text tbcm12 ".patch\">Patch</a> &#183; <a href=\""
90text tbcm13 ".diff\">Diff</a></p></div>\n"
91text tbcmnp "none"
92text tbst1 "<p class=\"stat\">"
93text tbst2 " files changed, <span class=\"ok\">+"
94text tbst3 "</span> <span class=\"bad\">-"
95text tbst4 "</span></p>\n<table class=\"stat\"><tbody>\n"
96text tbst5 "<tr><td><a href=\"#d"
97text tbst6 "</a></td><td class=\"ok\">+"
98text tbst7 "</td><td class=\"bad\">-"
99text tbst8 "</td></tr>\n"
100text tbst9 "</td><td class=\"muted\">binary</td><td></td></tr>\n"
101text tbdf1 "<div class=\"df\" id=\"d"
102text tbdf2 "\"><p class=\"dfh mono\">"
103text tbdf3 "</p>\n<table class=\"diff\"><tbody>\n"
104text tbdf4 "</tbody></table></div>\n"
105text tbdr1 "<tr class=\""
106text tbdr2 "\"><td class=\"ln\">"
107text tbdr3 "</td><td class=\"ln\">"
108text tbdr4 "</td><td class=\"dc\">"
109text tbdr5 "</td></tr>\n"
110text tbcda "da"
111text tbcdd "dd"
112text tbcdx "dx"
113text tbcdh "dh"
114text tbcdm "dm"
115text tbdcut "<p class=\"muted\">The diff is too large to show in full here; it was cut.</p>\n"
116text tbbr1 "<h2>Branches</h2>\n<table class=\"refs\"><tbody>\n"
117text tbtg1 "<h2>Tags</h2>\n<table class=\"refs\"><tbody>\n"
118text tbrr1 "<tr><td><a href=\""
119text tbrr2 "</a>"
120text tbrdef " <span class=\"badge\">default</span>"
121text tbrr3 "</td><td class=\"meta\">"
122text tbrr4 "</td><td><a class=\"mono\" href=\""
123text tbrr5 "</a> "
124text tbrr6 "</td><td><a href=\""
125text tbrr7 ".zip\">zip</a> <a href=\""
126text tbrr8 ".tar.gz\">tar.gz</a>"
127text tbrr9 "</td></tr>\n"
128text tbrrel " <a href=\""
129text tbrrel2 "\">release</a>"
130text tbarch "/archive/refs/heads/"
131text tbarcht "/archive/refs/tags/"
132text tbreltg "/releases/tag/"
133text tbnobr "<p class=\"muted\">No branches.</p>\n"
134text tbnotg "<p class=\"muted\">No tags.</p>\n"
135text tbcf1 "<h2>Compare</h2>\n<form class=\"inline\" method=\"get\" action=\""
136text tbcf2 "/compare\"><label>base <input name=\"a\" maxlength=\"200\" required></label> <label>head <input name=\"b\" maxlength=\"200\" required></label> <button type=\"submit\">Compare</button></form>\n<p class=\"muted\">Branch or tag names, or commit ids. The page shows what head has that base does not.</p>\n"
137text tbcp1 "<h2>Comparing <code>"
138text tbcp2 "</code> ... <code>"
139text tbcp3 "</code></h2>\n"
140text tbcpno "<p class=\"muted\">Head has no commits that base does not have.</p>\n"
141text tbcpcut "<p class=\"muted\">Showing the newest 250 commits.</p>\n"
142text tbdots "..."
143text tbdots2 ".."
144text tbqa "a"
145text tbqb "b"
146text tbcmpw "compare"
147note ---- argv helpers
148fn brkdiff to void
149fka tbmm
150fka tbnocol
151fka tbnoext
152end
153note brkcs: argument "<gbsa><sep><gbsha>" (sep ".." or "...")
154fn brkcs t view uchar * to void
155fkopen
156for i ulong 40
157fkc get gbsa i
158end
159fkt t
160brksha
161end
162note ---- commit list rows (log --format=%H%x1f%an%x1f%at%x1f%s, one per line)
163fn brcrow a ulong e ulong to void
164k = brsplit a e 31
165if lt k 4
166ret
167end
168fput tbli1
169brucmt brfa 0 brfl 0
170fput tbaq
171brfesc 3
172if eq brfl 3 0
173fxput brfa 0 7
174end
175fput tbli2
176brucmt brfa 0 brfl 0
177fput tbaq
178fxput brfa 0 7
179fput tbli3
180brfesc 1
181fput tbli4
182t = brxdec brfa 2 add brfa 2 brfl 2
183brdate t
184fputc 32
185brtime t
186fput tbli5
187brurepo
188fputc 47
189fput tbtree
190fputc 47
191brfurl 0
192fput tbli6
193end
194note brcrows: up to m rows from fxo; returns the number of lines seen
195fn brcrows m ulong to ulong
196n = get fxol 0
197s = ulong 0
198c = ulong 0
199fput tbul1
200while lt s n bound BRBIG
201e = brxfind s n 10
202if gt e s
203if lt c m
204brcrow s e
205end
206c = add c 1
207end
208s = add e 1
209end
210fput tbul2
211ret c
212end
213note ---- /commits[/<ref>[/<path>]]
214fn brpgnum to ulong
215r = fqget tbpage
216if lt r 1
217ret 1
218end
219v = ulong 0
220for i ulong ulong r bound 4096
221c = get fval i
222if not brdig c
223ret 1
224end
225if lt v 100000
226v = add mul v 10 ulong sub c 48
227end
228end
229if or eq v 0 gt v 100000
230ret 1
231end
232ret v
233end
234fn brcmtspg to long
235if eq get gbrl 0 0
236brdefref
237end
238if not brres
239ret brerr 404
240end
241p = brpgnum
242put gbpg 0 p
243fksource
244fka tblog
245fka tbfmtc
246fka tbn1
247fka tbn31
248fkopen
249fkt tbskip
250brknum mul sub p 1 30
251fkopen
252brksha
253if gt get gbpl 0 0
254fka tbdd
255fkopen
256brkp
257end
258st = fexec BRTMO
259if ne st 0
260ret brerr 404
261end
262note 31 log lines longer than fxo: rows past the cut would be missing and the pager would say there is
263note no older page. The whole 500 of fincut.
264if ne get fxotr 0 0
265fincut
266ret brerr 404
267end
268brti tbtcmts
269frepohd 1
270fput tbch1
271brrefesc
272fput tbch2
273if gt get gbpl 0 0
274fput tbch3
275brgesc 0 get gbpl 0
276fput tbch2
277end
278fput tbh2e
279c = brcrows 30
280if eq c 0
281fput tbnone
282end
283brpager c
284ret 200
285end
286fn brpager c ulong to void
287p = get gbpg 0
288if and le p 1 lt c 31
289ret
290end
291fput tbpg1
292if gt p 1
293fput tbah
294bruactp tbcmts get gbpl 0
295fput tbpg2
296fnum sub p 1
297fput tbpgn
298end
299if ge c 31
300fput tbah
301bruactp tbcmts get gbpl 0
302fput tbpg2
303fnum add p 1
304fput tbpgo
305end
306fput tbpe
307end
308note ---- /commit/<sha>[.patch|.diff]
309note brsuffix: gbr ends with t; drop it and return true
310fn brsuffix t view uchar * to bool
311n = get gbrl 0
312k = len t
313if le n k
314ret false
315end
316a = sub n k
317for i ulong k
318if ne get gbr add a i get t i
319ret false
320end
321end
322put gbrl 0 a
323ret true
324end
325fn brcmtpg to long
326mode = ulong 0
327if brsuffix tbxpatch
328mode = 1
329end
330if eq mode 0
331if brsuffix tbxdiff
332mode = 2
333end
334end
335if not brres
336ret brerr 404
337end
338if gt get gbpl 0 0
339ret brerr 404
340end
341if gt mode 0
342ret brcmtraw mode
343end
344if not brcmthd
345ret brerr 404
346end
347brcmtstat
348brcmtdiff
349ret 200
350end
351note brcmtraw: the commit as an mbox patch (1) or a plain diff (2), text/plain
352fn brcmtraw mode ulong to long
353brcmtargs mode
354st = fexec BRTMO
355n = get fxol 0
356if ne st 0
357ret brerr 404
358end
359put fobl 0 0
360fsetct tbctxt
361if or gt n len fob ne get fxotr 0 0
362brcmtargs mode
363put fkind 0 4
364ret 200
365end
366put fkind 0 1
367fxput 0 n
368ret 200
369end
370note brcmtargs: argv in fpk of git format-patch (mode 1) or git show -p (mode 2) of commit gbsha.
371note brcmtraw runs it; output larger than the capture runs again, streamed by the server (kind 4)
372fn brcmtargs mode ulong to void
373fksource
374if eq mode 1
375fka tbfmtp
376fka tbstdo
377fka tbx1
378fka tbnocol
379else
380fka tbshow
381fka tbfmt0
382fka tbpp
383fka tbdmfp
384brkdiff
385end
386fkopen
387brksha
388end
389note brcmthd: the commit header box; false when git show fails
390fn brcmthd to bool
391fksource
392fka tbshow
393fka tbsfmt
394fka tbfmtk
395fkopen
396brksha
397st = fexec BRTMO
398n = get fxol 0
399if or ne st 0 eq n 0
400ret false
401end
402k = brsplit 0 n 31
403if lt k 7
404ret false
405end
406fsetti tbtcmt
407ftic 32
408for i ulong 7
409ftic get gbsha i
410end
411ftic 32
412ftic 45
413ftic 32
414ftirepo
415frepohd 1
416brcmtmsg
417brcmtwho
418brcmtids
419ret true
420end
421note brcmtmsg: subject as h2, the rest of the message in pre
422fn brcmtmsg to void
423a = brfa 6
424e = add a brfl 6
425while gt e a bound BRBIG
426c = get fxo sub e 1
427if not brspc c
428break
429end
430e = sub e 1
431end
432s = brxfind a e 10
433fput tbcm1
434fxesc a sub s a
435fput tbh2e
436if lt s e
437b = add s 1
438while lt b e bound BRBIG
439if not brspc get fxo b
440break
441end
442b = add b 1
443end
444if lt b e
445fput tbcm2
446fxesc b sub e b
447fput tbcm3
448end
449end
450end
451fn brcmtwho to void
452fput tbcm4
453brfesc 2
454fput tbcm5
455t = brxdec brfa 3 add brfa 3 brfl 3
456brdate t
457fputc 32
458brtime t
459if brfne 2 4
460fput tbcm6
461brfesc 4
462fput tbcm7
463u = brxdec brfa 5 add brfa 5 brfl 5
464brdate u
465end
466fput tbpe
467end
468note brcmtids: sha, parents, browse / patch / diff links
469fn brcmtids to void
470fput tbcm8
471brfesc 0
472fput tbcm9
473a = brfa 1
474e = add a brfl 1
475if eq a e
476fput tbcmnp
477end
478note one pass per parent: a merge can have more than 64 (bound 64 was trap 4, exit 104, on such a commit)
479s = a
480while lt s e bound BRBIG
481x = brxfind s e 32
482if gt x s
483fput tbah
484brucmt s sub x s
485fput tbaq
486fxput s 7
487fput tbae
488fputc 32
489end
490s = add x 1
491end
492fput tbcm10
493brurepo
494fputc 47
495fput tbtree
496fputc 47
497brksh2
498fput tbcm11
499brucmt 0 0
500brksh2
501fput tbcm12
502brucmt 0 0
503brksh2
504fput tbcm13
505end
506note brksh2: write gbsha into fob (40 hex, URL-safe)
507fn brksh2 to void
508for i ulong 40
509fputc get gbsha i
510end
511end
512fn brcmtstat to void
513fksource
514fka tbshow
515fka tbfmt0
516fka tbnums
517fka tbmm
518fka tbdmfp
519fkopen
520brksha
521st = fexec BRTMO
522if eq st 0
523brstat
524end
525end
526fn brcmtdiff to void
527fksource
528fka tbshow
529fka tbfmt0
530fka tbpp
531fka tbdmfp
532brkdiff
533fkopen
534brksha
535st = fexec BRTMO
536if eq st 0
537brdiff
538end
539end
540note ---- numstat table: "<add>\t<del>\t<path>" per line ("-\t-\t" for binaries)
541fn brstat to void
542n = get fxol 0
543fls = ulong 0
544ad = ulong 0
545de = ulong 0
546s = ulong 0
547while lt s n bound BRBIG
548e = brxfind s n 10
549if gt e s
550fls = add fls 1
551ad = add ad brxdec s e
552t = brxfind s e 9
553de = add de brxdec add t 1 e
554end
555s = add e 1
556end
557fput tbst1
558fnum fls
559fput tbst2
560fnum ad
561fput tbst3
562fnum de
563fput tbst4
564brstrows n
565fput tbtab2
566end
567fn brstrows n ulong to void
568s = ulong 0
569i = ulong 1
570while lt s n bound BRBIG
571e = brxfind s n 10
572if gt e s
573brstrow s e i
574i = add i 1
575end
576if gt i 3000
577ret
578end
579s = add e 1
580end
581end
582fn brstrow s ulong e ulong i ulong to void
583k = brsplit s e 9
584if lt k 3
585ret
586end
587fput tbst5
588fnum i
589fput tbaq
590fxesc brfa 2 sub e brfa 2
591if eq get fxo s 45
592fput tbst9
593ret
594end
595fput tbst6
596fxput brfa 0 brfl 0
597fput tbst7
598fxput brfa 1 brfl 1
599fput tbst8
600end
601note ---- unified diff renderer over fxo
602fn brdiff to void
603n = get fxol 0
604put gbdi 0 0
605put gbdt 0 0
606put gbdh 0 0
607put gbdc 0 0
608s = ulong 0
609while lt s n bound BRBIG
610e = brxfind s n 10
611brdline s e
612s = add e 1
613if or gt s BRDMAX gt get gbdc 0 BRDLN
614if lt s n
615brdclose
616fput tbdcut
617ret
618end
619end
620end
621brdclose
622if ne get fxotr 0 0
623fput tbdcut
624end
625end
626fn brdclose to void
627if ne get gbdt 0 0
628fput tbdf4
629put gbdt 0 0
630end
631end
632fn brdline s ulong e ulong to void
633if brxat s e tbdgit
634brdfile s e
635ret
636end
637if brxat s e tbdat
638brdhunk s e
639ret
640end
641if eq get gbdt 0 0
642ret
643end
644if eq s e
645ret
646end
647c = get fxo s
648if ne get gbdh 0 0
649brdbody s e c
650ret
651end
652brdmeta s e
653end
654fn brdbody s ulong e ulong c uchar to void
655o = get gbdo 0
656m = get gbdn 0
657if eq c 43
658brdrow tbcda 0 m s e
659put gbdn 0 add m 1
660ret
661end
662if eq c 45
663brdrow tbcdd o 0 s e
664put gbdo 0 add o 1
665ret
666end
667if eq c 32
668brdrow tbcdx o m s e
669put gbdo 0 add o 1
670put gbdn 0 add m 1
671ret
672end
673brdrow tbcdm 0 0 s e
674end
675fn brdmeta s ulong e ulong to void
676ok = or brxat s e tbdnew brxat s e tbddel
677if or brxat s e tbdrf brxat s e tbdrt
678ok = true
679end
680if or brxat s e tbdbin or brxat s e tbdmd brxat s e tbdmn
681ok = true
682end
683if ok
684brdrow tbcdm 0 0 s e
685end
686end
687note brdrow: one diff row; 0 line numbers print empty
688fn brdrow cl view uchar * o ulong m ulong s ulong e ulong to void
689put gbdc 0 add get gbdc 0 1
690fput tbdr1
691fput cl
692fput tbdr2
693if gt o 0
694fnum o
695end
696fput tbdr3
697if gt m 0
698fnum m
699end
700fput tbdr4
701fxesc s sub e s
702fput tbdr5
703end
704note brdfile: "diff --git a/<p> b/<p>" opens a file table titled by the text after the last " b/"
705fn brdfile s ulong e ulong to void
706brdclose
707i = add get gbdi 0 1
708put gbdi 0 i
709put gbdt 0 1
710put gbdh 0 0
711a = add s len tbdgit
712k = e
713while gt k a bound BRBIG
714if brxat sub k 1 e tbdb
715break
716end
717k = sub k 1
718end
719p = a
720if gt k a
721p = add k 2
722end
723fput tbdf1
724fnum i
725fput tbdf2
726fxesc p sub e p
727fput tbdf3
728end
729note brdhunk: "@@ -o[,n] +m[,k] @@ ..."
730fn brdhunk s ulong e ulong to void
731if eq get gbdt 0 0
732ret
733end
734put gbdh 0 1
735a = brxfind s e 45
736put gbdo 0 brxdec add a 1 e
737b = brxfind a e 43
738put gbdn 0 brxdec add b 1 e
739brdrow tbcdh 0 0 s e
740end
741note ---- /branches and /tags
742fn brdefsave to void
743brdefref
744n = get gbrl 0
745if gt n 256
746n = 256
747end
748for i ulong n
749put gbdef i get gbr i
750end
751put gbdefl 0 n
752end
753note brrefs tg md p: for-each-ref over refs/heads (tg false) or refs/tags (tg true) at the root, else
754note the delegate namespace's, read one line at a time through fxo (fsnext), so no length of the list
755note cuts it. Rows (p - 1) * BRPG .. p * BRPG - 1 go to brrow1 in mode md; gbrpg 0 counts every row,
756note so the pager knows the total. false: git failed, or one line was longer than fxo (fincut).
757fn brrefs tg bool md ulong p ulong to bool
758for i ulong 8
759put gbrpg i 0
760end
761put gbrpg 2 md
762put gbrpg 3 p
763brkref tg
764if tg
765fka tbrt
766else
767fka tbrh
768end
769if not brrefs1
770ret false
771end
772if gt get gbrpg 0 0
773ret true
774end
775brkref tg
776if tg
777brkns tbnsrt
778else
779brkns tbnsrh
780end
781ret brrefs1
782end
783fn brrefs1 to bool
784if not fsopen BRTMO
785ret false
786end
787for it ulong 1000000000
788e = fsnext 10
789if or eq e FSEND eq e FSFAIL
790break
791end
792s = get fsrs 0
793if gt e s
794brrow1 s e
795end
796end
797st = fsclose
798if ne get fxotr 0 0
799fincut
800ret false
801end
802ret eq st 0
803end
804note brrow1 s e: one listed line; written only when it is on the requested page
805fn brrow1 s ulong e ulong to void
806c = get gbrpg 0
807put gbrpg 0 add c 1
808a = mul sub get gbrpg 3 1 BRPG
809if or lt c a ge c add a BRPG
810ret
811end
812w = get gbrpg 1
813put gbrpg 1 add w 1
814md = get gbrpg 2
815if eq md 0
816if eq w 0
817fput tbbr1
818end
819brbrrow s e
820ret
821end
822if eq md 1
823if eq w 0
824fput tbtg1
825end
826brtgrow s e
827ret
828end
829brzrow eq md 3 s e
830end
831note brmore: rows exist after page p
832fn brmore to bool
833ret gt get gbrpg 0 mul get gbrpg 3 BRPG
834end
835note brpgfoot: "Rows a to b of n." and the pager (?page=N, BRPG rows a page) under the table, only when the
836note list has more than one page: a list that fits one page is the same HTML as before paging (counts.sh)
837fn brpgfoot to void
838p = get gbrpg 3
839if and eq p 1 not brmore
840ret
841end
842a = add mul sub p 1 BRPG 1
843fput tbpgof
844fnum a
845fput tbpgto
846fnum sub add a get gbrpg 1 1
847fput tbpgof2
848fnum get gbrpg 0
849fput tbpgdot
850fput tbpg1
851if gt p 1
852fput tbah
853fput tbpg2
854fnum sub p 1
855fput tbpgn
856end
857if brmore
858fput tbah
859fput tbpg2
860fnum add p 1
861fput tbpgo
862end
863fput tbpe
864end
865fn brkref tg bool to void
866fksource
867fka tbfer
868if tg
869fka tbsortt
870fka tbfmtt
871else
872fka tbsort
873fka tbfmtb
874end
875end
876fn brbrpg to long
877if gt get gbrl 0 0
878ret brerr 404
879end
880brdefsave
881p = dlpageq
882brti tbtbr
883frepohd 2
884if not brrefs false 0 p
885ret brerr 404
886end
887if eq get gbrpg 0 0
888fput tbnobr
889ret 200
890end
891note a page past the last row is a 404, as on the releases pages
892if eq get gbrpg 1 0
893ret brerr 404
894end
895fput tbtab2
896brpgfoot
897ret 200
898end
899note brrsn: start of the short name in field 0 (after the refs prefix)
900fn brrsn to ulong
901a = brfa 0
902ret add a brpfx a add a brfl 0
903end
904fn brbrrow s ulong e ulong to void
905k = brsplit s e 31
906if lt k 4
907ret
908end
909a = brrsn
910l = sub add brfa 0 brfl 0 a
911fput tbrr1
912brurepo
913fputc 47
914fput tbtree
915fputc 47
916bruxo a l
917fput tbaq
918fxesc a l
919fput tbrr2
920if brisdef a l
921fput tbrdef
922end
923fput tbrr3
924brdate brxdec brfa 2 add brfa 2 brfl 2
925fput tbrr4
926brucmt brfa 1 brfl 1
927fput tbaq
928fxput brfa 1 7
929fput tbrr5
930brfesc 3
931fput tbrr6
932brarch tbarch a l
933fput tbrr9
934end
935fn brisdef a ulong l ulong to bool
936if ne l get gbdefl 0
937ret false
938end
939for i ulong l
940if ne get fxo add a i get gbdef i
941ret false
942end
943end
944ret true
945end
946note brarch: zip and tar.gz links <repo><p><name>.zip|.tar.gz (the downloads slice serves them)
947fn brarch p view uchar * a ulong l ulong to void
948brurepo
949fput p
950bruxo a l
951fput tbrr7
952brurepo
953fput p
954bruxo a l
955fput tbrr8
956end
957fn brtagpg to long
958if gt get gbrl 0 0
959ret brerr 404
960end
961p = dlpageq
962brti tbttag
963frepohd 3
964if not brrefs true 1 p
965ret brerr 404
966end
967if eq get gbrpg 0 0
968fput tbnotg
969ret 200
970end
971if eq get gbrpg 1 0
972ret brerr 404
973end
974fput tbtab2
975brpgfoot
976ret 200
977end
978note brtgrow: refname, object, *object (peeled commit of an annotated tag), date, subject
979fn brtgrow s ulong e ulong to void
980k = brsplit s e 31
981if lt k 5
982ret
983end
984a = brrsn
985l = sub add brfa 0 brfl 0 a
986fput tbrr1
987brurepo
988fputc 47
989fput tbtree
990fputc 47
991bruxo a l
992fput tbaq
993fxesc a l
994fput tbrr2
995fput tbrr3
996brdate brxdec brfa 3 add brfa 3 brfl 3
997fput tbrr4
998c = ulong 2
999if eq brfl 2 0
1000c = 1
1001end
1002brucmt brfa c brfl c
1003fput tbaq
1004fxput brfa c 7
1005fput tbrr5
1006brfesc 4
1007fput tbrr6
1008brarch tbarcht a l
1009fput tbrrel
1010brurepo
1011fput tbreltg
1012bruxo a l
1013fput tbrrel2
1014fput tbrr9
1015end
1016note ---- /compare and /compare/<a>...<b>
1017fn brcmppg to long
1018if eq get gbrl 0 0
1019ret brcmpform
1020end
1021if not brcmpsplit
1022ret brerr 404
1023end
1024if not brcmpres
1025ret brerr 404
1026end
1027brti tbtcmp
1028frepohd 1
1029fput tbcp1
1030for i ulong get gbcal 0
1031fescc get gbca i
1032end
1033fput tbcp2
1034for i ulong get gbcbl 0
1035fescc get gbcb i
1036end
1037fput tbcp3
1038brcmplog
1039brcmpdiff
1040ret 200
1041end
1042note brcmpform: a GET form; ?a=&b= redirects to /compare/<a>...<b>
1043fn brcmpform to long
1044la = fqget tbqa
1045if and gt la 0 le la 200
1046if brcmpq 0 la
1047lb = fqget tbqb
1048if and gt lb 0 le lb 200
1049if brcmpq 1 lb
1050brcmploc
1051ret 302
1052end
1053end
1054end
1055end
1056brti tbtcmp
1057frepohd 1
1058fput tbcf1
1059brurepo
1060fput tbcf2
1061ret 200
1062end
1063note brcmpq: copy fval[0, n) into gbca (w 0) or gbcb (w 1); refuse control bytes
1064fn brcmpq w ulong n long to bool
1065for i ulong ulong n bound 256
1066c = get fval i
1067if or lt c 33 eq c 127
1068ret false
1069end
1070if eq w 0
1071put gbca i c
1072else
1073put gbcb i c
1074end
1075end
1076if eq w 0
1077put gbcal 0 ulong n
1078else
1079put gbcbl 0 ulong n
1080end
1081ret true
1082end
1083fn brcmploc to void
1084put fkind 0 2
1085put fobl 0 0
1086flocb
1087for i ulong get fownl 0 bound 64
1088brlc get fown i
1089end
1090flocc 47
1091for i ulong get frepol 0 bound 128
1092brlc get frepo i
1093end
1094flocc 47
1095floct tbcmpw
1096flocc 47
1097for i ulong get gbcal 0
1098brlc get gbca i
1099end
1100floct tbdots
1101for i ulong get gbcbl 0
1102brlc get gbcb i
1103end
1104end
1105note brcmpsplit: gbr = "<a>...<b>" into gbca / gbcb
1106fn brdot3 k ulong to bool
1107if ne get gbr k 46
1108ret false
1109end
1110j = add k 1
1111if ne get gbr j 46
1112ret false
1113end
1114j = add k 2
1115ret eq get gbr j 46
1116end
1117fn brcmpsplit to bool
1118n = get gbrl 0
1119k = ulong 0
1120while lt add k 2 n bound BRBIG
1121if brdot3 k
1122break
1123end
1124k = add k 1
1125end
1126if or eq k 0 ge add k 3 n
1127ret false
1128end
1129m = sub n add k 3
1130if or gt k 200 gt m 200
1131ret false
1132end
1133for i ulong k
1134put gbca i get gbr i
1135end
1136put gbcal 0 k
1137for i ulong m
1138put gbcb i get gbr add add k 3 i
1139end
1140put gbcbl 0 m
1141ret true
1142end
1143note brcmpres: resolve a into gbsa, then b into gbsha / gbref; both must be bare refs
1144fn brcmpres to bool
1145n = get gbcal 0
1146for i ulong n
1147put gbr i get gbca i
1148end
1149put gbrl 0 n
1150if not brres
1151ret false
1152end
1153if gt get gbpl 0 0
1154ret false
1155end
1156for i ulong 40
1157put gbsa i get gbsha i
1158end
1159m = get gbcbl 0
1160for i ulong m
1161put gbr i get gbcb i
1162end
1163put gbrl 0 m
1164if not brres
1165ret false
1166end
1167ret eq get gbpl 0 0
1168end
1169fn brcmplog to void
1170fksource
1171fka tblog
1172fka tbfmtc
1173fka tbn1
1174fka tbn251
1175brkcs tbdots2
1176st = fexec BRTMO
1177if ne st 0
1178ret
1179end
1180c = brcrows 250
1181if eq c 0
1182fput tbcpno
1183end
1184if gt c 250
1185fput tbcpcut
1186end
1187end
1188fn brcmpdiff to void
1189fksource
1190fka tbdiff
1191fka tbnums
1192fka tbmm
1193brkcs tbdots
1194st = fexec BRTMO
1195if ne st 0
1196ret
1197end
1198if eq get fxol 0 0
1199ret
1200end
1201brstat
1202fksource
1203fka tbdiff
1204brkdiff
1205brkcs tbdots
1206st = fexec BRTMO
1207if eq st 0
1208brdiff
1209end
1210end