code: def test_clone_unborn_head(path=None):
      ds_origin = Dataset(op.join(path, "a")).create()
      repo = ds_origin.repo
      managed = repo.is_managed_branch()
  
      # The setup below is involved, mostly because it's accounting for adjusted
      # branches. The scenario itself isn't so complicated, though:
      #
      #   * a checked out default branch with no commits
      #   * a (potentially adjusted) "abc" branch with commits.
      #   * a (potentially adjusted) "chooseme" branch whose tip commit has a
      #     more recent commit than any in "abc".
      (ds_origin.pathobj / "foo").write_text("foo content")
      ds_origin.save(message="foo")
      for res in repo.for_each_ref_(fields="refname"):
          ref = res["refname"]
          if DEFAULT_BRANCH in ref:
              repo.update_ref(ref.replace(DEFAULT_BRANCH, "abc"), ref)
              repo.call_git(["update-ref", "-d", ref])
      repo.update_ref(
          "HEAD",
          "refs/heads/{}".format(
              "adjusted/abc(unlocked)" if managed else "abc"
          ),
          symbolic=True,
      )
      abc_ts = int(repo.format_commit("%ct"))
      repo.call_git(["checkout", "-b", "chooseme", "abc~1"])
      if managed:
          repo.adjust()
      (ds_origin.pathobj / "bar").write_text("bar content")
      with set_date(abc_ts + 1):
          ds_origin.save(message="bar")
      # Make the git-annex branch the most recently updated ref so that we test
      # that it is skipped.
      with set_date(abc_ts + 2):
          ds_origin.drop("bar", reckless="kill")
      ds_origin.repo.checkout(DEFAULT_BRANCH, options=["--orphan"])
  
      ds = clone(ds_origin.path, op.join(path, "b"))
      # We landed on the branch with the most recent commit, ignoring the
      # git-annex branch.
      branch = ds.repo.get_active_branch()
      eq_(
          ds.repo.get_corresponding_branch(branch) or branch, "chooseme"
      )
      eq_(
          ds_origin.repo.get_hexsha("chooseme"),
          ds.repo.get_hexsha("chooseme"),
      )
      # In the context of this test, the clone should be on an adjusted branch if
      # the source landed there initially because we're on the same file system.
      eq_(managed, ds.repo.is_managed_branch())
  
imports: import logging
  import os.path
  import stat
  from unittest.mock import patch
  import pytest
  from datalad import consts
  from datalad.api import clone, create, remove
  from datalad.cmd import GitWitlessRunner
  from datalad.cmd import WitlessRunner
  from datalad.config import ConfigManager
  from datalad.core.distributed.clone_utils import _get_installationpath_from_url, decode_source_spec
  from datalad.distribution.dataset import Dataset
  from datalad.support.annexrepo import AnnexRepo
  from datalad.support.exceptions import IncompleteResultsError
  from datalad.support.external_versions import external_versions
  from datalad.support.gitrepo import GitRepo
  from datalad.support.network import get_local_file_url
  from datalad.tests.utils_pytest import DEFAULT_BRANCH, DEFAULT_REMOTE, SkipTest, assert_false, assert_in, assert_in_results, assert_message, assert_not_in, assert_not_is_instance, assert_raises, assert_repo_status, assert_result_count, assert_result_values_equal, assert_status, create_tree, eq_, get_datasets_topdir, has_symlink_capability, integration, known_failure, known_failure_githubci_win, known_failure_osx, known_failure_windows, neq_, nok_, ok_, ok_file_has_content, ok_startswith, on_github, on_osx, on_travis, patch_config, serve_path_via_http, set_date, skip_if, skip_if_adjusted_branch, skip_if_no_network, skip_if_on_windows, skip_ssh, slow, swallow_logs, with_sameas_remote, with_tempfile, with_tree, xfail_buggy_annex_info
  from datalad.utils import Path, chpwd, get_home_envvars, on_windows, rmtree
label_desc: Use image node_id 37 for calling a global function with example usage: test_clone_unborn_head(path) without return types