§
    ÎÑßj‚  ã                   óÆ   — d Z ddgZddlmZ ddlmZmZmZ ddlm	Z	m
Z
 ddlmZ ddlmZ dd	lmZ dd
lmZmZ ddlmZ ddlmZ ddlmZ erddlmZ  G d„ de
¦  «        ZdS )zCModule with our own gitdb implementation - it uses the git command.ÚGitCmdObjectDBÚGitDBé    )ÚPIPE)ÚIStreamÚOInfoÚOStream)r   ÚLooseObjectDB)Ú	BadObject)Ústream_copy)Ú
force_text)Ú
bin_to_hexÚ
hex_to_bin)ÚGitCommandError)ÚTYPE_CHECKING)ÚPathLike)ÚGitc                   ót   ‡ — e Zd ZdZdeddddfˆ fd„Zdedefd	„Zdede	fd
„Z
dedefˆ fd„Zdedefd„Zˆ xZS )r   z¾A database representing the default git object store, which includes loose
    objects, pack files and an alternates file.

    It will create objects only in the loose object database.
    Ú	root_pathÚgitr   ÚreturnNc                 óX   •— t          ¦   «                              |¦  «         || _        dS )z9Initialize this instance with the root and a git command.N)ÚsuperÚ__init__Ú_git)Úselfr   r   Ú	__class__s      €ú:/opt/saltstack/salt/lib/python3.11/site-packages/git/db.pyr   zGitCmdObjectDB.__init__&   s&   ø€ å‰Œ×Ò˜Ñ#Ô#Ð#ØˆŒ	ˆ	ˆ	ó    Úbinshac                 ó”   — | j                              t          |¦  «        ¦  «        \  }}}t          t	          |¦  «        ||¦  «        S )z+Get a git object header (using git itself).)r   Úget_object_headerr   r   r   )r   r   ÚhexshaÚtypenameÚsizes        r   ÚinfozGitCmdObjectDB.info+   s@   € à!%¤×!<Ò!<½ZÈÑ=OÔ=OÑ!PÔ!PÑˆ�˜$Ý•Z Ñ'Ô'¨°4Ñ8Ô8Ð8r   c                 ó˜   — | j                              t          |¦  «        ¦  «        \  }}}}t          t	          |¦  «        |||¦  «        S )zIGet git object data as a stream supporting ``read()`` (using git itself).)r   Ústream_object_datar   r   r   )r   r   r"   r#   r$   Ústreams         r   r(   zGitCmdObjectDB.stream0   sE   € à)-¬×)EÒ)EÅjÐQWÑFXÔFXÑ)YÔ)YÑ&ˆ�˜$ Ý•z &Ñ)Ô)¨8°T¸6ÑBÔBÐBr   Úistreamc           	      ó‚  •— |j         €|                      ¦   «         �!t          ¦   «                              |¦  «        S | j                             dt          |j        ¦  «        ddddt          ¬¦  «        }|j	        €J ‚	 t          |j        |j	        j        |j        | j        ¦  «         |j	                             ¦   «          n# |j	                             ¦   «          w xY w|j        €J ‚|j                             ¦   «                              ¦   «         }|                     ¦   «          t'          |¦  «        |_         |S )z!Store an object using git itself.Nz-tz-wz--stdinz--literallyT)Ú
as_processr)   )r   Úostreamr   Ústorer   Úhash_objectr   Útyper   Ústdinr   ÚreadÚwriter$   Ústream_chunk_sizeÚcloseÚstdoutÚstripÚwaitr   )r   r)   Úprocr"   r   s       €r   r-   zGitCmdObjectDB.store5   s  ø€ àŒ>Ð%¨¯ª©¬Ð)CÝ‘7”7—=’= Ñ)Ô)Ð)àŒy×$Ò$Ø•*˜Wœ\Ñ*Ô*¨D°)¸]ÐW[Õeið %ñ 
ô 
ˆð ŒzÐ%Ð%Ð%ð	Ý˜œ d¤jÔ&6¸¼ÀdÔF\Ñ]Ô]Ð]àŒJ×ÒÑÔÐÐøˆDŒJ×ÒÑÔÐÐøøøØŒ{Ð&Ð&Ð&Ø”×!Ò!Ñ#Ô#×)Ò)Ñ+Ô+ˆØ�	Š	‰ŒˆÝ# FÑ+Ô+ˆŒØˆs   Â +C ÃC Úpartial_hexshac                 ó°   — 	 | j                              |¦  «        \  }}}t          |¦  «        S # t          t          f$ r}t          |¦  «        |‚d}~ww xY w)aF  
        :return:
            Full binary 20 byte sha from the given partial hexsha

        :raise gitdb.exc.AmbiguousObjectName:

        :raise gitdb.exc.BadObject:

        :note:
            Currently we only raise :exc:`~gitdb.exc.BadObject` as git does not
            communicate ambiguous objects separately.
        N)r   r!   r   r   Ú
ValueErrorr
   )r   r9   r"   Ú	_typenameÚ_sizeÚes         r   Úpartial_to_complete_sha_hexz*GitCmdObjectDB.partial_to_complete_sha_hexJ   se   € ð	3Ø'+¤y×'BÒ'BÀ>Ñ'RÔ'RÑ$ˆF�I˜uÝ˜fÑ%Ô%Ð%øÝ¥Ð,ð 	3ð 	3ð 	3Ý˜NÑ+Ô+°Ð2øøøøð	3øøøs   ‚,/ ¯AÁ AÁA)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Úbytesr   r%   r   r(   r   r-   Ústrr?   Ú__classcell__)r   s   @r   r   r      sô   ø€ € € € € ðð ð (ð °ð ¸4ð ð ð ð ð ð ð
9˜5ð 9 Uð 9ð 9ð 9ð 9ð
C˜Uð C wð Cð Cð Cð Cð
˜Wð ¨ð ð ð ð ð ð ð*3¸#ð 3À%ð 3ð 3ð 3ð 3ð 3ð 3ð 3ð 3r   N)rC   Ú__all__Ú
subprocessr   Ú
gitdb.baser   r   r   Úgitdb.dbr   r	   Ú	gitdb.excr
   Ú	gitdb.funr   Ú
git.compatr   Úgit.utilr   r   Úgit.excr   Útypingr   Ú	git.typesr   Úgit.cmdr   r   © r   r   ú<module>rT      s4  ðð JÐ Ià˜WÐ
%€à Ð Ð Ð Ð Ð à .Ð .Ð .Ð .Ð .Ð .Ð .Ð .Ð .Ð .Ø )Ð )Ð )Ð )Ð )Ð )Ð )Ð )Ø Ð Ð Ð Ð Ð Ø !Ð !Ð !Ð !Ð !Ð !à !Ð !Ð !Ð !Ð !Ð !Ø +Ð +Ð +Ð +Ð +Ð +Ð +Ð +Ø #Ð #Ð #Ð #Ð #Ð #ð !Ð  Ð  Ð  Ð  Ð  à Ð Ð Ð Ð Ð àð ØÐÐÐÐÐð
<3ð <3ð <3ð <3ð <3�]ñ <3ô <3ð <3ð <3ð <3r   