Skip to content

Commit fb1e4a8

Browse files
committed
Merge branch 'jk/smart-http-switch'
Allows users to turn off smart-http when talking to dumb-only servers. * jk/smart-http-switch: remote-curl: let users turn off smart http remote-curl: rename is_http variable
2 parents c318040 + 02572c2 commit fb1e4a8

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

remote-curl.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,16 @@ static struct discovery* discover_refs(const char *service)
9595
struct strbuf buffer = STRBUF_INIT;
9696
struct discovery *last = last_discovery;
9797
char *refs_url;
98-
int http_ret, is_http = 0;
98+
int http_ret, maybe_smart = 0;
9999

100100
if (last && !strcmp(service, last->service))
101101
return last;
102102
free_discovery(last);
103103

104104
strbuf_addf(&buffer, "%sinfo/refs", url);
105-
if (!prefixcmp(url, "http://") || !prefixcmp(url, "https://")) {
106-
is_http = 1;
105+
if ((!prefixcmp(url, "http://") || !prefixcmp(url, "https://")) &&
106+
git_env_bool("GIT_SMART_HTTP", 1)) {
107+
maybe_smart = 1;
107108
if (!strchr(url, '?'))
108109
strbuf_addch(&buffer, '?');
109110
else
@@ -131,7 +132,7 @@ static struct discovery* discover_refs(const char *service)
131132
last->buf_alloc = strbuf_detach(&buffer, &last->len);
132133
last->buf = last->buf_alloc;
133134

134-
if (is_http && 5 <= last->len && last->buf[4] == '#') {
135+
if (maybe_smart && 5 <= last->len && last->buf[4] == '#') {
135136
/* smart HTTP response; validate that the service
136137
* pkt-line matches our request.
137138
*/

t/t5551-http-fetch.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,18 @@ test_expect_success 'clone from auth-only-for-push repository' '
130130
test_cmp expect actual
131131
'
132132

133+
test_expect_success 'disable dumb http on server' '
134+
git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" \
135+
config http.getanyfile false
136+
'
137+
138+
test_expect_success 'GIT_SMART_HTTP can disable smart http' '
139+
(GIT_SMART_HTTP=0 &&
140+
export GIT_SMART_HTTP &&
141+
cd clone &&
142+
test_must_fail git fetch)
143+
'
144+
133145
test -n "$GIT_TEST_LONG" && test_set_prereq EXPENSIVE
134146

135147
test_expect_success EXPENSIVE 'create 50,000 tags in the repo' '

0 commit comments

Comments
 (0)