code: def test_ephemeral(
      origin_path=None,
      bare_path=None,
      clone1_path=None,
      clone2_path=None,
      clone3_path=None,
      clone4_path=None,
  ):
      can_symlink = has_symlink_capability()
  
      file_test = Path("ds") / "test.txt"
      file_testsub = Path("ds") / "subdir" / "testsub.txt"
  
      origin = Dataset(origin_path).create(force=True)
      origin.save()
  
      def check_clone(clone_):
          # common checks to do on a clone
          eq_(clone_.config.get("annex.private"), "true")
          if can_symlink:
              clone_annex = clone_.repo.dot_git / "annex"
              ok_(clone_annex.is_symlink())
              ok_(
                  clone_annex.resolve().samefile(
                      origin.repo.dot_git / "annex"
                  )
              )
              if not clone_.repo.is_managed_branch():
                  # TODO: We can't properly handle adjusted branch yet
                  eq_((clone_.pathobj / file_test).read_text(), "some")
                  eq_(
                      (clone_.pathobj / file_testsub).read_text(),
                      "somemore",
                  )
  
      # 1. clone via path
      clone1 = clone(origin_path, clone1_path, reckless="ephemeral")
      check_clone(clone1)
  
      # 2. clone via file-scheme URL
      clone2 = clone(
          "file://" + Path(origin_path).as_posix(),
          clone2_path,
          reckless="ephemeral",
      )
      check_clone(clone2)
  
      # 3. add something to clone1 and push back to origin availability from
      # clone1 should not be propagated (we declared 'here' dead to that end)
  
      (clone1.pathobj / "addition.txt").write_text("even more")
      clone1.save()
      origin.config.set(
          "receive.denyCurrentBranch", "updateInstead", scope="local"
      )
      # Note, that the only thing to test is git-annex-dead here,
      # if we couldn't symlink:
      clone1.push(
          to=DEFAULT_REMOTE, data="nothing" if can_symlink else "auto"
      )
  
      if external_versions["cmd:annex"] >= "8.20210428":
          # ephemeral clones are private (if supported by annex version). Despite
          # the push, clone1's UUID doesn't show up in origin
          recorded_locations = origin.repo.call_git(
              ["cat-file", "blob", "git-annex:uuid.log"], read_only=True
          )
          assert_not_in(
              clone1.config.get("annex.uuid"), recorded_locations
          )
  
      if not origin.repo.is_managed_branch():
          # test logic cannot handle adjusted branches
          eq_(origin.repo.get_hexsha(), clone1.repo.get_hexsha())
      res = origin.repo.whereis("addition.txt")
      if can_symlink:
          # obv. present in origin, but this is not yet known to origin:
          eq_(res, [])
          res = origin.repo.fsck()
          assert_result_count(res, 3, success=True)
          # TODO: Double check whether annex reports POSIX paths o windows!
          eq_(
              {str(file_test), str(file_testsub), "addition.txt"},
              {r["file"] for r in res},
          )
          # now origin knows:
      res = origin.repo.whereis("addition.txt")
      eq_(res, [origin.config.get("annex.uuid")])
  
      # 4. ephemeral clone from a bare repo
      runner = GitWitlessRunner()
      runner.run(["git", "clone", "--bare", origin_path, bare_path])
      runner.run(["git", "annex", "init"], cwd=bare_path)
  
      eph_from_bare = clone(
          bare_path, clone3_path, reckless="ephemeral"
      )
  
      if can_symlink:
          # Bare repo uses dirhashlower by default, while a standard repo uses
          # dirhashmixed. Symlinking different object trees doesn't really work.
          # Don't test that here, since this is not a matter of the "ephemeral"
          # option alone. We should have such a setup in the RIA tests and test
          # for data access there.
          # Here we only test for the correct linking.
          eph_annex = eph_from_bare.repo.dot_git / "annex"
          ok_(eph_annex.is_symlink())
          ok_(eph_annex.resolve().samefile(Path(bare_path) / "annex"))
  
      # 5. ephemeral clone using relative path
      # https://github.com/datalad/datalad/issues/7469
      with chpwd(op.dirname(origin_path)):
          clone4 = clone(
              op.basename(origin_path),
              op.basename(clone4_path),
              reckless="ephemeral",
          )
      check_clone(clone4)
  
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 36 for calling a global function with example usage: test_ephemeral(origin_path, bare_path, clone1_path, clone2_path, clone3_path, clone4_path) without return types