class_docstr: Representation of a Git repository
  
      
docstr: Allows for calling arbitrary commands.
  
  Internal helper to the call_git*() methods.
  Unlike call_git, _call_git returns both stdout and stderr.
  The parameters, return value, and raised exceptions match those
  documented for `call_git`, with the exception of env, which allows to
  specify the custom environment (variables) to be used.
docstr_tok: ["Allows","for","calling","arbitrary","commands",".","Internal","helper","to","the","call_git","*","(",")","methods",".","Unlike","call_git",",","_call_git","returns","both","stdout","and","stderr",".","The","parameters",",","return","value",",","and","raised","exceptions","match","those","documented","for","`","call_git","`",",","with","the","exception","of","env",",","which","allows","to","specify","the","custom","environment","(","variables",")","to","be","used","."]
code: def _call_git(
      self,
      args,
      files=None,
      expect_stderr=False,
      expect_fail=False,
      env=None,
      pathspec_from_file: Optional[bool] = False,
      read_only=False,
  ):
      """Allows for calling arbitrary commands.
  
      Internal helper to the call_git*() methods.
      Unlike call_git, _call_git returns both stdout and stderr.
      The parameters, return value, and raised exceptions match those
      documented for `call_git`, with the exception of env, which allows to
      specify the custom environment (variables) to be used.
      """
      runner = self._git_runner
      stderr_log_level = {True: 5, False: 11}[expect_stderr]
  
      read_write = not read_only
      if read_write and self._fake_dates_enabled:
          env = self.add_fake_dates_to_env(env if env else runner.env)
  
      output = {
          STDOUT_FILENO: [],
          STDERR_FILENO: [],
      }
  
      with lock_if_required(
          read_write, self._write_lock
      ), git_ignore_check(
          expect_fail, output[STDOUT_FILENO], output[STDERR_FILENO]
      ):
          for file_no, line in self._generator_call_git(
              args,
              files=files,
              env=env,
              pathspec_from_file=pathspec_from_file,
          ):
              output[file_no].append(line)
  
      for line in output[STDERR_FILENO]:
          lgr.log(stderr_log_level, "stderr| " + line.rstrip("\n"))
      return (
          "".join(output[STDOUT_FILENO]),
          "".join(output[STDERR_FILENO]),
      )
  
imports: import logging
  import re
  import threading
  import time
  from contextlib import contextmanager
  from locale import getpreferredencoding
  from os import environ
  from os.path import lexists
  from typing import Optional
  from weakref import finalize, WeakValueDictionary
  from datalad.cmd import GitWitlessRunner, StdOutErrCapture
  from datalad.config import ConfigManager
  from datalad.dataset.repo import PathBasedFlyweight, RepoInterface, path_based_str_repr
  from datalad.runner.nonasyncrunner import STDERR_FILENO, STDOUT_FILENO
  from datalad.runner.protocol import GeneratorMixIn
  from datalad.runner.utils import AssemblingDecoderMixIn, LineSplitter
  from datalad.support.exceptions import CommandError, GitIgnoreError, InvalidGitRepositoryError, PathKnownToRepositoryError
  from datalad.utils import ensure_list, lock_if_required, Path
label_desc: Use image node_id 12 for calling the GitRepo obj's underlying member method code with example usage: obj._call_git(args, files, expect_stderr, expect_fail, env, pathspec_from_file, read_only) and returns: str,  str