Artifactspublic-v0

curl

master
ply4 git calls24 ms290 KiB3 cachedprotocol v2
329 lines16 KiBRaw
1/***************************************************************************
2 * _ _ ____ _
3 * Project ___| | | | _ \| |
4 * / __| | | | |_) | |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
7 *
8 * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
9 *
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at https://curl.se/docs/copyright.html.
13 *
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
17 *
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
20 *
21 * SPDX-License-Identifier: curl
22 *
23 ***************************************************************************/
24#include "unitcheck.h"
26#ifndef CURL_DISABLE_FTP
27#include "curl_fnmatch.h"
29/*
30 CURL_FNMATCH_MATCH 0
31 CURL_FNMATCH_NOMATCH 1
32 CURL_FNMATCH_FAIL 2
33 */
35#define MATCH CURL_FNMATCH_MATCH
36#define NOMATCH CURL_FNMATCH_NOMATCH
38#define LINUX_DIFFER 0x80
39#define LINUX_SHIFT 8
40#define LINUX_MATCH ((CURL_FNMATCH_MATCH << LINUX_SHIFT) | LINUX_DIFFER)
41#define LINUX_NOMATCH ((CURL_FNMATCH_NOMATCH << LINUX_SHIFT) | LINUX_DIFFER)
42#define LINUX_FAIL ((CURL_FNMATCH_FAIL << LINUX_SHIFT) | LINUX_DIFFER)
44#define MAC_DIFFER 0x40
45#define MAC_SHIFT 16
46#define MAC_MATCH ((CURL_FNMATCH_MATCH << MAC_SHIFT) | MAC_DIFFER)
47#if 0
48#define MAC_NOMATCH ((CURL_FNMATCH_NOMATCH << MAC_SHIFT) | MAC_DIFFER)
49#endif
50#define MAC_FAIL ((CURL_FNMATCH_FAIL << MAC_SHIFT) | MAC_DIFFER)
52static const char *ret2name(int i)
54 switch(i) {
55 case 0:
56 return "MATCH";
57 case 1:
58 return "NOMATCH";
59 case 2:
60 return "FAIL";
61 default:
62 return "unknown";
63 }
64 /* not reached */
67static CURLcode test_unit1307(const char *arg)
69 UNITTEST_BEGIN_SIMPLE
71 struct testcase {
72 const char *pattern;
73 const char *string;
74 int result;
75 };
77 static const struct testcase tests[] = {
78 /* brackets syntax */
79 {"*[*[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[["
80 "[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[["
81 "[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[\001\177[[[[[[[[[[[[[[[[[[[[[",
82 "[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[["
83 "[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[["
84 "[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[",
85 NOMATCH|MAC_FAIL},
87 { "\\[", "[", MATCH },
88 { "[", "[", NOMATCH|LINUX_MATCH|MAC_FAIL},
89 { "[]", "[]", NOMATCH|LINUX_MATCH|MAC_FAIL},
90 { "[][]", "[", MATCH },
91 { "[][]", "]", MATCH },
92 { "[[]", "[", MATCH },
93 { "[[[]", "[", MATCH },
94 { "[[[[]", "[", MATCH },
95 { "[[[[]", "[", MATCH },
97 { "[][[]", "]", MATCH },
98 { "[][[[]", "[", MATCH },
99 { "[[]", "]", NOMATCH },
101 { "[a@]", "a", MATCH },
103 { "[a-z]", "a", MATCH },
104 { "[a-z]", "A", NOMATCH },
105 { "?[a-z]", "?Z", NOMATCH },
106 { "[A-Z]", "C", MATCH },
107 { "[A-Z]", "c", NOMATCH },
108 { "[0-9]", "7", MATCH },
109 { "[7-8]", "7", MATCH },
110 { "[7-]", "7", MATCH },
111 { "[7-]", "-", MATCH },
112 { "[7-]", "[", NOMATCH },
113 { "[a-bA-F]", "F", MATCH },
114 { "[a-bA-B9]", "9", MATCH },
115 { "[a-bA-B98]", "8", MATCH },
116 { "[a-bA-B98]", "C", NOMATCH },
117 { "[a-bA-Z9]", "F", MATCH },
118 { "[a-bA-Z9]ero*", "Zero chance.", MATCH },
119 { "S[a-][x]opho*", "Saxophone", MATCH },
120 { "S[a-][x]opho*", "SaXophone", NOMATCH },
121 { "S[a-][x]*.txt", "S-x.txt", MATCH },
122 { "[\\a-\\b]", "a", MATCH },
123 { "[\\a-\\b]", "b", MATCH },
124 { "[?*[][?*[][?*[]", "?*[", MATCH },
125 { "[][?*-]", "]", MATCH },
126 { "[][?*-]", "[", MATCH },
127 { "[][?*-]", "?", MATCH },
128 { "[][?*-]", "*", MATCH },
129 { "[][?*-]", "-", MATCH },
130 { "[]?*-]", "-", MATCH },
131 { "[\xFF]", "\xFF", MATCH|LINUX_FAIL|MAC_FAIL},
132 { "?/b/c", "a/b/c", MATCH },
133 { "^_{}~", "^_{}~", MATCH },
134 { "!#%+,-./01234567889", "!#%+,-./01234567889", MATCH },
135 { "PQRSTUVWXYZ]abcdefg", "PQRSTUVWXYZ]abcdefg", MATCH },
136 { ":;=@ABCDEFGHIJKLMNO", ":;=@ABCDEFGHIJKLMNO", MATCH },
138 /* negate */
139 { "[!a]", "b", MATCH },
140 { "[!a]", "a", NOMATCH },
141 { "[^a]", "b", MATCH },
142 { "[^a]", "a", NOMATCH },
143 { "[^a-z0-9A-Z]", "a", NOMATCH },
144 { "[^a-z0-9A-Z]", "-", MATCH },
145 { "curl[!a-z]lib", "curl lib", MATCH },
146 { "curl[! ]lib", "curl lib", NOMATCH },
147 { "[! ][ ]", " ", NOMATCH },
148 { "[! ][ ]", "a ", MATCH },
149 { "*[^a].t?t", "a.txt", NOMATCH },
150 { "*[^a].t?t", "ca.txt", NOMATCH },
151 { "*[^a].t?t", "ac.txt", MATCH },
152 { "*[^a]", "", NOMATCH },
153 { "[!\xFF]", "", NOMATCH|LINUX_FAIL},
154 { "[!\xFF]", "\xFF", NOMATCH|LINUX_FAIL|MAC_FAIL},
155 { "[!\xFF]", "a", MATCH|LINUX_FAIL|MAC_FAIL},
156 { "[!?*[]", "?", NOMATCH },
157 { "[!!]", "!", NOMATCH },
158 { "[!!]", "x", MATCH },
160 { "[[:alpha:]]", "a", MATCH },
161 { "[[:alpha:]]", "9", NOMATCH },
162 { "[[:alnum:]]", "a", MATCH },
163 { "[[:alnum:]]", "[", NOMATCH },
164 { "[[:alnum:]]", "]", NOMATCH },
165 { "[[:alnum:]]", "9", MATCH },
166 { "[[:digit:]]", "9", MATCH },
167 { "[[:xdigit:]]", "9", MATCH },
168 { "[[:xdigit:]]", "F", MATCH },
169 { "[[:xdigit:]]", "G", NOMATCH },
170 { "[[:upper:]]", "U", MATCH },
171 { "[[:upper:]]", "u", NOMATCH },
172 { "[[:lower:]]", "l", MATCH },
173 { "[[:lower:]]", "L", NOMATCH },
174 { "[[:print:]]", "L", MATCH },
175 { "[[:print:]]", "\10", NOMATCH },
176 { "[[:print:]]", "\10", NOMATCH },
177 { "[[:print:]]", "\t", NOMATCH },
178 { "[[:print:]]", "\n", NOMATCH },
179 { "[[:print:]]", "\r", NOMATCH },
180 { "[[:space:]]", " ", MATCH },
181 { "[[:space:]]", "x", NOMATCH },
182 { "[[:graph:]]", " ", NOMATCH },
183 { "[[:graph:]]", "x", MATCH },
184 { "[[:graph:]]", "\t", NOMATCH },
185 { "[[:graph:]]", "\r", NOMATCH },
186 { "[[:blank:]]", "\t", MATCH },
187 { "[[:blank:]]", " ", MATCH },
188 { "[[:blank:]]", "\r", NOMATCH },
189 { "[^[:blank:]]", "\t", NOMATCH },
190 { "[^[:print:]]", "\10", MATCH },
191 { "[[:lower:]][[:lower:]]", "ll", MATCH },
192 { "[[:foo:]]", "bar", NOMATCH|MAC_FAIL},
193 { "[[:foo:]]", "f]", MATCH|LINUX_NOMATCH|MAC_FAIL},
195 { "curl[[:blank:]];-)", "curl ;-)", MATCH },
196 { "*[[:blank:]]*", " ", MATCH },
197 { "*[[:blank:]]*", "", NOMATCH },
198 { "*[[:blank:]]*", "hi, im_Pavel", MATCH },
200 /* common using */
201 { "Filename.dat", "Filename.dat", MATCH },
202 { "*curl*", "lets use curl!!", MATCH },
203 { "filename.txt", "filename.dat", NOMATCH },
204 { "*.txt", "text.txt", MATCH },
205 { "*.txt", "a.txt", MATCH },
206 { "*.txt", ".txt", MATCH },
207 { "*.txt", "txt", NOMATCH },
208 { "??.txt", "99.txt", MATCH },
209 { "??.txt", "a99.txt", NOMATCH },
210 { "?.???", "a.txt", MATCH },
211 { "*.???", "somefile.dat", MATCH },
212 { "*.???", "photo.jpeg", NOMATCH },
213 { ".*", ".htaccess", MATCH },
214 { ".*", ".", MATCH },
215 { ".*", "..", MATCH },
217 /* many stars => one star */
218 { "**.txt", "text.txt", MATCH },
219 { "***.txt", "t.txt", MATCH },
220 { "****.txt", ".txt", MATCH },
222 /* custom matcher limits wildcard star groups */
223 { "*a*b*c", "abc", NOMATCH|LINUX_MATCH|MAC_MATCH },
225 /* empty string or pattern */
226 { "", "", MATCH },
227 { "", "hello", NOMATCH },
228 { "file", "", NOMATCH },
229 { "?", "", NOMATCH },
230 { "*", "", MATCH },
231 { "x", "", NOMATCH },
233 /* backslash */
234 { "\\", "\\", MATCH|LINUX_NOMATCH},
235 { "\\\\", "\\", MATCH },
236 { "\\\\", "\\\\", NOMATCH },
237 { "\\?", "?", MATCH },
238 { "\\*", "*", MATCH },
239 { "?.txt", "?.txt", MATCH },
240 { "*.txt", "*.txt", MATCH },
241 { "\\?.txt", "?.txt", MATCH },
242 { "\\*.txt", "*.txt", MATCH },
243 { "\\?.txt", "x.txt", NOMATCH },
244 { "\\*.txt", "x.txt", NOMATCH },
245 { "\\*\\\\.txt", "*\\.txt", MATCH },
246 { "*\\**\\?*\\\\*", "cc*cc?cccc", NOMATCH },
247 { "*\\?*\\**", "cc?cc", NOMATCH },
248 { "\\\"\\$\\&\\'\\(\\)", "\"$&'()", MATCH },
249 { "\\*\\?\\[\\\\\\`\\|", "*?[\\`|", MATCH },
250 { "[\\a\\b]c", "ac", MATCH },
251 { "[\\a\\b]c", "bc", MATCH },
252 { "[\\a\\b]d", "bc", NOMATCH },
253 { "[a-bA-B\\?]", "?", MATCH },
254 { "cu[a-ab-b\\r]l", "curl", MATCH },
255 { "[\\a-z]", "c", MATCH },
257 { "?*?*?.*?*", "abc.c", MATCH },
258 { "?*?*?.*?*", "abcc", NOMATCH },
259 { "?*?*?.*?*", "abc.", NOMATCH },
260 { "?*?*?.*?*", "abc.c++", MATCH },
261 { "?*?*?.*?*", "abcdef.c++", MATCH },
262 { "?*?*?.?", "abcdef.c", MATCH },
263 { "?*?*?.?", "abcdef.cd", NOMATCH },
265 /* U+00E4 Latin Small Letter A with Diaeresis */
266 { "Lindm\xc3\xa4tarv", "Lindm\xc3\xa4tarv", MATCH },
268 { "", "", MATCH},
269 {"**]*[*[\x13]**[*\x13)]*]*[**[*\x13~r-]*]**[.*]*[\xe3\xe3\xe3\xe3\xe3\xe3"
270 "\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3"
271 "\xe3\xe3\xe3\xe3\xe3*[\x13]**[*\x13)]*]*[*[\x13]*[~r]*]*\xba\x13\xa6~b-]"
272 "*",
273 "a", NOMATCH|LINUX_FAIL}
274 };
276 size_t i;
278 enum system {
279 SYSTEM_CUSTOM,
280 SYSTEM_LINUX,
281 SYSTEM_MACOS
282 };
284 enum system machine;
286#ifdef HAVE_FNMATCH
287#ifdef __APPLE__
288 machine = SYSTEM_MACOS;
289#else
290 machine = SYSTEM_LINUX;
291#endif
292 curl_mprintf("Tested with system fnmatch(), %s-style\n",
293 machine == SYSTEM_LINUX ? "linux" : "mac");
294#else
295 curl_mprintf("Tested with custom fnmatch()\n");
296 machine = SYSTEM_CUSTOM;
297#endif
299 for(i = 0; i < CURL_ARRAYSIZE(tests); i++) {
300 int result = tests[i].result;
301 int rc = Curl_fnmatch(NULL, tests[i].pattern, tests[i].string);
302 if(result & (LINUX_DIFFER | MAC_DIFFER)) {
303 if((result & LINUX_DIFFER) && (machine == SYSTEM_LINUX))
304 result >>= LINUX_SHIFT;
305 else if((result & MAC_DIFFER) && (machine == SYSTEM_MACOS))
306 result >>= MAC_SHIFT;
307 result &= 0x03; /* filter off all high bits */
308 }
309 if(rc != result) {
310 curl_mprintf("Curl_fnmatch(\"%s\", \"%s\") should return %s (returns %s)"
311 " [%zu]\n",
312 tests[i].pattern, tests[i].string, ret2name(result),
313 ret2name(rc), i);
314 fail("pattern mismatch");
315 }
316 }
318 UNITTEST_END_SIMPLE
321#else
323static CURLcode test_unit1307(const char *arg)
325 UNITTEST_BEGIN_SIMPLE
326 UNITTEST_END_SIMPLE
329#endif
Diagnostics4 git calls · 24 ms
CallStatusSizeTime024 ms
discover200152 B3 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=1
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 · hit2 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
git.response.bytes=149
git.response.cache=HIT
git.response.duration_ms=2
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 · hit1 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=20
git.response.bytes=293470
git.response.cache=HIT
git.response.duration_ms=1
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
fetch2003.3 KiB · hit20 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=3396
git.response.cache=HIT
git.response.duration_ms=20
git.fetch.wants=afd479c7deecdc49c0a6dcbdb4c6be2128488e50
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=3396
git.pkt.payload.max=3375
git.sideband.band1.bytes=3374
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
a5e2e602695f2947
Request
8413c503…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format