13 static const char http_push_usage[] =
14 "git-http-push [--complete] [--force] [--verbose] <url> <ref> [<ref>...]\n";
21 #define XML_STATUS_OK 1
22 #define XML_STATUS_ERROR 0
25 #define RANGE_HEADER_SIZE 30
28 #define DAV_LOCK "LOCK"
29 #define DAV_MKCOL "MKCOL"
30 #define DAV_MOVE "MOVE"
31 #define DAV_PROPFIND "PROPFIND"
33 #define DAV_UNLOCK "UNLOCK"
36 #define DAV_PROP_LOCKWR (1u << 0)
37 #define DAV_PROP_LOCKEX (1u << 1)
38 #define DAV_LOCK_OK (1u << 2)
40 /* DAV XML properties */
41 #define DAV_CTX_LOCKENTRY ".multistatus.response.propstat.prop.supportedlock.lockentry"
42 #define DAV_CTX_LOCKTYPE_WRITE ".multistatus.response.propstat.prop.supportedlock.lockentry.locktype.write"
43 #define DAV_CTX_LOCKTYPE_EXCLUSIVE ".multistatus.response.propstat.prop.supportedlock.lockentry.lockscope.exclusive"
44 #define DAV_ACTIVELOCK_OWNER ".prop.lockdiscovery.activelock.owner.href"
45 #define DAV_ACTIVELOCK_TIMEOUT ".prop.lockdiscovery.activelock.timeout"
46 #define DAV_ACTIVELOCK_TOKEN ".prop.lockdiscovery.activelock.locktoken.href"
47 #define DAV_PROPFIND_RESP ".multistatus.response"
48 #define DAV_PROPFIND_NAME ".multistatus.response.href"
49 #define DAV_PROPFIND_COLLECTION ".multistatus.response.propstat.prop.resourcetype.collection"
51 /* DAV request body templates */
52 #define PROPFIND_SUPPORTEDLOCK_REQUEST "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<D:propfind xmlns:D=\"DAV:\">\n<D:prop xmlns:R=\"%s\">\n<D:supportedlock/>\n</D:prop>\n</D:propfind>"
53 #define PROPFIND_ALL_REQUEST "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<D:propfind xmlns:D=\"DAV:\">\n<D:allprop/>\n</D:propfind>"
54 #define LOCK_REQUEST "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<D:lockinfo xmlns:D=\"DAV:\">\n<D:lockscope><D:exclusive/></D:lockscope>\n<D:locktype><D:write/></D:locktype>\n<D:owner>\n<D:href>mailto:%s</D:href>\n</D:owner>\n</D:lockinfo>"
57 #define LOCK_REFRESH 30
59 /* bits #0-4 in revision.h */
61 #define LOCAL (1u << 5)
62 #define REMOTE (1u << 6)
63 #define PUSHING (1u << 7)
65 static int pushing = 0;
66 static int aborted = 0;
67 static char remote_dir_exists[256];
69 static struct curl_slist *no_pragma_header;
70 static struct curl_slist *default_headers;
72 static int push_verbosely = 0;
73 static int push_all = 0;
74 static int force_all = 0;
76 static struct object_list *objects = NULL;
82 struct packed_git *packs;
83 struct remote_lock *locks;
86 static struct repo *remote = NULL;
97 struct transfer_request
102 struct remote_lock *lock;
103 struct curl_slist *headers;
104 struct buffer buffer;
105 char filename[PATH_MAX];
106 char tmpfile[PATH_MAX];
107 enum transfer_state state;
108 CURLcode curl_result;
109 char errorstr[CURL_ERROR_SIZE];
111 unsigned char real_sha1[20];
116 struct active_request_slot *slot;
117 struct transfer_request *next;
120 static struct transfer_request *request_queue_head = NULL;
127 void (*userFunc)(struct xml_ctx *ctx, int tag_closed);
139 struct remote_lock *next;
142 /* Flags that control remote_ls processing */
143 #define PROCESS_FILES (1u << 0)
144 #define PROCESS_DIRS (1u << 1)
145 #define RECURSIVE (1u << 2)
147 /* Flags that remote_ls passes to callback functions */
148 #define IS_DIR (1u << 0)
153 void (*userFunc)(struct remote_ls_ctx *ls);
158 struct remote_ls_ctx *parent;
161 static void finish_request(struct transfer_request *request);
163 static void process_response(void *callback_data)
165 struct transfer_request *request =
166 (struct transfer_request *)callback_data;
168 finish_request(request);
171 static void start_mkcol(struct transfer_request *request)
173 char *hex = sha1_to_hex(request->obj->sha1);
174 struct active_request_slot *slot;
177 request->url = xmalloc(strlen(remote->url) + 13);
178 strcpy(request->url, remote->url);
179 posn = request->url + strlen(remote->url);
180 strcpy(posn, "objects/");
182 memcpy(posn, hex, 2);
186 slot = get_active_slot();
187 slot->callback_func = process_response;
188 slot->callback_data = request;
189 curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1); /* undo PUT setup */
190 curl_easy_setopt(slot->curl, CURLOPT_URL, request->url);
191 curl_easy_setopt(slot->curl, CURLOPT_ERRORBUFFER, request->errorstr);
192 curl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_MKCOL);
193 curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_null);
195 if (start_active_slot(slot)) {
196 request->slot = slot;
197 request->state = RUN_MKCOL;
199 request->state = ABORTED;
205 static void start_put(struct transfer_request *request)
207 char *hex = sha1_to_hex(request->obj->sha1);
208 struct active_request_slot *slot;
218 unpacked = read_sha1_file(request->obj->sha1, type, &len);
219 hdrlen = sprintf(hdr, "%s %lu", type, len) + 1;
222 memset(&stream, 0, sizeof(stream));
223 deflateInit(&stream, Z_BEST_COMPRESSION);
224 size = deflateBound(&stream, len + hdrlen);
225 request->buffer.buffer = xmalloc(size);
228 stream.next_out = request->buffer.buffer;
229 stream.avail_out = size;
232 stream.next_in = (void *)hdr;
233 stream.avail_in = hdrlen;
234 while (deflate(&stream, 0) == Z_OK)
237 /* Then the data itself.. */
238 stream.next_in = unpacked;
239 stream.avail_in = len;
240 while (deflate(&stream, Z_FINISH) == Z_OK)
245 request->buffer.size = stream.total_out;
246 request->buffer.posn = 0;
248 request->url = xmalloc(strlen(remote->url) +
249 strlen(request->lock->token) + 51);
250 strcpy(request->url, remote->url);
251 posn = request->url + strlen(remote->url);
252 strcpy(posn, "objects/");
254 memcpy(posn, hex, 2);
257 strcpy(posn, hex + 2);
258 request->dest = xmalloc(strlen(request->url) + 14);
259 sprintf(request->dest, "Destination: %s", request->url);
262 strcpy(posn, request->lock->token);
264 slot = get_active_slot();
265 slot->callback_func = process_response;
266 slot->callback_data = request;
267 curl_easy_setopt(slot->curl, CURLOPT_INFILE, &request->buffer);
268 curl_easy_setopt(slot->curl, CURLOPT_INFILESIZE, request->buffer.size);
269 curl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, fread_buffer);
270 curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_null);
271 curl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_PUT);
272 curl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 1);
273 curl_easy_setopt(slot->curl, CURLOPT_PUT, 1);
274 curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0);
275 curl_easy_setopt(slot->curl, CURLOPT_URL, request->url);
277 if (start_active_slot(slot)) {
278 request->slot = slot;
279 request->state = RUN_PUT;
281 request->state = ABORTED;
287 static void start_move(struct transfer_request *request)
289 struct active_request_slot *slot;
290 struct curl_slist *dav_headers = NULL;
292 slot = get_active_slot();
293 slot->callback_func = process_response;
294 slot->callback_data = request;
295 curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1); /* undo PUT setup */
296 curl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_MOVE);
297 dav_headers = curl_slist_append(dav_headers, request->dest);
298 dav_headers = curl_slist_append(dav_headers, "Overwrite: T");
299 curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, dav_headers);
300 curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_null);
301 curl_easy_setopt(slot->curl, CURLOPT_URL, request->url);
303 if (start_active_slot(slot)) {
304 request->slot = slot;
305 request->state = RUN_MOVE;
307 request->state = ABORTED;
313 static int refresh_lock(struct remote_lock *lock)
315 struct active_request_slot *slot;
316 struct slot_results results;
318 char timeout_header[25];
319 struct curl_slist *dav_headers = NULL;
322 lock->refreshing = 1;
324 if_header = xmalloc(strlen(lock->token) + 25);
325 sprintf(if_header, "If: (<opaquelocktoken:%s>)", lock->token);
326 sprintf(timeout_header, "Timeout: Second-%ld", lock->timeout);
327 dav_headers = curl_slist_append(dav_headers, if_header);
328 dav_headers = curl_slist_append(dav_headers, timeout_header);
330 slot = get_active_slot();
331 slot->results = &results;
332 curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);
333 curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_null);
334 curl_easy_setopt(slot->curl, CURLOPT_URL, lock->url);
335 curl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_LOCK);
336 curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, dav_headers);
338 if (start_active_slot(slot)) {
339 run_active_slot(slot);
340 if (results.curl_result != CURLE_OK) {
341 fprintf(stderr, "LOCK HTTP error %ld\n",
344 lock->start_time = time(NULL);
349 lock->refreshing = 0;
350 curl_slist_free_all(dav_headers);
356 static void check_locks()
358 struct remote_lock *lock = remote->locks;
359 time_t current_time = time(NULL);
363 time_remaining = lock->start_time + lock->timeout -
365 if (!lock->refreshing && time_remaining < LOCK_REFRESH) {
366 if (!refresh_lock(lock)) {
368 "Unable to refresh lock for %s\n",
378 static void release_request(struct transfer_request *request)
380 struct transfer_request *entry = request_queue_head;
382 if (request == request_queue_head) {
383 request_queue_head = request->next;
385 while (entry->next != NULL && entry->next != request)
387 if (entry->next == request)
388 entry->next = entry->next->next;
391 if (request->url != NULL)
396 static void finish_request(struct transfer_request *request)
398 request->curl_result = request->slot->curl_result;
399 request->http_code = request->slot->http_code;
400 request->slot = NULL;
402 /* Keep locks active */
405 if (request->headers != NULL)
406 curl_slist_free_all(request->headers);
408 /* URL is reused for MOVE after PUT */
409 if (request->state != RUN_PUT) {
414 if (request->state == RUN_MKCOL) {
415 if (request->curl_result == CURLE_OK ||
416 request->http_code == 405) {
417 remote_dir_exists[request->obj->sha1[0]] = 1;
420 fprintf(stderr, "MKCOL %s failed, aborting (%d/%ld)\n",
421 sha1_to_hex(request->obj->sha1),
422 request->curl_result, request->http_code);
423 request->state = ABORTED;
426 } else if (request->state == RUN_PUT) {
427 if (request->curl_result == CURLE_OK) {
430 fprintf(stderr, "PUT %s failed, aborting (%d/%ld)\n",
431 sha1_to_hex(request->obj->sha1),
432 request->curl_result, request->http_code);
433 request->state = ABORTED;
436 } else if (request->state == RUN_MOVE) {
437 if (request->curl_result == CURLE_OK) {
438 fprintf(stderr, " sent %s\n",
439 sha1_to_hex(request->obj->sha1));
440 request->state = COMPLETE;
441 request->obj->flags |= REMOTE;
442 release_request(request);
444 fprintf(stderr, "MOVE %s failed, aborting (%d/%ld)\n",
445 sha1_to_hex(request->obj->sha1),
446 request->curl_result, request->http_code);
447 request->state = ABORTED;
453 void fill_active_slots(void)
455 struct transfer_request *request = request_queue_head;
456 struct active_request_slot *slot = active_queue_head;
462 while (active_requests < max_requests && request != NULL) {
463 if (pushing && request->state == NEED_PUSH) {
464 if (remote_dir_exists[request->obj->sha1[0]] == 1) {
467 start_mkcol(request);
469 curl_multi_perform(curlm, &num_transfers);
471 request = request->next;
474 while (slot != NULL) {
475 if (!slot->in_use && slot->curl != NULL) {
476 curl_easy_cleanup(slot->curl);
483 static void get_remote_object_list(unsigned char parent);
485 static void add_request(struct object *obj, struct remote_lock *lock)
487 struct transfer_request *request = request_queue_head;
488 struct packed_git *target;
490 /* Keep locks active */
494 * Don't push the object if it's known to exist on the remote
495 * or is already in the request queue
497 if (remote_dir_exists[obj->sha1[0]] == -1)
498 get_remote_object_list(obj->sha1[0]);
499 if (obj->flags & (REMOTE | PUSHING))
501 target = find_sha1_pack(obj->sha1, remote->packs);
503 obj->flags |= REMOTE;
507 obj->flags |= PUSHING;
508 request = xmalloc(sizeof(*request));
511 request->lock = lock;
512 request->headers = NULL;
513 request->state = NEED_PUSH;
514 request->next = request_queue_head;
515 request_queue_head = request;
521 static int fetch_index(unsigned char *sha1)
523 char *hex = sha1_to_hex(sha1);
526 char tmpfile[PATH_MAX];
528 char range[RANGE_HEADER_SIZE];
529 struct curl_slist *range_header = NULL;
532 struct active_request_slot *slot;
533 struct slot_results results;
535 /* Don't use the index if the pack isn't there */
536 url = xmalloc(strlen(remote->url) + 65);
537 sprintf(url, "%s/objects/pack/pack-%s.pack", remote->url, hex);
538 slot = get_active_slot();
539 slot->results = &results;
540 curl_easy_setopt(slot->curl, CURLOPT_URL, url);
541 curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 1);
542 if (start_active_slot(slot)) {
543 run_active_slot(slot);
544 if (results.curl_result != CURLE_OK) {
546 return error("Unable to verify pack %s is available",
550 return error("Unable to start request");
553 if (has_pack_index(sha1))
557 fprintf(stderr, "Getting index for pack %s\n", hex);
559 sprintf(url, "%s/objects/pack/pack-%s.idx", remote->url, hex);
561 filename = sha1_pack_index_name(sha1);
562 snprintf(tmpfile, sizeof(tmpfile), "%s.temp", filename);
563 indexfile = fopen(tmpfile, "a");
565 return error("Unable to open local file %s for pack index",
568 slot = get_active_slot();
569 slot->results = &results;
570 curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0);
571 curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);
572 curl_easy_setopt(slot->curl, CURLOPT_FILE, indexfile);
573 curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite);
574 curl_easy_setopt(slot->curl, CURLOPT_URL, url);
575 curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, no_pragma_header);
576 slot->local = indexfile;
578 /* If there is data present from a previous transfer attempt,
579 resume where it left off */
580 prev_posn = ftell(indexfile);
584 "Resuming fetch of index for pack %s at byte %ld\n",
586 sprintf(range, "Range: bytes=%ld-", prev_posn);
587 range_header = curl_slist_append(range_header, range);
588 curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, range_header);
591 if (start_active_slot(slot)) {
592 run_active_slot(slot);
593 if (results.curl_result != CURLE_OK) {
596 return error("Unable to get pack index %s\n%s", url,
602 return error("Unable to start request");
608 return move_temp_to_file(tmpfile, filename);
611 static int setup_index(unsigned char *sha1)
613 struct packed_git *new_pack;
615 if (fetch_index(sha1))
618 new_pack = parse_pack_index(sha1);
619 new_pack->next = remote->packs;
620 remote->packs = new_pack;
624 static int fetch_indices(void)
626 unsigned char sha1[20];
628 struct buffer buffer;
632 struct active_request_slot *slot;
633 struct slot_results results;
635 data = xmalloc(4096);
636 memset(data, 0, 4096);
639 buffer.buffer = data;
642 fprintf(stderr, "Getting pack list\n");
644 url = xmalloc(strlen(remote->url) + 21);
645 sprintf(url, "%s/objects/info/packs", remote->url);
647 slot = get_active_slot();
648 slot->results = &results;
649 curl_easy_setopt(slot->curl, CURLOPT_FILE, &buffer);
650 curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);
651 curl_easy_setopt(slot->curl, CURLOPT_URL, url);
652 curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, NULL);
653 if (start_active_slot(slot)) {
654 run_active_slot(slot);
655 if (results.curl_result != CURLE_OK) {
658 if (results.http_code == 404)
661 return error("%s", curl_errorstr);
666 return error("Unable to start request");
670 data = buffer.buffer;
671 while (i < buffer.posn) {
675 if (i + 52 < buffer.posn &&
676 !strncmp(data + i, " pack-", 6) &&
677 !strncmp(data + i + 46, ".pack\n", 6)) {
678 get_sha1_hex(data + i + 6, sha1);
684 while (data[i] != '\n')
694 static inline int needs_quote(int ch)
697 case '/': case '-': case '.':
698 case 'A'...'Z': case 'a'...'z': case '0'...'9':
705 static inline int hex(int v)
707 if (v < 10) return '0' + v;
708 else return 'A' + v - 10;
711 static char *quote_ref_url(const char *base, const char *ref)
715 int len, baselen, ch;
717 baselen = strlen(base);
719 for (cp = ref; (ch = *cp) != 0; cp++, len++)
721 len += 2; /* extra two hex plus replacement % */
723 memcpy(qref, base, baselen);
724 for (cp = ref, dp = qref + baselen; (ch = *cp) != 0; cp++) {
725 if (needs_quote(ch)) {
727 *dp++ = hex((ch >> 4) & 0xF);
728 *dp++ = hex(ch & 0xF);
738 int fetch_ref(char *ref, unsigned char *sha1)
742 struct buffer buffer;
743 char *base = remote->url;
744 struct active_request_slot *slot;
745 struct slot_results results;
751 url = quote_ref_url(base, ref);
752 slot = get_active_slot();
753 slot->results = &results;
754 curl_easy_setopt(slot->curl, CURLOPT_FILE, &buffer);
755 curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);
756 curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, NULL);
757 curl_easy_setopt(slot->curl, CURLOPT_URL, url);
758 if (start_active_slot(slot)) {
759 run_active_slot(slot);
760 if (results.curl_result != CURLE_OK)
761 return error("Couldn't get %s for %s\n%s",
762 url, ref, curl_errorstr);
764 return error("Unable to start request");
768 get_sha1_hex(hex, sha1);
772 static void one_remote_object(const char *hex)
774 unsigned char sha1[20];
777 if (get_sha1_hex(hex, sha1) != 0)
780 obj = lookup_object(sha1);
782 obj = parse_object(sha1);
784 /* Ignore remote objects that don't exist locally */
788 obj->flags |= REMOTE;
789 if (!object_list_contains(objects, obj))
790 add_object(obj, &objects, NULL, "");
793 static void handle_lockprop_ctx(struct xml_ctx *ctx, int tag_closed)
795 int *lock_flags = (int *)ctx->userData;
798 if (!strcmp(ctx->name, DAV_CTX_LOCKENTRY)) {
799 if ((*lock_flags & DAV_PROP_LOCKEX) &&
800 (*lock_flags & DAV_PROP_LOCKWR)) {
801 *lock_flags |= DAV_LOCK_OK;
803 *lock_flags &= DAV_LOCK_OK;
804 } else if (!strcmp(ctx->name, DAV_CTX_LOCKTYPE_WRITE)) {
805 *lock_flags |= DAV_PROP_LOCKWR;
806 } else if (!strcmp(ctx->name, DAV_CTX_LOCKTYPE_EXCLUSIVE)) {
807 *lock_flags |= DAV_PROP_LOCKEX;
812 static void handle_new_lock_ctx(struct xml_ctx *ctx, int tag_closed)
814 struct remote_lock *lock = (struct remote_lock *)ctx->userData;
816 if (tag_closed && ctx->cdata) {
817 if (!strcmp(ctx->name, DAV_ACTIVELOCK_OWNER)) {
818 lock->owner = xmalloc(strlen(ctx->cdata) + 1);
819 strcpy(lock->owner, ctx->cdata);
820 } else if (!strcmp(ctx->name, DAV_ACTIVELOCK_TIMEOUT)) {
821 if (!strncmp(ctx->cdata, "Second-", 7))
823 strtol(ctx->cdata + 7, NULL, 10);
824 } else if (!strcmp(ctx->name, DAV_ACTIVELOCK_TOKEN)) {
825 if (!strncmp(ctx->cdata, "opaquelocktoken:", 16)) {
826 lock->token = xmalloc(strlen(ctx->cdata) - 15);
827 strcpy(lock->token, ctx->cdata + 16);
833 static void one_remote_ref(char *refname);
836 xml_start_tag(void *userData, const char *name, const char **atts)
838 struct xml_ctx *ctx = (struct xml_ctx *)userData;
839 const char *c = index(name, ':');
847 new_len = strlen(ctx->name) + strlen(c) + 2;
849 if (new_len > ctx->len) {
850 ctx->name = xrealloc(ctx->name, new_len);
853 strcat(ctx->name, ".");
854 strcat(ctx->name, c);
861 ctx->userFunc(ctx, 0);
865 xml_end_tag(void *userData, const char *name)
867 struct xml_ctx *ctx = (struct xml_ctx *)userData;
868 const char *c = index(name, ':');
871 ctx->userFunc(ctx, 1);
878 ep = ctx->name + strlen(ctx->name) - strlen(c) - 1;
883 xml_cdata(void *userData, const XML_Char *s, int len)
885 struct xml_ctx *ctx = (struct xml_ctx *)userData;
888 ctx->cdata = xcalloc(len+1, 1);
889 strncpy(ctx->cdata, s, len);
892 static struct remote_lock *lock_remote(char *path, long timeout)
894 struct active_request_slot *slot;
895 struct slot_results results;
896 struct buffer out_buffer;
897 struct buffer in_buffer;
902 char timeout_header[25];
903 struct remote_lock *lock = NULL;
904 XML_Parser parser = XML_ParserCreate(NULL);
905 enum XML_Status result;
906 struct curl_slist *dav_headers = NULL;
909 url = xmalloc(strlen(remote->url) + strlen(path) + 1);
910 sprintf(url, "%s%s", remote->url, path);
912 /* Make sure leading directories exist for the remote ref */
913 ep = strchr(url + strlen(remote->url) + 11, '/');
916 slot = get_active_slot();
917 slot->results = &results;
918 curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);
919 curl_easy_setopt(slot->curl, CURLOPT_URL, url);
920 curl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_MKCOL);
921 curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_null);
922 if (start_active_slot(slot)) {
923 run_active_slot(slot);
924 if (results.curl_result != CURLE_OK &&
925 results.http_code != 405) {
927 "Unable to create branch path %s\n",
933 fprintf(stderr, "Unable to start request\n");
938 ep = strchr(ep + 1, '/');
941 out_buffer.size = strlen(LOCK_REQUEST) + strlen(git_default_email) - 2;
942 out_data = xmalloc(out_buffer.size + 1);
943 snprintf(out_data, out_buffer.size + 1, LOCK_REQUEST, git_default_email);
945 out_buffer.buffer = out_data;
947 in_buffer.size = 4096;
948 in_data = xmalloc(in_buffer.size);
950 in_buffer.buffer = in_data;
952 sprintf(timeout_header, "Timeout: Second-%ld", timeout);
953 dav_headers = curl_slist_append(dav_headers, timeout_header);
954 dav_headers = curl_slist_append(dav_headers, "Content-Type: text/xml");
956 slot = get_active_slot();
957 slot->results = &results;
958 curl_easy_setopt(slot->curl, CURLOPT_INFILE, &out_buffer);
959 curl_easy_setopt(slot->curl, CURLOPT_INFILESIZE, out_buffer.size);
960 curl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, fread_buffer);
961 curl_easy_setopt(slot->curl, CURLOPT_FILE, &in_buffer);
962 curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);
963 curl_easy_setopt(slot->curl, CURLOPT_URL, url);
964 curl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 1);
965 curl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_LOCK);
966 curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, dav_headers);
968 lock = xcalloc(1, sizeof(*lock));
971 if (start_active_slot(slot)) {
972 run_active_slot(slot);
973 if (results.curl_result == CURLE_OK) {
974 ctx.name = xcalloc(10, 1);
977 ctx.userFunc = handle_new_lock_ctx;
979 XML_SetUserData(parser, &ctx);
980 XML_SetElementHandler(parser, xml_start_tag,
982 XML_SetCharacterDataHandler(parser, xml_cdata);
983 result = XML_Parse(parser, in_buffer.buffer,
986 if (result != XML_STATUS_OK) {
987 fprintf(stderr, "XML error: %s\n",
989 XML_GetErrorCode(parser)));
994 fprintf(stderr, "Unable to start request\n");
997 curl_slist_free_all(dav_headers);
1001 if (lock->token == NULL || lock->timeout <= 0) {
1002 if (lock->token != NULL)
1004 if (lock->owner != NULL)
1011 lock->start_time = time(NULL);
1012 lock->next = remote->locks;
1013 remote->locks = lock;
1019 static int unlock_remote(struct remote_lock *lock)
1021 struct active_request_slot *slot;
1022 struct slot_results results;
1023 struct remote_lock *prev = remote->locks;
1024 char *lock_token_header;
1025 struct curl_slist *dav_headers = NULL;
1028 lock_token_header = xmalloc(strlen(lock->token) + 31);
1029 sprintf(lock_token_header, "Lock-Token: <opaquelocktoken:%s>",
1031 dav_headers = curl_slist_append(dav_headers, lock_token_header);
1033 slot = get_active_slot();
1034 slot->results = &results;
1035 curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_null);
1036 curl_easy_setopt(slot->curl, CURLOPT_URL, lock->url);
1037 curl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_UNLOCK);
1038 curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, dav_headers);
1040 if (start_active_slot(slot)) {
1041 run_active_slot(slot);
1042 if (results.curl_result == CURLE_OK)
1045 fprintf(stderr, "UNLOCK HTTP error %ld\n",
1048 fprintf(stderr, "Unable to start UNLOCK request\n");
1051 curl_slist_free_all(dav_headers);
1052 free(lock_token_header);
1054 if (remote->locks == lock) {
1055 remote->locks = lock->next;
1057 while (prev && prev->next != lock)
1060 prev->next = prev->next->next;
1063 if (lock->owner != NULL)
1072 static void remote_ls(const char *path, int flags,
1073 void (*userFunc)(struct remote_ls_ctx *ls),
1076 static void process_ls_object(struct remote_ls_ctx *ls)
1078 unsigned int *parent = (unsigned int *)ls->userData;
1079 char *path = ls->dentry_name;
1082 if (!strcmp(ls->path, ls->dentry_name) && (ls->flags & IS_DIR)) {
1083 remote_dir_exists[*parent] = 1;
1087 if (strlen(path) != 49)
1090 obj_hex = xmalloc(strlen(path));
1091 strncpy(obj_hex, path, 2);
1092 strcpy(obj_hex + 2, path + 3);
1093 one_remote_object(obj_hex);
1097 static void process_ls_ref(struct remote_ls_ctx *ls)
1099 if (!strcmp(ls->path, ls->dentry_name) && (ls->dentry_flags & IS_DIR)) {
1100 fprintf(stderr, " %s\n", ls->dentry_name);
1104 if (!(ls->dentry_flags & IS_DIR))
1105 one_remote_ref(ls->dentry_name);
1108 static void handle_remote_ls_ctx(struct xml_ctx *ctx, int tag_closed)
1110 struct remote_ls_ctx *ls = (struct remote_ls_ctx *)ctx->userData;
1113 if (!strcmp(ctx->name, DAV_PROPFIND_RESP) && ls->dentry_name) {
1114 if (ls->dentry_flags & IS_DIR) {
1115 if (ls->flags & PROCESS_DIRS) {
1118 if (strcmp(ls->dentry_name, ls->path) &&
1119 ls->flags & RECURSIVE) {
1120 remote_ls(ls->dentry_name,
1125 } else if (ls->flags & PROCESS_FILES) {
1128 } else if (!strcmp(ctx->name, DAV_PROPFIND_NAME) && ctx->cdata) {
1129 ls->dentry_name = xmalloc(strlen(ctx->cdata) -
1130 remote->path_len + 1);
1131 strcpy(ls->dentry_name, ctx->cdata + remote->path_len);
1132 } else if (!strcmp(ctx->name, DAV_PROPFIND_COLLECTION)) {
1133 ls->dentry_flags |= IS_DIR;
1135 } else if (!strcmp(ctx->name, DAV_PROPFIND_RESP)) {
1136 if (ls->dentry_name) {
1137 free(ls->dentry_name);
1139 ls->dentry_name = NULL;
1140 ls->dentry_flags = 0;
1144 static void remote_ls(const char *path, int flags,
1145 void (*userFunc)(struct remote_ls_ctx *ls),
1148 char *url = xmalloc(strlen(remote->url) + strlen(path) + 1);
1149 struct active_request_slot *slot;
1150 struct slot_results results;
1151 struct buffer in_buffer;
1152 struct buffer out_buffer;
1155 XML_Parser parser = XML_ParserCreate(NULL);
1156 enum XML_Status result;
1157 struct curl_slist *dav_headers = NULL;
1159 struct remote_ls_ctx ls;
1162 ls.path = strdup(path);
1163 ls.dentry_name = NULL;
1164 ls.dentry_flags = 0;
1165 ls.userData = userData;
1166 ls.userFunc = userFunc;
1168 sprintf(url, "%s%s", remote->url, path);
1170 out_buffer.size = strlen(PROPFIND_ALL_REQUEST);
1171 out_data = xmalloc(out_buffer.size + 1);
1172 snprintf(out_data, out_buffer.size + 1, PROPFIND_ALL_REQUEST);
1173 out_buffer.posn = 0;
1174 out_buffer.buffer = out_data;
1176 in_buffer.size = 4096;
1177 in_data = xmalloc(in_buffer.size);
1179 in_buffer.buffer = in_data;
1181 dav_headers = curl_slist_append(dav_headers, "Depth: 1");
1182 dav_headers = curl_slist_append(dav_headers, "Content-Type: text/xml");
1184 slot = get_active_slot();
1185 slot->results = &results;
1186 curl_easy_setopt(slot->curl, CURLOPT_INFILE, &out_buffer);
1187 curl_easy_setopt(slot->curl, CURLOPT_INFILESIZE, out_buffer.size);
1188 curl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, fread_buffer);
1189 curl_easy_setopt(slot->curl, CURLOPT_FILE, &in_buffer);
1190 curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);
1191 curl_easy_setopt(slot->curl, CURLOPT_URL, url);
1192 curl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 1);
1193 curl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_PROPFIND);
1194 curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, dav_headers);
1196 if (start_active_slot(slot)) {
1197 run_active_slot(slot);
1198 if (results.curl_result == CURLE_OK) {
1199 ctx.name = xcalloc(10, 1);
1202 ctx.userFunc = handle_remote_ls_ctx;
1204 XML_SetUserData(parser, &ctx);
1205 XML_SetElementHandler(parser, xml_start_tag,
1207 XML_SetCharacterDataHandler(parser, xml_cdata);
1208 result = XML_Parse(parser, in_buffer.buffer,
1212 if (result != XML_STATUS_OK) {
1213 fprintf(stderr, "XML error: %s\n",
1215 XML_GetErrorCode(parser)));
1219 fprintf(stderr, "Unable to start PROPFIND request\n");
1225 free(in_buffer.buffer);
1226 curl_slist_free_all(dav_headers);
1229 static void get_remote_object_list(unsigned char parent)
1231 char path[] = "objects/XX/";
1232 static const char hex[] = "0123456789abcdef";
1233 unsigned int val = parent;
1235 path[8] = hex[val >> 4];
1236 path[9] = hex[val & 0xf];
1237 remote_dir_exists[val] = 0;
1238 remote_ls(path, (PROCESS_FILES | PROCESS_DIRS),
1239 process_ls_object, &val);
1242 static int locking_available(void)
1244 struct active_request_slot *slot;
1245 struct slot_results results;
1246 struct buffer in_buffer;
1247 struct buffer out_buffer;
1250 XML_Parser parser = XML_ParserCreate(NULL);
1251 enum XML_Status result;
1252 struct curl_slist *dav_headers = NULL;
1257 strlen(PROPFIND_SUPPORTEDLOCK_REQUEST) +
1258 strlen(remote->url) - 2;
1259 out_data = xmalloc(out_buffer.size + 1);
1260 snprintf(out_data, out_buffer.size + 1,
1261 PROPFIND_SUPPORTEDLOCK_REQUEST, remote->url);
1262 out_buffer.posn = 0;
1263 out_buffer.buffer = out_data;
1265 in_buffer.size = 4096;
1266 in_data = xmalloc(in_buffer.size);
1268 in_buffer.buffer = in_data;
1270 dav_headers = curl_slist_append(dav_headers, "Depth: 0");
1271 dav_headers = curl_slist_append(dav_headers, "Content-Type: text/xml");
1273 slot = get_active_slot();
1274 slot->results = &results;
1275 curl_easy_setopt(slot->curl, CURLOPT_INFILE, &out_buffer);
1276 curl_easy_setopt(slot->curl, CURLOPT_INFILESIZE, out_buffer.size);
1277 curl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, fread_buffer);
1278 curl_easy_setopt(slot->curl, CURLOPT_FILE, &in_buffer);
1279 curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);
1280 curl_easy_setopt(slot->curl, CURLOPT_URL, remote->url);
1281 curl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 1);
1282 curl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_PROPFIND);
1283 curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, dav_headers);
1285 if (start_active_slot(slot)) {
1286 run_active_slot(slot);
1287 if (results.curl_result == CURLE_OK) {
1288 ctx.name = xcalloc(10, 1);
1291 ctx.userFunc = handle_lockprop_ctx;
1292 ctx.userData = &lock_flags;
1293 XML_SetUserData(parser, &ctx);
1294 XML_SetElementHandler(parser, xml_start_tag,
1296 result = XML_Parse(parser, in_buffer.buffer,
1300 if (result != XML_STATUS_OK) {
1301 fprintf(stderr, "XML error: %s\n",
1303 XML_GetErrorCode(parser)));
1308 fprintf(stderr, "Unable to start request\n");
1312 free(in_buffer.buffer);
1313 curl_slist_free_all(dav_headers);
1318 static struct object_list **process_blob(struct blob *blob,
1319 struct object_list **p,
1320 struct name_path *path,
1323 struct object *obj = &blob->object;
1325 obj->flags |= LOCAL;
1327 if (obj->flags & (UNINTERESTING | SEEN))
1331 return add_object(obj, p, path, name);
1334 static struct object_list **process_tree(struct tree *tree,
1335 struct object_list **p,
1336 struct name_path *path,
1339 struct object *obj = &tree->object;
1340 struct tree_entry_list *entry;
1341 struct name_path me;
1343 obj->flags |= LOCAL;
1345 if (obj->flags & (UNINTERESTING | SEEN))
1347 if (parse_tree(tree) < 0)
1348 die("bad tree object %s", sha1_to_hex(obj->sha1));
1351 p = add_object(obj, p, NULL, name);
1354 me.elem_len = strlen(name);
1355 entry = tree->entries;
1356 tree->entries = NULL;
1358 struct tree_entry_list *next = entry->next;
1359 if (entry->directory)
1360 p = process_tree(entry->item.tree, p, &me, entry->name);
1362 p = process_blob(entry->item.blob, p, &me, entry->name);
1369 static void get_delta(struct rev_info *revs, struct remote_lock *lock)
1371 struct commit *commit;
1372 struct object_list **p = &objects, *pending;
1374 while ((commit = get_revision(revs)) != NULL) {
1375 p = process_tree(commit->tree, p, NULL, "");
1376 commit->object.flags |= LOCAL;
1377 if (!(commit->object.flags & UNINTERESTING))
1378 add_request(&commit->object, lock);
1381 for (pending = revs->pending_objects; pending; pending = pending->next) {
1382 struct object *obj = pending->item;
1383 const char *name = pending->name;
1385 if (obj->flags & (UNINTERESTING | SEEN))
1387 if (obj->type == tag_type) {
1389 p = add_object(obj, p, NULL, name);
1392 if (obj->type == tree_type) {
1393 p = process_tree((struct tree *)obj, p, NULL, name);
1396 if (obj->type == blob_type) {
1397 p = process_blob((struct blob *)obj, p, NULL, name);
1400 die("unknown pending object %s (%s)", sha1_to_hex(obj->sha1), name);
1404 if (!(objects->item->flags & UNINTERESTING))
1405 add_request(objects->item, lock);
1406 objects = objects->next;
1410 static int update_remote(unsigned char *sha1, struct remote_lock *lock)
1412 struct active_request_slot *slot;
1413 struct slot_results results;
1416 struct buffer out_buffer;
1417 struct curl_slist *dav_headers = NULL;
1420 if_header = xmalloc(strlen(lock->token) + 25);
1421 sprintf(if_header, "If: (<opaquelocktoken:%s>)", lock->token);
1422 dav_headers = curl_slist_append(dav_headers, if_header);
1424 out_buffer.size = 41;
1425 out_data = xmalloc(out_buffer.size + 1);
1426 i = snprintf(out_data, out_buffer.size + 1, "%s\n", sha1_to_hex(sha1));
1427 if (i != out_buffer.size) {
1428 fprintf(stderr, "Unable to initialize PUT request body\n");
1431 out_buffer.posn = 0;
1432 out_buffer.buffer = out_data;
1434 slot = get_active_slot();
1435 slot->results = &results;
1436 curl_easy_setopt(slot->curl, CURLOPT_INFILE, &out_buffer);
1437 curl_easy_setopt(slot->curl, CURLOPT_INFILESIZE, out_buffer.size);
1438 curl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, fread_buffer);
1439 curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_null);
1440 curl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_PUT);
1441 curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, dav_headers);
1442 curl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 1);
1443 curl_easy_setopt(slot->curl, CURLOPT_PUT, 1);
1444 curl_easy_setopt(slot->curl, CURLOPT_URL, lock->url);
1446 if (start_active_slot(slot)) {
1447 run_active_slot(slot);
1450 if (results.curl_result != CURLE_OK) {
1452 "PUT error: curl result=%d, HTTP code=%ld\n",
1453 results.curl_result, results.http_code);
1454 /* We should attempt recovery? */
1460 fprintf(stderr, "Unable to start PUT request\n");
1467 static struct ref *local_refs, **local_tail;
1468 static struct ref *remote_refs, **remote_tail;
1470 static int one_local_ref(const char *refname, const unsigned char *sha1)
1473 int len = strlen(refname) + 1;
1474 ref = xcalloc(1, sizeof(*ref) + len);
1475 memcpy(ref->new_sha1, sha1, 20);
1476 memcpy(ref->name, refname, len);
1478 local_tail = &ref->next;
1482 static void one_remote_ref(char *refname)
1485 unsigned char remote_sha1[20];
1487 if (fetch_ref(refname, remote_sha1) != 0) {
1489 "Unable to fetch ref %s from %s\n",
1490 refname, remote->url);
1494 int len = strlen(refname) + 1;
1495 ref = xcalloc(1, sizeof(*ref) + len);
1496 memcpy(ref->old_sha1, remote_sha1, 20);
1497 memcpy(ref->name, refname, len);
1499 remote_tail = &ref->next;
1502 static void get_local_heads(void)
1504 local_tail = &local_refs;
1505 for_each_ref(one_local_ref);
1508 static void get_dav_remote_heads(void)
1510 remote_tail = &remote_refs;
1511 remote_ls("refs/", (PROCESS_FILES | PROCESS_DIRS | RECURSIVE), process_ls_ref, NULL);
1514 static int is_zero_sha1(const unsigned char *sha1)
1518 for (i = 0; i < 20; i++) {
1525 static void unmark_and_free(struct commit_list *list, unsigned int mark)
1528 struct commit_list *temp = list;
1529 temp->item->object.flags &= ~mark;
1535 static int ref_newer(const unsigned char *new_sha1,
1536 const unsigned char *old_sha1)
1539 struct commit *old, *new;
1540 struct commit_list *list, *used;
1543 /* Both new and old must be commit-ish and new is descendant of
1544 * old. Otherwise we require --force.
1546 o = deref_tag(parse_object(old_sha1), NULL, 0);
1547 if (!o || o->type != commit_type)
1549 old = (struct commit *) o;
1551 o = deref_tag(parse_object(new_sha1), NULL, 0);
1552 if (!o || o->type != commit_type)
1554 new = (struct commit *) o;
1556 if (parse_commit(new) < 0)
1560 commit_list_insert(new, &list);
1562 new = pop_most_recent_commit(&list, TMP_MARK);
1563 commit_list_insert(new, &used);
1569 unmark_and_free(list, TMP_MARK);
1570 unmark_and_free(used, TMP_MARK);
1574 static void mark_edge_parents_uninteresting(struct commit *commit)
1576 struct commit_list *parents;
1578 for (parents = commit->parents; parents; parents = parents->next) {
1579 struct commit *parent = parents->item;
1580 if (!(parent->object.flags & UNINTERESTING))
1582 mark_tree_uninteresting(parent->tree);
1586 static void mark_edges_uninteresting(struct commit_list *list)
1588 for ( ; list; list = list->next) {
1589 struct commit *commit = list->item;
1591 if (commit->object.flags & UNINTERESTING) {
1592 mark_tree_uninteresting(commit->tree);
1595 mark_edge_parents_uninteresting(commit);
1599 int main(int argc, char **argv)
1601 struct transfer_request *request;
1602 struct transfer_request *next_request;
1604 char **refspec = NULL;
1605 struct remote_lock *ref_lock = NULL;
1606 struct rev_info revs;
1610 setup_git_directory();
1613 remote = xcalloc(sizeof(*remote), 1);
1616 for (i = 1; i < argc; i++, argv++) {
1620 if (!strcmp(arg, "--all")) {
1624 if (!strcmp(arg, "--force")) {
1628 if (!strcmp(arg, "--verbose")) {
1632 usage(http_push_usage);
1636 char *path = strstr(arg, "//");
1638 path = index(path+2, '/');
1640 remote->path_len = strlen(path);
1645 nr_refspec = argc - i;
1650 usage(http_push_usage);
1652 memset(remote_dir_exists, -1, 256);
1656 no_pragma_header = curl_slist_append(no_pragma_header, "Pragma:");
1657 default_headers = curl_slist_append(default_headers, "Range:");
1658 default_headers = curl_slist_append(default_headers, "Destination:");
1659 default_headers = curl_slist_append(default_headers, "If:");
1660 default_headers = curl_slist_append(default_headers,
1661 "Pragma: no-cache");
1663 /* Verify DAV compliance/lock support */
1664 if (!locking_available()) {
1665 fprintf(stderr, "Error: no DAV locking support on remote repo %s\n", remote->url);
1670 /* Get a list of all local and remote heads to validate refspecs */
1672 fprintf(stderr, "Fetching remote heads...\n");
1673 get_dav_remote_heads();
1677 remote_tail = &remote_refs;
1678 if (match_refs(local_refs, remote_refs, &remote_tail,
1679 nr_refspec, refspec, push_all))
1682 fprintf(stderr, "No refs in common and none specified; doing nothing.\n");
1689 for (ref = remote_refs; ref; ref = ref->next) {
1690 char old_hex[60], *new_hex;
1693 if (!memcmp(ref->old_sha1, ref->peer_ref->new_sha1, 20)) {
1694 if (push_verbosely || 1)
1695 fprintf(stderr, "'%s': up-to-date\n", ref->name);
1700 !is_zero_sha1(ref->old_sha1) &&
1702 if (!has_sha1_file(ref->old_sha1) ||
1703 !ref_newer(ref->peer_ref->new_sha1,
1705 /* We do not have the remote ref, or
1706 * we know that the remote ref is not
1707 * an ancestor of what we are trying to
1708 * push. Either way this can be losing
1709 * commits at the remote end and likely
1710 * we were not up to date to begin with.
1712 error("remote '%s' is not a strict "
1713 "subset of local ref '%s'. "
1714 "maybe you are not up-to-date and "
1715 "need to pull first?",
1717 ref->peer_ref->name);
1722 memcpy(ref->new_sha1, ref->peer_ref->new_sha1, 20);
1723 if (is_zero_sha1(ref->new_sha1)) {
1724 error("cannot happen anymore");
1729 strcpy(old_hex, sha1_to_hex(ref->old_sha1));
1730 new_hex = sha1_to_hex(ref->new_sha1);
1732 fprintf(stderr, "updating '%s'", ref->name);
1733 if (strcmp(ref->name, ref->peer_ref->name))
1734 fprintf(stderr, " using '%s'", ref->peer_ref->name);
1735 fprintf(stderr, "\n from %s\n to %s\n", old_hex, new_hex);
1738 /* Lock remote branch ref */
1739 ref_lock = lock_remote(ref->name, LOCK_TIME);
1740 if (ref_lock == NULL) {
1741 fprintf(stderr, "Unable to lock remote branch %s\n",
1747 /* Set up revision info for this refspec */
1748 const char *commit_argv[4];
1749 int commit_argc = 3;
1750 char *new_sha1_hex = strdup(sha1_to_hex(ref->new_sha1));
1751 char *old_sha1_hex = NULL;
1752 commit_argv[1] = "--objects";
1753 commit_argv[2] = new_sha1_hex;
1754 if (!push_all && !is_zero_sha1(ref->old_sha1)) {
1755 old_sha1_hex = xmalloc(42);
1756 sprintf(old_sha1_hex, "^%s",
1757 sha1_to_hex(ref->old_sha1));
1758 commit_argv[3] = old_sha1_hex;
1761 setup_revisions(commit_argc, commit_argv, &revs, NULL);
1765 commit_argv[1] = NULL;
1768 /* Generate a list of objects that need to be pushed */
1770 prepare_revision_walk(&revs);
1771 mark_edges_uninteresting(revs.commits);
1773 get_delta(&revs, ref_lock);
1774 finish_all_active_slots();
1776 /* Push missing objects to remote, this would be a
1777 convenient time to pack them first if appropriate. */
1779 fill_active_slots();
1780 finish_all_active_slots();
1782 /* Update the remote branch if all went well */
1783 if (aborted || !update_remote(ref->new_sha1, ref_lock)) {
1790 fprintf(stderr, " done\n");
1791 unlock_remote(ref_lock);
1798 curl_slist_free_all(no_pragma_header);
1799 curl_slist_free_all(default_headers);
1803 request = request_queue_head;
1804 while (request != NULL) {
1805 next_request = request->next;
1806 release_request(request);
1807 request = next_request;