
    64%e4                        d dl Z d dlmZ d dlmZ d dlmZ d dlZd dlm	Z	m
Z
mZmZ d dl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 dZdedefdZdedefdZdddeddfdZde
d         deddfdZ G d de          ZdS )     N)InvalidGitRepositoryError)GitConfigParser)BytesIO)AnySequenceTYPE_CHECKINGUnion)PathLike   )	Submodule)ReferenceType)Repo)Head)Remote)RemoteReference)
sm_sectionsm_namemkheadfind_first_remote_branchSubmoduleConfigParsernamereturnc                     d|  dS )z=:return: section title used in .gitmodules configuration filezsubmodule "" )r   s    :lib/python3.11/site-packages/git/objects/submodule/util.pyr   r   "   s             sectionc                 >    |                                  } | dd         S )z>:return: name of the submodule as parsed from the section name   )strip)r   s    r   r   r   '   s    mmooG2b5>r   repor   pathr   c                 f    t          j        | t           j                            |                    S )z!:return: New branch/head instance)gitr   to_full_path)r#   r$   s     r   r   r   -   s$    8D#(//55666r   remotesr   branch_namer   c                 n    | D ]!}	 |j         |         c S # t          $ r Y w xY wt          d|z            )z_Find the remote branch matching the name of the given branch or raise InvalidGitRepositoryErrorz:Didn't find remote branch '%r' in any of the given remotes)refs
IndexErrorr   )r(   r)   remotes      r   r   r   2   s`      	;{++++ 	 	 	H	 $$`cn$n
o
oos   
""c                   L     e Zd ZdZdededdf fdZdd	Zdd
Zd fdZ xZ	S )r   aX  
    Catches calls to _write, and updates the .gitmodules blob in the index
    with the new data, if we have written into a stream. Otherwise it will
    add the local file to the index to make it correspond with the working tree.
    Additionally, the cache must be cleared

    Please note that no mutating method will work in bare mode
    argskwargsr   Nc                 r    d | _         d | _        d| _         t          t          |           j        |i | d S )NT)_smref_index_auto_writesuperr   __init__)selfr/   r0   	__class__s      r   r6   zSubmoduleConfigParser.__init__O   sB    ?C3#T**3TDVDDDDDr   	submoduler   c                 8    t          j        |          | _        dS )z`Set this instance's submodule. It must be called before
        the first write operation beginsN)weakrefrefr2   )r7   r9   s     r   set_submodulez#SubmoduleConfigParser.set_submoduleV   s     k),,r   c                    | j         J t          | j        t                    rJ |                                  }|M| j        }||j        j        }|                    |j        g| j	                   |
                                 dS dS )z4Flush changes in our configuration file to the indexN)write)r2   
isinstance_file_or_filesr   r3   r#   indexaddk_modules_filer4   _clear_cache)r7   smrB   s      r   flush_to_indexz$SubmoduleConfigParser.flush_to_index[   s    {&&&d17;;;;;[[]]>KE}IIr()1AIBBBOO >r   c                 ~    t          t          |                                           }|                                  |S )N)r5   r   r?   rG   )r7   rvalr8   s     r   r?   zSubmoduleConfigParser.writen   s6    0$77==??r   )r9   r   r   N)r   N)
__name__
__module____qualname____doc__r   r6   r=   rG   r?   __classcell__)r8   s   @r   r   r   D   s         Ec ES ET E E E E E E- - - -
   &         r   r   )r&   git.excr   
git.configr   ior   r;   typingr   r   r   r	   	git.typesr
   baser   r   git.repor   git.refsr   r   r   __all__strr   r   r   r   r   r   r   r   <module>rY      s   



 - - - - - - & & & & & &       
 7 6 6 6 6 6 6 6 6 6 6 6       )%%%%%%((((((!S !S ! ! ! !
S S    7 7x 7F 7 7 7 7
	phx&8 	ps 	pO` 	p 	p 	p 	p$- - - - -O - - - - -r   