>If detach head is the same hash value with master, clone will auto choose
>"master", not detached HEAD. I already try git. that's the same behaviors.
>

*Sigh* You're right, I forgot about the `oid based guessing` algorithm.

>So I have to detach head as "master~1".

Do you know about the `git_revparse_single()` function? This might help make the test more explicit.

Below a quick proposal that leverages it and also asserts that the detached cloned head points to the correct oid.

```diff
diff --git a/tests-clar/clone/nonetwork.c b/tests-clar/clone/nonetwork.c
index e47a5ae..3e82256 100644
--- a/tests-clar/clone/nonetwork.c
+++ b/tests-clar/clone/nonetwork.c
@@ -177,21 +177,29 @@ void test_clone_nonetwork__can_checkout_given_branch(void)
 
 void test_clone_nonetwork__can_detached_head(void)
 {
diff --git a/tests-clar/clone/nonetwork.c b/tests-clar/clone/nonetwork.c
index e47a5ae..f409c5d 100644
--- a/tests-clar/clone/nonetwork.c
+++ b/tests-clar/clone/nonetwork.c
@@ -177,21 +177,29 @@ void test_clone_nonetwork__can_checkout_given_branch(void)
 
 void test_clone_nonetwork__can_detached_head(void)
 {
-	git_oid out;
-	git_commit *commit = NULL;
+	git_oid parent_oid;
+	git_object *commit;
+	git_reference *cloned_head;
+
 	cl_git_pass(git_clone(&g_repo, cl_git_fixture_url("testrepo.git"), "./foo", &g_options));
-	cl_git_pass(git_reference_name_to_id(&out, g_repo, "refs/heads/master"));
-	cl_git_pass(git_commit_lookup(&commit, g_repo, &out));
-	cl_git_pass(git_repository_set_head_detached(g_repo, git_commit_parent_id(commit, 0)));
+	
+	cl_git_pass(git_revparse_single(&commit, g_repo, "master~1"));
+	git_oid_cpy(&parent_oid, git_object_id(commit));
+	cl_git_pass(git_repository_set_head_detached(g_repo, &parent_oid));
 
-	/* remove all branch to make sure head detached */
+	git_object_free(commit);
 	git_repository_free(g_repo);
 	g_repo = NULL;
 
 	g_options.checkout_branch = NULL;
 	g_options.checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE_CREATE;
 	cl_git_pass(git_clone(&g_repo, "./foo", "./foo1", &g_options));
+
 	cl_assert(git_repository_head_detached(g_repo));
 
+	cl_git_pass(git_repository_head(&cloned_head, g_repo));
+	cl_assert(git_oid_cmp(&parent_oid, git_reference_target(cloned_head)) == 0);
+
+	git_reference_free(cloned_head);
 	cl_fixture_cleanup("./foo1");
 }
```