code: def _try_git_clone_candidate(
      *, destds: Dataset, cand: Dict, clone_opts: List
  ) -> Tuple:
      """_try_clone_candidate() using `git-clone`
  
      Parameters and return value behavior is as described in
      `_try_clone_candidate()`.
      """
      if cand.get("version", None):
          opts = clone_opts + ["--branch=" + cand["version"]]
      else:
          opts = clone_opts
  
      try:
          GitRepo.clone(
              path=destds.path,
              url=cand["giturl"],
              clone_options=opts,
              create=True,
          )
  
      except CommandError as e:
          ce = CapturedException(e)
          e_stderr = e.stderr
  
          # MIH thinks this should rather use any of ce's message generating
          # methods, but kept it to avoid behavior changes
          error_msg = e
  
          if (
              e_stderr
              and "could not create work tree" in e_stderr.lower()
          ):
              # this cannot be fixed by trying another URL
              re_match = re.match(
                  r".*fatal: (.*)$",
                  e_stderr,
                  flags=re.MULTILINE | re.DOTALL,
              )
              # existential failure
              return (
                  cand["giturl"],
                  error_msg,
                  dict(
                      status="error",
                      message=re_match.group(1).strip()
                      if re_match
                      else "stderr: " + e_stderr,
                  ),
              )
  
          # failure for this URL
          return cand["giturl"], error_msg, None
  
      # success
      return cand["giturl"], None, None
  
imports: import logging
  import re
  from os.path import expanduser
  from pathlib import Path
  from typing import Dict, List, Tuple
  from urllib.parse import unquote
  from datalad.cmd import CommandError, GitWitlessRunner, StdOutCapture
  from datalad.config import ConfigManager
  from datalad.distributed.ora_remote import LocalIO, RIARemoteError, SSHRemoteIO
  from datalad.distribution.dataset import Dataset
  from datalad.distribution.utils import _get_flexible_source_candidates
  from datalad.dochelpers import single_or_plural
  from datalad.log import log_progress
  from datalad.runner.exception import CommandError
  from datalad.support.annexrepo import AnnexRepo
  from datalad.support.exceptions import CapturedException, DownloadError
  from datalad.support.gitrepo import GitRepo
  from datalad.support.network import RI, SSHRI, URL, DataLadRI, download_url, get_local_file_url, is_url
  from datalad.support.strings import get_replacement_dict
  from datalad.utils import Path, PurePosixPath, ensure_bool, ensure_list, make_tempfile, rmtree
label_desc: Use image node_id 12 for calling a global function with example usage: _try_git_clone_candidate() and returns: cand,  None,  None, cand,  error_msg,  None, cand,  error_msg,  dict