MCPcopy Index your code
hub / github.com/git/git / locking_available

Function locking_available

http-push.c:1212–1279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1210}
1211
1212static int locking_available(void)
1213{
1214 struct active_request_slot *slot;
1215 struct slot_results results;
1216 struct strbuf in_buffer = STRBUF_INIT;
1217 struct buffer out_buffer = { STRBUF_INIT, 0 };
1218 struct curl_slist *dav_headers = http_copy_default_headers();
1219 struct xml_ctx ctx;
1220 int lock_flags = 0;
1221 char *escaped;
1222
1223 escaped = xml_entities(repo->url);
1224 strbuf_addf(&out_buffer.buf, PROPFIND_SUPPORTEDLOCK_REQUEST, escaped);
1225 free(escaped);
1226
1227 dav_headers = curl_slist_append(dav_headers, "Depth: 0");
1228 dav_headers = curl_slist_append(dav_headers, "Content-Type: text/xml");
1229
1230 slot = get_active_slot();
1231 slot->results = &results;
1232 curl_setup_http(slot->curl, repo->url, DAV_PROPFIND,
1233 &out_buffer, fwrite_buffer);
1234 curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, dav_headers);
1235 curl_easy_setopt(slot->curl, CURLOPT_WRITEDATA, &in_buffer);
1236
1237 if (start_active_slot(slot)) {
1238 run_active_slot(slot);
1239 if (results.curl_result == CURLE_OK) {
1240 XML_Parser parser = XML_ParserCreate(NULL);
1241 enum XML_Status result;
1242 ctx.name = xcalloc(10, 1);
1243 ctx.len = 0;
1244 ctx.cdata = NULL;
1245 ctx.userFunc = handle_lockprop_ctx;
1246 ctx.userData = &lock_flags;
1247 XML_SetUserData(parser, &ctx);
1248 XML_SetElementHandler(parser, xml_start_tag,
1249 xml_end_tag);
1250 result = XML_Parse(parser, in_buffer.buf,
1251 in_buffer.len, 1);
1252 free(ctx.name);
1253
1254 if (result != XML_STATUS_OK) {
1255 fprintf(stderr, "XML error: %s\n",
1256 XML_ErrorString(
1257 XML_GetErrorCode(parser)));
1258 lock_flags = 0;
1259 }
1260 XML_ParserFree(parser);
1261 if (!lock_flags)
1262 error("no DAV locking support on %s",
1263 repo->url);
1264
1265 } else {
1266 error("Cannot access URL %s, return code %d",
1267 repo->url, results.curl_result);
1268 lock_flags = 0;
1269 }

Callers 1

cmd_mainFunction · 0.85

Calls 10

xml_entitiesFunction · 0.85
strbuf_addfFunction · 0.85
get_active_slotFunction · 0.85
curl_setup_httpFunction · 0.85
start_active_slotFunction · 0.85
run_active_slotFunction · 0.85
xcallocFunction · 0.85
errorFunction · 0.85
strbuf_releaseFunction · 0.85

Tested by

no test coverage detected