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)
95
95
struct strbuf buffer = STRBUF_INIT ;
96
96
struct discovery * last = last_discovery ;
97
97
char * refs_url ;
98
- int http_ret , is_http = 0 ;
98
+ int http_ret , maybe_smart = 0 ;
99
99
100
100
if (last && !strcmp (service , last -> service ))
101
101
return last ;
102
102
free_discovery (last );
103
103
104
104
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 ;
107
108
if (!strchr (url , '?' ))
108
109
strbuf_addch (& buffer , '?' );
109
110
else
@@ -131,7 +132,7 @@ static struct discovery* discover_refs(const char *service)
131
132
last -> buf_alloc = strbuf_detach (& buffer , & last -> len );
132
133
last -> buf = last -> buf_alloc ;
133
134
134
- if (is_http && 5 <= last -> len && last -> buf [4 ] == '#' ) {
135
+ if (maybe_smart && 5 <= last -> len && last -> buf [4 ] == '#' ) {
135
136
/* smart HTTP response; validate that the service
136
137
* pkt-line matches our request.
137
138
*/
Original file line number Diff line number Diff line change @@ -130,6 +130,18 @@ test_expect_success 'clone from auth-only-for-push repository' '
130
130
test_cmp expect actual
131
131
'
132
132
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
+
133
145
test -n " $GIT_TEST_LONG " && test_set_prereq EXPENSIVE
134
146
135
147
test_expect_success EXPENSIVE ' create 50,000 tags in the repo' '
You can’t perform that action at this time.
0 commit comments