}
 #endif
 
-static long get_curl_allowed_protocols(void)
+static long get_curl_allowed_protocols(int from_user)
 {
        long allowed_protocols = 0;
 
-       if (is_transport_allowed("http"))
+       if (is_transport_allowed("http", from_user))
                allowed_protocols |= CURLPROTO_HTTP;
-       if (is_transport_allowed("https"))
+       if (is_transport_allowed("https", from_user))
                allowed_protocols |= CURLPROTO_HTTPS;
-       if (is_transport_allowed("ftp"))
+       if (is_transport_allowed("ftp", from_user))
                allowed_protocols |= CURLPROTO_FTP;
-       if (is_transport_allowed("ftps"))
+       if (is_transport_allowed("ftps", from_user))
                allowed_protocols |= CURLPROTO_FTPS;
 
        return allowed_protocols;
 #endif
 #if LIBCURL_VERSION_NUM >= 0x071304
        curl_easy_setopt(result, CURLOPT_REDIR_PROTOCOLS,
-                        get_curl_allowed_protocols());
+                        get_curl_allowed_protocols(0));
        curl_easy_setopt(result, CURLOPT_PROTOCOLS,
-                        get_curl_allowed_protocols());
+                        get_curl_allowed_protocols(-1));
 #else
        warning("protocol restrictions not applied to curl redirects because\n"
                "your curl version is too old (>= 7.19.4)");
 
        test_must_fail git clone "$HTTPD_URL/loop-redir/smart/repo.git"
 '
 
+test_expect_success 'http can be limited to from-user' '
+       git -c protocol.http.allow=user \
+               clone "$HTTPD_URL/smart/repo.git" plain.git &&
+       test_must_fail git -c protocol.http.allow=user \
+               clone "$HTTPD_URL/smart-redir-perm/repo.git" redir.git
+'
+
 stop_httpd
 test_done
 
        return PROTOCOL_ALLOW_USER_ONLY;
 }
 
-int is_transport_allowed(const char *type)
+int is_transport_allowed(const char *type, int from_user)
 {
        const struct string_list *whitelist = protocol_whitelist();
        if (whitelist)
        case PROTOCOL_ALLOW_NEVER:
                return 0;
        case PROTOCOL_ALLOW_USER_ONLY:
-               return git_env_bool("GIT_PROTOCOL_FROM_USER", 1);
+               if (from_user < 0)
+                       from_user = git_env_bool("GIT_PROTOCOL_FROM_USER", 1);
+               return from_user;
        }
 
        die("BUG: invalid protocol_allow_config type");
 
 void transport_check_allowed(const char *type)
 {
-       if (!is_transport_allowed(type))
+       if (!is_transport_allowed(type, -1))
                die("transport '%s' not allowed", type);
 }
 
 
 struct transport *transport_get(struct remote *, const char *);
 
 /*
- * Check whether a transport is allowed by the environment. Type should
- * generally be the URL scheme, as described in Documentation/git.txt
+ * Check whether a transport is allowed by the environment.
+ *
+ * Type should generally be the URL scheme, as described in
+ * Documentation/git.txt
+ *
+ * from_user specifies if the transport was given by the user.  If unknown pass
+ * a -1 to read from the environment to determine if the transport was given by
+ * the user.
+ *
  */
-int is_transport_allowed(const char *type);
+int is_transport_allowed(const char *type, int from_user);
 
 /*
  * Check whether a transport is allowed by the environment,