MCPcopy Create free account
hub / github.com/git/git / is_alternate_allowed

Function is_alternate_allowed

http-walker.c:172–201  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

170}
171
172static int is_alternate_allowed(const char *url)
173{
174 const char *protocols[] = {
175 "http", "https", "ftp", "ftps"
176 };
177 int i;
178
179 if (http_follow_config != HTTP_FOLLOW_ALWAYS) {
180 warning("alternate disabled by http.followRedirects: %s", url);
181 return 0;
182 }
183
184 for (i = 0; i < ARRAY_SIZE(protocols); i++) {
185 const char *end;
186 if (skip_prefix(url, protocols[i], &end) &&
187 starts_with(end, "://"))
188 break;
189 }
190
191 if (i >= ARRAY_SIZE(protocols)) {
192 warning("ignoring alternate with unknown protocol: %s", url);
193 return 0;
194 }
195 if (!is_transport_allowed(protocols[i], 0)) {
196 warning("ignoring alternate with restricted protocol: %s", url);
197 return 0;
198 }
199
200 return 1;
201}
202
203static void process_alternates_response(void *callback_data)
204{

Callers 1

Calls 3

warningFunction · 0.85
starts_withFunction · 0.85
is_transport_allowedFunction · 0.85

Tested by

no test coverage detected