http: init and cleanup separately from http-walker
Previously, all our http operations were done with http-walker. With the new remote-curl helper, we find ourselves using http methods outside of http-walker - for example, fetching info/refs. Accomodate this by separating http_init() and http_cleanup() invocations from http-walker. Signed-off-by: Tay Ray Chuan <rctay89@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Tay Ray Chuan committed
Mar 2, 2010 at 18:49 UTC
888692b733b3109874bb570bb0680e93287ed338
4 files changed
+12
-8
http-fetch.c
+4
-1
@@ -1,5 +1,6 @@
1
#include "cache.h"
2
#include "exec_cmd.h"
3
+#include "http.h"
4
#include "walker.h"
5
6
static const char http_fetch_usage[] = "git http-fetch "
@@ -69,7 +70,8 @@ int main(int argc, const char **argv)
70
url = rewritten_url;
71
}
72
72
- walker = get_http_walker(url, NULL);
73
+ http_init(NULL);
74
+ walker = get_http_walker(url);
75
walker->get_tree = get_tree;
76
walker->get_history = get_history;
77
walker->get_all = get_all;
@@ -89,6 +91,7 @@ int main(int argc, const char **argv)
91
}
92
93
walker_free(walker);
94
+ http_cleanup();
95
96
free(rewritten_url);
97
http-walker.c
+1
-5
@@ -559,18 +559,14 @@ static void cleanup(struct walker *walker)
559
free(data);
560
walker->data = NULL;
561
}
562
-
563
- http_cleanup();
562
}
563
566
-struct walker *get_http_walker(const char *url, struct remote *remote)
564
+struct walker *get_http_walker(const char *url)
565
{
566
char *s;
567
struct walker_data *data = xmalloc(sizeof(struct walker_data));
568
struct walker *walker = xmalloc(sizeof(struct walker));
569
572
- http_init(remote);
573
-
570
data->alt = xmalloc(sizeof(*data->alt));
571
data->alt->base = xmalloc(strlen(url) + 1);
572
strcpy(data->alt->base, url);
remote-curl.c
+6
-1
@@ -25,7 +25,7 @@ static struct options options;
25
static void init_walker(void)
26
{
27
if (!walker)
28
- walker = get_http_walker(url, remote);
28
+ walker = get_http_walker(url);
29
}
30
31
static int set_option(const char *name, const char *value)
@@ -810,6 +810,8 @@ int main(int argc, const char **argv)
810
url = remote->url[0];
811
}
812
813
+ http_init(remote);
814
+
815
do {
816
if (strbuf_getline(&buf, stdin, '\n') == EOF)
817
break;
@@ -855,5 +857,8 @@ int main(int argc, const char **argv)
857
}
858
strbuf_reset(&buf);
859
} while (1);
860
+
861
+ http_cleanup();
862
+
863
return 0;
864
}
walker.h
+1
-1
@@ -34,6 +34,6 @@ int walker_fetch(struct walker *impl, int targets, char **target,
34
35
void walker_free(struct walker *walker);
36
37
-struct walker *get_http_walker(const char *url, struct remote *remote);
37
+struct walker *get_http_walker(const char *url);
38
39
#endif /* WALKER_H */