From de46138826cbc8229e25691e613e09ae1f683235 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 4 Mar 2017 08:36:45 +0000 Subject: http: inform about alternates-as-redirects behavior It is disconcerting for users to not notice the behavior change in handling alternates from commit cb4d2d35c4622ec2 ("http: treat http-alternates like redirects") Give the user a hint about the config option so they can see the URL and decide whether or not they want to enable http.followRedirects in their config. Signed-off-by: Eric Wong Reviewed-by: Jeff King Signed-off-by: Junio C Hamano --- http-walker.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'http-walker.c') diff --git a/http-walker.c b/http-walker.c index b34b6ace7c..6396cebe5e 100644 --- a/http-walker.c +++ b/http-walker.c @@ -168,6 +168,11 @@ static int is_alternate_allowed(const char *url) }; int i; + if (http_follow_config != HTTP_FOLLOW_ALWAYS) { + warning("alternate disabled by http.followRedirects: %s", url); + return 0; + } + for (i = 0; i < ARRAY_SIZE(protocols); i++) { const char *end; if (skip_prefix(url, protocols[i], &end) && @@ -331,9 +336,6 @@ static void fetch_alternates(struct walker *walker, const char *base) struct alternates_request alt_req; struct walker_data *cdata = walker->data; - if (http_follow_config != HTTP_FOLLOW_ALWAYS) - return; - /* * If another request has already started fetching alternates, * wait for them to arrive and return to processing this request's -- cgit v1.2.3 From 5cae73d5d23ec109322948478a957e77d2733f94 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 4 Mar 2017 01:50:16 +0000 Subject: http: release strbuf on disabled alternates This likely has no real-world impact on memory usage, but it is cleaner for future readers. Fixes: abcbdc03895f ("http: respect protocol.*.allow=user for http-alternates") Signed-off-by: Eric Wong Reviewed-by: Jeff King Signed-off-by: Junio C Hamano --- http-walker.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'http-walker.c') diff --git a/http-walker.c b/http-walker.c index 6396cebe5e..ab7d5537ae 100644 --- a/http-walker.c +++ b/http-walker.c @@ -319,6 +319,8 @@ static void process_alternates_response(void *callback_data) while (tail->next != NULL) tail = tail->next; tail->next = newalt; + } else { + strbuf_release(&target); } } } -- cgit v1.2.3