File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed
Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff 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 */
Original file line number Diff line number Diff 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+
133145test -n " $GIT_TEST_LONG " && test_set_prereq EXPENSIVE
134146
135147test_expect_success EXPENSIVE ' create 50,000 tags in the repo' '
You can’t perform that action at this time.
0 commit comments