From: Junio C Hamano Date: Sun, 2 Mar 2008 23:11:26 +0000 (-0800) Subject: Merge branch 'mh/maint-http-proxy-fix' X-Git-Tag: v1.5.5-rc0~89 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/7ab9f8f8b12853d4cb0e45031bf2ee9a0517ad22?hp=-c Merge branch 'mh/maint-http-proxy-fix' * mh/maint-http-proxy-fix: Set proxy override with http_init() --- 7ab9f8f8b12853d4cb0e45031bf2ee9a0517ad22 diff --combined builtin-http-fetch.c index 299093ff91,48128c610e..b1f33891c3 --- a/builtin-http-fetch.c +++ b/builtin-http-fetch.c @@@ -59,7 -59,7 +59,7 @@@ int cmd_http_fetch(int argc, const cha url = rewritten_url; } - walker = get_http_walker(url); + walker = get_http_walker(url, NULL); walker->get_tree = get_tree; walker->get_history = get_history; walker->get_all = get_all; @@@ -80,7 -80,8 +80,7 @@@ walker_free(walker); - if (rewritten_url) - free(rewritten_url); + free(rewritten_url); return rc; } diff --combined http-push.c index 5bc77361f9,869c01c75b..5b230380cc --- a/http-push.c +++ b/http-push.c @@@ -664,7 -664,8 +664,7 @@@ static void release_request(struct tran close(request->local_fileno); if (request->local_stream) fclose(request->local_stream); - if (request->url != NULL) - free(request->url); + free(request->url); free(request); } @@@ -1282,8 -1283,10 +1282,8 @@@ static struct remote_lock *lock_remote( strbuf_release(&in_buffer); if (lock->token == NULL || lock->timeout <= 0) { - if (lock->token != NULL) - free(lock->token); - if (lock->owner != NULL) - free(lock->owner); + free(lock->token); + free(lock->owner); free(url); free(lock); lock = NULL; @@@ -1341,7 -1344,8 +1341,7 @@@ static int unlock_remote(struct remote_ prev->next = prev->next->next; } - if (lock->owner != NULL) - free(lock->owner); + free(lock->owner); free(lock->url); free(lock->token); free(lock); @@@ -1630,19 -1634,12 +1630,19 @@@ static struct object_list **process_tre init_tree_desc(&desc, tree->buffer, tree->size); - while (tree_entry(&desc, &entry)) { - if (S_ISDIR(entry.mode)) + while (tree_entry(&desc, &entry)) + switch (object_type(entry.mode)) { + case OBJ_TREE: p = process_tree(lookup_tree(entry.sha1), p, &me, name); - else + break; + case OBJ_BLOB: p = process_blob(lookup_blob(entry.sha1), p, &me, name); - } + break; + default: + /* Subproject commit - not in this repository */ + break; + } + free(tree->buffer); tree->buffer = NULL; return p; @@@ -2031,7 -2028,8 +2031,7 @@@ static void fetch_symref(const char *pa } free(url); - if (*symref != NULL) - free(*symref); + free(*symref); *symref = NULL; hashclr(sha1); @@@ -2133,8 -2131,6 +2133,8 @@@ static int delete_remote_branch(char *p /* Send delete request */ fprintf(stderr, "Removing remote branch '%s'\n", remote_ref->name); + if (dry_run) + return 0; url = xmalloc(strlen(remote->url) + strlen(remote_ref->name) + 1); sprintf(url, "%s%s", remote->url, remote_ref->name); slot = get_active_slot(); @@@ -2237,7 -2233,7 +2237,7 @@@ int main(int argc, char **argv memset(remote_dir_exists, -1, 256); - http_init(); + http_init(NULL); no_pragma_header = curl_slist_append(no_pragma_header, "Pragma:"); @@@ -2308,16 -2304,6 +2308,16 @@@ if (!ref->peer_ref) continue; + + if (is_zero_sha1(ref->peer_ref->new_sha1)) { + if (delete_remote_branch(ref->name, 1) == -1) { + error("Could not remove %s", ref->name); + rc = -4; + } + new_refs++; + continue; + } + if (!hashcmp(ref->old_sha1, ref->peer_ref->new_sha1)) { if (push_verbosely || 1) fprintf(stderr, "'%s': up-to-date\n", ref->name); @@@ -2349,6 -2335,11 +2349,6 @@@ } } hashcpy(ref->new_sha1, ref->peer_ref->new_sha1); - if (is_zero_sha1(ref->new_sha1)) { - error("cannot happen anymore"); - rc = -3; - continue; - } new_refs++; strcpy(old_hex, sha1_to_hex(ref->old_sha1)); new_hex = sha1_to_hex(ref->new_sha1); @@@ -2392,8 -2383,7 +2392,8 @@@ /* Generate a list of objects that need to be pushed */ pushing = 0; - prepare_revision_walk(&revs); + if (prepare_revision_walk(&revs)) + die("revision walk setup failed"); mark_edges_uninteresting(revs.commits); objects_to_send = get_delta(&revs, ref_lock); finish_all_active_slots(); @@@ -2408,17 -2398,15 +2408,17 @@@ fill_active_slots(); add_fill_function(NULL, fill_active_slot); #endif - finish_all_active_slots(); + do { + finish_all_active_slots(); +#ifdef USE_CURL_MULTI + fill_active_slots(); +#endif + } while (request_queue_head && !aborted); /* Update the remote branch if all went well */ - if (aborted || !update_remote(ref->new_sha1, ref_lock)) { + if (aborted || !update_remote(ref->new_sha1, ref_lock)) rc = 1; - goto unlock; - } - unlock: if (!rc) fprintf(stderr, " done\n"); unlock_remote(ref_lock); @@@ -2437,7 -2425,8 +2437,7 @@@ } cleanup: - if (rewritten_url) - free(rewritten_url); + free(rewritten_url); if (info_ref_lock) unlock_remote(info_ref_lock); free(remote); diff --combined transport.c index 0a5cf0a9c2,97c59dce60..166c1d1d46 --- a/transport.c +++ b/transport.c @@@ -442,7 -442,8 +442,8 @@@ static struct ref *get_refs_via_curl(st struct ref *last_ref = NULL; if (!transport->data) - transport->data = get_http_walker(transport->url); + transport->data = get_http_walker(transport->url, + transport->remote); refs_url = xmalloc(strlen(transport->url) + 11); sprintf(refs_url, "%s/info/refs", transport->url); @@@ -453,9 -454,6 +454,6 @@@ curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer); curl_easy_setopt(slot->curl, CURLOPT_URL, refs_url); curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, NULL); - if (transport->remote->http_proxy) - curl_easy_setopt(slot->curl, CURLOPT_PROXY, - transport->remote->http_proxy); if (start_active_slot(slot)) { run_active_slot(slot); @@@ -509,7 -507,8 +507,8 @@@ static int fetch_objs_via_curl(struct t int nr_objs, struct ref **to_fetch) { if (!transport->data) - transport->data = get_http_walker(transport->url); + transport->data = get_http_walker(transport->url, + transport->remote); return fetch_objs_via_walker(transport, nr_objs, to_fetch); } @@@ -562,8 -561,6 +561,8 @@@ struct git_transport_data unsigned thin : 1; unsigned keep : 1; int depth; + struct child_process *conn; + int fd[2]; const char *uploadpack; const char *receivepack; }; @@@ -594,20 -591,20 +593,20 @@@ static int set_git_option(struct transp return 1; } +static int connect_setup(struct transport *transport) +{ + struct git_transport_data *data = transport->data; + data->conn = git_connect(data->fd, transport->url, data->uploadpack, 0); + return 0; +} + static struct ref *get_refs_via_connect(struct transport *transport) { struct git_transport_data *data = transport->data; struct ref *refs; - int fd[2]; - char *dest = xstrdup(transport->url); - struct child_process *conn = git_connect(fd, dest, data->uploadpack, 0); - - get_remote_heads(fd[0], &refs, 0, NULL, 0); - packet_flush(fd[1]); - - finish_connect(conn); - free(dest); + connect_setup(transport); + get_remote_heads(data->fd[0], &refs, 0, NULL, 0); return refs; } @@@ -618,11 -615,10 +617,11 @@@ static int fetch_refs_via_pack(struct t struct git_transport_data *data = transport->data; char **heads = xmalloc(nr_heads * sizeof(*heads)); char **origh = xmalloc(nr_heads * sizeof(*origh)); - struct ref *refs; + const struct ref *refs; char *dest = xstrdup(transport->url); struct fetch_pack_args args; int i; + struct ref *refs_tmp = NULL; memset(&args, 0, sizeof(args)); args.uploadpack = data->uploadpack; @@@ -634,27 -630,13 +633,27 @@@ for (i = 0; i < nr_heads; i++) origh[i] = heads[i] = xstrdup(to_fetch[i]->name); - refs = fetch_pack(&args, dest, nr_heads, heads, &transport->pack_lockfile); + + if (!data->conn) { + connect_setup(transport); + get_remote_heads(data->fd[0], &refs_tmp, 0, NULL, 0); + } + + refs = fetch_pack(&args, data->fd, data->conn, + refs_tmp ? refs_tmp : transport->remote_refs, + dest, nr_heads, heads, &transport->pack_lockfile); + close(data->fd[0]); + close(data->fd[1]); + if (finish_connect(data->conn)) + refs = NULL; + data->conn = NULL; + + free_refs(refs_tmp); for (i = 0; i < nr_heads; i++) free(origh[i]); free(origh); free(heads); - free_refs(refs); free(dest); return (refs ? 0 : -1); } @@@ -677,15 -659,7 +676,15 @@@ static int git_transport_push(struct tr static int disconnect_git(struct transport *transport) { - free(transport->data); + struct git_transport_data *data = transport->data; + if (data->conn) { + packet_flush(data->fd[1]); + close(data->fd[0]); + close(data->fd[1]); + finish_connect(data->conn); + } + + free(data); return 0; } @@@ -745,7 -719,6 +744,7 @@@ struct transport *transport_get(struct ret->disconnect = disconnect_git; data->thin = 1; + data->conn = NULL; data->uploadpack = "git-upload-pack"; if (remote && remote->uploadpack) data->uploadpack = remote->uploadpack;