Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit 7c7a77d

Browse files
committed
Fix host redirect handling
If you try to clone from a url that redirects to another host e.g. `example.com/repo` -> `github.com/org/repo.git`, it results in a redirect to `example.com/org/repo.git` because ModifyEndpointIfRedirect only takes into account the scheme and path. Signed-off-by: DisposaBoy <[email protected]>
1 parent 87cc819 commit 7c7a77d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

plumbing/transport/http/common.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ func (s *session) ModifyEndpointIfRedirect(res *http.Response) {
152152
}
153153

154154
s.endpoint.Protocol = r.URL.Scheme
155+
s.endpoint.Host = r.URL.Hostname()
156+
s.endpoint.Port, _ = strconv.Atoi(r.URL.Port())
155157
s.endpoint.Path = r.URL.Path[:len(r.URL.Path)-len(infoRefsPath)]
156158
}
157159

0 commit comments

Comments
 (0)