@@ -21,6 +21,7 @@ static git_clone_options g_options;
2121static char * _remote_url = NULL ;
2222static char * _remote_user = NULL ;
2323static char * _remote_pass = NULL ;
24+ static char * _remote_branch = NULL ;
2425static char * _remote_sslnoverify = NULL ;
2526static char * _remote_ssh_pubkey = NULL ;
2627static char * _remote_ssh_privkey = NULL ;
@@ -69,6 +70,7 @@ void test_online_clone__initialize(void)
6970 _remote_url = cl_getenv ("GITTEST_REMOTE_URL" );
7071 _remote_user = cl_getenv ("GITTEST_REMOTE_USER" );
7172 _remote_pass = cl_getenv ("GITTEST_REMOTE_PASS" );
73+ _remote_branch = cl_getenv ("GITTEST_REMOTE_BRANCH" );
7274 _remote_sslnoverify = cl_getenv ("GITTEST_REMOTE_SSL_NOVERIFY" );
7375 _remote_ssh_pubkey = cl_getenv ("GITTEST_REMOTE_SSH_PUBKEY" );
7476 _remote_ssh_privkey = cl_getenv ("GITTEST_REMOTE_SSH_KEY" );
@@ -102,6 +104,7 @@ void test_online_clone__cleanup(void)
102104 git__free (_remote_url );
103105 git__free (_remote_user );
104106 git__free (_remote_pass );
107+ git__free (_remote_branch );
105108 git__free (_remote_sslnoverify );
106109 git__free (_remote_ssh_pubkey );
107110 git__free (_remote_ssh_privkey );
@@ -1025,3 +1028,23 @@ void test_online_clone__namespace_bare(void)
10251028
10261029 git_reference_free (head );
10271030}
1031+
1032+ void test_online_clone__namespace_with_specified_branch (void )
1033+ {
1034+ git_clone_options options = GIT_CLONE_OPTIONS_INIT ;
1035+ git_reference * head ;
1036+
1037+ if (!_remote_url || !_remote_branch )
1038+ cl_skip ();
1039+
1040+ options .checkout_branch = _remote_branch ;
1041+
1042+ cl_git_pass (git_clone (& g_repo , _remote_url , "./namespaced" , & options ));
1043+
1044+ cl_git_pass (git_reference_lookup (& head , g_repo , GIT_HEAD_FILE ));
1045+ cl_assert_equal_i (GIT_REFERENCE_SYMBOLIC , git_reference_type (head ));
1046+ cl_assert_equal_strn ("refs/heads/" , git_reference_symbolic_target (head ), 11 );
1047+ cl_assert_equal_s (_remote_branch , git_reference_symbolic_target (head ) + 11 );
1048+
1049+ git_reference_free (head );
1050+ }
0 commit comments