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

Function remote_ls

http-push.c:1129–1197  ·  view source on GitHub ↗

* NEEDSWORK: remote_ls() ignores info/refs on the remote side. But it * should _only_ heed the information from that file, instead of trying to * determine the refs from the remote file system (badly: it does not even * know about packed-refs). */

Source from the content-addressed store, hash-verified

1127 * know about packed-refs).
1128 */
1129static void remote_ls(const char *path, int flags,
1130 void (*userFunc)(struct remote_ls_ctx *ls),
1131 void *userData)
1132{
1133 char *url = xstrfmt("%s%s", repo->url, path);
1134 struct active_request_slot *slot;
1135 struct slot_results results;
1136 struct strbuf in_buffer = STRBUF_INIT;
1137 struct buffer out_buffer = { STRBUF_INIT, 0 };
1138 struct curl_slist *dav_headers = http_copy_default_headers();
1139 struct xml_ctx ctx;
1140 struct remote_ls_ctx ls;
1141
1142 ls.flags = flags;
1143 ls.path = xstrdup(path);
1144 ls.dentry_name = NULL;
1145 ls.dentry_flags = 0;
1146 ls.userData = userData;
1147 ls.userFunc = userFunc;
1148
1149 strbuf_addstr(&out_buffer.buf, PROPFIND_ALL_REQUEST);
1150
1151 dav_headers = curl_slist_append(dav_headers, "Depth: 1");
1152 dav_headers = curl_slist_append(dav_headers, "Content-Type: text/xml");
1153
1154 slot = get_active_slot();
1155 slot->results = &results;
1156 curl_setup_http(slot->curl, url, DAV_PROPFIND,
1157 &out_buffer, fwrite_buffer);
1158 curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, dav_headers);
1159 curl_easy_setopt(slot->curl, CURLOPT_WRITEDATA, &in_buffer);
1160
1161 if (start_active_slot(slot)) {
1162 run_active_slot(slot);
1163 if (results.curl_result == CURLE_OK) {
1164 XML_Parser parser = XML_ParserCreate(NULL);
1165 enum XML_Status result;
1166 ctx.name = xcalloc(10, 1);
1167 ctx.len = 0;
1168 ctx.cdata = NULL;
1169 ctx.userFunc = handle_remote_ls_ctx;
1170 ctx.userData = &ls;
1171 XML_SetUserData(parser, &ctx);
1172 XML_SetElementHandler(parser, xml_start_tag,
1173 xml_end_tag);
1174 XML_SetCharacterDataHandler(parser, xml_cdata);
1175 result = XML_Parse(parser, in_buffer.buf,
1176 in_buffer.len, 1);
1177 free(ctx.name);
1178 free(ctx.cdata);
1179
1180 if (result != XML_STATUS_OK) {
1181 fprintf(stderr, "XML error: %s\n",
1182 XML_ErrorString(
1183 XML_GetErrorCode(parser)));
1184 }
1185 XML_ParserFree(parser);
1186 }

Callers 4

handle_remote_ls_ctxFunction · 0.85
get_remote_object_listFunction · 0.85
get_dav_remote_headsFunction · 0.85
update_remote_info_refsFunction · 0.85

Calls 10

xstrfmtFunction · 0.85
xstrdupFunction · 0.85
strbuf_addstrFunction · 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
strbuf_releaseFunction · 0.85

Tested by

no test coverage detected