r%"EbddlmZddlZddlmZddlmZddlmZddl m Z m Z m Z m Z mZmZddlmZmZdd lmZdd lmZmZmZmZmZmZmZmZmZdd lmZmZer$dd l m!Z!dd l"m#Z#m$Z$m%Z%m&Z&ddlm'Z'ddl(m)Z)ddlm*Z*eddZ+dgZ,dddeedfdefdZ-Gdde.Z/dS))PathLikeN)defenc)Object)Commit) join_pathjoin_path_nativeto_native_path_linuxassure_directory_exists hex_to_binLockedFD) BadObjectBadName)RefLog) AnyIteratorListTupleTypeTypeVarUnion TYPE_CHECKINGcast) Commit_ishr)RepoHead TagReferenceRemoteReference Reference) RefLogEntry)GitConfigParser)Actor T_ReferencesSymbolicReference)boundreporpathreturnc,|}|dvr|jS|jS)z0Find the git dir that's appropriate for the path)HEAD ORIG_HEAD FETCH_HEADindexlogs)git_dir common_dir)r'r(names /srv/buildsys-work-dir/castor/build_node/builder-2/WGSG1/unpkd_srcs/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/git/refs/symbolic.py_git_dirr42s%9D CCC| ?ceZdZUdZdZdZdZdZdZdZ dJdd d e d e fd Z d e fdZd e fdZded e fdZded e fdZd efdZed e fdZed e fdZedd d e fdZedd d eee e ffdZedd dee dfd e fdZedd dee dfd eee dfede fffdZedd dee dfd eee dfede fffdZ d e!fdZ"dKdZ# dLd ee$de fd!ee dfd dfd"Z% dLd#ee!de fd!ee dfd dfd$Z&ee#e%d%&Z'ee"e&d'&ZdMd(Z( dLd)ee!de fd!ee dfd dfd*Z)ed+e*d,<ee(e)d-&Z+e+Z,d e fd.Z-ed e fd/Z.dNd1Z/ dLd2e0d3ee dfd4ee0dfd d5fd6Z1d7ed d5fd8Z2ed ee dfd e fd9Z3edd d e d dfd:Z4e dLd;e5e6dd d e dZ7e dOd;e5e6dd d e d,ede fd!ee dfd=e d@e8d e6fdAZ9dJdBe d=e d dfdCZ:e dLd;e5e6dd dDee dfd ee6fdEZ;e dLd;e5e6dd dDee dfdFe8d@e8d ee6f dGZdS)Pr%zRepresents a special case of a reference such that this reference is symbolic. It does not point to a specific commit, but to another Head, which itself specifies a commit. A typical example for a symbolic reference is HEAD.r'r(FTz refs/remotesr2r'rr( check_pathc"||_||_dSNr7)selfr'r(r9s r3__init__zSymbolicReference.__init__Is  r5r)c*t|jSr;strr(r<s r3__str__zSymbolicReference.__str__Ms49~~r5c2d|jjd|jdS)Nz) __class____name__r(rAs r3__repr__zSymbolicReference.__repr__Ps "&."9"9"94999EEr5othercpt|dr%tt|}|j|jkSdS)Nr(F)hasattrrr%r(r<rGs r3__eq__zSymbolicReference.__eq__Ss8 5& ! ! +*E22E9 * *ur5c||k Sr;rJs r3__ne__zSymbolicReference.__ne__YsEM""r5c*t|jSr;)hashr(rAs r3__hash__zSymbolicReference.__hash__\sDIr5c*t|jS)zy :return: In case of symbolic references, the shortest assumable name is the path itself.r?rAs r3r2zSymbolicReference.name_s 49~~r5c\tt|j|j|jSr;)rr4r'r(rAs r3abspathzSymbolicReference.abspathgs"DI > > JJJr5cLtj|jdS)N packed-refs)osr(joinr1)clsr's r3_get_packed_refs_pathz'SymbolicReference._get_packed_refs_pathksw||DO];;;r5c #K t||dd5}|D]}|}|s|dr,|drd|vrt d|zZ|dd krgt t ttft| d d V d d d d S#1swxYwYd S#t$rYd SwxYw) zReturns an iterator yielding pairs of sha1/path pairs (as strings) for the corresponding refs. :note: The packed refs file will be kept open as long as we iteratertUTF-8encoding#z# pack-refs with:peeledz-PackingType of packed-Refs not understood: %rr^ rN) openrZstrip startswith TypeErrorrrr@tuplesplitOSError)rYr'fplines r3_iter_packed_refsz#SymbolicReference._iter_packed_refsos c//55tgNNN KRTKKD::<??dHTXDXDX"+,[^b,b"c"cc Aw#~~ uS#Xdjja6H6H0I0IJJJJJJ1K K K K K K K K K K K K K K K K K K K6   44 s5%C9B5C, C9,C00C93C04C99 DDref_pathNc@ |||\}}||S)z :return: hexsha stored in the reference at the given ref_path, recursively dereferencing all intermediate references as required :param repo: the repository containing the reference at ref_path) _get_ref_info)rYr'rnhexshas r3dereference_recursivez'SymbolicReference.dereference_recursives1 "00x@@ FH!  r5cd}t||} ttj|t |dd5}|}dddn #1swxYwY|}t|dksJn6#t$r)| |D]\}}||kr ||f}YnwxYw|td|z|ddkr d|dfS|j |dr |ddfStd |z) Return: (str(sha), str(target_ref_path)) if available, the sha the file at rela_path points to, or None. target_ref_path is the reference we point to, or NoneNr\r]r^rzReference at %r does not existzref:rz-Failed to parse reference information from %r)r4rdrWr(rXr@readrstriprilenrjrm ValueErrorre_hexsha_onlymatch) rYr'rntokensrepodirrkvalueshar(s r3_get_ref_info_helperz&SymbolicReference._get_ref_info_helpers;?4** bgll7CMM::D7SSS +WY ((** + + + + + + + + + + + + + + +[[]]Fv;;!#####   !22488   T8##d  >=HII I !9  &)$ $   $ $VAY / / %1It$ $H8STTTs5=B9'B8 B9BB9 B ,B990C,+C,c.|||S)rt)r)rYr'rns r3rpzSymbolicReference._get_ref_infos ''h777r5c tj|jt||j|jS)z :return: The object our ref currently refers to. Refs can be cached, they will always point to the actual object as it gets re-created on each query)r new_from_shar'r rrr(rAs r3 _get_objectzSymbolicReference._get_objects9"49j9S9STXT]_c_h9i9i.j.jkkkr5rc|}|jdkr|j}|jtjkrt d|z|S)z :return: Commit object we point to, works for detached and non-detached SymbolicReferences. The symbolic reference will be dereferenced recursively.tagz??QF G  =2V;<< < ''' s-B B6B11B6rct|tr|j}d} |j}n#t$rYnwxYw|r|||S|||S)a8Set the object we point to, possibly dereference our symbolic reference first. If the reference does not exist, it will be created :param object: a refspec, a SymbolicReference or an Object instance. SymbolicReferences will be dereferenced beforehand to obtain the object they point to :param logmsg: If not None, the message will be used in the reflog entry to be written. Otherwise the reflog is not altered :note: plain SymbolicReferences may not actually point to objects by convention :return: selfT)rr%r is_detachedrx set_reference_get_referencer)r<rrrs r3rzSymbolicReference.set_object s f/ 0 0 #]F  *KK    D   6%%ff55 5""$$//???s ( 55zQuery or set commits directly)docz-Return the object our ref currently refers toc||j|j\}}|t|d|||j|S)z:return: Reference Object we point to :raise TypeError: If this symbolic reference is detached, hence it doesn't point to a reference, but to a commitNz2 is a detached symbolic reference as it points to )rpr'r(rg from_path)r<r~target_ref_paths r3rz SymbolicReference._get_reference/s\ $11$)TYGG_  "X\X\X\^a^abcc c~~di999r5refcd}d}t|tr d|jz}nt|tr |}|j}nyt|t rR |j|dz}|j}n>#ttf$r}td|z|d}~wwxYwtd|z|.|j r'|j tj krtd|zd}|* |jj}n#t$rtj}YnwxYw|j}t'|d t)|}|dd } d} | |d d z|d} | s|n#| s|wwxYw|||||S) aSet ourselves to the given ref. It will stay a symbol if the ref is a Reference. Otherwise an Object, given as Object instance or refspec, is assumed and if valid, will be set which effectively detaches the reference if it was a purely symbolic one. :param ref: SymbolicReference instance, Object instance or refspec string Only if the ref is a SymbolicRef instance, we will point to it. Everything else is dereferenced to obtain the actual object. :param logmsg: If set to a string, the message will be used in the reflog. Otherwise, a reflog entry is not written for the changed reference. The previous commit of the entry will be the commit we point to now. See also: log_append() :return: self :note: This symbolic reference will not be dereferenced. For that, see ``set_object(...)``Nzref: %sz^{}z Could not extract object from %szUnrecognized Value: %rzRequire commit, got %rr5T)is_file)writestreamzutf-8 )rr%r(rrqr@r'rr rrx_points_to_commits_onlyrrrgrbinsha NULL_BIN_SHArTr r rdrencoderollback log_append) r<rr write_valuerr oldbinshafpathlfdfdoks r3rzSymbolicReference.set_reference8s),  c, - - =#ch.KK V $ $ =C*KK S ! ! = Ri))#+66!j w' R R R !Cc!IJJPQQ R5;<< < ?t;?FK@W@W4s:;; ;   0 K.  0 0 0"/  0  t4444uoo XXDX . .   HH[''0058 9 9 9 JJLLLB        OOIv . . . s7$A??B(B##B(2 C??DDAF44G r referencez!Returns the Reference we point tocF |jdS#ttf$rYdSwxYw)z :return: True if the reference is valid, hence it can be read and points to a valid object or reference.TF)rrjrxrAs r3is_validzSymbolicReference.is_valids>   KK4$   55 s    c8 |jdS#t$rYdSwxYw)z :return: True if we are a detached reference, hence we point to a specific commit instead to another referenceFT)rrgrAs r3rzSymbolicReference.is_detacheds5   HH5   44 s  rcNtjtj|S)a. :return: RefLog for this reference. Its last entry reflects the latest change applied to this reference .. note:: As the log is parsed every time, its recommended to cache it for use instead of calling this method repeatedly. It should be considered read-only.)r from_filer(rAs r3logzSymbolicReference.logs D 1 1222r5rmessage newbinshar!c |jj}n)#t$r|j}YnwxYw| |jj}|d}t j|t j||||S)aBAppend a logentry to the logfile of this ref :param oldbinsha: binary sha this ref used to point to :param message: A message describing the change :param newbinsha: The sha the ref points to now. If None, our current commit sha will be used :return: added RefLogEntry instanceNr8) r committerrxr' config_readerrr append_entryr()r<rrrcommitter_or_readers r3rzSymbolicReference.log_appends  z+SymbolicReference.delete.. s.%P%Pddkk&&9&9%P%P%P%P%P%Pr5)rrWr(rXr1existsremoverZrddecoder partitionrerfappend writelinesrjrisfile)rYr'r(rabs_pathpack_file_pathreader new_lines made_changedropped_last_line line_bytesrl_line_refr reflog_paths r3deletezSymbolicReference.deletes((.. 7<<?? 7>>( # #&  Ih    !66t<>#3#3 !OOC00%MX4M4M 15N5F5NOS_bOcOc5N&,,T22205-$'+ ,0))%1 1111111111111112Qnd33Qr %P%Pi%P%P%PPPPQQQQQQQQQQQQQQQ    k##dM":":;; 7>>+ & & # Ik " " " " " # #s[FB#E: FE  F E F# F FFFFF F('F(rYresolveforcect||}||}tj||} |} |r"|t |} |stj| rt | } t| trt | j} |sd| z} t| d5} | t} dddn #1swxYwY| | krtd|d| d| |||}|| ||S)a*internal method used to create a new symbolic reference. If resolve is False, the reference will be taken as is, creating a proper symbolic reference. Otherwise it will be resolved to the corresponding object and a detached symbolic reference will be created insteadzref: rNz Reference at z! does already exist, pointing to z, requested was )r4rrWr(rXrr@rrr%rdrurrrerjr)rYr'r(rrrrr0r abs_ref_pathtarget target_datar existing_datars r3_createzSymbolicReference._creates4&&((.. w||G];;   4^^C NN33F  55 f++K&"344 /!&+..  4% 3 lD)) AR " 0 0 8 8 > > @ @  A A A A A A A A A A A A A A A ++g$}}mmm[[B c$ && &&))) s?D''D+.D+r+kwargsc @||||j|||S)aCreate a new symbolic reference, hence a reference pointing , to another reference. :param repo: Repository to create the reference in :param path: full path at which the new symbolic reference is supposed to be created at, i.e. "NEW_HEAD" or "symrefs/my_new_symref" :param reference: The reference to which the new symbolic reference should point to. If it is a commit'ish, the symbolic ref will be detached. :param force: if True, force creation even if a symbolic reference with that name already exists. Raise OSError otherwise :param logmsg: If not None, the message to append to the reflog. Otherwise no reflog entry is written. :return: Newly created symbolic Reference :raise OSError: If a (Symbolic)Reference with the same name but different contents already exists. :note: This does not alter the current HEAD, index or Working Tree)r_resolve_ref_on_create)rYr'r(rrrrs r3createzSymbolicReference.createAs%L{{4s'A9eU[\\\r5new_pathc||}|j|kr|Stjt |j||}tjt |j|j|j}tj|r|st|d5}| }dddn #1swxYwYt|d5}| }dddn #1swxYwY||krtd|ztj |tj |} tj | stj| tj||||_|S)a7Rename self to a new path :param new_path: Either a simple name or a full path, i.e. new_name or features/new_name. The prefix refs/ is implied for references and will be set as needed. In case this is a symbolic ref, there is no implied prefix :param force: If True, the rename will succeed even if a head with the target name already exists. It will be overwritten in that case :return: self :raise OSError: In case a file at path but a different contents already existsrNzFile at path %r already exists)rr(rWrXr4r'rrdrurerjrdirnameisdirmakedirsrename) r<rr new_abs_path cur_abs_pathfd1f1fd2f2dnames r3rzSymbolicReference.renameis$$X.. 9 Kw||HTY$A$A8LL w||HTY $B$BDINN 7>>, ' ' $ S,--,))++B,,,,,,,,,,,,,,,,--,))++B,,,,,,,,,,,,,,,88!"B\"QRRR Il # # # --w}}U##  K    , ---  s$'C77C;>C;'EE  E  common_pathc #K||j}t}tjt |j|D]\}}}d|tjvrd|D}|rdg|dd<|D]d}|dkr tt||} | | t|jdzde| |D]<\} } | t|r| | =t|D]+} ||| V#t"$rY(wxYwdS)Nrefscg|] }|dk| S)rrM)rds r3 z1SymbolicReference._iter_items..s:::a6kk1kkkr5rrVrr8)rsetrWwalkrr1risepr raddreplacermrfr@sortedrrx) rYr'r rela_pathsrootdirsfilesrefs_idfr_sha rela_pathr(s r3 _iter_itemszSymbolicReference._iter_itemss  2KUU "$)9$/;)W)W!X!X b b D$TZZ////::d:::( &xDH b b %%/ $0B0BCCx//0DT_0U0UX[0[]_``aaaa  b #44T:: * *OD)##C $4$455 *y))) :&&  D mmD$//////      s E## E0/E0argscBd|||DS)aFind all refs in the repository :param repo: is the Repo :param common_path: Optional keyword argument to the path which is to be shared by all returned Ref objects. Defaults to class specific portion if None assuring that only refs suitable for the actual class are returned. :return: git.SymbolicReference[], each of them is guaranteed to be a symbolic ref which is not detached and pointing to a valid ref List is lexicographically sorted The returned objects represent actual subclasses, such as Head or TagReferencec3HK|]}|jtks|j|VdSr;)rDr%r)rrs r3rz/SymbolicReference.iter_items..s8wwaPaAaAaijivAaAaAaAaAawwr5)r)rYr'rr rs r3 iter_itemszSymbolicReference.iter_itemss'0xw3??4==wwwwr5c|std|zddlm}m}m}m}m}|||||tfD]H} |||} | jtkr| j rtd| cS#t$rYEwxYwtd|z)a& :param path: full .git-directory-relative path name to the Reference to instantiate :note: use to_full_path() if you only have a partial path of a known Reference Type :return: Instance of type Reference, Head, or Tag depending on the given pathzCannot create Reference from %rr)r+rrrr z"SymbolRef was detached, we drop itz8Could not find reference type suitable to handle path %r) rxr8r+rrrr r%rDr) rYr'r(r+rrrr ref_typeinstances r3rzSymbolicReference.from_paths G>EFF F KJJJJJJJJJJJJJ          H #8D$//%):::x?S:$%IJJJ#OOO    SVZZ[[[s3A)) A65A6c`t|j|jdzS)zB:return: True if this symbolic reference points to a remote branchr)r@r(rf_remote_common_path_defaultrAs r3 is_remotezSymbolicReference.is_remotes&49~~(()IC)OPPPr5)F)r)rr;)r)r%)r)r)r+NF)?rE __module__ __qualname____doc__ __slots__rrrr_id_attribute_rboolr=r@rBrFrrKrNintrQpropertyr2rT classmethodrZrrrmrrrrrprrrrrrrrr__annotations__rrrrrbytesrrrrrr$rrrrrr rrrMr5r3r%r%:sj;; !I"""0NV8F#FFFFFt #F#t#####cXKKKKXK<%:&U uS$YtSy!11 2&U&U&U[&UP88543H8USXY\^bYbScejkoqtkteuSuMv888[8 lZllll    $$(f1367c4i   H$(@@j"5s:;@c4i @  @@@@>Xk:3R S S SF Xk:3b c c cF::::$(GG :2C7 8Gc4i G  GGGGTKLLLL<_```I C $     T   X 3333)- jjjsDy!j% j  jjjj:9s9}9999 h0C&C D    [ 7#&7#7#T7#7#7#[7#t$((( , ((( ( ,c12 (  (c4i ( ((([(T 6<#' %]%] , %]%]%],c12 %] c4i %]  %]%] %]%]%][%]N++x++AT++++ZTX$$ , $'-$*x x  x ,  xxx[x2"\tL)"\"\x"\L"\"\"\["\HQ4QQQQQQr5)0 git.typesrrW git.compatr git.objectsrgit.objects.commitrgit.utilrrr r r r gitdb.excr rrrtypingrrrrrrrrrrgit.reporgit.refsrrrr r! git.configr"r#r$__all__r4rr%rMr5r3r*si %%%%%%)(((((((                      +*******)GGGGGGGGGGGG      ******((((((w~-@AAA  6x~!68E QE QE QE QE QE QE QE QE QE Qr5