yL iUddlmZddgZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z m Z m Z ddlZddlmZddlZddlZddlmZmZmZddlmZmZmZmZmZdd lmZmZm Z m!Z!m"Z"m#Z#dd l$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5ejld k\rdd l$m7Z7ndd l8m7Z7dd l9m:Z:m;Z;mZ>ddl?m@Z@hdZAejeCZD d* d+dZEdeFd<ejdk(rddd d,dZHeHZIne ZId-dZJd.d/dZKd.d0dZLGddZMdeM_CdeM_NGdd ZOd!eO_Cd"eO_Nd#ZPd$ZQd1d%ZRGd&d'eSZTeTZU Gd(deT)ZVy)2) annotationsGitMetaGitN)DEVNULLPIPEPopen)dedent)defenc force_bytes safe_decode) CommandErrorGitCommandErrorGitCommandNotFoundUnsafeOptionErrorUnsafeProtocolError)cygpath expand_path is_cygwin_git patch_envremove_password_if_present stream_copy)AnyAnyStrBinaryIOCallableDictIOIteratorListMappingOptionalSequence TYPE_CHECKINGTextIOTupleUnioncastoverload) ) TypeAlias)LiteralPathLikeTBD) DiffIndex)Repo> envshellistream as_process with_stdout output_streammax_chunk_sizewith_exceptionsstdout_as_stringkill_after_timeoutuniversal_newlineswith_extended_outputstrip_newline_in_stdoutc , dd}t|drltd|}t|jdd}|jr|jjnd}|jr|jj nd} n5tt |}t|dd}|j}|j } t|ttfs|j}g} |r| jd||f| r| jd| |fg} | D]J\} } }tj||| | ||f }d |_|j| j|L| D]}|j!| |j#s&t|t$j&r|j)nt+d |d |scd|d }|s0t| t,r tt.|}|j1}|||r ||yy)aRegister for notifications to learn that process output is ready to read, and dispatch lines to the respective line handlers. This function returns once the finalizer returns. :param process: :class:`subprocess.Popen` instance. :param stdout_handler: f(stdout_line_string), or ``None``. :param stderr_handler: f(stderr_line_string), or ``None``. :param finalizer: f(proc) - wait for proc to finish. :param decode_streams: Assume stdout/stderr streams are binary and decode them before pushing their contents to handlers. This defaults to ``True``. Set it to ``False`` if: - ``universal_newlines == True``, as then streams are in text mode, or - decoding must happen later, such as for :class:`~git.diff.Diff`\s. :param kill_after_timeout: :class:`float` or ``None``, Default = ``None`` To specify a timeout in seconds for the git command, after which the process should be killed. c  |D]?}|s|r0t|tsJ|jt}||8||A |jy#t$r\}t j d|dt|d|dt|vrtd|dgt|z||Yd}~qd}~wwxYw#|jwxYw)NzPumping z of cmd(z) failed due to: zI/O operation on closed file) isinstancebytesdecoder Exception_loggererrorrstrr close)cmdlinenamestream is_decodehandlerlineline_strexs M/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/git/cmd.py pump_streamz*handle_process_output..pump_streams  & )$666#';;v#6)  & LLN  i MMHTHH5OPW5X4YYjkmjpq r-SW<"avV$4#58RSZ8[#[]_`fhh= i LLNs5A>>> gt} ---/>@E h.9: h.9:&(G!&fg   Kwfn^e6f g  q * )* ::<'3#4#45""$"++=*>hHUVhUiiqr&*Xx*H $S) 4I ) 0 0 2Iy))*,'zCallable[..., Popen] safer_popenwin32F)r2r1c tjtjz}|r|in t|}d|d<t dd5t |f|||d|cdddS#1swYyxYw)aCall :class:`subprocess.Popen` on Windows but don't include a CWD in the search. This avoids an untrusted search path condition where a file like ``git.exe`` in a malicious repository would be run when GitPython operates on the repository. The process using GitPython may have an untrusted repository's working tree as its current working directory. Some operations may temporarily change to that directory before running a subprocess. In addition, while by default GitPython does not run external commands with a shell, it can be made to do so, in which case the CWD of the subprocess, which GitPython usually sets to a repository working tree, can itself be searched automatically by the shell. This wrapper covers all those cases. :note: This currently works by setting the :envvar:`NoDefaultCurrentDirectoryInExePath` environment variable during subprocess creation. It also takes care of passing Windows-specific process creation flags, but that is unrelated to path search. :note: The current implementation contains a race condition on :attr:`os.environ`. GitPython isn't thread-safe, but a program using it on one thread should ideally be able to mutate :attr:`os.environ` on another, without unpredictable results. See comments in: https://github.com/gitpython-developers/GitPython/pull/1650 N1"NoDefaultCurrentDirectoryInExePath)r2r1 creationflags) subprocessCREATE_NO_WINDOWCREATE_NEW_PROCESS_GROUPdictrr)commandr2r1kwargsrs rQ_safer_popen_windowsrsH#33j6Y6YY   "cC8;C4 5;S A +      s AA'c&|jddS)N_-)replace)strings rQdashifyr+s >>#s ##r{c`|jDcic]}||vs|t||c}Scc}wN) __slots__r`)selfexcludess rQ slots_to_dictr/s-)- LA1G;KAwtQ  LL Ls ++cv|jD]\}}t||||D]}t||dyr)itemssetattr)rdexcludedkvs rQ$dict_to_slots_and__excluded_are_noner3sB 1a ar{cNeZdZUdZdZdZded<d dZd dZd dZ dd Z ddd Z y )_AutoInterruptaProcess wrapper that terminates the wrapped process on finalization. This kills/interrupts the stored process instance once this instance goes out of scope. It is used to prevent processes piling up in case iterators stop reading. All attributes are wired through to the contained process object. The wait method is overridden to perform automatic status code checking and possibly raise. rSrUstatusrint_status_code_if_terminatec.||_||_d|_yrr)rrSrUs rQ__init__z_AutoInterrupt.__init__Os  (, r{c|jy|j}d|_|jr|jj|jr|jj|jr|jj |j $|j xs|j |_y tttddy |j|j}|j xs||_y#t$r }tjd|Yd}~sd}~wwxYw#t$r }tjd|Yd}~yd}~wwxYw)z!Terminate the underlying process.Nz(Ignored error after process had died: %rkill)rSstdinrHrWrXpollrrOSErrorrEinfoosr` terminatewait)rrSrPrs rQrlz_AutoInterrupt._terminateTs& 99  yy :: JJ    ;; KK    ;; KK    Iyy{&"<<K  ' :VT2:  I NN YY[F88BFDK I LLCR H H I I LLCR H H Is03D"5E E!D<<E E- E((E-c$|jyr)rlrs rQ__del__z_AutoInterrupt.__del__ws  r{c.t|j|Sr)r`rS)rattrs rQ __getattr__z_AutoInterrupt.__getattr__zstyy$''r{cV|dt|d|j1|jj}|jj}n|j}d}dfd }|dk7r@||}t j d|tt|j|||S) a[Wait for the process and return its status code. :param stderr: Previously read value of stderr, in case stderr is already closed. :warn: May deadlock if output or error pipes are used and not handled separately. :raise git.exc.GitCommandError: If the return status is not 0. Nr{zutf-8)dataencodingc|r t|jzSxsdS#ttf$r xsdcYSwxYw)Nr{)r readr ValueError)rKstderr_bs rQ$read_all_from_possibly_closed_streamzA_AutoInterrupt.wait..read_all_from_possibly_closed_streamsM+#k&++-&@@@ 3& ,+#?s*+s '??rzAutoInterrupt wait stderr: )rKzUnion[IO[bytes], None]r]rB) r rSrrXrrEdebugrrrU)rrXrrurerrstrrs @rQrz_AutoInterrupt.wait~s >HFW= 99 YY^^%Fyy''H[[FH ' Q;9(CF MMVE F!"dZed?dZeed@dAdZeed=dBdZed=dCdZedDdZedEdZeZded<e Z!ded<d=dFfd Z"dGfd Z#dGfd Z$dHdZ%e&dIdZ'e&dJdZ(e dKdZ)ed d  dLd!Z)ed d d" dMd#Z)e dNd$Z)e dOd%Z)dd d&d dd&dd&d dde*jVd&f dPfd' Z)dQd(Z,dRd)Z-e.j^dSd*Z0dTd+Z1dUdVd,Z2edWd-Z3dXd.Z4e dYd/Z5e dZd0Z5e d[d1Z5 d[d2Z5d\d3Z6d]d4Z7d^d5Z8d_d6Z9d`d7Z:dad8Z;dbd9ZS)draThe Git class manages communication with the Git binary. It provides a convenient interface to calling the Git binary, such as in:: g = Git( git_dir ) g.init() # calls 'git init' program rval = g.ls_files() # calls 'git ls-files' program Debugging: * Set the :envvar:`GIT_PYTHON_TRACE` environment variable to print each invocation of the command to stdout. * Set its value to ``full`` to see details about the returned values. ) _working_dir cat_file_allcat_file_header _version_info_version_info_token _git_options_persistent_git_options _environment)rrrrz(.+)::.+c0t||jS)N)r)r _excluded_rs rQ __getstate__zGit.__getstate__sT4??;;r{c4t|||jy)N)r)rr )rrs rQ __setstate__zGit.__setstate__s,T1tOr{gitGIT_PYTHON_TRACEFr\rGIT_PYTHON_GIT_EXECUTABLEGIT_PYTHON_REFRESHNc |?tjj|}tjj|}n4tjj |j |j}|j}|j}||_t|_ d} |jd}|sktd|j z}||_||_ |6tjj |jdj!}gd}gd} gd} ||vrn|| vs|| vr~td||jd j#|d j#| d j#| |j|d fz}|| vrt$j'|n_t)|td |jd j#|d j#| d j#| fz}t)||j|_|St|||S#ttf$rYwxYw) a5 Update information about the git executable :class:`Git` objects will use. Called by the :func:`git.refresh` function in the top level ``__init__``. :param path: Optional path to the git executable. If not absolute, it is resolved immediately, relative to the current directory. (See note below.) :note: The top-level :func:`git.refresh` should be preferred because it calls this method and may also update other state accordingly. :note: There are three different ways to specify the command that refreshing causes to be used for git: 1. Pass no `path` argument and do not set the :envvar:`GIT_PYTHON_GIT_EXECUTABLE` environment variable. The command name ``git`` is used. It is looked up in a path search by the system, in each command run (roughly similar to how git is found when running ``git`` commands manually). This is usually the desired behavior. 2. Pass no `path` argument but set the :envvar:`GIT_PYTHON_GIT_EXECUTABLE` environment variable. The command given as the value of that variable is used. This may be a simple command or an arbitrary path. It is looked up in each command run. Setting :envvar:`GIT_PYTHON_GIT_EXECUTABLE` to ``git`` has the same effect as not setting it. 3. Pass a `path` argument. This path, if not absolute, is immediately resolved, relative to the current directory. This resolution occurs at the time of the refresh. When git commands are run, they are run using that previously resolved path. If a `path` argument is passed, the :envvar:`GIT_PYTHON_GIT_EXECUTABLE` environment variable is not consulted. :note: Refreshing always sets the :attr:`Git.GIT_PYTHON_GIT_EXECUTABLE` class attribute, which can be read on the :class:`Git` class or any of its instances to check what command is used to run git. This attribute should not be confused with the related :envvar:`GIT_PYTHON_GIT_EXECUTABLE` environment variable. The class attribute is set no matter how refreshing is performed. FTa0 Bad git executable. The git executable must be specified in one of the following ways: - be included in your $PATH - be set via $%s - explicitly set via git.refresh() raise)quietqsilencersilentnonen0)rwwarningloglr)rFe exceptionrr2ae %s All git commands will error until this is rectified. This initial message can be silenced or aggravated in the future by setting the $%s environment variable. Use one of the following values: - %s: for no message or exception - %s: for a warning message (logging level CRITICAL, displayed by default) - %s: for a raised exception Example: export %s=%s |ra %s environment variable has been set but it has been set with an invalid value. Use only the following values: - %s: for no message or exception - %s: for a warning message (logging level CRITICAL, displayed by default) - %s: for a raised exception )rpath expanduserabspathenvironget_git_exec_env_var git_exec_namer_refresh_tokenobjectversionrPermissionErrorr _refresh_env_varlowerrirEcritical ImportError) rr%new_gitold_gitold_refresh_tokenhas_giterrmoderrrFs rQrefreshz Git.refreshs2\  gg((.Gggoog.GjjnnS%:%:Cs rQr@zGit.polish_urlsORr{c*||j}|r t|}|Stjj |}|j drtjj |}|jddjdd}|S)aRemove any backslashes from URLs to be written in config files. Windows might create config files containing paths with backslashes, but git stops liking them as it will escape the backslashes. Hence we undo the escaping just to be sure. ~z\\\/)r<rrr% expandvars startswithr&rr>s rQr@zGit.polish_urls   I #,C  ''$$S)C~~c"gg((-++fd+33D#>C r{c~|jj|}|r |jd}td|dy)a}Check for unsafe protocols. Apart from the usual protocols (http, git, ssh), Git allows "remote helpers" that have the form ``::
``. One of these helpers (``ext::``) can be used to invoke any arbitrary command. See: - https://git-scm.com/docs/gitremote-helpers - https://git-scm.com/docs/git-remote-ext rzThe `zM::` protocol looks suspicious, use `allow_unsafe_protocols=True` to allow it.N)re_unsafe_protocolmatchgroupr)rr?rJprotocols rQcheck_unsafe_protocolszGit.check_unsafe_protocolssI&&,,S1 {{1~H%z!no  r{c|Dcgc]}|jd}}|D]:}t||D])\}}|j|s||k(st|d<ycc}w)zCheck for unsafe options. Some options that are passed to ``git `` can be used to execute arbitrary commands. These are blocked by default. rz= is not allowed, use `allow_unsafe_options=True` to allow it.N)lstripziprGr)roptionsunsafe_optionsoptionbare_unsafe_options unsafe_option bare_options rQcheck_unsafe_optionszGit.check_unsafe_optionssAOOfv}}S1OO F.1.BU.V * {$$]3v7L+(/)fg  PsAr+rkrct|t||_d|_g|_i|_d|_d|_d|_ d|_ y)aaInitialize this instance with: :param working_dir: Git directory we should work in. If ``None``, we always work in the current directory as returned by :func:`os.getcwd`. This is meant to be the working tree directory if available, or the ``.git`` directory in case of bare repositories. rN) rrrrrrr rrrr)r working_dirrs rQrz Git.__init__s\ ' 4?A24$-/<@+/ 26.2r{cD|dk(r tdt| |SrrrrJrs rQrzGit.__getattribute__rr{cTjdrt SfdS)zA convenience method as it allows to call the command as if it was an object. :return: Callable object that will execute call :meth:`_call_process` with your arguments. rc0jg|i|Sr) _call_process)rUrrJrs rQz!Git.__getattr__..s'9t'9'9$'P'P'Pr{)rGrrr[s``rQrzGit.__getattr__s' ??3 7+D1 1PPr{c 6|jdddi||_y)a7Specify command line options to the git executable for subsequent subcommand calls. :param kwargs: A dict of keyword arguments. These arguments are passed as in :meth:`_call_process`, but will be passed to the git command rather than the subcommand. split_single_char_optionsTNr)transform_kwargsrrrs rQset_persistent_git_optionszGit.set_persistent_git_optionss#(=t'<'<'fW['f_e'f$r{c|jS)z(:return: Git directory we are working on)rrs rQrYzGit.working_dirs   r{c|j}|j|ur|jJd|jS|jd}|j dd}|j ddd}t j tj|}ttt||_||_|jS)a :return: Tuple with integers representing the major, minor and additional version numbers as parsed from :manpage:`git-version(1)`. Up to four fields are used. This value is generated on demand and is cached. Nz Bug: corrupted token-check stater. .) r,rrr^rc itertools takewhilerGisdigitramapr)r refresh_tokenprocess_versionversion_stringversion_fieldsleading_numeric_fieldss rQ version_infozGit.version_infos++   # #} 4%%1 U3U U1%% %,,Y7(..s3A6'--c22A6!*!4!4S[[.!Q"3s,B#CD$1 !!!r{cyrr)rrr4s rQexecutez Git.executes r{)r4cyrrrrr4r9s rQrvz Git.execute"s,/r{)r4r9cyrrrxs rQrvz Git.execute+s03r{cyrrrrr<r4r9s rQrvz Git.execute4sr{cyrrr{s rQrvz Git.execute>sr{Tc |   !t||jr5|jdk7s|r$tjdj  |j xst j}t jt|t jsd}| }t jj} d| d<d| d<| j|j|| j|t j"dk(r| t%dt&}nt}| rt(n,t+t,d dxst/t j0d }| t2"|id } tj7d ||rd nd|  t9|f| |d|xst:t(|| rt<ndd |t?t@jB_!t?t@jD_"|r|jI|St j"dk7rM|K| dfd }d !fd }tKjLtKjN |jPf!n jR}d}d}d} rdnd} E|\}}|jU|r|r|dd}|jU|r|dd}jV}n| r| dkDr| ntXjZ} t]jB| jBj_}jDj_}|jU|r|dd}ja}jBjcjDjc|jdk(rzdj }dfd }|r)tjd||||te|n8|rtjd||||ntjd|||r|dk7rt%|||tg|thr |r te|}|r||te|fS|S#t$rd}YwxYw#|$r}tG||d}~wwxYw#jBjcjDjcwxYw)aHandle executing the command, and consume and return the returned information (stdout). :param command: The command argument list to execute. It should be a sequence of program arguments, or a string. The program to execute is the first item in the args sequence or string. :param istream: Standard input filehandle passed to :class:`subprocess.Popen`. :param with_extended_output: Whether to return a (status, stdout, stderr) tuple. :param with_exceptions: Whether to raise an exception when git returns a non-zero status. :param as_process: Whether to return the created process instance directly from which streams can be read on demand. This will render `with_extended_output` and `with_exceptions` ineffective - the caller will have to deal with the details. It is important to note that the process will be placed into an :class:`AutoInterrupt` wrapper that will interrupt the process once it goes out of scope. If you use the command in iterators, you should pass the whole process instance instead of a single stream. :param output_stream: If set to a file-like object, data produced by the git command will be copied to the given stream instead of being returned as a string. This feature only has any effect if `as_process` is ``False``. :param stdout_as_string: If ``False``, the command's standard output will be bytes. Otherwise, it will be decoded into a string using the default encoding (usually UTF-8). The latter can fail, if the output contains binary data. :param kill_after_timeout: Specifies a timeout in seconds for the git command, after which the process should be killed. This will have no effect if `as_process` is set to ``True``. It is set to ``None`` by default and will let the process run until the timeout is explicitly specified. Uses of this feature should be carefully considered, due to the following limitations: 1. This feature is not supported at all on Windows. 2. Effectiveness may vary by operating system. ``ps --ppid`` is used to enumerate child processes, which is available on most GNU/Linux systems but not most others. 3. Deeper descendants do not receive signals, though they may sometimes terminate as a consequence of their parent processes being killed. 4. `kill_after_timeout` uses ``SIGKILL``, which can have negative side effects on a repository. For example, stale locks in case of :manpage:`git-gc(1)` could render the repository incapable of accepting changes until the lock is manually removed. :param with_stdout: If ``True``, default ``True``, we open stdout on the created process. :param universal_newlines: If ``True``, pipes will be opened as text, and lines are split at all known line endings. :param shell: Whether to invoke commands through a shell (see :class:`Popen(..., shell=True) `). If this is not ``None``, it overrides :attr:`USE_SHELL`. Passing ``shell=True`` to this or any other GitPython function should be avoided, as it is unsafe under most circumstances. This is because it is typically not feasible to fully consider and account for the effect of shell expansions, especially when passing ``shell=True`` to other methods that forward it to :meth:`Git.execute`. Passing ``shell=True`` is also no longer needed (nor useful) to work around any known operating system specific issues. :param env: A dictionary of environment variables to be passed to :class:`subprocess.Popen`. :param max_chunk_size: Maximum number of bytes in one chunk of data passed to the `output_stream` in one invocation of its ``write()`` method. If the given number is not positive then the default value is used. :param strip_newline_in_stdout: Whether to strip the trailing ``\n`` of the command stdout. :param subprocess_kwargs: Keyword arguments to be passed to :class:`subprocess.Popen`. Please note that some of the valid kwargs are already set by this method; the ones you specify may not be the same ones. :return: * str(output), if `extended_output` is ``False`` (Default) * tuple(int(status), str(stdout), str(stderr)), if `extended_output` is ``True`` If `output_stream` is ``True``, the stdout value will be your output stream: * output_stream, if `extended_output` is ``False`` * tuple(int(status), output_stream, str(stderr)), if `extended_output` is ``True`` Note that git is executed with ``LC_MESSAGES="C"`` to ensure consistent output regardless of system language. :raise git.exc.GitCommandError: :note: If you add additional keyword arguments to the signature of this method, you must update the ``execute_kwargs`` variable housed in this module. fullrgNCLANGUAGELC_ALLr}z9"kill_after_timeout" feature is not supported on Windows.rwbrzr^r) r1cwdbufsizerrXrWr2r;rc2tddt|gt}g}|jl|jD]]}t |j dkDs |j d}|j sD|jt|_ tj|tj|D]'} tj|tj)jy#t$rYFwxYw#t$rYywxYw)zCallback to kill a process. This callback implementation would be ineffective and unsafe on Windows. psz--ppid)rWNr)rrGrrWrrcrmrdrrrsignalSIGKILLrset)pidp child_pidsrN local_pid child_pid kill_checks rQ kill_processz!Git.execute..kill_processs 43s84TB 88' !Btzz|,q0)-q(9I(002 * 1 1#i. A B GGC0%/! !GGIv~~>! NN$  '! ! s6)D $C;(D ; DD DD DDcjj\}}jjr-ddj fz}s|j t }||fS)Nz6Timeout: the command "%s" did not complete in %d secs.rg)rh communicatecancelis_setrirnr )rr8rrSredacted_commandrZr;watchdogs rQrz Git.execute..communicate6sq ++-S!$$&R!12VC.!jj0Cxr{)rUrr{  c, xr t|xsdS)Nz)r ) stdout_valuer6s rQas_textzGit.execute..as_textjs((F[-F[J[[r{z$%s -> %d; stdout: '%s'; stderr: '%s'z%s -> %d; stdout: '%s'z%s -> %d)rrr]r^)r]zTuple[AnyStr, AnyStr])rzUnion[bytes, str]r]rG)5rrrErrirrgetcwdaccessrGX_OKFileNotFoundErrorr(copyupdater sysplatformrrrr`ropendevnullrrrr|rr r'rrWrXrrkreEventTimerrrendswith returncodeioDEFAULT_BUFFER_SIZErrrrHr rArB)#rrr3r<r8r4r6r9r:r5r;r2r1r7r=subprocess_kwargsr inline_envcmd_not_found_exception stdout_sinkr8rrrr stderr_valuenewlinecmdstrrrrSrrZrrs# ` ` @@@@@rQrvz Git.executeHs_D6g>  d&;&;v&E LL"23 4 ##2ryy{C99SXrww/  jjoo JH  4$$%  ! JJz " <<7 "!-%$O'. #&7 #*dwz9d/S/mW[\^\f\fhlWm = G,[9E J   ' V     6 )'"#5#54 $ D"x5DKx5DK %%dG4 4 <<7 "'9'E(G 8 #*J w DHH;OH**K*- *- ,$% $-8]* l((16M#/#4L((1#/#4L3AnWXFX^`^t^tDKKG#{{//1 #{{//1 ((1#/#4L KK    KK     F *XX./F \  :L) -  5vvw|G\] Z8 v{!"2FL,W W lE */?&|4L L+l*CD D i! C r' E$%5s; D Ep KK    KK   s8AQ*Q+CR Q('Q(+R0 Q==R6R;c|jSr)r rs rQ environmentzGit.environments   r{c i}|jD]c\}}|.|jj|||<||j|<6||jvsE|j|||<|j|=e|S)aSet environment variables for future git invocations. Return all changed values in a format that can be passed back into this function to revert the changes. Examples:: old_env = self.update_environment(PWD='/tmp') self.update_environment(**old_env) :param kwargs: Environment variables to use for git processes. :return: Dict that maps environment variables to their old values )rr r))rrold_envkeyrs rQupdate_environmentzGit.update_environments  ,,. +JC #0044S9 ).!!#&)))#005 %%c* +r{c+K|jdi|} d|jdi|y#|jdi|wxYww)agA context manager around the above :meth:`update_environment` method to restore the environment back to its previous state after operation. Examples:: with self.custom_environment(GIT_SSH='/bin/ssh_wrapper'): repo.remotes.origin.fetch() :param kwargs: See :meth:`update_environment`. Nr)r)rrrs rQcustom_environmentzGit.custom_environmentsL*$))3F3 /  #D # # .g . #D # # .g .sA-AAAct|dk(r$|durd|zgS|dvr|r d|zd|zgSd||gSgS|durdt|zgS|dur|d t|d |gSgS) NrTz-%s)FNz%srz--%sFz--=)rr)rrJrras rQtransform_kwargzGit.transform_kwargs t9>} ~%m+,!DL$,77-(,U344  }.//e#(9%,T]E:;; r{c g}|jD]O\}}t|ttfr|D]}||j |||z }:||j |||z }Q|S)z:Qq!tR R +0Et L)4((7;7$$%GAa%GH ( 8+I  '<=!519-88EAIK;PPI../ D001 D%%& GFO$ It||D0K00IOR&H  ,c(m= s:EEEE E!E!(E&& F/F  FcB|j}t|dk7rL|s(d|jd|jd}t|td|dd|j t|ddk7rtd |z|d|d t |d fS) a. :param header_line: A line of the form:: type_string size_as_int :return: (hex_sha, type_string, size_as_int) :raise ValueError: If the header contains indication for an error due to incorrect input sha. r)z>SHA is empty, possible dubious ownership in the repository at zj. If this is unintended run: "git config --global --add safe.directory z" zSHA rz& could not be resolved, git returned: (zFailed to parse header: %rrrh)rcrrrstripr)r header_linetokenserr_msgs rQ_parse_object_headerzGit._parse_object_headerRs""$ v;!  --./PPTPaPaObbdh !)) U[\]U^`k`q`q`s!tuu vay>R 9KGH Hq 6!9c&)n55r{ct|tr|jd}nt|ts t|}n|}|j ds|dz }|j t S)Nasciir)rArBrCrGrrnr )rrefrefstrs rQ _prepare_refzGit._prepare_refqsV c5 !**W-FC%XFFt$ dNF}}V$$r{ct||}||Stdd}|j||j|g|i|}t |||t d|}|S)NT)r3r4rT)r`rrr^rr')r attr_namecmd_namerUrcur_valrQcmds rQ_get_persistent_cmdzGit._get_persistent_cmdsi$ *  N"$7v d   % 4 2 . Ur{) metaclass)NTN)roz'Git.AutoInterrupt' | PopenrpzsUnion[None, Callable[[AnyStr], None], Callable[[List[AnyStr]], None], Callable[[bytes, 'Repo', 'DiffIndex'], None]]rqzEUnion[None, Callable[[AnyStr], None], Callable[[List[AnyStr]], None]]rrz@Union[None, Callable[[Union[Popen, 'Git.AutoInterrupt']], None]]rsr\r:rr]r^) rrr2r\r1zOptional[Mapping[str, str]]rrr]r)rrGr]rG)r)rrrrr]r)rr-rzMapping[str, Any]rrr]r^)rr\r]r^)W __future__r__all__rrrkloggingrr rrrrrrtextwrapr rer git.compatr r r git.excr rrrrgit.utilrrrrrrtypingrrrrrrrrr r!r"r#r$r%r&r'r(rtr+typing_extensions git.typesr,r-r.git.diffr/ git.repo.baser0r getLoggerrrErzrrrr|rrrrrrrrrtyperrrrr{rQr s # e   ++ 77(w +,,"" '  H %&SW-1| (||Z|P||+| |~"!<<7 +/ ;*;;) ;  ;  ;z'KK$MggT*1i.i.Z"8%?". / t 2 2iHir{