{"thread":{"id":"20383","subject":"[PATCH 02/13] Use an external program to implement fetching with curl","startedAt":"2009-08-05T05:01:56Z","lastAt":"2009-08-07T19:19:07Z","messageCount":7,"participants":["Daniel Barkalow","Johannes Schindelin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":13},"messages":[{"id":"119563","messageId":"alpine.LNX.2.00.0908050053580.2147@iabervon.org","threadId":"20383","inReplyTo":null,"subject":"[PATCH 02/13] Use an external program to implement fetching with curl","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2009-08-05T05:01:56Z","receivedAt":"2009-08-05T05:01:56Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"Use the transport native helper mechanism to fetch by http (and ftp, etc).\n\nSigned-off-by: Daniel Barkalow <barkalow@iabervon.org>\n---\n Makefile      |    5 ++\n remote-curl.c |  139 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n transport.c   |  136 +-------------------------------------------------------\n 3 files changed, 145 insertions(+), 135 deletions(-)\n create mode 100644 remote-curl.c\n\ndiff --git a/Makefile b/Makefile\nindex 504646a..35117fc 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -981,6 +981,7 @@ else\n \t\tCURL_LIBCURL = -lcurl\n \tendif\n \tBUILTIN_OBJS += builtin-http-fetch.o\n+\tPROGRAMS += git-remote-http$X git-remote-https$X git-remote-ftp$X git-http-fetch$X\n \tEXTLIBS += $(CURL_LIBCURL)\n \tLIB_OBJS += http.o http-walker.o\n \tcurl_check := $(shell (echo 070908; curl-config --vernum) | sort -r | sed -ne 2p)\n@@ -1491,6 +1492,10 @@ git-http-push$X: revision.o http.o http-push.o $(GITLIBS)\n \t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n \t\t$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)\n \n+git-remote-http$X git-remote-https$X git-remote-ftp$X: remote-curl.o http.o http-walker.o $(GITLIBS)\n+\t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n+\t\t$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)\n+\n $(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)\n $(patsubst git-%$X,%.o,$(PROGRAMS)) git.o: $(LIB_H) $(wildcard */*.h)\n builtin-revert.o wt-status.o: wt-status.h\ndiff --git a/remote-curl.c b/remote-curl.c\nnew file mode 100644\nindex 0000000..ad6a163\n--- /dev/null\n+++ b/remote-curl.c\n@@ -0,0 +1,139 @@\n+#include \"cache.h\"\n+#include \"remote.h\"\n+#include \"strbuf.h\"\n+#include \"walker.h\"\n+#include \"http.h\"\n+\n+static struct ref *get_refs(struct walker *walker, const char *url)\n+{\n+\tstruct strbuf buffer = STRBUF_INIT;\n+\tchar *data, *start, *mid;\n+\tchar *ref_name;\n+\tchar *refs_url;\n+\tint i = 0;\n+\tint http_ret;\n+\n+\tstruct ref *refs = NULL;\n+\tstruct ref *ref = NULL;\n+\tstruct ref *last_ref = NULL;\n+\n+\trefs_url = xmalloc(strlen(url) + 11);\n+\tsprintf(refs_url, \"%s/info/refs\", url);\n+\n+\thttp_ret = http_get_strbuf(refs_url, &buffer, HTTP_NO_CACHE);\n+\tswitch (http_ret) {\n+\tcase HTTP_OK:\n+\t\tbreak;\n+\tcase HTTP_MISSING_TARGET:\n+\t\tdie(\"%s not found: did you run git update-server-info on the\"\n+\t\t    \" server?\", refs_url);\n+\tdefault:\n+\t\thttp_error(refs_url, http_ret);\n+\t\tdie(\"HTTP request failed\");\n+\t}\n+\n+\tdata = buffer.buf;\n+\tstart = NULL;\n+\tmid = data;\n+\twhile (i < buffer.len) {\n+\t\tif (!start) {\n+\t\t\tstart = &data[i];\n+\t\t}\n+\t\tif (data[i] == '\\t')\n+\t\t\tmid = &data[i];\n+\t\tif (data[i] == '\\n') {\n+\t\t\tdata[i] = 0;\n+\t\t\tref_name = mid + 1;\n+\t\t\tref = xmalloc(sizeof(struct ref) +\n+\t\t\t\t      strlen(ref_name) + 1);\n+\t\t\tmemset(ref, 0, sizeof(struct ref));\n+\t\t\tstrcpy(ref->name, ref_name);\n+\t\t\tget_sha1_hex(start, ref->old_sha1);\n+\t\t\tif (!refs)\n+\t\t\t\trefs = ref;\n+\t\t\tif (last_ref)\n+\t\t\t\tlast_ref->next = ref;\n+\t\t\tlast_ref = ref;\n+\t\t\tstart = NULL;\n+\t\t}\n+\t\ti++;\n+\t}\n+\n+\tstrbuf_release(&buffer);\n+\n+\tref = alloc_ref(\"HEAD\");\n+\tif (!walker->fetch_ref(walker, ref) &&\n+\t    !resolve_remote_symref(ref, refs)) {\n+\t\tref->next = refs;\n+\t\trefs = ref;\n+\t} else {\n+\t\tfree(ref);\n+\t}\n+\n+\tstrbuf_release(&buffer);\n+\tfree(refs_url);\n+\treturn refs;\n+}\n+\n+int main(int argc, const char **argv)\n+{\n+\tstruct remote *remote;\n+\tstruct strbuf buf = STRBUF_INIT;\n+\tconst char *url;\n+\tstruct walker *walker = NULL;\n+\n+\tsetup_git_directory();\n+\tif (argc < 2) {\n+\t\tfprintf(stderr, \"Remote needed\\n\");\n+\t\treturn 1;\n+\t}\n+\n+\tremote = remote_get(argv[1]);\n+\n+\tif (argc > 2) {\n+\t\turl = argv[2];\n+\t} else {\n+\t\turl = remote->url[0];\n+\t}\n+\n+\tdo {\n+\t\tif (strbuf_getline(&buf, stdin, '\\n') == EOF)\n+\t\t\tbreak;\n+\t\tif (!prefixcmp(buf.buf, \"fetch \")) {\n+\t\t\tchar *obj = buf.buf + strlen(\"fetch \");\n+\t\t\tif (!walker)\n+\t\t\t\twalker = get_http_walker(url, remote);\n+\t\t\twalker->get_all = 1;\n+\t\t\twalker->get_tree = 1;\n+\t\t\twalker->get_history = 1;\n+\t\t\twalker->get_verbosely = 0;\n+\t\t\twalker->get_recover = 0;\n+\t\t\tif (walker_fetch(walker, 1, &obj, NULL, NULL))\n+\t\t\t\tdie(\"Fetch failed.\");\n+\t\t\tprintf(\"\\n\");\n+\t\t\tfflush(stdout);\n+\t\t} else if (!strcmp(buf.buf, \"list\")) {\n+\t\t\tstruct ref *refs;\n+\t\t\tstruct ref *posn;\n+\t\t\tif (!walker)\n+\t\t\t\twalker = get_http_walker(url, remote);\n+\t\t\trefs = get_refs(walker, url);\n+\t\t\tfor (posn = refs; posn; posn = posn->next) {\n+\t\t\t\tif (posn->symref)\n+\t\t\t\t\tprintf(\"@%s %s\\n\", posn->symref, posn->name);\n+\t\t\t\telse\n+\t\t\t\t\tprintf(\"%s %s\\n\", sha1_to_hex(posn->old_sha1), posn->name);\n+\t\t\t}\n+\t\t\tprintf(\"\\n\");\n+\t\t\tfflush(stdout);\n+\t\t} else if (!strcmp(buf.buf, \"capabilities\")) {\n+\t\t\tprintf(\"fetch\\n\");\n+\t\t\tprintf(\"\\n\");\n+\t\t\tfflush(stdout);\n+\t\t} else {\n+\t\t\treturn 1;\n+\t\t}\n+\t\tstrbuf_reset(&buf);\n+\t} while (1);\n+\treturn 0;\n+}\ndiff --git a/transport.c b/transport.c\nindex de0d587..9935c85 100644\n--- a/transport.c\n+++ b/transport.c\n@@ -1,9 +1,6 @@\n #include \"cache.h\"\n #include \"transport.h\"\n #include \"run-command.h\"\n-#ifndef NO_CURL\n-#include \"http.h\"\n-#endif\n #include \"pkt-line.h\"\n #include \"fetch-pack.h\"\n #include \"send-pack.h\"\n@@ -352,45 +349,6 @@ static int rsync_transport_push(struct transport *transport,\n \treturn result;\n }\n \n-/* Generic functions for using commit walkers */\n-\n-#ifndef NO_CURL /* http fetch is the only user */\n-static int fetch_objs_via_walker(struct transport *transport,\n-\t\t\t\t int nr_objs, const struct ref **to_fetch)\n-{\n-\tchar *dest = xstrdup(transport->url);\n-\tstruct walker *walker = transport->data;\n-\tchar **objs = xmalloc(nr_objs * sizeof(*objs));\n-\tint i;\n-\n-\twalker->get_all = 1;\n-\twalker->get_tree = 1;\n-\twalker->get_history = 1;\n-\twalker->get_verbosely = transport->verbose >= 0;\n-\twalker->get_recover = 0;\n-\n-\tfor (i = 0; i < nr_objs; i++)\n-\t\tobjs[i] = xstrdup(sha1_to_hex(to_fetch[i]->old_sha1));\n-\n-\tif (walker_fetch(walker, nr_objs, objs, NULL, NULL))\n-\t\tdie(\"Fetch failed.\");\n-\n-\tfor (i = 0; i < nr_objs; i++)\n-\t\tfree(objs[i]);\n-\tfree(objs);\n-\tfree(dest);\n-\treturn 0;\n-}\n-#endif /* NO_CURL */\n-\n-static int disconnect_walker(struct transport *transport)\n-{\n-\tstruct walker *walker = transport->data;\n-\tif (walker)\n-\t\twalker_free(walker);\n-\treturn 0;\n-}\n-\n #ifndef NO_CURL\n static int curl_transport_push(struct transport *transport, int refspec_nr, const char **refspec, int flags)\n {\n@@ -432,96 +390,6 @@ static int curl_transport_push(struct transport *transport, int refspec_nr, cons\n \treturn !!err;\n }\n \n-static struct ref *get_refs_via_curl(struct transport *transport, int for_push)\n-{\n-\tstruct strbuf buffer = STRBUF_INIT;\n-\tchar *data, *start, *mid;\n-\tchar *ref_name;\n-\tchar *refs_url;\n-\tint i = 0;\n-\tint http_ret;\n-\n-\tstruct ref *refs = NULL;\n-\tstruct ref *ref = NULL;\n-\tstruct ref *last_ref = NULL;\n-\n-\tstruct walker *walker;\n-\n-\tif (for_push)\n-\t\treturn NULL;\n-\n-\tif (!transport->data)\n-\t\ttransport->data = get_http_walker(transport->url,\n-\t\t\t\t\t\ttransport->remote);\n-\n-\twalker = transport->data;\n-\n-\trefs_url = xmalloc(strlen(transport->url) + 11);\n-\tsprintf(refs_url, \"%s/info/refs\", transport->url);\n-\n-\thttp_ret = http_get_strbuf(refs_url, &buffer, HTTP_NO_CACHE);\n-\tswitch (http_ret) {\n-\tcase HTTP_OK:\n-\t\tbreak;\n-\tcase HTTP_MISSING_TARGET:\n-\t\tdie(\"%s not found: did you run git update-server-info on the\"\n-\t\t    \" server?\", refs_url);\n-\tdefault:\n-\t\thttp_error(refs_url, http_ret);\n-\t\tdie(\"HTTP request failed\");\n-\t}\n-\n-\tdata = buffer.buf;\n-\tstart = NULL;\n-\tmid = data;\n-\twhile (i < buffer.len) {\n-\t\tif (!start)\n-\t\t\tstart = &data[i];\n-\t\tif (data[i] == '\\t')\n-\t\t\tmid = &data[i];\n-\t\tif (data[i] == '\\n') {\n-\t\t\tdata[i] = 0;\n-\t\t\tref_name = mid + 1;\n-\t\t\tref = xmalloc(sizeof(struct ref) +\n-\t\t\t\t      strlen(ref_name) + 1);\n-\t\t\tmemset(ref, 0, sizeof(struct ref));\n-\t\t\tstrcpy(ref->name, ref_name);\n-\t\t\tget_sha1_hex(start, ref->old_sha1);\n-\t\t\tif (!refs)\n-\t\t\t\trefs = ref;\n-\t\t\tif (last_ref)\n-\t\t\t\tlast_ref->next = ref;\n-\t\t\tlast_ref = ref;\n-\t\t\tstart = NULL;\n-\t\t}\n-\t\ti++;\n-\t}\n-\n-\tstrbuf_release(&buffer);\n-\n-\tref = alloc_ref(\"HEAD\");\n-\tif (!walker->fetch_ref(walker, ref) &&\n-\t    !resolve_remote_symref(ref, refs)) {\n-\t\tref->next = refs;\n-\t\trefs = ref;\n-\t} else {\n-\t\tfree(ref);\n-\t}\n-\n-\tstrbuf_release(&buffer);\n-\tfree(refs_url);\n-\treturn refs;\n-}\n-\n-static int fetch_objs_via_curl(struct transport *transport,\n-\t\t\t\t int nr_objs, const struct ref **to_fetch)\n-{\n-\tif (!transport->data)\n-\t\ttransport->data = get_http_walker(transport->url,\n-\t\t\t\t\t\ttransport->remote);\n-\treturn fetch_objs_via_walker(transport, nr_objs, to_fetch);\n-}\n-\n #endif\n \n struct bundle_transport_data {\n@@ -950,14 +818,12 @@ struct transport *transport_get(struct remote *remote, const char *url)\n \t} else if (!prefixcmp(url, \"http://\")\n \t        || !prefixcmp(url, \"https://\")\n \t        || !prefixcmp(url, \"ftp://\")) {\n+\t\ttransport_helper_init(ret);\n #ifdef NO_CURL\n \t\terror(\"git was compiled without libcurl support.\");\n #else\n-\t\tret->get_refs_list = get_refs_via_curl;\n-\t\tret->fetch = fetch_objs_via_curl;\n \t\tret->push = curl_transport_push;\n #endif\n-\t\tret->disconnect = disconnect_walker;\n \n \t} else if (is_local(url) && is_file(url)) {\n \t\tstruct bundle_transport_data *data = xcalloc(1, sizeof(*data));\n-- \n1.6.4.rc3.27.g95032.dirty\n"},{"id":"119605","messageId":"alpine.DEB.1.00.0908051206460.8306@pacific.mpi-cbg.de","threadId":"20383","inReplyTo":"alpine.LNX.2.00.0908050053580.2147@iabervon.org","subject":"Re: [PATCH 02/13] Use an external program to implement fetching with curl","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-08-05T10:07:30Z","receivedAt":"2009-08-05T10:07:30Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 5 Aug 2009, Daniel Barkalow wrote:\n\n> diff --git a/Makefile b/Makefile\n> index 504646a..35117fc 100644\n> --- a/Makefile\n> +++ b/Makefile\n> @@ -981,6 +981,7 @@ else\n>  \t\tCURL_LIBCURL = -lcurl\n>  \tendif\n>  \tBUILTIN_OBJS += builtin-http-fetch.o\n> +\tPROGRAMS += git-remote-http$X git-remote-https$X git-remote-ftp$X git-http-fetch$X\n>  \tEXTLIBS += $(CURL_LIBCURL)\n>  \tLIB_OBJS += http.o http-walker.o\n>  \tcurl_check := $(shell (echo 070908; curl-config --vernum) | sort -r | sed -ne 2p)\n> @@ -1491,6 +1492,10 @@ git-http-push$X: revision.o http.o http-push.o $(GITLIBS)\n>  \t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n>  \t\t$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)\n>  \n> +git-remote-http$X git-remote-https$X git-remote-ftp$X: remote-curl.o http.o http-walker.o $(GITLIBS)\n> +\t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n> +\t\t$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)\n> +\n\nOoops, I missed this part.  How about making git-remote-https and \ngit-remote-ftp hardlinks to git-remote-http?\n\nCiao,\nDscho\n"},{"id":"119628","messageId":"alpine.LNX.2.00.0908051145250.2147@iabervon.org","threadId":"20383","inReplyTo":"alpine.DEB.1.00.0908051206460.8306@pacific.mpi-cbg.de","subject":"Re: [PATCH 02/13] Use an external program to implement fetching with curl","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2009-08-05T15:52:22Z","receivedAt":"2009-08-05T15:52:22Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Wed, 5 Aug 2009, Johannes Schindelin wrote:\n\n> Hi,\n> \n> On Wed, 5 Aug 2009, Daniel Barkalow wrote:\n> \n> > diff --git a/Makefile b/Makefile\n> > index 504646a..35117fc 100644\n> > --- a/Makefile\n> > +++ b/Makefile\n> > @@ -981,6 +981,7 @@ else\n> >  \t\tCURL_LIBCURL = -lcurl\n> >  \tendif\n> >  \tBUILTIN_OBJS += builtin-http-fetch.o\n> > +\tPROGRAMS += git-remote-http$X git-remote-https$X git-remote-ftp$X git-http-fetch$X\n> >  \tEXTLIBS += $(CURL_LIBCURL)\n> >  \tLIB_OBJS += http.o http-walker.o\n> >  \tcurl_check := $(shell (echo 070908; curl-config --vernum) | sort -r | sed -ne 2p)\n> > @@ -1491,6 +1492,10 @@ git-http-push$X: revision.o http.o http-push.o $(GITLIBS)\n> >  \t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n> >  \t\t$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)\n> >  \n> > +git-remote-http$X git-remote-https$X git-remote-ftp$X: remote-curl.o http.o http-walker.o $(GITLIBS)\n> > +\t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n> > +\t\t$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)\n> > +\n> \n> Ooops, I missed this part.  How about making git-remote-https and \n> git-remote-ftp hardlinks to git-remote-http?\n\nSure. Is \"ln ... || ln -s ... || cp ...\" the right way to do this \ncross-platform?\n\n\t-Daniel\n*This .sig left intentionally blank*\n"},{"id":"119667","messageId":"alpine.DEB.1.00.0908052154000.8306@pacific.mpi-cbg.de","threadId":"20383","inReplyTo":"alpine.LNX.2.00.0908051145250.2147@iabervon.org","subject":"Re: [PATCH 02/13] Use an external program to implement fetching with curl","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-08-05T19:54:44Z","receivedAt":"2009-08-05T19:54:44Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 5 Aug 2009, Daniel Barkalow wrote:\n\n> On Wed, 5 Aug 2009, Johannes Schindelin wrote:\n> \n> > On Wed, 5 Aug 2009, Daniel Barkalow wrote:\n> > \n> > > diff --git a/Makefile b/Makefile\n> > > index 504646a..35117fc 100644\n> > > --- a/Makefile\n> > > +++ b/Makefile\n> > > @@ -981,6 +981,7 @@ else\n> > >  \t\tCURL_LIBCURL = -lcurl\n> > >  \tendif\n> > >  \tBUILTIN_OBJS += builtin-http-fetch.o\n> > > +\tPROGRAMS += git-remote-http$X git-remote-https$X git-remote-ftp$X git-http-fetch$X\n> > >  \tEXTLIBS += $(CURL_LIBCURL)\n> > >  \tLIB_OBJS += http.o http-walker.o\n> > >  \tcurl_check := $(shell (echo 070908; curl-config --vernum) | sort -r | sed -ne 2p)\n> > > @@ -1491,6 +1492,10 @@ git-http-push$X: revision.o http.o http-push.o $(GITLIBS)\n> > >  \t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n> > >  \t\t$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)\n> > >  \n> > > +git-remote-http$X git-remote-https$X git-remote-ftp$X: remote-curl.o http.o http-walker.o $(GITLIBS)\n> > > +\t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n> > > +\t\t$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)\n> > > +\n> > \n> > Ooops, I missed this part.  How about making git-remote-https and \n> > git-remote-ftp hardlinks to git-remote-http?\n> \n> Sure. Is \"ln ... || ln -s ... || cp ...\" the right way to do this \n> cross-platform?\n\nYou mean as in\n\n\t$(BUILT_INS): git$X\n\t        $(QUIET_BUILT_IN)$(RM) $@ && \\\n\t        ln git$X $@ 2>/dev/null || \\\n\t        ln -s git$X $@ 2>/dev/null || \\\n\t        cp git$X $@\n\n?  I guess so ;-)\n\nCiao,\nDscho\n"},{"id":"119885","messageId":"7v63d06wjq.fsf@alter.siamese.dyndns.org","threadId":"20383","inReplyTo":"alpine.LNX.2.00.0908051145250.2147@iabervon.org","subject":"Re: [PATCH 02/13] Use an external program to implement fetching with curl","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-08-07T05:08:09Z","receivedAt":"2009-08-07T05:08:09Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Daniel Barkalow <barkalow@iabervon.org> writes:\n\n> On Wed, 5 Aug 2009, Johannes Schindelin wrote:\n>\n>> Ooops, I missed this part.  How about making git-remote-https and \n>> git-remote-ftp hardlinks to git-remote-http?\n>\n> Sure. Is \"ln ... || ln -s ... || cp ...\" the right way to do this \n> cross-platform?\n\nI've queued the first three from this series to 'next' (and the rest to\n'pu'), as I wanted to give wider testing to the smaller footprint git with\nthe libcurl-less-ness they bring in, with Linus's standalone SHA-1.\n\nSince then two fix-ups (adding git-remote-* to .gitignore and the\ndependency fix to git-http-fetch) were posted to the list, which I also\nrebased in to the series, making the total number of patches merged to\n'next' from the series 5.\n\nIf there are major changes/rewrites/redesign in the remaining part of the\nseries that are only in 'pu', please feel free to either send incrementals\nor replacements.\n\nI do not think I've seen any issues raised but unresolved against the part\nfrom this series already in 'next', other than that this builds three\ncopies of git-remote-* programs based on libcurl.  I'll rebase a patch\nlike this in after the Makefile fixup ae209bd (http-fetch: Fix Makefile\ndependancies, 2009-08-06) and queue the result to 'next'.\n\nI suspect that the \"install\" target may need a patch similar to this one,\nthough...\n\n-- >8 --\nSubject: Makefile: do not link three copies of git-remote-* programs\n\nInstead, link only one and make the rest hardlinks/copies, like we do for\nthe built-ins. \n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n\n Makefile |    9 ++++++++-\n 1 files changed, 8 insertions(+), 1 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 2900057..38924f2 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1256,6 +1256,7 @@ ifndef V\n \tQUIET_LINK     = @echo '   ' LINK $@;\n \tQUIET_BUILT_IN = @echo '   ' BUILTIN $@;\n \tQUIET_GEN      = @echo '   ' GEN $@;\n+\tQUIET_LNCP     = @echo '   ' LN/CP $@;\n \tQUIET_SUBDIR0  = +@subdir=\n \tQUIET_SUBDIR1  = ;$(NO_SUBDIR) echo '   ' SUBDIR $$subdir; \\\n \t\t\t $(MAKE) $(PRINT_DIR) -C $$subdir\n@@ -1494,10 +1495,16 @@ git-http-push$X: revision.o http.o http-push.o $(GITLIBS)\n \t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n \t\t$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)\n \n-git-remote-http$X git-remote-https$X git-remote-ftp$X: remote-curl.o http.o http-walker.o $(GITLIBS)\n+git-remote-http$X: remote-curl.o http.o http-walker.o $(GITLIBS)\n \t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n \t\t$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)\n \n+git-remote-https$X git-remote-ftp$X: git-remote-http$X\n+\t$(QUIET_LNCP)$(RM) $@ && \\\n+\tln git-remote-http$X $@ 2>/dev/null || \\\n+\tln -s  git-remote-http$X $@ 2>/dev/null || \\\n+\tcp git-remote-http$X $@\n+\n $(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)\n $(patsubst git-%$X,%.o,$(PROGRAMS)) git.o: $(LIB_H) $(wildcard */*.h)\n builtin-revert.o wt-status.o: wt-status.h\n"},{"id":"119889","messageId":"alpine.LNX.2.00.0908070111410.2147@iabervon.org","threadId":"20383","inReplyTo":"7v63d06wjq.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 02/13] Use an external program to implement fetching with curl","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2009-08-07T05:34:04Z","receivedAt":"2009-08-07T05:34:04Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Thu, 6 Aug 2009, Junio C Hamano wrote:\n\n> Daniel Barkalow <barkalow@iabervon.org> writes:\n> \n> > On Wed, 5 Aug 2009, Johannes Schindelin wrote:\n> >\n> >> Ooops, I missed this part.  How about making git-remote-https and \n> >> git-remote-ftp hardlinks to git-remote-http?\n> >\n> > Sure. Is \"ln ... || ln -s ... || cp ...\" the right way to do this \n> > cross-platform?\n> \n> I've queued the first three from this series to 'next' (and the rest to\n> 'pu'), as I wanted to give wider testing to the smaller footprint git with\n> the libcurl-less-ness they bring in, with Linus's standalone SHA-1.\n> \n> Since then two fix-ups (adding git-remote-* to .gitignore and the\n> dependency fix to git-http-fetch) were posted to the list, which I also\n> rebased in to the series, making the total number of patches merged to\n> 'next' from the series 5.\n>\n> If there are major changes/rewrites/redesign in the remaining part of the\n> series that are only in 'pu', please feel free to either send incrementals\n> or replacements.\n\nGreat. Johannes had a bunch of suggestions for making it less error-prone \nto extend, which I hope to get to this weekend.\n\n> I do not think I've seen any issues raised but unresolved against the part\n> from this series already in 'next', other than that this builds three\n> copies of git-remote-* programs based on libcurl.  I'll rebase a patch\n> like this in after the Makefile fixup ae209bd (http-fetch: Fix Makefile\n> dependancies, 2009-08-06) and queue the result to 'next'.\n\nI think there were remaining improvements (e.g., transport-helper.c could \nwrite commands with strbufs), but nothing that couldn't just as well be \napplied afterwards.\n\n> I suspect that the \"install\" target may need a patch similar to this one,\n> though...\n\nAh, yes, avoiding the duplication in the build directory isn't a big win \nif the installed location doesn't get links.\n\n> -- >8 --\n> Subject: Makefile: do not link three copies of git-remote-* programs\n> \n> Instead, link only one and make the rest hardlinks/copies, like we do for\n> the built-ins. \n> \n> Signed-off-by: Junio C Hamano <gitster@pobox.com>\n> ---\n> \n>  Makefile |    9 ++++++++-\n>  1 files changed, 8 insertions(+), 1 deletions(-)\n> \n> diff --git a/Makefile b/Makefile\n> index 2900057..38924f2 100644\n> --- a/Makefile\n> +++ b/Makefile\n> @@ -1256,6 +1256,7 @@ ifndef V\n>  \tQUIET_LINK     = @echo '   ' LINK $@;\n>  \tQUIET_BUILT_IN = @echo '   ' BUILTIN $@;\n>  \tQUIET_GEN      = @echo '   ' GEN $@;\n> +\tQUIET_LNCP     = @echo '   ' LN/CP $@;\n>  \tQUIET_SUBDIR0  = +@subdir=\n>  \tQUIET_SUBDIR1  = ;$(NO_SUBDIR) echo '   ' SUBDIR $$subdir; \\\n>  \t\t\t $(MAKE) $(PRINT_DIR) -C $$subdir\n> @@ -1494,10 +1495,16 @@ git-http-push$X: revision.o http.o http-push.o $(GITLIBS)\n>  \t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n>  \t\t$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)\n>  \n> -git-remote-http$X git-remote-https$X git-remote-ftp$X: remote-curl.o http.o http-walker.o $(GITLIBS)\n> +git-remote-http$X: remote-curl.o http.o http-walker.o $(GITLIBS)\n>  \t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n>  \t\t$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)\n>  \n> +git-remote-https$X git-remote-ftp$X: git-remote-http$X\n> +\t$(QUIET_LNCP)$(RM) $@ && \\\n> +\tln git-remote-http$X $@ 2>/dev/null || \\\n> +\tln -s  git-remote-http$X $@ 2>/dev/null || \\\n> +\tcp git-remote-http$X $@\n\nMaybe \"$<\" for \"git-remote-http$X\", since that would make the rule portion \ngeneric.\n"},{"id":"119917","messageId":"7v7hxfxwic.fsf_-_@alter.siamese.dyndns.org","threadId":"20383","inReplyTo":"7v63d06wjq.fsf@alter.siamese.dyndns.org","subject":"[PATCH/RFC] Makefile: build/install git-remote-<scheme> as hardlinks when able","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-08-07T19:19:07Z","receivedAt":"2009-08-07T19:19:07Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Three git-remote-<scheme> helper programs are the same executable that\nuses libcurl to implement the named protocol transfer.  Instead of\nrunning the linker three times to build different programs, build one and\nhardlink (or copy if the underlying filesystem does not support it) the\nother two.\n\nInstall one to $(gitexecdir) and make the other two hardnlinks, in a way\nsimilar to how we install programs that implement built-in commands.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n\nI do not particularly like this one.  ALL_PROGRAMS does not include any of\nthe built-in programs, but because CURL_SYNONYMS are part of PROGRAMS, the\ninstall step needs to filter them out, so that we can arrange to make\nhardlinks to the synonyms in a separate step.\n\nPutting git-remote-http$X on OTHER_PROGRAMS like we do for git$X does not\nwork well either, as that won't install it in gitexecdir.\n\n Makefile |   23 +++++++++++++++++++----\n 1 files changed, 19 insertions(+), 4 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex e29b15f..438cffb 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -383,7 +383,8 @@ BUILT_INS += git-stage$X\n BUILT_INS += git-status$X\n BUILT_INS += git-whatchanged$X\n \n-# what 'all' will build and 'install' will install, in gitexecdir\n+# what 'all' will build and 'install' will install in gitexecdir,\n+# excluding programs for built-in commands\n ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)\n \n # what 'all' will build but not install in gitexecdir\n@@ -980,7 +981,8 @@ else\n \telse\n \t\tCURL_LIBCURL = -lcurl\n \tendif\n-\tPROGRAMS += git-remote-http$X git-remote-https$X git-remote-ftp$X git-http-fetch$X\n+\tCURL_SYNONYMS = git-remote-https$X git-remote-ftp$X\n+\tPROGRAMS += git-remote-http$X $(CURL_SYNONYMS) git-http-fetch$X\n \tcurl_check := $(shell (echo 070908; curl-config --vernum) | sort -r | sed -ne 2p)\n \tifeq \"$(curl_check)\" \"070908\"\n \t\tifndef NO_EXPAT\n@@ -1256,6 +1258,7 @@ ifndef V\n \tQUIET_LINK     = @echo '   ' LINK $@;\n \tQUIET_BUILT_IN = @echo '   ' BUILTIN $@;\n \tQUIET_GEN      = @echo '   ' GEN $@;\n+\tQUIET_LNCP     = @echo '   ' LN/CP $@;\n \tQUIET_SUBDIR0  = +@subdir=\n \tQUIET_SUBDIR1  = ;$(NO_SUBDIR) echo '   ' SUBDIR $$subdir; \\\n \t\t\t $(MAKE) $(PRINT_DIR) -C $$subdir\n@@ -1494,10 +1497,16 @@ git-http-push$X: revision.o http.o http-push.o $(GITLIBS)\n \t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n \t\t$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)\n \n-git-remote-http$X git-remote-https$X git-remote-ftp$X: remote-curl.o http.o http-walker.o $(GITLIBS)\n+git-remote-http$X: remote-curl.o http.o http-walker.o $(GITLIBS)\n \t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n \t\t$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)\n \n+$(CURL_SYNONYMS): git-remote-http$X\n+\t$(QUIET_LNCP)$(RM) $@ && \\\n+\tln $< $@ 2>/dev/null || \\\n+\tln -s $< $@ 2>/dev/null || \\\n+\tcp $< $@\n+\n $(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)\n $(patsubst git-%$X,%.o,$(PROGRAMS)) git.o: $(LIB_H) $(wildcard */*.h)\n builtin-revert.o wt-status.o: wt-status.h\n@@ -1653,7 +1662,7 @@ export gitexec_instdir\n install: all\n \t$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'\n \t$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n-\t$(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n+\t$(INSTALL) $(filter-out $(CURL_SYNONYMS), $(ALL_PROGRAMS)) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'\n \t$(INSTALL) git$X git-upload-pack$X git-receive-pack$X git-upload-archive$X git-shell$X git-cvsserver '$(DESTDIR_SQ)$(bindir_SQ)'\n \t$(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install\n ifndef NO_PERL\n@@ -1679,6 +1688,12 @@ endif\n \t\tln -s \"git$X\" \"$$execdir/$$p\" 2>/dev/null || \\\n \t\tcp \"$$execdir/git$X\" \"$$execdir/$$p\" || exit; \\\n \t  done; } && \\\n+\t{ for p in $(CURL_SYNONYMS); do \\\n+\t\t$(RM) \"$$execdir/$$p\" && \\\n+\t\tln \"$$execdir/git-remote-http$X\" \"$$execdir/$$p\" 2>/dev/null || \\\n+\t\tln -s \"git-remote-http$X\" \"$$execdir/$$p\" 2>/dev/null || \\\n+\t\tcp \"$$execdir/git-remote-http$X\" \"$$execdir/$$p\" || exit; \\\n+\t  done; } && \\\n \t./check_bindir \"z$$bindir\" \"z$$execdir\" \"$$bindir/git-add$X\"\n \n install-doc:\n"}]}