{"thread":{"id":"18338","subject":"[PATCH][v2] http authentication via prompts (with correct line lengths)","startedAt":"2009-03-17T05:15:12Z","lastAt":"2009-03-18T22:41:36Z","messageCount":5,"participants":["Amos King","Junio C Hamano","Daniel Barkalow"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"108175","messageId":"d8c371a80903162215k4c27762cva650ea64d7850afa@mail.gmail.com","threadId":"18338","inReplyTo":null,"subject":"[PATCH][v2] http authentication via prompts (with correct line lengths)","fromName":"Amos King","fromEmail":"amos.l.king@gmail.com","sentAt":"2009-03-17T05:15:12Z","receivedAt":"2009-03-17T05:15:12Z","isPatch":true,"sender":{"key":"amos.l.king@gmail.com","avatar":"https://gravatar.com/avatar/764a302e2d39acef19662089f068068e8ea0e4313091f66b3c855dfc57950e29?d=mp&s=160"},"body":"Junio,\n\nI'm working with Mike on the http auth stuff, and I was testing out\nyour patch.  I can get it to work for fetch but push is giving me some\ngrief.  Looking through the code I noticed that online 219 of\nhttp-push.c that http_init is being called with NULL instead of a\nremote.  If I pass in the remote then there is no remotre-url.  I've\nbeen digging around and can't find where or when that is being set.\nIt has been a while since I worked with C but I'd love to jump in and\nhelp out here.  Can you point me in the right direction to get the\nremote->url[0] set for the http_auth_init to use?\n\nThanks,\n\n-- \nAmos King\nhttp://dirtyInformation.com\nhttp://github.com/Adkron\n--\nLooking for something to do? Visit http://ImThere.com\n"},{"id":"108180","messageId":"7v8wn4u0ip.fsf@gitster.siamese.dyndns.org","threadId":"18338","inReplyTo":"d8c371a80903162215k4c27762cva650ea64d7850afa@mail.gmail.com","subject":"Re: [PATCH][v2] http authentication via prompts (with correct line lengths)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-03-17T06:27:42Z","receivedAt":"2009-03-17T06:27:42Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Amos King <amos.l.king@gmail.com> writes:\n\n> Junio,\n>\n> I'm working with Mike on the http auth stuff, and I was testing out\n> your patch.  I can get it to work for fetch but push is giving me some\n> grief.  Looking through the code I noticed that online 219 of\n> http-push.c that http_init is being called with NULL instead of a\n> remote.  If I pass in the remote then there is no remotre-url.  I've\n> been digging around and can't find where or when that is being set.\n> It has been a while since I worked with C but I'd love to jump in and\n> help out here.  Can you point me in the right direction to get the\n> remote->url[0] set for the http_auth_init to use?\n\nDaniel is the primary culprit who introduced the transport abstraction,\nand I think he muttered something about his work-in-progress that involves\nin some change in the API.  Perhaps he has some insights here?\n\nNaah.  I forgot that the transport abstraction on the fetch side is much\nmore integrated but curl_transport_push() simply launches http-push.c that\nhas a world on its own.  Worse yet, \"remote\" in http-push.c is not even\nthe \"struct remote\"; it is something private to http-push.c called \"struct\nrepo\".\n\nI am not sure how much work would be involved in converting (or if it is\neven worth to convert) http-push.c to fit better into the transport API,\nbut if that is feasible, it might be a better longer-term solution.\nRight now, builtin-push.c does all the remote inspection and when\nhttp-push is called, the latter gets the information at the lowest level\nonly; the higher level information such as what nickname was used by the\nuser to initiate the \"git push\" process and whether the refspecs came from\nthe command line or from the config are all lost, which is quite sad.\n\nBut as a much lower impact interim solution, I suspect that you can fake a\nminimally usable remote.  The http_push() codepath only cares about\nremote->http_proxy and remote->url settings as far as I can tell, so\nperhaps you can start (with a big warning that the remote you are creating\nis a fake one) by filling the absolute minimum?\n\nThat is, something along these lines (this comes on top of an obvious\npatch that renames existing \"remote\" variable in http-push. to \"repo\").\n\ndiff --git a/http-push.c b/http-push.c\nindex dfbb247..f04ac74 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -2197,6 +2197,7 @@ int main(int argc, char **argv)\n \tint new_refs;\n \tstruct ref *ref;\n \tchar *rewritten_url = NULL;\n+\tstruct remote *remote;\n \n \tgit_extract_argv0_path(argv[0]);\n \n@@ -2258,12 +2259,14 @@ int main(int argc, char **argv)\n \tif (!repo->url)\n \t\tusage(http_push_usage);\n \n+\tremote = remote_get(repo->url);\n+\n \tif (delete_branch && nr_refspec != 1)\n \t\tdie(\"You must specify only one branch name when deleting a remote branch\");\n \n \tmemset(remote_dir_exists, -1, 256);\n \n-\thttp_init(NULL);\n+\thttp_init(remote);\n \n \tno_pragma_header = curl_slist_append(no_pragma_header, \"Pragma:\");\n \n"},{"id":"108181","messageId":"7v4oxstzm3.fsf@gitster.siamese.dyndns.org","threadId":"18338","inReplyTo":"7v8wn4u0ip.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH][v2] http authentication via prompts (with correct line lengths)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-03-17T06:47:16Z","receivedAt":"2009-03-17T06:47:16Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> That is, something along these lines (this comes on top of an obvious\n> patch that renames existing \"remote\" variable in http-push. to \"repo\").\n\nAnd to save you the trouble, here is the \"obvious\" renaming patch, that\napplies on top of 750d930 (http.c: CURLOPT_NETRC_OPTIONAL is not available\nin ancient versions of cURL, 2009-03-12).\n\ndiff --git a/http-push.c b/http-push.c\nindex 30d2d34..dfbb247 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -97,7 +97,7 @@ struct repo\n \tstruct remote_lock *locks;\n };\n \n-static struct repo *remote;\n+static struct repo *repo;\n \n enum transfer_state {\n \tNEED_FETCH,\n@@ -324,7 +324,7 @@ static void start_fetch_loose(struct transfer_request *request)\n \n \tgit_SHA1_Init(&request->c);\n \n-\turl = get_remote_object_url(remote->url, hex, 0);\n+\turl = get_remote_object_url(repo->url, hex, 0);\n \trequest->url = xstrdup(url);\n \n \t/* If a previous temp file is present, process what was already\n@@ -389,7 +389,7 @@ static void start_fetch_loose(struct transfer_request *request)\n \trequest->state = RUN_FETCH_LOOSE;\n \tif (!start_active_slot(slot)) {\n \t\tfprintf(stderr, \"Unable to start GET request\\n\");\n-\t\tremote->can_update_info_refs = 0;\n+\t\trepo->can_update_info_refs = 0;\n \t\trelease_request(request);\n \t}\n }\n@@ -399,7 +399,7 @@ static void start_mkcol(struct transfer_request *request)\n \tchar *hex = sha1_to_hex(request->obj->sha1);\n \tstruct active_request_slot *slot;\n \n-\trequest->url = get_remote_object_url(remote->url, hex, 1);\n+\trequest->url = get_remote_object_url(repo->url, hex, 1);\n \n \tslot = get_active_slot();\n \tslot->callback_func = process_response;\n@@ -434,10 +434,10 @@ static void start_fetch_packed(struct transfer_request *request)\n \tstruct transfer_request *check_request = request_queue_head;\n \tstruct active_request_slot *slot;\n \n-\ttarget = find_sha1_pack(request->obj->sha1, remote->packs);\n+\ttarget = find_sha1_pack(request->obj->sha1, repo->packs);\n \tif (!target) {\n \t\tfprintf(stderr, \"Unable to fetch %s, will not be able to update server info refs\\n\", sha1_to_hex(request->obj->sha1));\n-\t\tremote->can_update_info_refs = 0;\n+\t\trepo->can_update_info_refs = 0;\n \t\trelease_request(request);\n \t\treturn;\n \t}\n@@ -450,9 +450,9 @@ static void start_fetch_packed(struct transfer_request *request)\n \tsnprintf(request->tmpfile, sizeof(request->tmpfile),\n \t\t \"%s.temp\", filename);\n \n-\turl = xmalloc(strlen(remote->url) + 64);\n+\turl = xmalloc(strlen(repo->url) + 64);\n \tsprintf(url, \"%sobjects/pack/pack-%s.pack\",\n-\t\tremote->url, sha1_to_hex(target->sha1));\n+\t\trepo->url, sha1_to_hex(target->sha1));\n \n \t/* Make sure there isn't another open request for this pack */\n \twhile (check_request) {\n@@ -469,7 +469,7 @@ static void start_fetch_packed(struct transfer_request *request)\n \tif (!packfile) {\n \t\tfprintf(stderr, \"Unable to open local file %s for pack\",\n \t\t\trequest->tmpfile);\n-\t\tremote->can_update_info_refs = 0;\n+\t\trepo->can_update_info_refs = 0;\n \t\tfree(url);\n \t\treturn;\n \t}\n@@ -505,7 +505,7 @@ static void start_fetch_packed(struct transfer_request *request)\n \trequest->state = RUN_FETCH_PACKED;\n \tif (!start_active_slot(slot)) {\n \t\tfprintf(stderr, \"Unable to start GET request\\n\");\n-\t\tremote->can_update_info_refs = 0;\n+\t\trepo->can_update_info_refs = 0;\n \t\trelease_request(request);\n \t}\n }\n@@ -554,10 +554,10 @@ static void start_put(struct transfer_request *request)\n \trequest->buffer.buf.len = stream.total_out;\n \n \tstrbuf_addstr(&buf, \"Destination: \");\n-\tappend_remote_object_url(&buf, remote->url, hex, 0);\n+\tappend_remote_object_url(&buf, repo->url, hex, 0);\n \trequest->dest = strbuf_detach(&buf, NULL);\n \n-\tappend_remote_object_url(&buf, remote->url, hex, 0);\n+\tappend_remote_object_url(&buf, repo->url, hex, 0);\n \tstrbuf_add(&buf, request->lock->tmpfile_suffix, 41);\n \trequest->url = strbuf_detach(&buf, NULL);\n \n@@ -648,7 +648,7 @@ static int refresh_lock(struct remote_lock *lock)\n \n static void check_locks(void)\n {\n-\tstruct remote_lock *lock = remote->locks;\n+\tstruct remote_lock *lock = repo->locks;\n \ttime_t current_time = time(NULL);\n \tint time_remaining;\n \n@@ -788,7 +788,7 @@ static void finish_request(struct transfer_request *request)\n \t\tif (request->curl_result != CURLE_OK) {\n \t\t\tfprintf(stderr, \"Unable to get pack file %s\\n%s\",\n \t\t\t\trequest->url, curl_errorstr);\n-\t\t\tremote->can_update_info_refs = 0;\n+\t\t\trepo->can_update_info_refs = 0;\n \t\t} else {\n \t\t\toff_t pack_size = ftell(request->local_stream);\n \n@@ -798,7 +798,7 @@ static void finish_request(struct transfer_request *request)\n \t\t\t\t\t       request->filename)) {\n \t\t\t\ttarget = (struct packed_git *)request->userData;\n \t\t\t\ttarget->pack_size = pack_size;\n-\t\t\t\tlst = &remote->packs;\n+\t\t\t\tlst = &repo->packs;\n \t\t\t\twhile (*lst != target)\n \t\t\t\t\tlst = &((*lst)->next);\n \t\t\t\t*lst = (*lst)->next;\n@@ -806,7 +806,7 @@ static void finish_request(struct transfer_request *request)\n \t\t\t\tif (!verify_pack(target))\n \t\t\t\t\tinstall_packed_git(target);\n \t\t\t\telse\n-\t\t\t\t\tremote->can_update_info_refs = 0;\n+\t\t\t\t\trepo->can_update_info_refs = 0;\n \t\t\t}\n \t\t}\n \t\trelease_request(request);\n@@ -889,7 +889,7 @@ static int add_send_request(struct object *obj, struct remote_lock *lock)\n \t\tget_remote_object_list(obj->sha1[0]);\n \tif (obj->flags & (REMOTE | PUSHING))\n \t\treturn 0;\n-\ttarget = find_sha1_pack(obj->sha1, remote->packs);\n+\ttarget = find_sha1_pack(obj->sha1, repo->packs);\n \tif (target) {\n \t\tobj->flags |= REMOTE;\n \t\treturn 0;\n@@ -930,8 +930,8 @@ static int fetch_index(unsigned char *sha1)\n \tstruct slot_results results;\n \n \t/* Don't use the index if the pack isn't there */\n-\turl = xmalloc(strlen(remote->url) + 64);\n-\tsprintf(url, \"%sobjects/pack/pack-%s.pack\", remote->url, hex);\n+\turl = xmalloc(strlen(repo->url) + 64);\n+\tsprintf(url, \"%sobjects/pack/pack-%s.pack\", repo->url, hex);\n \tslot = get_active_slot();\n \tslot->results = &results;\n \tcurl_easy_setopt(slot->curl, CURLOPT_URL, url);\n@@ -956,7 +956,7 @@ static int fetch_index(unsigned char *sha1)\n \tif (push_verbosely)\n \t\tfprintf(stderr, \"Getting index for pack %s\\n\", hex);\n \n-\tsprintf(url, \"%sobjects/pack/pack-%s.idx\", remote->url, hex);\n+\tsprintf(url, \"%sobjects/pack/pack-%s.idx\", repo->url, hex);\n \n \tfilename = sha1_pack_index_name(sha1);\n \tsnprintf(tmpfile, sizeof(tmpfile), \"%s.temp\", filename);\n@@ -1018,8 +1018,8 @@ static int setup_index(unsigned char *sha1)\n \t\treturn -1;\n \n \tnew_pack = parse_pack_index(sha1);\n-\tnew_pack->next = remote->packs;\n-\tremote->packs = new_pack;\n+\tnew_pack->next = repo->packs;\n+\trepo->packs = new_pack;\n \treturn 0;\n }\n \n@@ -1037,8 +1037,8 @@ static int fetch_indices(void)\n \tif (push_verbosely)\n \t\tfprintf(stderr, \"Getting pack list\\n\");\n \n-\turl = xmalloc(strlen(remote->url) + 20);\n-\tsprintf(url, \"%sobjects/info/packs\", remote->url);\n+\turl = xmalloc(strlen(repo->url) + 20);\n+\tsprintf(url, \"%sobjects/info/packs\", repo->url);\n \n \tslot = get_active_slot();\n \tslot->results = &results;\n@@ -1223,11 +1223,11 @@ static struct remote_lock *lock_remote(const char *path, long timeout)\n \tstruct curl_slist *dav_headers = NULL;\n \tstruct xml_ctx ctx;\n \n-\turl = xmalloc(strlen(remote->url) + strlen(path) + 1);\n-\tsprintf(url, \"%s%s\", remote->url, path);\n+\turl = xmalloc(strlen(repo->url) + strlen(path) + 1);\n+\tsprintf(url, \"%s%s\", repo->url, path);\n \n \t/* Make sure leading directories exist for the remote ref */\n-\tep = strchr(url + strlen(remote->url) + 1, '/');\n+\tep = strchr(url + strlen(repo->url) + 1, '/');\n \twhile (ep) {\n \t\tchar saved_character = ep[1];\n \t\tep[1] = '\\0';\n@@ -1319,8 +1319,8 @@ static struct remote_lock *lock_remote(const char *path, long timeout)\n \t} else {\n \t\tlock->url = url;\n \t\tlock->start_time = time(NULL);\n-\t\tlock->next = remote->locks;\n-\t\tremote->locks = lock;\n+\t\tlock->next = repo->locks;\n+\t\trepo->locks = lock;\n \t}\n \n \treturn lock;\n@@ -1330,7 +1330,7 @@ static int unlock_remote(struct remote_lock *lock)\n {\n \tstruct active_request_slot *slot;\n \tstruct slot_results results;\n-\tstruct remote_lock *prev = remote->locks;\n+\tstruct remote_lock *prev = repo->locks;\n \tstruct curl_slist *dav_headers;\n \tint rc = 0;\n \n@@ -1356,8 +1356,8 @@ static int unlock_remote(struct remote_lock *lock)\n \n \tcurl_slist_free_all(dav_headers);\n \n-\tif (remote->locks == lock) {\n-\t\tremote->locks = lock->next;\n+\tif (repo->locks == lock) {\n+\t\trepo->locks = lock->next;\n \t} else {\n \t\twhile (prev && prev->next != lock)\n \t\t\tprev = prev->next;\n@@ -1375,7 +1375,7 @@ static int unlock_remote(struct remote_lock *lock)\n \n static void remove_locks(void)\n {\n-\tstruct remote_lock *lock = remote->locks;\n+\tstruct remote_lock *lock = repo->locks;\n \n \tfprintf(stderr, \"Removing remote locks...\\n\");\n \twhile (lock) {\n@@ -1457,7 +1457,7 @@ static void handle_remote_ls_ctx(struct xml_ctx *ctx, int tag_closed)\n \t\t\t\t}\n \t\t\t}\n \t\t\tif (path) {\n-\t\t\t\tpath += remote->path_len;\n+\t\t\t\tpath += repo->path_len;\n \t\t\t\tls->dentry_name = xstrdup(path);\n \t\t\t}\n \t\t} else if (!strcmp(ctx->name, DAV_PROPFIND_COLLECTION)) {\n@@ -1480,7 +1480,7 @@ static void remote_ls(const char *path, int flags,\n \t\t      void (*userFunc)(struct remote_ls_ctx *ls),\n \t\t      void *userData)\n {\n-\tchar *url = xmalloc(strlen(remote->url) + strlen(path) + 1);\n+\tchar *url = xmalloc(strlen(repo->url) + strlen(path) + 1);\n \tstruct active_request_slot *slot;\n \tstruct slot_results results;\n \tstruct strbuf in_buffer = STRBUF_INIT;\n@@ -1496,7 +1496,7 @@ static void remote_ls(const char *path, int flags,\n \tls.userData = userData;\n \tls.userFunc = userFunc;\n \n-\tsprintf(url, \"%s%s\", remote->url, path);\n+\tsprintf(url, \"%s%s\", repo->url, path);\n \n \tstrbuf_addf(&out_buffer.buf, PROPFIND_ALL_REQUEST);\n \n@@ -1574,7 +1574,7 @@ static int locking_available(void)\n \tstruct xml_ctx ctx;\n \tint lock_flags = 0;\n \n-\tstrbuf_addf(&out_buffer.buf, PROPFIND_SUPPORTEDLOCK_REQUEST, remote->url);\n+\tstrbuf_addf(&out_buffer.buf, PROPFIND_SUPPORTEDLOCK_REQUEST, repo->url);\n \n \tdav_headers = curl_slist_append(dav_headers, \"Depth: 0\");\n \tdav_headers = curl_slist_append(dav_headers, \"Content-Type: text/xml\");\n@@ -1586,7 +1586,7 @@ static int locking_available(void)\n \tcurl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, fread_buffer);\n \tcurl_easy_setopt(slot->curl, CURLOPT_FILE, &in_buffer);\n \tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_URL, remote->url);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_URL, repo->url);\n \tcurl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 1);\n \tcurl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_PROPFIND);\n \tcurl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, dav_headers);\n@@ -1617,15 +1617,15 @@ static int locking_available(void)\n \t\t\tXML_ParserFree(parser);\n \t\t\tif (!lock_flags)\n \t\t\t\terror(\"Error: no DAV locking support on %s\",\n-\t\t\t\t      remote->url);\n+\t\t\t\t      repo->url);\n \n \t\t} else {\n \t\t\terror(\"Cannot access URL %s, return code %d\",\n-\t\t\t      remote->url, results.curl_result);\n+\t\t\t      repo->url, results.curl_result);\n \t\t\tlock_flags = 0;\n \t\t}\n \t} else {\n-\t\terror(\"Unable to start PROPFIND request on %s\", remote->url);\n+\t\terror(\"Unable to start PROPFIND request on %s\", repo->url);\n \t}\n \n \tstrbuf_release(&out_buffer.buf);\n@@ -1814,10 +1814,10 @@ static void one_remote_ref(char *refname)\n \n \tref = alloc_ref(refname);\n \n-\tif (http_fetch_ref(remote->url, ref) != 0) {\n+\tif (http_fetch_ref(repo->url, ref) != 0) {\n \t\tfprintf(stderr,\n \t\t\t\"Unable to fetch ref %s from %s\\n\",\n-\t\t\trefname, remote->url);\n+\t\t\trefname, repo->url);\n \t\tfree(ref);\n \t\treturn;\n \t}\n@@ -1826,7 +1826,7 @@ static void one_remote_ref(char *refname)\n \t * Fetch a copy of the object if it doesn't exist locally - it\n \t * may be required for updating server info later.\n \t */\n-\tif (remote->can_update_info_refs && !has_sha1_file(ref->old_sha1)) {\n+\tif (repo->can_update_info_refs && !has_sha1_file(ref->old_sha1)) {\n \t\tobj = lookup_unknown_object(ref->old_sha1);\n \t\tif (obj) {\n \t\t\tfprintf(stderr,\t\"  fetch %s for %s\\n\",\n@@ -1921,10 +1921,10 @@ static void add_remote_info_ref(struct remote_ls_ctx *ls)\n \n \tref = alloc_ref(ls->dentry_name);\n \n-\tif (http_fetch_ref(remote->url, ref) != 0) {\n+\tif (http_fetch_ref(repo->url, ref) != 0) {\n \t\tfprintf(stderr,\n \t\t\t\"Unable to fetch ref %s from %s\\n\",\n-\t\t\tls->dentry_name, remote->url);\n+\t\t\tls->dentry_name, repo->url);\n \t\taborted = 1;\n \t\tfree(ref);\n \t\treturn;\n@@ -1999,12 +1999,12 @@ static void update_remote_info_refs(struct remote_lock *lock)\n \n static int remote_exists(const char *path)\n {\n-\tchar *url = xmalloc(strlen(remote->url) + strlen(path) + 1);\n+\tchar *url = xmalloc(strlen(repo->url) + strlen(path) + 1);\n \tstruct active_request_slot *slot;\n \tstruct slot_results results;\n \tint ret = -1;\n \n-\tsprintf(url, \"%s%s\", remote->url, path);\n+\tsprintf(url, \"%s%s\", repo->url, path);\n \n \tslot = get_active_slot();\n \tslot->results = &results;\n@@ -2034,8 +2034,8 @@ static void fetch_symref(const char *path, char **symref, unsigned char *sha1)\n \tstruct active_request_slot *slot;\n \tstruct slot_results results;\n \n-\turl = xmalloc(strlen(remote->url) + strlen(path) + 1);\n-\tsprintf(url, \"%s%s\", remote->url, path);\n+\turl = xmalloc(strlen(repo->url) + strlen(path) + 1);\n+\tsprintf(url, \"%s%s\", repo->url, path);\n \n \tslot = get_active_slot();\n \tslot->results = &results;\n@@ -2150,7 +2150,7 @@ static int delete_remote_branch(char *pattern, int force)\n \t\t\t\t     \"of your current HEAD.\\n\"\n \t\t\t\t     \"If you are sure you want to delete it,\"\n \t\t\t\t     \" run:\\n\\t'git http-push -D %s %s'\",\n-\t\t\t\t     remote_ref->name, remote->url, pattern);\n+\t\t\t\t     remote_ref->name, repo->url, pattern);\n \t\t}\n \t}\n \n@@ -2158,8 +2158,8 @@ static int delete_remote_branch(char *pattern, int force)\n \tfprintf(stderr, \"Removing remote branch '%s'\\n\", remote_ref->name);\n \tif (dry_run)\n \t\treturn 0;\n-\turl = xmalloc(strlen(remote->url) + strlen(remote_ref->name) + 1);\n-\tsprintf(url, \"%s%s\", remote->url, remote_ref->name);\n+\turl = xmalloc(strlen(repo->url) + strlen(remote_ref->name) + 1);\n+\tsprintf(url, \"%s%s\", repo->url, remote_ref->name);\n \tslot = get_active_slot();\n \tslot->results = &results;\n \tcurl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);\n@@ -2202,7 +2202,7 @@ int main(int argc, char **argv)\n \n \tsetup_git_directory();\n \n-\tremote = xcalloc(sizeof(*remote), 1);\n+\trepo = xcalloc(sizeof(*repo), 1);\n \n \targv++;\n \tfor (i = 1; i < argc; i++, argv++) {\n@@ -2235,14 +2235,14 @@ int main(int argc, char **argv)\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t}\n-\t\tif (!remote->url) {\n+\t\tif (!repo->url) {\n \t\t\tchar *path = strstr(arg, \"//\");\n-\t\t\tremote->url = arg;\n-\t\t\tremote->path_len = strlen(arg);\n+\t\t\trepo->url = arg;\n+\t\t\trepo->path_len = strlen(arg);\n \t\t\tif (path) {\n-\t\t\t\tremote->path = strchr(path+2, '/');\n-\t\t\t\tif (remote->path)\n-\t\t\t\t\tremote->path_len = strlen(remote->path);\n+\t\t\t\trepo->path = strchr(path+2, '/');\n+\t\t\t\tif (repo->path)\n+\t\t\t\t\trepo->path_len = strlen(repo->path);\n \t\t\t}\n \t\t\tcontinue;\n \t\t}\n@@ -2255,7 +2255,7 @@ int main(int argc, char **argv)\n \tdie(\"git-push is not available for http/https repository when not compiled with USE_CURL_MULTI\");\n #endif\n \n-\tif (!remote->url)\n+\tif (!repo->url)\n \t\tusage(http_push_usage);\n \n \tif (delete_branch && nr_refspec != 1)\n@@ -2267,13 +2267,13 @@ int main(int argc, char **argv)\n \n \tno_pragma_header = curl_slist_append(no_pragma_header, \"Pragma:\");\n \n-\tif (remote->url && remote->url[strlen(remote->url)-1] != '/') {\n-\t\trewritten_url = xmalloc(strlen(remote->url)+2);\n-\t\tstrcpy(rewritten_url, remote->url);\n+\tif (repo->url && repo->url[strlen(repo->url)-1] != '/') {\n+\t\trewritten_url = xmalloc(strlen(repo->url)+2);\n+\t\tstrcpy(rewritten_url, repo->url);\n \t\tstrcat(rewritten_url, \"/\");\n-\t\tremote->path = rewritten_url + (remote->path - remote->url);\n-\t\tremote->path_len++;\n-\t\tremote->url = rewritten_url;\n+\t\trepo->path = rewritten_url + (repo->path - repo->url);\n+\t\trepo->path_len++;\n+\t\trepo->url = rewritten_url;\n \t}\n \n \t/* Verify DAV compliance/lock support */\n@@ -2285,20 +2285,20 @@ int main(int argc, char **argv)\n \tsigchain_push_common(remove_locks_on_signal);\n \n \t/* Check whether the remote has server info files */\n-\tremote->can_update_info_refs = 0;\n-\tremote->has_info_refs = remote_exists(\"info/refs\");\n-\tremote->has_info_packs = remote_exists(\"objects/info/packs\");\n-\tif (remote->has_info_refs) {\n+\trepo->can_update_info_refs = 0;\n+\trepo->has_info_refs = remote_exists(\"info/refs\");\n+\trepo->has_info_packs = remote_exists(\"objects/info/packs\");\n+\tif (repo->has_info_refs) {\n \t\tinfo_ref_lock = lock_remote(\"info/refs\", LOCK_TIME);\n \t\tif (info_ref_lock)\n-\t\t\tremote->can_update_info_refs = 1;\n+\t\t\trepo->can_update_info_refs = 1;\n \t\telse {\n \t\t\tfprintf(stderr, \"Error: cannot lock existing info/refs\\n\");\n \t\t\trc = 1;\n \t\t\tgoto cleanup;\n \t\t}\n \t}\n-\tif (remote->has_info_packs)\n+\tif (repo->has_info_packs)\n \t\tfetch_indices();\n \n \t/* Get a list of all local and remote heads to validate refspecs */\n@@ -2456,8 +2456,8 @@ int main(int argc, char **argv)\n \t}\n \n \t/* Update remote server info if appropriate */\n-\tif (remote->has_info_refs && new_refs) {\n-\t\tif (info_ref_lock && remote->can_update_info_refs) {\n+\tif (repo->has_info_refs && new_refs) {\n+\t\tif (info_ref_lock && repo->can_update_info_refs) {\n \t\t\tfprintf(stderr, \"Updating remote server info\\n\");\n \t\t\tif (!dry_run)\n \t\t\t\tupdate_remote_info_refs(info_ref_lock);\n@@ -2470,7 +2470,7 @@ int main(int argc, char **argv)\n \tfree(rewritten_url);\n \tif (info_ref_lock)\n \t\tunlock_remote(info_ref_lock);\n-\tfree(remote);\n+\tfree(repo);\n \n \tcurl_slist_free_all(no_pragma_header);\n \n"},{"id":"108250","messageId":"alpine.LNX.1.00.0903171206490.19665@iabervon.org","threadId":"18338","inReplyTo":"7v8wn4u0ip.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH][v2] http authentication via prompts (with correct line lengths)","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2009-03-17T16:24:01Z","receivedAt":"2009-03-17T16:24:01Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Mon, 16 Mar 2009, Junio C Hamano wrote:\n\n> Amos King <amos.l.king@gmail.com> writes:\n> \n> > Junio,\n> >\n> > I'm working with Mike on the http auth stuff, and I was testing out\n> > your patch.  I can get it to work for fetch but push is giving me some\n> > grief.  Looking through the code I noticed that online 219 of\n> > http-push.c that http_init is being called with NULL instead of a\n> > remote.  If I pass in the remote then there is no remotre-url.  I've\n> > been digging around and can't find where or when that is being set.\n> > It has been a while since I worked with C but I'd love to jump in and\n> > help out here.  Can you point me in the right direction to get the\n> > remote->url[0] set for the http_auth_init to use?\n> \n> Daniel is the primary culprit who introduced the transport abstraction,\n> and I think he muttered something about his work-in-progress that involves\n> in some change in the API.  Perhaps he has some insights here?\n> \n> Naah.  I forgot that the transport abstraction on the fetch side is much\n> more integrated but curl_transport_push() simply launches http-push.c that\n> has a world on its own.  Worse yet, \"remote\" in http-push.c is not even\n> the \"struct remote\"; it is something private to http-push.c called \"struct\n> repo\".\n>\n> I am not sure how much work would be involved in converting (or if it is\n> even worth to convert) http-push.c to fit better into the transport API,\n> but if that is feasible, it might be a better longer-term solution.\n\nI think it would be a good thing to do. With the new transport push \nmethod, it could even get support for updating the tracking refs that \ntrack the refs you changed, since I broke that out of the git-native \nprotocol code and into the transport code.\n\nMy guess is that converting http-push to be called in-process would \nactually be pretty easy, because the two sides don't look at the same data \ncurrently. (Some things were tricky with fetch, because the same process \nsometimes wants to do fetches multiple times, for getting tags; this isn't \nas big a deal.)\n\nI think it should just be a matter of breaking http-push's main() into a \nfunction that deals with the http-push command line and a function that \ndoes the work, setting up a header file like send-pack.h, and changing \ntransport.c to just call the function.\n\n> Right now, builtin-push.c does all the remote inspection and when\n> http-push is called, the latter gets the information at the lowest level\n> only; the higher level information such as what nickname was used by the\n> user to initiate the \"git push\" process and whether the refspecs came from\n> the command line or from the config are all lost, which is quite sad.\n\nWhat I did short-term for the send-pack version was introduce an optional \ncommand line argument, \"--remote\", that names the remote used, so the \nother program could get the configuration as well. It's a pretty easy \nstep, but I don't think it's too worthwhile in this case.\n\n> But as a much lower impact interim solution, I suspect that you can fake a\n> minimally usable remote.  The http_push() codepath only cares about\n> remote->http_proxy and remote->url settings as far as I can tell, so\n> perhaps you can start (with a big warning that the remote you are creating\n> is a fake one) by filling the absolute minimum?\n> \n> That is, something along these lines (this comes on top of an obvious\n> patch that renames existing \"remote\" variable in http-push. to \"repo\").\n> \n> diff --git a/http-push.c b/http-push.c\n> index dfbb247..f04ac74 100644\n> --- a/http-push.c\n> +++ b/http-push.c\n> @@ -2197,6 +2197,7 @@ int main(int argc, char **argv)\n>  \tint new_refs;\n>  \tstruct ref *ref;\n>  \tchar *rewritten_url = NULL;\n> +\tstruct remote *remote;\n>  \n>  \tgit_extract_argv0_path(argv[0]);\n>  \n> @@ -2258,12 +2259,14 @@ int main(int argc, char **argv)\n>  \tif (!repo->url)\n>  \t\tusage(http_push_usage);\n>  \n> +\tremote = remote_get(repo->url);\n> +\n>  \tif (delete_branch && nr_refspec != 1)\n>  \t\tdie(\"You must specify only one branch name when deleting a remote branch\");\n>  \n>  \tmemset(remote_dir_exists, -1, 256);\n>  \n> -\thttp_init(NULL);\n> +\thttp_init(remote);\n>  \n>  \tno_pragma_header = curl_slist_append(no_pragma_header, \"Pragma:\");\n\nThis should work, although it obviously won't figure out the proxy for the \nconfiguration for the remote that was actually used.\n\n\t-Daniel\n*This .sig left intentionally blank*\n"},{"id":"108455","messageId":"d8c371a80903181541g71696ae4xe65b7ae2ac3f4e97@mail.gmail.com","threadId":"18338","inReplyTo":"alpine.LNX.1.00.0903171206490.19665@iabervon.org","subject":"Re: [PATCH][v2] http authentication via prompts (with correct line lengths)","fromName":"Amos King","fromEmail":"amos.l.king@gmail.com","sentAt":"2009-03-18T22:41:36Z","receivedAt":"2009-03-18T22:41:36Z","isPatch":true,"sender":{"key":"amos.l.king@gmail.com","avatar":"https://gravatar.com/avatar/764a302e2d39acef19662089f068068e8ea0e4313091f66b3c855dfc57950e29?d=mp&s=160"},"body":"I got push working.  I wanted to ask one thing before I submit.  I\nknow that it is nice to keep changes local.  There is a method in\nremote.c called add_url, but it is not exposed.  Right now to keep the\nchanges local I moved the internals of that method inline, but is it\nok for me to expose that method instead?\n\nAmos\n\nPS - Junio sorry for the double send.  I didn't notice that we weren't\non the list.\n\nOn Tue, Mar 17, 2009 at 11:24 AM, Daniel Barkalow <barkalow@iabervon.org> wrote:\n> On Mon, 16 Mar 2009, Junio C Hamano wrote:\n>\n>> Amos King <amos.l.king@gmail.com> writes:\n>>\n>> > Junio,\n>> >\n>> > I'm working with Mike on the http auth stuff, and I was testing out\n>> > your patch.  I can get it to work for fetch but push is giving me some\n>> > grief.  Looking through the code I noticed that online 219 of\n>> > http-push.c that http_init is being called with NULL instead of a\n>> > remote.  If I pass in the remote then there is no remotre-url.  I've\n>> > been digging around and can't find where or when that is being set.\n>> > It has been a while since I worked with C but I'd love to jump in and\n>> > help out here.  Can you point me in the right direction to get the\n>> > remote->url[0] set for the http_auth_init to use?\n>>\n>> Daniel is the primary culprit who introduced the transport abstraction,\n>> and I think he muttered something about his work-in-progress that involves\n>> in some change in the API.  Perhaps he has some insights here?\n>>\n>> Naah.  I forgot that the transport abstraction on the fetch side is much\n>> more integrated but curl_transport_push() simply launches http-push.c that\n>> has a world on its own.  Worse yet, \"remote\" in http-push.c is not even\n>> the \"struct remote\"; it is something private to http-push.c called \"struct\n>> repo\".\n>>\n>> I am not sure how much work would be involved in converting (or if it is\n>> even worth to convert) http-push.c to fit better into the transport API,\n>> but if that is feasible, it might be a better longer-term solution.\n>\n> I think it would be a good thing to do. With the new transport push\n> method, it could even get support for updating the tracking refs that\n> track the refs you changed, since I broke that out of the git-native\n> protocol code and into the transport code.\n>\n> My guess is that converting http-push to be called in-process would\n> actually be pretty easy, because the two sides don't look at the same data\n> currently. (Some things were tricky with fetch, because the same process\n> sometimes wants to do fetches multiple times, for getting tags; this isn't\n> as big a deal.)\n>\n> I think it should just be a matter of breaking http-push's main() into a\n> function that deals with the http-push command line and a function that\n> does the work, setting up a header file like send-pack.h, and changing\n> transport.c to just call the function.\n>\n>> Right now, builtin-push.c does all the remote inspection and when\n>> http-push is called, the latter gets the information at the lowest level\n>> only; the higher level information such as what nickname was used by the\n>> user to initiate the \"git push\" process and whether the refspecs came from\n>> the command line or from the config are all lost, which is quite sad.\n>\n> What I did short-term for the send-pack version was introduce an optional\n> command line argument, \"--remote\", that names the remote used, so the\n> other program could get the configuration as well. It's a pretty easy\n> step, but I don't think it's too worthwhile in this case.\n>\n>> But as a much lower impact interim solution, I suspect that you can fake a\n>> minimally usable remote.  The http_push() codepath only cares about\n>> remote->http_proxy and remote->url settings as far as I can tell, so\n>> perhaps you can start (with a big warning that the remote you are creating\n>> is a fake one) by filling the absolute minimum?\n>>\n>> That is, something along these lines (this comes on top of an obvious\n>> patch that renames existing \"remote\" variable in http-push. to \"repo\").\n>>\n>> diff --git a/http-push.c b/http-push.c\n>> index dfbb247..f04ac74 100644\n>> --- a/http-push.c\n>> +++ b/http-push.c\n>> @@ -2197,6 +2197,7 @@ int main(int argc, char **argv)\n>>       int new_refs;\n>>       struct ref *ref;\n>>       char *rewritten_url = NULL;\n>> +     struct remote *remote;\n>>\n>>       git_extract_argv0_path(argv[0]);\n>>\n>> @@ -2258,12 +2259,14 @@ int main(int argc, char **argv)\n>>       if (!repo->url)\n>>               usage(http_push_usage);\n>>\n>> +     remote = remote_get(repo->url);\n>> +\n>>       if (delete_branch && nr_refspec != 1)\n>>               die(\"You must specify only one branch name when deleting a remote branch\");\n>>\n>>       memset(remote_dir_exists, -1, 256);\n>>\n>> -     http_init(NULL);\n>> +     http_init(remote);\n>>\n>>       no_pragma_header = curl_slist_append(no_pragma_header, \"Pragma:\");\n>\n> This should work, although it obviously won't figure out the proxy for the\n> configuration for the remote that was actually used.\n>\n>        -Daniel\n> *This .sig left intentionally blank*\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n>\n\n\n\n-- \nAmos King\nhttp://dirtyInformation.com\nhttp://github.com/Adkron\n--\nLooking for something to do? Visit http://ImThere.com\n"}]}