
    64%e                         d Z ddl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 ddlmZ dd	lmZ erdd
lmZ dZ G d de	          ZdS )zBModule with our own gitdb implementation - it uses the git command    )
bin_to_hex
hex_to_bin)OInfoOStream)GitDB)LooseObjectDB)	BadObject)GitCommandError)TYPE_CHECKING)PathLike)Git)GitCmdObjectDBr   c                   `     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dZ xZS )r   a=  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.
    :note: for now, we use the git command to do all the lookup, just until he
        have packs and the other implementations
    	root_pathgitr   returnNc                 f    t          t          |                               |           || _        dS )z8Initialize this instance with the root and a git commandN)superr   __init___git)selfr   r   	__class__s      &lib/python3.11/site-packages/git/db.pyr   zGitCmdObjectDB.__init__"   s,    nd##,,Y777			    binshac                     | j                             t          |                    \  }}}t          t	          |          ||          S )N)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 )z)For now, all lookup is done by git itself)r   stream_object_datar   r   r   )r   r   r   r   r    streams         r   r$   zGitCmdObjectDB.stream+   sE    )-)E)EjQWFXFX)Y)Y&$z&))8T6BBBr   partial_hexshac                     	 | j                             |          \  }}}t          |          S # t          t          f$ r}t          |          |d}~ww xY w)z:return: Full binary 20 byte sha from the given partial hexsha
        :raise AmbiguousObjectName:
        :raise BadObject:
        :note: currently we only raise BadObject as git does not communicate
            AmbiguousObjects separatelyN)r   r   r   r
   
ValueErrorr	   )r   r%   r   	_typename_sizees         r   partial_to_complete_sha_hexz*GitCmdObjectDB.partial_to_complete_sha_hex2   se    	3'+y'B'B>'R'R$FIuf%%%, 	3 	3 	3N++2	3s   ,/ A AA)__name__
__module____qualname____doc__r   r   bytesr   r!   r   r$   strr+   __classcell__)r   s   @r   r   r      s         (  4      
95 9U 9 9 9 9CU Cw C C C C
3# 
3% 
3 
3 
3 
3 
3 
3 
3 
3r   r   N)r/   git.utilr   r   
gitdb.baser   r   gitdb.dbr   r   	gitdb.excr	   git.excr
   typingr   	git.typesr   git.cmdr   __all__r    r   r   <module>r=      s    H H + + + + + + + + % % % % % % % %       " " " " " "       # # # # # # !                 
 &$3 $3 $3 $3 $3] $3 $3 $3 $3 $3r   