code: def test_empty_git_upstairs(topdir=None):
      # create() doesn't get confused by an empty .git/ upstairs (gh-3473)
      assert_in_results(
          create(op.join(topdir, "empty", "ds"), **raw),
          status="ok",
          type="dataset",
          action="create",
      )
      # ... and it will ignore non-meaningful content in .git
      assert_in_results(
          create(op.join(topdir, "nonempty", "ds"), **raw),
          status="ok",
          type="dataset",
          action="create",
      )
      # ... but it will raise if it detects a valid repo
      # (by existence of .git/HEAD as defined in GitRepo._valid_git_test_path)
      with assert_raises(CommandError):
          create(op.join(topdir, "git_with_head", "ds"), **raw)
  
imports: import os
  import os.path
  import pytest
  from datalad.api import create
  from datalad.cmd import WitlessRunner
  from datalad.distribution.dataset import Dataset
  from datalad.support.annexrepo import AnnexRepo
  from datalad.support.exceptions import CommandError
  from datalad.tests.utils_pytest import OBSCURE_FILENAME, assert_in, assert_in_results, assert_not_in, assert_raises, assert_repo_status, assert_status, eq_, has_symlink_capability, ok_, ok_exists, swallow_outputs, with_tempfile, with_tree
  from datalad.utils import Path, chpwd
label_desc: Use image node_id 15 for calling a global function with example usage: test_empty_git_upstairs(topdir) without return types