Merge branch 'jk/dumb-http-alternate-fix'

The HTTP walker misinterpreted the alternates file that gives an
absolute path when the server URL does not have the final slash
(i.e., "https://example.com" not "https://example.com/").

* jk/dumb-http-alternate-fix:
  http: handle absolute-path alternates from server root
This commit is contained in:
Junio C Hamano
2026-05-25 09:40:08 +09:00
2 changed files with 21 additions and 1 deletions
+1 -1
View File
@@ -268,7 +268,7 @@ static void process_alternates_response(void *callback_data)
*/
const char *colon_ss = strstr(base,"://");
if (colon_ss) {
serverlen = (strchr(colon_ss + 3, '/')
serverlen = (strchrnul(colon_ss + 3, '/')
- base);
okay = 1;
}
+20
View File
@@ -555,4 +555,24 @@ test_expect_success 'dumb http can fetch index v1' '
git -C idx-v1 fsck
'
test_expect_success 'absolute-path alternate when url has no path' '
src=$HTTPD_DOCUMENT_ROOT_PATH/repo.git &&
alt=absolute-alt.git &&
git clone --bare --shared "$src" "$alt" &&
# Our repo has an alternate pointing to the absolute filesystem path,
# but that will not make any sense to an http client. So we will
# manually give it the equivalent path that the http server will
# understand.
echo "/dumb/repo.git/objects" >"$alt/objects/info/http-alternates" &&
# Now make our alt repository available at the root of the http
# server without any path (i.e., just http://localhost:1234).
git -C "$alt" update-server-info &&
mv absolute-alt.git/* "$HTTPD_DOCUMENT_ROOT_PATH" &&
git -c http.followRedirects=true clone "$HTTPD_URL" alt-clone.git 2>err &&
test_grep "adding alternate object store: $HTTPD_URL/dumb/repo.git" err
'
test_done