code: def _clone_default_branch(url, rev):  # noqa: PLR0912
      """Get or create a clean clone of the url.
  
      The cloned is reactualized with git pull unless rev is a known sha.
      """
      from dvc.scm import Git
  
      clone_path, shallow = CLONES.get(url) or (None, False)
  
      git = None
      try:
          if clone_path:
              git = Git(clone_path)
              # Do not pull for known shas, branches and tags might move
              if not Git.is_sha(rev) or not git.has_rev(rev):
                  if shallow:
                      # If we are missing a rev in a shallow clone, fallback to
                      # a full (unshallowed) clone. Since fetching specific rev
                      # SHAs is only available in certain git versions, if we
                      # have need to reference multiple specific revs for a
                      # given repo URL it is easier/safer for us to work with
                      # full clones in this case.
                      logger.debug(
                          "erepo: unshallowing clone for '%s'", url
                      )
                      _pull(git, unshallow=True)
                      shallow = False
                      CLONES[url] = (clone_path, shallow)
                  else:
                      logger.debug("erepo: git pull '%s'", url)
                      _pull(git)
          else:
              from dvc.scm import clone
  
              logger.debug(
                  "erepo: git clone '%s' to a temporary dir", url
              )
              clone_path = tempfile.mkdtemp("dvc-clone")
              if rev and not Git.is_sha(rev):
                  # If rev is a tag or branch name try shallow clone first
  
                  try:
                      git = clone(url, clone_path, shallow_branch=rev)
                      shallow = os.path.exists(
                          os.path.join(
                              clone_path, Git.GIT_DIR, "shallow"
                          )
                      )
                      if shallow:
                          logger.debug(
                              "erepo: using shallow clone for branch '%s'",
                              rev,
                          )
                  except CloneError:
                      git_dir = os.path.join(clone_path, ".git")
                      if os.path.exists(git_dir):
                          _remove(git_dir)
              if not git:
                  git = clone(url, clone_path)
                  shallow = False
              CLONES[url] = (clone_path, shallow)
      finally:
          if git:
              git.close()
  
      return clone_path, shallow
  
imports: import os
  import tempfile
  import threading
  from typing import TYPE_CHECKING, Dict, Optional, Tuple
  from funcy import retry, wrap_with
  from dvc.exceptions import NotDvcRepoError
  from dvc.log import logger
  from dvc.repo import Repo
  from dvc.scm import CloneError, map_scm_exception
  from dvc.utils import relpath
label_desc: Use image node_id 8 for calling a global function with example usage: _clone_default_branch(url, rev) and returns: clone_path,  shallow