threads / discuss / 2416

HTTP redirection with git-clone/git-fetch ?

Subject: HTTP redirection with git-clone/git-fetch ?

## tl;dr

4 messages between Nov 9, 2005 and Nov 11, 2005.

replies: 3people: 3as markdown or json

Josef Weidendorfer· Nov 9, 2005, 22:31 UTC · lore
Hi,

git-clone fails silently with a HTTP URL where the server responds with a redirection (ie. header line "Location:..."). I tried to add "-L" to the curl command line in git-clone.sh, but this is only half of a fix. Afterwards I get:

defaulting to local storage area error: Couldn't get http://repo/project.git/refs/heads/origin for heads/origin Failed writing body error: Could not interpret heads/origin as something to pull

This seems because git-fetch should understand redirections, too. I am not familiar to the curl API. So perhaps another one can try to fix this?

Josef
Nick Hengeveld· Nov 10, 2005, 00:24 UTC · re: Josef Weidendorfer · lore

Re: HTTP redirection with git-clone/git-fetch ?

On Wed, Nov 09, 2005 at 11:31:36PM +0100, Josef Weidendorfer wrote:
> This seems because git-fetch should understand redirections, too.
> I am not familiar to the curl API. So perhaps another one can try to
> fix this?

This should fix it, although it still tries every GET with the original URL which is a bit inefficient.

Configure HTTP fetch to follow redirects
Signed-off-by: Nick Hengeveld <nickh@reactrix.com>
---
 git-fetch.sh |    2 +-
 http-fetch.c |    2 ++
 2 files changed, 3 insertions(+), 1 deletions(-)

applies-to: bc694e972ad9e82f65359788db6ef788078a975f deb8d58781a60d4611651478c5b08739edf981b7

diff --git a/git-fetch.sh b/git-fetch.sh
index 31e5f4c..8564cbf 100755
--- a/git-fetch.sh
+++ b/git-fetch.sh
@@ -230,7 +230,7 @@ do
 	    $u =~ s{([^-a-zA-Z0-9/.])}{sprintf"%%%02x",ord($1)}eg;
 	    print "$u";
 	' "$remote_name")
-	head=$(curl -nsf $curl_extra_args "$remote/$remote_name_quoted") &&
+	head=$(curl -nsfL $curl_extra_args "$remote/$remote_name_quoted") &&
 	expr "$head" : "$_x40\$" >/dev/null ||
 		die "Failed to fetch $remote_name from $remote"
 	echo >&2 Fetching "$remote_name from $remote" using http
diff --git a/http-fetch.c b/http-fetch.c
index ea8af1b..28d225c 100644
--- a/http-fetch.c
+++ b/http-fetch.c
@@ -269,6 +269,8 @@ static CURL* get_curl_handle(void)
 				 curl_low_speed_time);
 	}
 
+	curl_easy_setopt(result, CURLOPT_FOLLOWLOCATION, 1);
+
 	return result;
 }
 
---
0.99.9.GIT
Josef Weidendorfer· Nov 10, 2005, 13:09 UTC · re: Nick Hengeveld · lore

Re: HTTP redirection with git-clone/git-fetch ?

On Thursday 10 November 2005 01:24, Nick Hengeveld wrote:
Show 8 quoted lines
> On Wed, Nov 09, 2005 at 11:31:36PM +0100, Josef Weidendorfer wrote:
> 
> > This seems because git-fetch should understand redirections, too.
> > I am not familiar to the curl API. So perhaps another one can try to
> > fix this?
> 
> This should fix it, although it still tries every GET with the original
> URL which is a bit inefficient.

Thanks, I just sent a patch for git-clone, including your patch, to Junio.

Josef
Junio C Hamano· Nov 11, 2005, 17:38 UTC · re: Josef Weidendorfer · lore

Re: HTTP redirection with git-clone/git-fetch ?

Josef Weidendorfer <Josef.Weidendorfer@gmx.de> writes:
Show 5 quoted lines
>> This should fix it, although it still tries every GET with the original
>> URL which is a bit inefficient.
>
> Thanks, I just sent a patch for git-clone, including your patch, to
> Junio.
Thank you both.

← back to recent threads