class_docstr: Mix-in class for Runners to be used to run git and git annex commands
  
  Overloads the runner class to check & update GIT_DIR and
  GIT_WORK_TREE environment variables set to the absolute path
  if is defined and is relative path
class_docstr_tok: ["Mix-in","class","for","Runners","to","be","used","to","run","git","and","git","annex","commands","Overloads","the","runner","class","to","check","&","update","GIT_DIR","and","GIT_WORK_TREE","environment","variables","set","to","the","absolute","path","if","is","defined","and","is","relative","path"]
docstr: Replaces GIT_DIR and GIT_WORK_TREE with absolute paths if relative path and defined
docstr_tok: ["Replaces","GIT_DIR","and","GIT_WORK_TREE","with","absolute","paths","if","relative","path","and","defined"]
code: def get_git_environ_adjusted(env=None):
      """
      Replaces GIT_DIR and GIT_WORK_TREE with absolute paths if relative path and defined
      """
      # if env set copy else get os environment
      git_env = env.copy() if env else os.environ.copy()
      if GitRunnerBase._GIT_PATH:
          git_env["PATH"] = (
              op.pathsep.join(
                  [GitRunnerBase._GIT_PATH, git_env["PATH"]]
              )
              if "PATH" in git_env
              else GitRunnerBase._GIT_PATH
          )
  
      for varstring in ["GIT_DIR", "GIT_WORK_TREE"]:
          var = git_env.get(varstring)
          if var:  # if env variable set
              if not op.isabs(var):  # and it's a relative path
                  git_env[varstring] = op.abspath(
                      var
                  )  # to absolute path
                  lgr.log(
                      9,
                      "Updated %s to %s",
                      varstring,
                      git_env[varstring],
                  )
  
      if "GIT_SSH_COMMAND" not in git_env:
          git_env["GIT_SSH_COMMAND"] = GIT_SSH_COMMAND
          git_env["GIT_SSH_VARIANT"] = "ssh"
      git_env["GIT_ANNEX_USE_GIT_SSH"] = "1"
  
      # We are parsing error messages and hints. For those to work more
      # reliably we are doomed to sacrifice i18n effort of git, and enforce
      # consistent language of the messages
      git_env["LC_MESSAGES"] = "C"
      # But since LC_ALL takes precedence, over LC_MESSAGES, we cannot
      # "leak" that one inside, and are doomed to pop it
      git_env.pop("LC_ALL", None)
  
      return git_env
  
imports: import logging
  import os
  import os.path
  from typing import Optional
  from datalad.dochelpers import borrowdoc
  from datalad.utils import generate_file_chunks, make_tempfile
  from .runner import GeneratorMixIn, WitlessRunner
label_desc: Use image node_id 3 for calling the GitRunnerBase obj's underlying member method code with example usage: obj.get_git_environ_adjusted(env) and returns: git_env