§
    ÎÑßj-(  ã                   ó  — d dgZ ddlmZ ddlmZ ddlmZ ddl	m
Z
mZmZmZ ddlmZ ddlmZmZmZ dd	lmZmZmZ er$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d         Z$ G d„ d e
¦  «        Z% G d„ de%¦  «        Z&dS )ÚObjectÚIndexObjecté    N)ÚWorkTreeRepositoryUnsupported)Ú	LazyMixinÚ
bin_to_hexÚjoin_path_nativeÚstream_copyé   )Úget_object_type_by_name)ÚAnyÚTYPE_CHECKINGÚUnion)ÚAnyGitObjectÚGitObjectTypeStringÚPathLike)ÚOStream)Ú	Reference)ÚRepo)ÚBlob)Ú	Submodule)ÚTree)r   r   r   c                   ó~  ‡ — e Zd ZU dZdZdZej        ej        ej	        ej
        fZdZdZeedf         ed<   	 ddd	ed
dfˆ fd„Zedddeedf         d
efd„¦   «         Zeddded
efd„¦   «         Zded
dfˆ fd„Zded
efd„Zded
efd„Zd
efd„Zd
efd„Zd
efd„Z e!d
efd„¦   «         Z"e!dd„¦   «         Z#dd„Z$ˆ xZ%S ) r   ar  Base class for classes representing git object types.

    The following four leaf classes represent specific kinds of git objects:

    * :class:`Blob <git.objects.blob.Blob>`
    * :class:`Tree <git.objects.tree.Tree>`
    * :class:`Commit <git.objects.commit.Commit>`
    * :class:`TagObject <git.objects.tag.TagObject>`

    See :manpage:`gitglossary(7)` on:

    * "object": https://git-scm.com/docs/gitglossary#def_object
    * "object type": https://git-scm.com/docs/gitglossary#def_object_type
    * "blob": https://git-scm.com/docs/gitglossary#def_blob_object
    * "tree object": https://git-scm.com/docs/gitglossary#def_tree_object
    * "commit object": https://git-scm.com/docs/gitglossary#def_commit_object
    * "tag object": https://git-scm.com/docs/gitglossary#def_tag_object

    :note:
        See the :class:`~git.types.AnyGitObject` union type of the four leaf subclasses
        that represent actual git object types.

    :note:
        :class:`~git.objects.submodule.base.Submodule` is defined under the hierarchy
        rooted at this :class:`Object` class, even though submodules are not really a
        type of git object. (This also applies to its
        :class:`~git.objects.submodule.root.RootModule` subclass.)

    :note:
        This :class:`Object` class should not be confused with :class:`object` (the root
        of the class hierarchy in Python).
    Ú(0000000000000000000000000000000000000000s                       )ÚrepoÚbinshaÚsizeNÚtyper   r   r   Úreturnc                 óÂ   •— t          ¦   «                              ¦   «          || _        || _        t	          |¦  «        dk    sJ d|t	          |¦  «        fz  ¦   «         ‚dS )zýInitialize an object by identifying it by its binary sha.

        All keyword arguments will be set on demand if ``None``.

        :param repo:
            Repository this object is located in.

        :param binsha:
            20 byte SHA1
        é   z,Require 20 byte binary sha, got %r, len = %iN)ÚsuperÚ__init__r   r   Úlen)Úselfr   r   Ú	__class__s      €úD/opt/saltstack/salt/lib/python3.11/site-packages/git/objects/base.pyr"   zObject.__init__d   sf   ø€ õ 	‰Œ×ÒÑÔÐØˆŒ	ØˆŒÝ�6‰{Œ{˜bÒ Ð Ð Ð"PØÝ�‰KŒKðT
ñ #
Ñ Ô Ð Ð Ð ó    Úidr   c                 óF   — |                      t          |¦  «        ¦  «        S )a)  
        :return:
            New :class:`Object` instance of a type appropriate to the object type behind
            `id`. The id of the newly created object will be a binsha even though the
            input id may have been a :class:`~git.refs.reference.Reference` or rev-spec.

        :param id:
            :class:`~git.refs.reference.Reference`, rev-spec, or hexsha.

        :note:
            This cannot be a ``__new__`` method as it would always call :meth:`__init__`
            with the input id which is not necessarily a binsha.
        )Ú	rev_parseÚstr)Úclsr   r(   s      r&   Únewz
Object.neww   s   € ð �~Š~�c "™gœgÑ&Ô&Ð&r'   Úsha1c                 óà   — || j         k    r t          d¦  «        ||¦  «        S |j                             |¦  «        } t          |j        ¦  «        ||j        ¦  «        }|j        |_        |S )zª
        :return:
            New object instance of a type appropriate to represent the given binary sha1

        :param sha1:
            20 byte binary sha1.
        s   commit)ÚNULL_BIN_SHAr   ÚodbÚinfor   r   r   )r,   r   r.   ÚoinfoÚinsts        r&   Únew_from_shazObject.new_from_shaˆ   sl   € ð �3Ô#Ò#Ð#à5Õ*¨9Ñ5Ô5°d¸DÑAÔAÐAà”—’˜dÑ#Ô#ˆØ2Õ& u¤zÑ2Ô2°4¸¼ÑFÔFˆØ”JˆŒ	Øˆr'   Úattrc                 óº   •— |dk    r2| j         j                             | j        ¦  «        }|j        | _        dS t          ¦   «                              |¦  «         dS )zRetrieve object information.r   N)r   r1   r2   r   r   r!   Ú_set_cache_)r$   r6   r3   r%   s      €r&   r8   zObject._set_cache_š   sP   ø€ à�6Š>ˆ>Ø”I”M×&Ò& t¤{Ñ3Ô3ˆEØœ
ˆDŒIˆIˆIå‰GŒG×Ò Ñ%Ô%Ð%Ð%Ð%r'   Úotherc                 óF   — t          |d¦  «        sdS | j        |j        k    S )z3:return: ``True`` if the objects have the same SHA1r   F©Úhasattrr   ©r$   r9   s     r&   Ú__eq__zObject.__eq__¢   s(   € å�u˜hÑ'Ô'ð 	Ø�5ØŒ{˜eœlÒ*Ð*r'   c                 óF   — t          |d¦  «        sdS | j        |j        k    S )z::return: ``True`` if the objects do not have the same SHA1r   Tr;   r=   s     r&   Ú__ne__zObject.__ne__¨   s(   € å�u˜hÑ'Ô'ð 	Ø�4ØŒ{˜eœlÒ*Ð*r'   c                 ó*   — t          | j        ¦  «        S )zE:return: Hash of our id allowing objects to be used in dicts and sets)Úhashr   ©r$   s    r&   Ú__hash__zObject.__hash__®   s   € å�D”KÑ Ô Ð r'   c                 ó   — | j         S )z=:return: String of our SHA1 as understood by all git commands)ÚhexsharC   s    r&   Ú__str__zObject.__str__²   s
   € àŒ{Ðr'   c                 ó2   — d| j         j        ›d| j        ›d�S )z::return: String with pythonic representation of our objectz<git.z "z">)r%   Ú__name__rF   rC   s    r&   Ú__repr__zObject.__repr__¶   s    € € à"&¤.Ô"9Ð"9Ð"9¸4¼;¸;¸;ÐGÐGr'   c                 óP   — t          | j        ¦  «                             d¦  «        S )z6:return: 40 byte hex version of our 20 byte binary shaÚascii)r   r   ÚdecoderC   s    r&   rF   zObject.hexshaº   s"   € õ ˜$œ+Ñ&Ô&×-Ò-¨gÑ6Ô6Ð6r'   r   c                 óJ   — | j         j                             | j        ¦  «        S )z³
        :return:
            File-object compatible stream to the uncompressed raw data of the object

        :note:
            Returned streams must be read in order.
        )r   r1   Ústreamr   rC   s    r&   Údata_streamzObject.data_streamÀ   s   € ð ŒyŒ}×#Ò# D¤KÑ0Ô0Ð0r'   Úostreamc                 ón   — | j         j                             | j        ¦  «        }t	          ||¦  «         | S )zªWrite our data directly to the given output stream.

        :param ostream:
            File-object compatible stream object.

        :return:
            self
        )r   r1   rO   r   r	   )r$   rQ   Úistreams      r&   Ústream_datazObject.stream_dataË   s2   € ð ”)”-×&Ò& t¤{Ñ3Ô3ˆÝ�G˜WÑ%Ô%Ð%Øˆr'   )r   r   )rQ   r   r   r   )&rI   Ú
__module__Ú__qualname__Ú__doc__ÚNULL_HEX_SHAr0   ÚdbtypÚstr_blob_typeÚstr_tree_typeÚstr_commit_typeÚstr_tag_typeÚTYPESÚ	__slots__r   r   r   Ú__annotations__Úbytesr"   Úclassmethodr+   r   r-   r5   r8   r   Úboolr>   r@   ÚintrD   rG   rJ   ÚpropertyrF   rP   rT   Ú__classcell__©r%   s   @r&   r   r   &   sH  ø€ € € € € € ðð ðB €LØ€Lð 	ÔØÔØÔØÔð	€Eð +€Ià-1€Dˆ%Ð# TÐ)Ô
*Ð1Ð1Ñ1ðð
˜Vð 
¨Uð 
°tð 
ð 
ð 
ð 
ð 
ð 
ð& ð'�vð ' 5¨¨kÐ)9Ô#:ð '¸|ð 'ð 'ð 'ñ „[ð'ð  ð ð ¨eð ¸ð ð ð ñ „[ðð"& ð &¨ð &ð &ð &ð &ð &ð &ð+˜Cð + Dð +ð +ð +ð +ð+˜Cð + Dð +ð +ð +ð +ð!˜#ð !ð !ð !ð !ð˜ð ð ð ð ðH˜#ð Hð Hð Hð Hð ð7˜ð 7ð 7ð 7ñ „Xð7ð
 ð1ð 1ð 1ñ „Xð1ðð ð ð ð ð ð ð r'   c                   ó¾   ‡ — e Zd ZdZdZdZ	 	 ddddededef         dede	f         d	df
ˆ fd
„Z
d	efd„Zded	dfˆ fd„Zed	efd„¦   «         Zed	e	fd„¦   «         Zˆ xZS )r   a}  Base for all objects that can be part of the index file.

    The classes representing git object types that can be part of the index file are
    :class:`~git.objects.tree.Tree` and :class:`~git.objects.blob.Blob`. In addition,
    :class:`~git.objects.submodule.base.Submodule`, which is not really a git object
    type but can be part of an index file, is also a subclass.
    )ÚpathÚmoderi   Nr   r   r   rj   r   c                 ót   •— t          ¦   «                              ||¦  «         |�|| _        |�	|| _        dS dS )a¥  Initialize a newly instanced :class:`IndexObject`.

        :param repo:
            The :class:`~git.repo.base.Repo` we are located in.

        :param binsha:
            20 byte sha1.

        :param mode:
            The stat-compatible file mode as :class:`int`.
            Use the :mod:`stat` module to evaluate the information.

        :param path:
            The path to the file in the file system, relative to the git repository
            root, like ``file.ext`` or ``folder/other.ext``.

        :note:
            Path may not be set if the index object has been created directly, as it
            cannot be retrieved without knowing the parent tree.
        N)r!   r"   rj   ri   )r$   r   r   rj   ri   r%   s        €r&   r"   zIndexObject.__init__ç   sE   ø€ õ6 	‰Œ×Ò˜˜vÑ&Ô&Ð&ØÐØˆDŒIØÐØˆDŒIˆIˆIð Ðr'   c                 ó*   — t          | j        ¦  «        S )zˆ
        :return:
            Hash of our path as index items are uniquely identifiable by path, not by
            their data!
        )rB   ri   rC   s    r&   rD   zIndexObject.__hash__  s   € õ �D”I‰ŒÐr'   r6   c                 ó¶   •— |t           j        v r(t          d|›dt          | ¦  «        j        ›d�¦  «        ‚t          ¦   «                              |¦  «         d S )NzAttribute 'z<' unset: path and mode attributes must have been set during z object creation)r   r_   ÚAttributeErrorr   rI   r!   r8   )r$   r6   r%   s     €r&   r8   zIndexObject._set_cache_  sb   ø€ Ø•;Ô(Ð(Ð(å �.à�4�4�˜d™œÔ,Ð,Ð,ð.ñô ð õ
 ‰GŒG×Ò Ñ%Ô%Ð%Ð%Ð%r'   c                 ó4   — t          j        | j        ¦  «        S )zA:return: Name portion of the path, effectively being the basename)ÚospÚbasenameri   rC   s    r&   ÚnamezIndexObject.name  s   € õ Œ|˜DœIÑ&Ô&Ð&r'   c                 óv   — | j         j        �t          | j         j        | j        ¦  «        S t	          d¦  «        ‚)a&  
        :return:
            Absolute path to this index object in the file system (as opposed to the
            :attr:`path` field which is a path relative to the git repository).

            The returned path will be native to the system and contains ``\`` on
            Windows.
        Nz"working_tree_dir was None or empty)r   Úworking_tree_dirr   ri   r   rC   s    r&   ÚabspathzIndexObject.abspath   s5   € ð Œ9Ô%Ð1Ý# D¤IÔ$>ÀÄ	ÑJÔJÐJå/Ð0TÑUÔUÐUr'   )NN)rI   rU   rV   rW   r_   Ú_id_attribute_ra   r   rd   r   r"   rD   r+   r8   re   rr   ru   rf   rg   s   @r&   r   r   Ù   sC  ø€ € € € € ðð ð !€Ið €Nð "&Ø&*ðð àðð ðð �D˜#�IÔð	ð
 �D˜(�NÔ#ðð 
ðð ð ð ð ð ðB˜#ð ð ð ð ð& ð &¨ð &ð &ð &ð &ð &ð &ð ð'�cð 'ð 'ð 'ñ „Xð'ð ðV˜ð Vð Vð Vñ „XðVð Vð Vð Vð Vr'   )'Ú__all__Úos.pathri   rp   Ú	gitdb.typÚtyprY   Úgit.excr   Úgit.utilr   r   r   r	   Úutilr   Útypingr   r   r   Ú	git.typesr   r   r   Ú
gitdb.baser   Úgit.refs.referencer   Úgit.repor   Úblobr   Úsubmodule.baser   Útreer   ÚIndexObjUnionr   r   © r'   r&   ú<module>rˆ      sµ  ðð �]Ð
#€à Ð Ð Ð Ð Ð à Ð Ð Ð Ð Ð à 1Ð 1Ð 1Ð 1Ð 1Ð 1Ø IÐ IÐ IÐ IÐ IÐ IÐ IÐ IÐ IÐ IÐ IÐ Ià )Ð )Ð )Ð )Ð )Ð )ð -Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,à AÐ AÐ AÐ AÐ AÐ AÐ AÐ AÐ AÐ Aàð Ø"Ð"Ð"Ð"Ð"Ð"à,Ð,Ð,Ð,Ð,Ð,ØÐÐÐÐÐàÐÐÐÐÐØ)Ð)Ð)Ð)Ð)Ð)ØÐÐÐÐÐàÐ1Ô2€ð
pð pð pð pð pˆYñ pô pð pðfTVð TVð TVð TVð TV�&ñ TVô TVð TVð TVð TVr'   