summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 78affc4)
raw | patch | inline | side by side (parent: 78affc4)
author | Shawn O. Pearce <spearce@spearce.org> | |
Sat, 31 Oct 2009 00:47:26 +0000 (17:47 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 31 Oct 2009 02:20:54 +0000 (19:20 -0700) |
We will need the walker, url and remote in other functions as the
code grows larger to support smart HTTP. Extract this out into a
set of globals we can easily reference once configured.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
CC: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
code grows larger to support smart HTTP. Extract this out into a
set of globals we can easily reference once configured.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
CC: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
remote-curl.c | patch | blob | history |
diff --git a/remote-curl.c b/remote-curl.c
index 2faf1c634415d139f15c4829937e0460be31dc1d..478f3ea7d3849d3dccc870ca4e9a6f779e8504c7 100644 (file)
--- a/remote-curl.c
+++ b/remote-curl.c
#include "http.h"
#include "exec_cmd.h"
-static struct ref *get_refs(struct walker *walker, const char *url)
+static struct remote *remote;
+static const char *url;
+static struct walker *walker;
+
+static void init_walker(void)
+{
+ if (!walker)
+ walker = get_http_walker(url, remote);
+}
+
+static struct ref *get_refs(void)
{
struct strbuf buffer = STRBUF_INIT;
char *data, *start, *mid;
refs_url = xmalloc(strlen(url) + 11);
sprintf(refs_url, "%s/info/refs", url);
+ init_walker();
http_ret = http_get_strbuf(refs_url, &buffer, HTTP_NO_CACHE);
switch (http_ret) {
case HTTP_OK:
int main(int argc, const char **argv)
{
- struct remote *remote;
struct strbuf buf = STRBUF_INIT;
- const char *url;
- struct walker *walker = NULL;
git_extract_argv0_path(argv[0]);
setup_git_directory();
break;
if (!prefixcmp(buf.buf, "fetch ")) {
char *obj = buf.buf + strlen("fetch ");
- if (!walker)
- walker = get_http_walker(url, remote);
+ init_walker();
walker->get_all = 1;
walker->get_tree = 1;
walker->get_history = 1;
printf("\n");
fflush(stdout);
} else if (!strcmp(buf.buf, "list")) {
- struct ref *refs;
+ struct ref *refs = get_refs();
struct ref *posn;
- if (!walker)
- walker = get_http_walker(url, remote);
- refs = get_refs(walker, url);
for (posn = refs; posn; posn = posn->next) {
if (posn->symref)
printf("@%s %s\n", posn->symref, posn->name);