@@ -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 );
@@ -1016,3 +1019,42 @@ void test_online_clone__redirect_initial_fails_for_subsequent(void)
10161019
10171020 cl_git_fail (git_clone (& g_repo , _remote_redirect_subsequent , "./fail" , & options ));
10181021}
1022+
1023+ void test_online_clone__namespace_bare (void )
1024+ {
1025+ git_clone_options options = GIT_CLONE_OPTIONS_INIT ;
1026+ git_reference * head ;
1027+
1028+ if (!_remote_url )
1029+ cl_skip ();
1030+
1031+ options .bare = true;
1032+
1033+ cl_git_pass (git_clone (& g_repo , _remote_url , "./namespaced.git" , & options ));
1034+
1035+ cl_git_pass (git_reference_lookup (& head , g_repo , GIT_HEAD_FILE ));
1036+ cl_assert_equal_i (GIT_REFERENCE_SYMBOLIC , git_reference_type (head ));
1037+ cl_assert_equal_s ("refs/heads/master" , git_reference_symbolic_target (head ));
1038+
1039+ git_reference_free (head );
1040+ }
1041+
1042+ void test_online_clone__namespace_with_specified_branch (void )
1043+ {
1044+ git_clone_options options = GIT_CLONE_OPTIONS_INIT ;
1045+ git_reference * head ;
1046+
1047+ if (!_remote_url || !_remote_branch )
1048+ cl_skip ();
1049+
1050+ options .checkout_branch = _remote_branch ;
1051+
1052+ cl_git_pass (git_clone (& g_repo , _remote_url , "./namespaced" , & options ));
1053+
1054+ cl_git_pass (git_reference_lookup (& head , g_repo , GIT_HEAD_FILE ));
1055+ cl_assert_equal_i (GIT_REFERENCE_SYMBOLIC , git_reference_type (head ));
1056+ cl_assert_equal_strn ("refs/heads/" , git_reference_symbolic_target (head ), 11 );
1057+ cl_assert_equal_s (_remote_branch , git_reference_symbolic_target (head ) + 11 );
1058+
1059+ git_reference_free (head );
1060+ }
0 commit comments