code: def git_clone(url, dir, name, commithash=None):
      # TODO clone into temporary dir and move if successful
  
      if os.path.exists(dir):
          if commithash is None:
              return
  
          current_hash = run_git(
              dir,
              name,
              "rev-parse HEAD",
              None,
              f"Couldn't determine {name}'s hash: {commithash}",
              live=False,
          ).strip()
          if current_hash == commithash:
              return
  
          if (
              run_git(
                  dir,
                  name,
                  "config --get remote.origin.url",
                  None,
                  f"Couldn't determine {name}'s origin URL",
                  live=False,
              ).strip()
              != url
          ):
              run_git(
                  dir,
                  name,
                  f'remote set-url origin "{url}"',
                  None,
                  f"Failed to set {name}'s origin URL",
                  live=False,
              )
  
          run_git(
              dir,
              name,
              "fetch",
              f"Fetching updates for {name}...",
              f"Couldn't fetch {name}",
              autofix=False,
          )
  
          run_git(
              dir,
              name,
              f"checkout {commithash}",
              f"Checking out commit for {name} with hash: {commithash}...",
              f"Couldn't checkout commit {commithash} for {name}",
              live=True,
          )
  
          return
  
      try:
          run(
              f'"{git}" clone "{url}" "{dir}"',
              f"Cloning {name} into {dir}...",
              f"Couldn't clone {name}",
              live=True,
          )
      except RuntimeError:
          shutil.rmtree(dir, ignore_errors=True)
          raise
  
      if commithash is not None:
          run(
              f'"{git}" -C "{dir}" checkout {commithash}',
              None,
              "Couldn't checkout {name}'s hash: {commithash}",
          )
  
imports: import logging
  import re
  import subprocess
  import os
  import shutil
  import sys
  import importlib.util
  import importlib.metadata
  import platform
  import json
  from functools import lru_cache
  from modules import cmd_args, errors
  from modules.paths_internal import script_path, extensions_dir
  from modules.timer import startup_timer
  from modules import logging_config
label_desc: Use image node_id 11 for calling a global function with example usage: git_clone(url, dir, name, commithash) without return types