Skip to content

Commit 888692b

Browse files
rctaygitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 09ae9ac commit 888692b

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

http-fetch.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "cache.h"
22
#include "exec_cmd.h"
3+
#include "http.h"
34
#include "walker.h"
45

56
static const char http_fetch_usage[] = "git http-fetch "
@@ -69,7 +70,8 @@ int main(int argc, const char **argv)
6970
url = rewritten_url;
7071
}
7172

72-
walker = get_http_walker(url, NULL);
73+
http_init(NULL);
74+
walker = get_http_walker(url);
7375
walker->get_tree = get_tree;
7476
walker->get_history = get_history;
7577
walker->get_all = get_all;
@@ -89,6 +91,7 @@ int main(int argc, const char **argv)
8991
}
9092

9193
walker_free(walker);
94+
http_cleanup();
9295

9396
free(rewritten_url);
9497

http-walker.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -559,18 +559,14 @@ static void cleanup(struct walker *walker)
559559
free(data);
560560
walker->data = NULL;
561561
}
562-
563-
http_cleanup();
564562
}
565563

566-
struct walker *get_http_walker(const char *url, struct remote *remote)
564+
struct walker *get_http_walker(const char *url)
567565
{
568566
char *s;
569567
struct walker_data *data = xmalloc(sizeof(struct walker_data));
570568
struct walker *walker = xmalloc(sizeof(struct walker));
571569

572-
http_init(remote);
573-
574570
data->alt = xmalloc(sizeof(*data->alt));
575571
data->alt->base = xmalloc(strlen(url) + 1);
576572
strcpy(data->alt->base, url);

remote-curl.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ static struct options options;
2525
static void init_walker(void)
2626
{
2727
if (!walker)
28-
walker = get_http_walker(url, remote);
28+
walker = get_http_walker(url);
2929
}
3030

3131
static int set_option(const char *name, const char *value)
@@ -810,6 +810,8 @@ int main(int argc, const char **argv)
810810
url = remote->url[0];
811811
}
812812

813+
http_init(remote);
814+
813815
do {
814816
if (strbuf_getline(&buf, stdin, '\n') == EOF)
815817
break;
@@ -855,5 +857,8 @@ int main(int argc, const char **argv)
855857
}
856858
strbuf_reset(&buf);
857859
} while (1);
860+
861+
http_cleanup();
862+
858863
return 0;
859864
}

walker.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ int walker_fetch(struct walker *impl, int targets, char **target,
3434

3535
void walker_free(struct walker *walker);
3636

37-
struct walker *get_http_walker(const char *url, struct remote *remote);
37+
struct walker *get_http_walker(const char *url);
3838

3939
#endif /* WALKER_H */

0 commit comments

Comments
 (0)