class_docstr: Representation of a Git repository
  
      
docstr: Call git, yield stdout and stderr lines when available. Output lines
  are split at line ends or `sep` if `sep` is not None.
  
  Parameters
  ----------
  sep : str, optional
    Use `sep` as line separator. Does not create an empty last line if
    the input ends on sep. The lines contain the separator, if it exists.
  
  All other parameters match those described for `call_git`.
  
  Returns
  -------
  Generator that yields tuples of `(file_no, line)`, where `file_no` is
  either:
  
   - `datalad.runner.nonasyncrunner.STDOUT_FILENO` for stdout, or
   - `datalad.runner.nonasyncrunner.STDERR_FILENO` for stderr,
  
  and `line` is the next result line, split on `sep`, or on standard line
  ends.
  
  Raises
  ------
  CommandError if the call exits with a non-zero status.
docstr_tok: ["Call","git",",","yield","stdout","and","stderr","lines","when","available",".","Output","lines","are","split","at","line","ends","or","`","sep","`","if","`","sep","`","is","not","None",".","Parameters","--","--","--","--","--","sep",":","str",",","optional","Use","`","sep","`","as","line","separator",".","Does","not","create","an","empty","last","line","if","the","input","ends","on","sep",".","The","lines","contain","the","separator",",","if","it","exists",".","All","other","parameters","match","those","described","for","`","call_git","`",".","Returns","--","--","--","-","Generator","that","yields","tuples","of","`","(","file_no",",","line",")","`",",","where","`","file_no","`","is","either",":","-","`","datalad.runner.nonasyncrunner.STDOUT_FILENO","`","for","stdout",",","or","-","`","datalad.runner.nonasyncrunner.STDERR_FILENO","`","for","stderr",",","and","`","line","`","is","the","next","result","line",",","split","on","`","sep","`",",","or","on","standard","line","ends",".","Raises","--","--","--","CommandError","if","the","call","exits","with","a","non-zero","status","."]
code: def _generator_call_git(
      self,
      args,
      *,
      files=None,
      env=None,
      pathspec_from_file: Optional[bool] = False,
      sep=None,
  ):
      """
      Call git, yield stdout and stderr lines when available. Output lines
      are split at line ends or `sep` if `sep` is not None.
  
      Parameters
      ----------
      sep : str, optional
        Use `sep` as line separator. Does not create an empty last line if
        the input ends on sep. The lines contain the separator, if it exists.
  
      All other parameters match those described for `call_git`.
  
      Returns
      -------
      Generator that yields tuples of `(file_no, line)`, where `file_no` is
      either:
  
       - `datalad.runner.nonasyncrunner.STDOUT_FILENO` for stdout, or
       - `datalad.runner.nonasyncrunner.STDERR_FILENO` for stderr,
  
      and `line` is the next result line, split on `sep`, or on standard line
      ends.
  
      Raises
      ------
      CommandError if the call exits with a non-zero status.
      """
  
      class GeneratorStdOutErrCapture(
          GeneratorMixIn, AssemblingDecoderMixIn, StdOutErrCapture
      ):
          """
          Generator-runner protocol that captures and yields stdout and stderr.
          """
  
          def __init__(self):
              GeneratorMixIn.__init__(self)
              AssemblingDecoderMixIn.__init__(self)
              StdOutErrCapture.__init__(self)
  
          def pipe_data_received(self, fd, data):
              if fd in (1, 2):
                  self.send_result(
                      (fd, self.decode(fd, data, self.encoding))
                  )
              else:
                  StdOutErrCapture.pipe_data_received(self, fd, data)
  
      cmd = self._git_cmd_prefix + args
  
      if files:
          # only call the wrapper if needed (adds distraction logs
          # otherwise, and also maintains the possibility to connect
          # stdin in the future)
          generator = self._git_runner.run_on_filelist_chunks_items_(
              cmd,
              files,
              protocol=GeneratorStdOutErrCapture,
              env=env,
              pathspec_from_file=pathspec_from_file,
          )
      elif files is not None:
          # it was an empty structure, so we did provide paths but "empty",
          # then we must not return anything. For more reasoning see
          # ec0243c92822f36ada5e87557eb9f5f53929c9ff which added similar code pattern
          # within get_content_info
          return
      else:
          generator = self._git_runner.run(
              cmd, protocol=GeneratorStdOutErrCapture, env=env
          )
  
      line_splitter = {
          STDOUT_FILENO: LineSplitter(sep, keep_ends=True),
          STDERR_FILENO: LineSplitter(sep, keep_ends=True),
      }
  
      for file_no, content in generator:
          if file_no in (STDOUT_FILENO, STDERR_FILENO):
              for line in line_splitter[file_no].process(content):
                  yield file_no, line
          else:
              raise ValueError(f"unknown file number: {file_no}")
  
      for file_no in (STDOUT_FILENO, STDERR_FILENO):
          remaining_content = line_splitter[file_no].finish_processing()
          if remaining_content is not None:
              yield file_no, remaining_content
  
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 11 for calling the GitRepo obj's underlying member method code with example usage: obj._generator_call_git(args) without return types