@@ -32,6 +32,8 @@ static char *_remote_proxy_user = NULL;
3232static char * _remote_proxy_pass = NULL ;
3333static char * _remote_proxy_selfsigned = NULL ;
3434static char * _remote_expectcontinue = NULL ;
35+ static char * _remote_redirect_initial = NULL ;
36+ static char * _remote_redirect_subsequent = NULL ;
3537
3638static int _orig_proxies_need_reset = 0 ;
3739static char * _orig_http_proxy = NULL ;
@@ -78,6 +80,8 @@ void test_online_clone__initialize(void)
7880 _remote_proxy_pass = cl_getenv ("GITTEST_REMOTE_PROXY_PASS" );
7981 _remote_proxy_selfsigned = cl_getenv ("GITTEST_REMOTE_PROXY_SELFSIGNED" );
8082 _remote_expectcontinue = cl_getenv ("GITTEST_REMOTE_EXPECTCONTINUE" );
83+ _remote_redirect_initial = cl_getenv ("GITTEST_REMOTE_REDIRECT_INITIAL" );
84+ _remote_redirect_subsequent = cl_getenv ("GITTEST_REMOTE_REDIRECT_SUBSEQUENT" );
8185
8286 if (_remote_expectcontinue )
8387 git_libgit2_opts (GIT_OPT_ENABLE_HTTP_EXPECT_CONTINUE , 1 );
@@ -92,6 +96,8 @@ void test_online_clone__cleanup(void)
9296 g_repo = NULL ;
9397 }
9498 cl_fixture_cleanup ("./foo" );
99+ cl_fixture_cleanup ("./initial" );
100+ cl_fixture_cleanup ("./subsequent" );
95101
96102 git__free (_remote_url );
97103 git__free (_remote_user );
@@ -107,6 +113,8 @@ void test_online_clone__cleanup(void)
107113 git__free (_remote_proxy_pass );
108114 git__free (_remote_proxy_selfsigned );
109115 git__free (_remote_expectcontinue );
116+ git__free (_remote_redirect_initial );
117+ git__free (_remote_redirect_subsequent );
110118
111119 if (_orig_proxies_need_reset ) {
112120 cl_setenv ("HTTP_PROXY" , _orig_http_proxy );
@@ -938,3 +946,59 @@ void test_online_clone__path_whitespace(void)
938946 cl_git_pass (git_clone (& g_repo , "https://libgit2@dev.azure.com/libgit2/test/_git/spaces%20in%20the%20name" , "./foo" , & g_options ));
939947 cl_assert (git_fs_path_exists ("./foo/master.txt" ));
940948}
949+
950+ void test_online_clone__redirect_default_succeeds_for_initial (void )
951+ {
952+ git_clone_options options = GIT_CLONE_OPTIONS_INIT ;
953+
954+ if (!_remote_redirect_initial || !_remote_redirect_subsequent )
955+ cl_skip ();
956+
957+ cl_git_pass (git_clone (& g_repo , _remote_redirect_initial , "./initial" , & options ));
958+ }
959+
960+ void test_online_clone__redirect_default_fails_for_subsequent (void )
961+ {
962+ git_clone_options options = GIT_CLONE_OPTIONS_INIT ;
963+
964+ if (!_remote_redirect_initial || !_remote_redirect_subsequent )
965+ cl_skip ();
966+
967+ cl_git_fail (git_clone (& g_repo , _remote_redirect_subsequent , "./fail" , & options ));
968+ }
969+
970+ void test_online_clone__redirect_none (void )
971+ {
972+ git_clone_options options = GIT_CLONE_OPTIONS_INIT ;
973+
974+ if (!_remote_redirect_initial )
975+ cl_skip ();
976+
977+ options .fetch_opts .follow_redirects = GIT_REMOTE_REDIRECT_NONE ;
978+
979+ cl_git_fail (git_clone (& g_repo , _remote_redirect_initial , "./fail" , & options ));
980+ }
981+
982+ void test_online_clone__redirect_initial_succeeds_for_initial (void )
983+ {
984+ git_clone_options options = GIT_CLONE_OPTIONS_INIT ;
985+
986+ if (!_remote_redirect_initial || !_remote_redirect_subsequent )
987+ cl_skip ();
988+
989+ options .fetch_opts .follow_redirects = GIT_REMOTE_REDIRECT_INITIAL ;
990+
991+ cl_git_pass (git_clone (& g_repo , _remote_redirect_initial , "./initial" , & options ));
992+ }
993+
994+ void test_online_clone__redirect_initial_fails_for_subsequent (void )
995+ {
996+ git_clone_options options = GIT_CLONE_OPTIONS_INIT ;
997+
998+ if (!_remote_redirect_initial || !_remote_redirect_subsequent )
999+ cl_skip ();
1000+
1001+ options .fetch_opts .follow_redirects = GIT_REMOTE_REDIRECT_INITIAL ;
1002+
1003+ cl_git_fail (git_clone (& g_repo , _remote_redirect_subsequent , "./fail" , & options ));
1004+ }
0 commit comments