Artifactspublic-v0

curl

master
ply4 git calls167 ms289 KiB2 cachedprotocol v2
337 lines8.6 KiBexecutableRaw
1#!/usr/bin/env perl
2#***************************************************************************
3# _ _ ____ _
4# Project ___| | | | _ \| |
5# / __| | | | |_) | |
6# | (__| |_| | _ <| |___
7# \___|\___/|_| \_\_____|
8#
9# Copyright (C) Viktor Szakats
11# This software is licensed as described in the file COPYING, which
12# you should have received as part of this distribution. The terms
13# are also available at https://curl.se/docs/copyright.html.
15# You may opt to use, copy, modify, merge, publish, distribute and/or sell
16# copies of the Software, and permit persons to whom the Software is
17# furnished to do so, under the terms of the COPYING file.
19# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20# KIND, either express or implied.
22# SPDX-License-Identifier: curl
24###########################################################################
26use strict;
27use warnings;
29use File::Basename;
31my @executable = (
32 '\.(pl|py|sh)$',
33 '^\.github/scripts/',
34 '^scripts/',
35);
37my @is_executable = (
38 '\.pl$',
39);
41my @tabs = (
42 '^m4/zz40-xc-ovr\.m4$',
43 'Makefile\.(am|example)$',
44 '\.sln$',
45 '^tests/data/data1706-stdout\.txt',
46 '^tests/data/test',
47);
49my @need_crlf = (
50 '\.(bat|sln)$',
51);
53my @double_empty_lines = (
54 '^RELEASE-NOTES$',
55 '^lib/.+\.(c|h)$',
56 '^projects/OS400/',
57 '^projects/vms/',
58 '^tests/data/test',
59 '\.(m4|py)$',
60);
62my @longline = (
63 '^\.github/renovate\.json$',
64 '^\.github/workflows/windows\.yml$',
65 '^docs/DISTROS\.md$',
66 '^projects/Windows/tmpl/.+\.vcxproj$',
67 '^tests/data/test',
68);
70my @non_ascii_allowed = (
71 '\xC3\xB6', # UTF-8 for U+00F6 LATIN SMALL LETTER O WITH DIAERESIS
72);
74my $non_ascii_allowed = join(', ', @non_ascii_allowed);
76my @non_ascii = (
77 '^\.github/scripts/pyspelling\.words$',
78 '^\.mailmap$',
79 '^RELEASE-NOTES$',
80 '^docs/BINDINGS\.md$',
81 '^docs/THANKS$',
82 '^docs/THANKS-filter$',
83);
85sub fn_match {
86 my ($filename, @masklist) = @_;
88 foreach my $mask (@masklist) {
89 if($filename =~ $mask) {
90 return 1;
91 }
92 }
93 return 0;
96sub eol_detect {
97 my ($cr, $lf) = @_;
99 if($cr > 0 && $lf == 0) {
100 return 'cr';
101 }
102 elsif($cr == 0 && $lf > 0) {
103 return 'lf';
104 }
105 elsif($cr == 0 && $lf == 0) {
106 return 'bin';
107 }
108 elsif($cr == $lf) {
109 return 'crlf';
110 }
112 return '';
115my $max_repeat_space = 79;
116my $max_line_len = 192;
117my $max_lines = 10000;
118my $max_path_len = 64;
119my $max_filename_len = 48;
121my $issues = 0;
123open(my $git_ls_files, '-|', 'git', 'ls-files') or die "Failed running git ls-files: $!";
124while(my $filename = <$git_ls_files>) {
125 chomp $filename;
127 my @err = ();
129 if(!fn_match($filename, @executable)) {
130 my $mode = (stat($filename))[2];
131 if($mode & 0111) {
132 push @err, sprintf('file has executable bit(s) set: %o', $mode);
133 }
134 }
136 if(fn_match($filename, @is_executable)) {
137 my $mode = (stat($filename))[2];
138 if(($mode & 0100) != 0100) {
139 push @err, sprintf('executable file missing executable bit: %o', $mode);
140 }
141 }
143 if(length($filename) > $max_path_len) {
144 push @err, sprintf('long (%d > %d) path', length($filename), $max_path_len);
145 }
147 my $bn = basename($filename);
148 if(length($bn) > $max_filename_len) {
149 push @err, sprintf('long (%d > %d) filename', length($bn), $max_filename_len);
150 }
152 if($filename !~ /^[A-Za-z0-9\/._-]+$/) {
153 push @err, sprintf("filename contains character(s) outside [A-Za-z0-9/._-]");
154 }
156 open(my $fh, '<', $filename) or die "Cannot open '$filename': $!";
157 my $content = do { local $/; <$fh> };
158 close $fh;
160 if(!fn_match($filename, @tabs) &&
161 $content =~ /\t/) {
162 push @err, 'content: has tab';
163 }
165 my $cnt_cr = () = $content =~ /\r/g;
166 my $cnt_lf = () = $content =~ /\n/g;
168 my $eol = eol_detect($cnt_cr, $cnt_lf);
170 if($eol eq '') {
171 push @err, 'content: has mixed EOL types';
172 }
174 if($eol ne 'crlf' &&
175 fn_match($filename, @need_crlf)) {
176 push @err, 'content: must use CRLF EOL for this file type';
177 }
179 if($eol ne 'lf' && $content ne '' &&
180 !fn_match($filename, @need_crlf)) {
181 push @err, 'content: must use LF EOL for this file type';
182 }
184 if($cnt_cr > $max_lines) {
185 push @err, sprintf('content: too many lines (%d > %d)', $cnt_cr, $max_lines);
186 }
187 elsif($cnt_lf > $max_lines) {
188 push @err, sprintf('content: too many lines (%d > %d)', $cnt_lf, $max_lines);
189 }
191 if($content =~ /[ \t]\n/) {
192 my $line;
193 for my $l (split(/\n/, $content)) {
194 $line++;
195 if($l =~ /[ \t]$/) {
196 push @err, "line $line: trailing whitespace";
197 }
198 }
199 }
201 if($content ne '' &&
202 $content !~ /\n\z/) {
203 push @err, 'content: has no EOL at EOF';
204 }
206 if($content =~ /\n\n\z/ ||
207 $content =~ /\r\n\r\n\z/) {
208 push @err, 'content: has multiple EOL at EOF';
209 }
211 if((!fn_match($filename, @double_empty_lines) &&
212 ($content =~ /\n\n\n/ ||
213 $content =~ /\r\n\r\n\r\n/)) ||
214 $content =~ />\n\n\n+[<#]/) {
215 my $line = 0;
216 my $blank = 0;
217 for my $l (split(/\n/, $content)) {
218 chomp $l;
219 $line++;
220 if($l =~ /^$/) {
221 if($blank) {
222 my $lineno = sprintf('duplicate empty line @ line %d', $line);
223 push @err, $lineno;
224 }
225 $blank = 1;
226 }
227 else {
228 $blank = 0;
229 }
230 }
231 }
233 if($content =~ /\n\n\n\n/ ||
234 $content =~ /\r\n\r\n\r\n\r\n/) {
235 my $line = 0;
236 my $blank = 0;
237 for my $l (split(/\n/, $content)) {
238 chomp $l;
239 $line++;
240 if($l =~ /^$/) {
241 if($blank > 1) {
242 my $lineno = sprintf('3 or more consecutive empty lines @ line %d', $line);
243 push @err, $lineno;
244 }
245 $blank++;
246 }
247 else {
248 $blank = 0;
249 }
250 }
251 }
253 if(!fn_match($filename, @longline)) {
254 my $line = 0;
255 for my $l (split(/\n/, $content)) {
256 $line++;
257 if(length($l) > $max_line_len) {
258 push @err, sprintf('line %d: long (%d > %d) line', $line, length($l), $max_line_len);
259 }
260 }
261 }
263 my $line = 0;
264 for my $l (split(/\n/, $content)) {
265 $line++;
266 if($l =~ /( {$max_repeat_space,})/) {
267 push @err, sprintf('line %d: repeat spaces (%d >= %d)', $line, length($1), $max_repeat_space);
268 }
269 }
271 my $search = $content;
272 my $linepos = 0;
273 while($search =~ /[^ ] "\n *" [^ ]/) {
274 my $part = substr($search, 0, $+[0]);
275 $search = substr($search, $+[0]);
276 my $line = ($part =~ tr/\n//);
277 push @err, sprintf('line %d: double spaces in folded string', $linepos + $line);
278 $linepos += $line;
279 }
281 $search = $content;
282 $linepos = 0;
283 while($search =~ /\n\n *}\n/) {
284 my $part = substr($search, 0, $+[0] - 1);
285 $search = substr($search, $+[0]);
286 my $line = ($part =~ tr/\n//);
287 push @err, sprintf("line %d: '}' preceded by empty line", $linepos + $line);
288 $linepos += $line + 1;
289 }
291 $search = $content;
292 $linepos = 0;
293 while($search =~ /\n\{\n\n/) {
294 my $part = substr($search, 0, $+[0]);
295 $search = substr($search, $+[0]);
296 my $line = ($part =~ tr/\n//);
297 push @err, sprintf("line %d: top-level '{' followed by empty line", $linepos + $line);
298 $linepos += $line;
299 }
301 if($content =~ /([\x00-\x08\x0b\x0c\x0e-\x1f\x7f])/) {
302 push @err, 'content: has binary contents';
303 }
305 if($filename !~ /tests\/data/) {
306 # the tests have no allowed UTF bytes
307 $content =~ s/[$non_ascii_allowed]//g;
308 }
310 if(!fn_match($filename, @non_ascii) &&
311 ($content =~ /([\x80-\xff]+)/)) {
312 my $non = $1;
313 my $hex;
314 for my $e (split(//, $non)) {
315 $hex .= sprintf('%s%02x', $hex ? ' ': '', ord($e));
316 }
317 my $line;
318 for my $l (split(/\n/, $content)) {
319 $line++;
320 if($l =~ /([\x80-\xff]+)/) {
321 push @err, "line $line: has non-ASCII: '$non' ($hex)";
322 }
323 }
324 }
326 if(@err) {
327 $issues++;
328 foreach my $err (@err) {
329 print "$filename: $err\n";
330 }
331 }
333close $git_ls_files;
335if($issues) {
336 exit 1;
Diagnostics4 git calls · 167 ms
CallStatusSizeTime0167 ms
discover200152 B3 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=3
git.response.bytes=152
git.server.agent=gitty/1.0
git.server.object_format=sha1
git.server.caps=agent ls-refs fetch object-format
git.server.fetch=shallow filter sideband-all
git.protocol.version=2
git.pkt.frames=8
git.pkt.data=6
git.pkt.flush=2
git.pkt.delim=0
git.pkt.bytes=152
git.pkt.payload.max=34
ls-refs200149 B · hit3 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=3
git.response.bytes=149
git.response.cache=HIT
git.response.duration_ms=3
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=149
git.pkt.payload.max=78
git.ls_refs.count=2
git.ls_refs.head=refs/heads/master
fetchblob:none · deepen 10200287 KiB · hit3 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=2
git.response.bytes=293470
git.response.cache=HIT
git.response.duration_ms=3
git.fetch.filter=blob:none
git.fetch.filter.requested=tree:0
git.fetch.filter.fallback=blob:none
git.fetch.filter.learned=false
git.fetch.wants=31c911efe5652725e930f4d2e60c9060e5f6646d
git.fetch.haves.count=0
git.fetch.deepen=10
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=10
git.pkt.data=8
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=293470
git.pkt.payload.max=65516
git.sideband.band1.bytes=293354
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=87
git.pack.bytes=293354
git.pack.ofs_delta=0
git.pack.ref_delta=1
git.pack.chain.max=1
git.pack.trailer=6a646bcda6740bab42e321b51998b52ea15146c0
git.pack.full=86
Open pack map
fetch2002.5 KiB161 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=161
git.response.bytes=2603
git.response.cache=MISS
git.response.duration_ms=161
git.fetch.wants=0b300dbd881c7571e59c0a5659dce45394df35a4
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=2603
git.pkt.payload.max=2582
git.sideband.band1.bytes=2581
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0

Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.

Remote
https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/curl.git
Ref
refs/heads/master
Commit
31c911efe5652725e930f4d2e60c9060e5f6646d
cf-ray
a5e201297a8b70b8
Request
87f15210…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format