yL iNdZgdZddlZddlZddlZddlmZddlZddlm Z ddl m Z ddl Z ddlZddlZddlmZddlmZddlmZmZddlmZdd lmZmZmZmZdd lm Z m!Z!m"Z"m#Z#m$Z$dd l%m&Z&dd l'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/d dl0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8d dl9m:Z:m;Z;mZ>m?Z?m@Z@mAZAddlBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPddlQmRZRmSZSeNrddl mTZTddlUmVZVddlWmXZXePe$e!eYeZfZ[ejdeSdeGeYddffdZ]Gdde)eje&Z_y)zModule containing :class:`IndexFile`, an Index implementation facilitating all kinds of index manipulations such as querying and merging.) IndexFile CheckoutError StageTypeN)BytesIO)S_ISLNK)IStream)MemoryDB)defenc force_bytes)rGitCommandErrorGitErrorInvalidGitRepositoryError)BlobCommitObject SubmoduleTree) Serializable)Actor LazyMixinLockedFDjoin_path_nativefile_contents_roto_native_path_linux unbare_repo to_bin_sha) S_IFGITLINKaggressive_tree_merge entry_key read_cacherun_commit_hookstat_mode_to_index_mode write_cachewrite_tree_from_cache)BaseIndexEntry IndexEntryr)TemporaryFileSwappost_clear_cache default_indexgit_working_dir)AnyBinaryIOCallableDict GeneratorIOIterableIteratorListNoReturnSequence TYPE_CHECKINGTupleUnion)LiteralPathLike)Popen) Reference)Repo directoryreturnc#jKtjdk(rItj|\}}t j | |t j |ytj|5}|jdddy#t j |wxYw#1swYyxYww)a$Create a named temporary file git subprocesses can open, deleting it afterward. :param directory: The directory in which the file is created. :return: A context manager object that creates the file and provides its name on entry, and deletes it on exit. win32)dirN) sysplatformtempfilemkstemposcloseremoveNamedTemporaryFilename)r?fdrLctxs T/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/git/index/base.py$_named_temporary_file_for_subprocessrPWs ||w## 2D   J IIdO  ( (Y 7 3((N   IIdO  s6AB3B ,B35B' B3 B$$B3'B0,B3ceZdZdZdZdZ eZ dedddeedfddfd Z d e ddffd Z defd Z e defd ZdfdZdeddfdZdeefdZdgdededdfdZ dhdedefdeddfdZeededededefddfdZedddee efddfdZedddededdfdZ e!ddde"ede#efd Z$ did"d#d$ed%ed&e%d'e&fd(e%eeegdfd)edede ffd*Z'd+fd,e%e(e)e*fgefde#e(e)e*ffd-Z+de,eee(e)e*fffd.Z-ed/ee.ee)fde(ee)ffd0Z/d1e#e*ddfd2Z0djd3Z1defd4Z2d5eeed6fdeeed6ffd7Z3d8edefd9Z4d:eee"eee*e.d;ffde(eeee.ffd<Z5d$ed(e%de.fd=Z6e!e7dee d>ee%dfd(e%d?ee.dee.f d@Z8d!dAdd!dfd:eee"eee*e.d;ffdBed(e%d>ee%d'efdfdCedDedee.fdEZ9d:eee"eee.e*e:ffdeefdFZ;ee dgd:eee"eee*e.d;ffdGededee fdHZdfdMedNede?fdOede?fdPee@je dfdQee@je dfdRede>fdSZAdKe ddfdTZBdfdUZCde fdVZDde fdWZEdgd"dXdYedeFfdZZGeddd[fdedeHefdBed(e%dedede#ee"eff d\ZIe dld]ee>d^e fdGededeHefdMededdf d_ZJeKjddfd`eeMeKjjdadbe dfdeeeee(ed'fdfdcededeKjeKjf fdd ZQxZRS)mraAn Index that can be manipulated using a native implementation in order to save git command function calls wherever possible. This provides custom merging facilities allowing to merge without actually changing your index or your working tree. This way you can perform your own test merges based on the index only without having to deal with the working copy. This is useful in case of partial working trees. Entries: The index contains an entries dict whose keys are tuples of type :class:`~git.index.typ.IndexEntry` to facilitate access. You may read the entries dict or manipulate it using IndexEntry instance, i.e.:: index.entries[index.entry_key(index_entry_instance)] = index_entry_instance Make sure you use :meth:`index.write() ` once you are done manipulating the index directly before operating on it using the git command. )repoversionentries_extension_data _file_pathNrRr> file_pathr@ct||_|j|_d|_|xs|j |_y)aInitialize this Index instance, optionally from the given `file_path`. If no `file_path` is given, we will be created from the current index file. If a stream is not given, the stream will be initialized from the current repository's index on demand. N)rR_VERSIONrSrU _index_pathrV)selfrRrXs rO__init__zIndexFile.__init__s3 }} "$-$C1A1A1CrZattrcX|dk(re tj|jtj} t |dd}tj||j|yt|)|y#t$r i|_YywxYw#tj|wxYw)NrTT)stream allow_mmap) rHopenrVO_RDONLYOSErrorrTrrI _deserializesuper _set_cache_)r]r_rMra __class__s rOrhzIndexFile._set_cache_s 9  WWT__bkk: )"TdK   f % G  % MO   s.A<B<BBB)c|jjr t|jjdStd)Nindexz)No git directory given to join index path)rRgit_dirrr r]s rOr\zIndexFile._index_paths2 99  #DII$5$5w? ?!"MN NrZc|jS)z3:return: Path to the index file we are representing)rVrms rOpathzIndexFile.pathsrZc( |`y#t$rYywxYw)z6Safely clear the entries cache so it can be recreated.N)rTAttributeErrorrms rO_delete_entries_cachezIndexFile._delete_entries_caches      s  racDt|\|_|_|_}|S)zFInitialize this instance with index values read from the given stream.)r!rSrTrU)r]ra _conten_shas rOrfzIndexFile._deserializes"HRSYHZE dlD$8+ rZcNt|jjdS)zK:return: List of entries, in a sorted fashion, first by path, then by stagec2|j|jfSNrostagees rOz+IndexFile._entries_sorted..sAFFAGG;LrZ)key)sortedrTvaluesrms rO_entries_sortedzIndexFile._entries_sortedsdll))+1LMMrZFignore_extension_datac`|j}|j}|rd}t||||Srw)rrUr$)r]rarrTextension_datas rO _serializezIndexFile._serializes4&&(-- !NGV^4 rZc |jt|xs |j}|jdd} |j |||j|||_yy#t $r|j wxYw)aWrite the current state to our file path or to the given one. :param file_path: If ``None``, we will write to our stored file path from which we have been initialized. Otherwise we write to the given file path. Please note that this will change the `file_path` of this index to the one you gave. :param ignore_extension_data: If ``True``, the TREE type extension data read in the index will not be written to disk. NOTE that no extension data is actually written. Use this if you have altered the index and would like to use :manpage:`git-write-tree(1)` afterwards to create a tree representing your written changes. If this data is present in the written index, :manpage:`git-write-tree(1)` will instead write the stored/cached tree. Alternatively, use :meth:`write_tree` to handle this case automatically. T)writeraN)rTrrVrcr BaseExceptionrollbackcommit)r]rXrlfdras rOrzIndexFile.writes0 y3DOO4T2  OOF$9 :   'DO !  LLN  s A''Brhsbasecgd}||j||j||jjj||S)aMerge the given `rhs` treeish into the current index, possibly taking a common base treeish into account. As opposed to the :func:`from_tree` method, this allows you to use an already existing tree as the left side of the merge. :param rhs: Treeish reference pointing to the 'other' side of the merge. :param base: Optional treeish reference pointing to the common base of `rhs` and this index which equals lhs. :return: self (containing the merge and possibly unmerged entries in case of conflicts) :raise git.exc.GitCommandError: If there is a merge conflict. The error will be raised at the first conflicting path. If you want to have proper merge resolution to be done by yourself, you have to commit the changed index (or make a valid tree from it) and retry with a three-way :meth:`index.from_tree ` call. ) --aggressivez-iz-m)appendrRgit read_tree)r]rrargss rO merge_treezIndexFile.merge_treesC:+G   KK  C % rZtree_shac|Dcgc]}tt|}}t|j|}||}t t d|Dd|D}||_|Scc}w)aMerge the given treeish revisions into a new index which is returned. This method behaves like ``git-read-tree --aggressive`` when doing the merge. :param repo: The repository treeish are located in. :param tree_sha: 20 byte or 40 byte tree sha or tree objects. :return: New :class:`IndexFile` instance. Its path will be undefined. If you intend to write such a merged Index, supply an alternate ``file_path`` to its :meth:`write` method. c3LK|]}|j|jfywrwrx.0r{s rO z IndexFile.new..;s9q!&&!''"9s"$c3FK|]}tj|ywrw)r' from_basers rOrz IndexFile.new..<s?Q%%a(?s!)rstrrodbdictziprT)clsrRrttree_sha_bytes base_entriesinstrTs rOnewz IndexFile.new#sq"DL&Laz#a&'9&L&L,TXX~F 4y:> 9L9?,? ;   'MsA,treeishkwargscPt|dk(st|dkDrtdt|zg}t|dkDr"|jd|jdt|j5}|jd|z|j |t t|jd5|jj|i||||}|j|cd d d cd d d S#1swYnxYw d d d y #1swYy xYw) aMerge the given treeish revisions into a new index which is returned. The original index will remain unaltered. :param repo: The repository treeish are located in. :param treeish: One, two or three :class:`~git.objects.tree.Tree` objects, :class:`~git.objects.commit.Commit`\s or 40 byte hexshas. The result changes according to the amount of trees: 1. If 1 Tree is given, it will just be read into a new index. 2. If 2 Trees are given, they will be merged into a new index using a two way merge algorithm. Tree 1 is the 'current' tree, tree 2 is the 'other' one. It behaves like a fast-forward. 3. If 3 Trees are given, a 3-way merge will be performed with the first tree being the common ancestor of tree 2 and tree 3. Tree 2 is the 'current' tree, tree 3 is the 'other' one. :param kwargs: Additional arguments passed to :manpage:`git-read-tree(1)`. :return: New :class:`IndexFile` instance. It will point to a temporary index location which does not exist anymore. If you intend to write such a merged Index, supply an alternate ``file_path`` to its :meth:`write` method. :note: In the three-way merge case, ``--aggressive`` will be specified to automatically resolve more cases in a commonly correct manner. Specify ``trivial=True`` as a keyword argument to override that. As the underlying :manpage:`git-read-tree(1)` command takes into account the current index, it will be temporarily moved out of the way to prevent any unexpected interference. rz.Please specify between 1 and 3 treeish, got %irz--resetrz--index-output=%srkN) len ValueErrorrrPrlextendr(rrrrT)rrRrrarg_list tmp_indexrks rO from_treezIndexFile.from_treeCsN w<1 G q 0MPST[P\\] ].0 w.raise_excsGrZ?*[)onerrorN) Exceptionr5rrRworking_tree_dirrHsepospisabsjoinlstatrst_modereplacereroexistsglob_iter_expand_pathswalk)r]rrrrsroabs_pathstresolved_pathsfroot_dirsfiles rela_files rOrzIndexFile._iter_expand_pathss  x   ** + Z( /D4yH99X&88At, XXh' 2::&"**2r2277>>(+C8OWZ^fWf!%8!4>1!44TYYx5HI5!!fnnR445 /*,''(I*NH&D%%*H !hht||B';YGGHHA( /  < /&&r2.. /sPA?GF!B6GAF0G! F-*G,F--G0G GGGTprocr<filepathitemfmakeexc. fprogressread_from_stdoutc||d|d}|jL |jjd|zjt|jj |r4|j (|j jj}||d||S#t$r }||d}~wwxYw)aWrite path to ``proc.stdin`` and make sure it processes the item, including progress. :return: stdout string :param read_from_stdout: If ``True``, ``proc.stdout`` will be read after the item was sent to stdin. In that case, it will return ``None``. :note: There is a bug in :manpage:`git-update-index(1)` that prevents it from sending reports just in time. This is why we have a version that tries to read stdout and one which doesn't. In fact, the stdout is not important as the piped-in files are processed anyway and just in time. :note: Newlines are essential here, git's behaviour is somewhat inconsistent on this depending on the version, hence we try our best to deal with newlines carefully. Usually the last newline will not be sent, instead we will close stdin to break the pipe. FNz%s T) stdinrencoder IOErrorflushstdoutreadlinestrip) r]rrrrrrrvalr{s rO_write_path_to_stdinzIndexFile._write_path_to_stdins> (E4(!% :: ! (   &8"3!;!;F!CD JJ     7;;'')//1D(D$'  (ja' (s1B'' B=0B88B=cy)NTrrs rOr|zIndexFile.rZ predicatec#K|jjD]I}|j|j}|j|_|j |f}||sF|Kyw)a :return: Iterator yielding tuples of :class:`~git.objects.blob.Blob` objects and stages, tuple(stage, Blob). :param predicate: Function(t) returning ``True`` if tuple(stage, Blob) should be yielded by the iterator. A default filter, the :class:`~git.index.typ.BlobFilter`, allows you to yield blobs only if they match a given list of paths. N)rTrto_blobrRsizery)r]rentrybloboutputs rO iter_blobszIndexFile.iter_blobss\\\((* E==+D DIkk4(F   s A A*#A*cdtttfdtfd}i}|j |D]2\}}|j |j gj||f4|jD]}|j|S)a :return: Dict(path : list(tuple(stage, Blob, ...))), being a dictionary associating a path in the index with a list containing sorted stage/blob pairs. :note: Blobs that have been removed in one side simply do not exist in the given stage. That is, a file removed on the 'other' branch whose entries are at stage 3 will not have a stage 3 entry. rr@c|ddk7S)Nrrrs rOis_unmerged_blobz2IndexFile.unmerged_blobs..is_unmerged_blobsQ419 rZ) r8rrboolr setdefaultrorrsort)r]rpath_mapryrlines rOunmerged_blobszIndexFile.unmerged_blobs s io 6 4 BD??+;< EKE4    2 . 5 5udm D EOO% D IIK rZrct|Srw)r )rrs rOr zIndexFile.entry_key"s %  rZrc2|D]}|jdf}||jvr!tdt|jzdD]} |j|j|f=t j ||j|<|S#t$rYPwxYw)amResolve the blobs given in blob iterator. This will effectively remove the index entries of the respective path at all non-null stages and add the given blob as new stage null blob. For each path there may only be one blob, otherwise a :exc:`ValueError` will be raised claiming the path is already at stage 0. :raise ValueError: If one of the blobs already existed at stage 0. :return: self :note: You will have to write the index manually once you are done, i.e. ``index.resolve_blobs(blobs).write()``. rz!Path %r already exists at stage 0)rrWr)rorTrrKeyErrorr' from_blob)r]rrstage_null_keyrys rO resolve_blobszIndexFile.resolve_blobs&s& FD"ii^N- !Ds499~!UVV#  dii%78 ,6+?+?+EDLL ( F$  s B  BBc&|j|S)aReread the contents of our index file, discarding all cached information we might have. :note: This is a possibly dangerous operations as it will discard your changes to :attr:`index.entries `. :return: self )rrrms rOupdatezIndexFile.updateMs ""$ rZc &t}|j}t||tdt |\}}|j |j |jjt|j|d}||_ |S)aOWrite this index to a corresponding :class:`~git.objects.tree.Tree` object into the repository's object database and return it. :return: :class:`~git.objects.tree.Tree` object representing this index. :note: The tree will be written even if one or more objects the tree refers to does not yet exist in the object database. This could happen if you added entries to the index directly. :raise ValueError: If there are no entries in the cache. :raise git.exc.UnmergedEntriesError: rrro) r rr%slicer stream_copysha_iterrRrr_cache)r]mdbrTbinsha tree_items root_trees rO write_treezIndexFile.write_tree\sw&j&&(27Cq#g,AWX    6F4 % rZrzgit_diff.Diffablech |j|j||S#t$rY|SwxYwrw)poprk IndexError)r]rs rO_process_diff_argszIndexFile._process_diff_args|s<  HHTZZ% &     s $ 11rocptj|s|S|jjr t dtj t |jt |jjs%td|d|jjtjj||jj}t |jtjr2|jtjs|tjz }|S)z :return: Version of path relative to our git directory or raise :exc:`ValueError` if it is not within our git directory. :raise ValueError: zrequire non-bare repositoryzAbsolute path z is not in git repository at )rrrRbarernormpathr startswithrrrHrorelpathendswithr)r]roresults rO_to_relative_pathzIndexFile._to_relative_pathsyyK 99>>+,IJ J||CI&11#dii6P6P2QRRVX\XaXaXrXrst ttyy'A'AB t9  bff %foobff.E bff F rZitemsrcg}g}t|ttjfr|g}|D]}t|ttjfr!|j |j |Dt|t tfr%|j tj|t|tr|j |td|z||fS)z?Split the items into two lists of path strings and BaseEntries.zInvalid Type: %r) isinstancerrHr;rrrrr&r TypeError)r]rrrTrs rO_preprocess_add_itemszIndexFile._preprocess_add_itemss ec2;;/ 0GE ;D$bkk 23 T33D9:D4"34~77=>D.1t$ 2T 9:: ;g~rZctj}t|jr dtffd }n dtffd }|5}|d|j j jttj|j|}|ddddtt|jjdtfS#1swY>xYw)zStore file at filepath in the database and return the base index entry. :note: This needs the :func:`~git.index.util.git_working_dir` decorator active! This must be ensured in the calling code. r@c^tttjtS)N)encoding)rr rHreadlinkr rsrO open_streamz*IndexFile._store_path..open_streams{2;;x+@6RSSrZctdSNrb)rcrsrOrz*IndexFile._store_path..open_streamsHd++rZFTNr)rHrrrr-rRrstorerrtypest_sizer&r#rr)r]rrrrraistreams ` rO _store_pathzIndexFile._store_pathsXXh  2::  T T , ,] 0f hx 0iimm))'$))RZZ*PQG hh / 0' 3$X.     0 0s AC&&C/ path_rewriterrTc g}|r|D]}tj|r1|}|tt|jj dzd}nB|}|jj r*tj |jj |}t|jtjttjjt|} |jtj | |dd=t|dk(sJ|j#|D]#} |j|j%| |%|S)Nrr)rrrrrRrrr NULL_BIN_SHAr#rHstatrrrr&rrr&) r]rr'rrT entries_addedroabspathgitrelative_pathrrs rO_entries_for_pathszIndexFile._entries_for_pathss3/1  ?99T?"G'+CDII4N4N0O,PST,T,V'W$'+$yy11"%((499+E+EGW"XII%%+BGGG,<,D,DE()9: ~77=># ?&a=!Q&&&//6 HH  !1!1(I!F G HrZcyrwrrs rOr|zIndexFile.rrZforcerwrite_extension_datac t|j|\}g}|r#|j|j||r!D cgc]} | jdk(s| } } | r t dt D cgc]%\} } | j tjk(s$| 'c} } rtdfd } | ||rIt D];\} } t| j| j | j|| f| <=t D]4\} } | v}|r | jd| | jd| 6|j|D]0} tj| |j| jdf<2|r|j!| |Scc} wcc} } w)aAdd files from the working tree, specific blobs, or :class:`~git.index.typ.BaseIndexEntry`\s to the index. :param items: Multiple types of items are supported, types can be mixed within one call. Different types imply a different handling. File paths may generally be relative or absolute. - path string Strings denote a relative or absolute path into the repository pointing to an existing file, e.g., ``CHANGES``, ``lib/myfile.ext``, ``/home/gitrepo/lib/myfile.ext``. Absolute paths must start with working tree directory of this index's repository to be considered valid. For example, if it was initialized with a non-normalized path, like ``/root/repo/../repo``, absolute paths to be added must start with ``/root/repo/../repo``. Paths provided like this must exist. When added, they will be written into the object database. PathStrings may contain globs, such as ``lib/__init__*``. Or they can be directories like ``lib``, which will add all the files within the directory and subdirectories. This equals a straight :manpage:`git-add(1)`. They are added at stage 0. - :class:`~git.objects.blob.Blob` or :class:`~git.objects.submodule.base.Submodule` object Blobs are added as they are assuming a valid mode is set. The file they refer to may or may not exist in the file system, but must be a path relative to our repository. If their sha is null (40*0), their path must exist in the file system relative to the git repository as an object will be created from the data at the path. The handling now very much equals the way string paths are processed, except that the mode you have set will be kept. This allows you to create symlinks by settings the mode respectively and writing the target of the symlink directly into the file. This equals a default Linux symlink which is not dereferenced automatically, except that it can be created on filesystems not supporting it as well. Please note that globs or directories are not allowed in :class:`~git.objects.blob.Blob` objects. They are added at stage 0. - :class:`~git.index.typ.BaseIndexEntry` or type Handling equals the one of :class:`~git.objects.blob.Blob` objects, but the stage may be explicitly set. Please note that Index Entries require binary sha's. :param force: **CURRENTLY INEFFECTIVE** If ``True``, otherwise ignored or excluded files will be added anyway. As opposed to the :manpage:`git-add(1)` command, we enable this flag by default as the API user usually wants the item to be added even though they might be excluded. :param fprogress: Function with signature ``f(path, done=False, item=item)`` called for each path to be added, one time once it is about to be added where ``done=False`` and once after it was added where ``done=True``. ``item`` is set to the actual item we handle, either a path or a :class:`~git.index.typ.BaseIndexEntry`. Please note that the processed path is not guaranteed to be present in the index already as the index is currently being processed. :param path_rewriter: Function, with signature ``(string) func(BaseIndexEntry)``, returning a path for each passed entry which is the path to be actually recorded for the object created from :attr:`entry.path `. This allows you to write an index which is not identical to the layout of the actual files on your hard-disk. If not ``None`` and `items` contain plain paths, these paths will be converted to Entries beforehand and passed to the path_rewriter. Please note that ``entry.path`` is relative to the git repository. :param write: If ``True``, the index will be written once it was altered. Otherwise the changes only exist in memory and are not available to git commands. :param write_extension_data: If ``True``, extension data will be written back to the index. This can lead to issues in case it is containing the 'TREE' extension, which will cause the :manpage:`git-commit(1)` command to write an old tree, instead of a new one representing the now changed index. This doesn't matter if you use :meth:`IndexFile.commit`, which ignores the 'TREE' extension altogether. You should set it to ``True`` if you intend to use :meth:`IndexFile.commit` exclusively while maintaining support for third-party extensions. Besides that, you can usually safely ignore the built-in extensions when using GitPython on repositories that are not handled manually at all. All current built-in extensions are listed here: https://git-scm.com/docs/index-format :return: List of :class:`~git.index.typ.BaseIndexEntry`\s representing the entries just actually added. :raise OSError: If a supplied path did not exist. Please note that :class:`~git.index.typ.BaseIndexEntry` objects that do not have a null sha will be added even if their paths do not exist. rzXAt least one Entry has a null-mode - please use index.remove to remove files for claritycD]]}|}|j|j}t|j|j|j |jf|<_yrw)r&ror&moderry)r]ei null_entry new_entryrTrnull_entries_indicess rOhandle_null_entriesz*IndexFile.add..handle_null_entriessf2 %,R[ $($4$4Z__i$P '5 * ) 0 0 * 0 0 * ' rZFT)r)r]rr@N)rrr.r5r enumeraterrr)r+r&ryror'rrTr)r]rr1rr'rr2rr+r{null_mode_entriesir:r progress_sentrTr9s ` @@rOaddz IndexFile.addsB33E:w.0    !8!8 yZa!b c ,3 Cqqvv{ C  C  n3?D3 "45 T33D9: 7$ >??  @ rZ working_treec g}|s|jd|jd|j|}|jjj||fi|j }|Dcgc]}|dd c}Scc}w)a&Remove the given items from the index and optionally from the working tree as well. :param items: Multiple types of items are supported which may be be freely mixed. - path string Remove the given path at all stages. If it is a directory, you must specify the ``r=True`` keyword argument to remove all file entries below it. If absolute paths are given, they will be converted to a path relative to the git repository directory containing the working tree The path string may include globs, such as ``*.c``. - :class:`~git.objects.blob.Blob` object Only the path portion is used in this case. - :class:`~git.index.typ.BaseIndexEntry` or compatible type The only relevant information here is the path. The stage is ignored. :param working_tree: If ``True``, the entry will also be removed from the working tree, physically removing the respective file. This may fail if there are uncommitted changes in it. :param kwargs: Additional keyword arguments to be passed to :manpage:`git-rm(1)`, such as ``r`` to allow recursive removal. :return: List(path_string, ...) list of repository relative paths that have been removed effectively. This is interesting to know in case you have provided a directory or globs. Paths are relative to the repository. z--cachedz--)rrArRrrm splitlines)r]rrBrrr removed_pathsps rOrJzIndexFile.removes}^ KK # D))%0( ((u??JJL "//A!B///s2 B skip_errorsc g}|r|jd|j|}t|dkr td|j d|j dd}d|d<g}|j j j||fi|j}ttt|dz t|D]M} || jd} t| dk(s Jd || z|j| d d d| d fO|r|S|j d|j j j||fi||S) aRename/move the items, whereas the last item is considered the destination of the move operation. If the destination is a file, the first item (of two) must be a file as well. If the destination is a directory, it may be preceded by one or more directories or files. The working tree will be affected in non-bare repositories. :param items: Multiple types of items are supported, please see the :meth:`remove` method for reference. :param skip_errors: If ``True``, errors such as ones resulting from missing source files will be skipped. :param kwargs: Additional arguments you would like to pass to :manpage:`git-mv(1)`, such as ``dry_run`` or ``force``. :return: List(tuple(source_path_string, destination_path_string), ...) A list of pairs, containing the source file moved as well as its actual destination. Relative to the repository root. :raise ValueError: If only one item was given. :raise git.exc.GitCommandError: If git could not handle your request. z-krWzLPlease provide at least one source and one destination of the move operationdry_runnNTz to zToo many tokens in %sr r) rrArrr rRrmvrGrangeintsplit) r]rrJrrr was_dry_runoutmvlineslntokenss rOmovezIndexFile.movesRT  KK ))%0 u:>kl ljjFJJsD,AB  y"$))--""49&9DDFCL1,-s7|< 3BR[&&v.Fv;!# J%`. :note: If you have manually altered the :attr:`entries` member of this instance, don't forget to :meth:`write` your changes to disk beforehand. :note: Passing ``skip_hooks=True`` is the equivalent of using ``-n`` or ``--no-verify`` on the command line. :return: :class:`~git.objects.commit.Commit` object representing the new commit z pre-commitz commit-msg)r\r]r^r_z post-commit) r"_write_commit_editmsg_commit_editmsg_filepath_read_commit_editmsg_remove_commit_editmsgrrcreate_from_treerR) r]rYrZr[r\r]r^r_r`treers rOrzIndexFile.commitfs8 L$ /  & &w / L$0M0M0O P//1G  ' ' ) && II    ##   M4 0 rZct|jd5}|j|jtdddy#1swYyxYw)Nwb)rcrcrrr )r]rYcommit_editmsg_files rOrbzIndexFile._write_commit_editmsgsD $//14 8 > > >s %A  AcJtj|jyrw)rHrJrcrms rOrez IndexFile._remove_commit_editmsgs $//12rZct|jd5}|jjtcdddS#1swYyxYwr )rcrcreaddecoder )r]rjs rOrdzIndexFile._read_commit_editmsgsD $//14 8 =??rZ Popen[bytes] ignore_stdoutc"|j}|r |j|jd}|s&|jr|jj }|jr*|jj|j |S)NrZ)rrrIrrmwait)rrrsstdin_IOrs rO_flush_stdin_and_waitzIndexFile._flush_stdin_and_waitsg::  NN  NN [[%%'F ;; KK    IIK rZcyrwrr0s rOr|zIndexFile.rrZc dg|rjdgggdddttddffd }|jd d |d <|dd d|jjj i|j |dd dd|jjD}|||St|tr|g}|jjdd |d <tj|d<|jjj fi|dtffd }g}|D][} t|j| } d } |j| df| r4|j)| | ||d |j| ] |j+d |||S#t $rt| } | j#ds| dz } |jjD]]} t| j$j'| s(| j$}|j)||||d |j|d } _YwxYw#t$rt-dgwxYw)aCheck out the given paths or all files from the version known to the index into the working tree. :note: Be sure you have written pending changes using the :meth:`write` method in case you have altered the entries dictionary directly. :param paths: If ``None``, all paths in the index will be checked out. Otherwise an iterable of relative or absolute paths or a single path pointing to files or directories in the index is expected. :param force: If ``True``, existing files will be overwritten even if they contain local modifications. If ``False``, these will trigger a :exc:`~git.exc.CheckoutError`. :param fprogress: See :meth:`IndexFile.add` for signature and explanation. The provided progress information will contain ``None`` as path and item if no explicit paths are given. Otherwise progress information will be send prior and after a file has been checked out. :param kwargs: Additional arguments to be passed to :manpage:`git-checkout-index(1)`. :return: Iterable yielding paths to files which have been checked out and are guaranteed to match the version stored in the index. :raise git.exc.CheckoutError: * If at least one file failed to be checked out. This is a summary, hence it will checkout as many files as it can anyway. * If one of files or directories do not exist in the index (as opposed to the original git command, which ignores them). :raise git.exc.GitCommandError: If error lines could not be parsed - this truly is an exceptional state. :note: The checkout is limited to checking out the files in the index. Files which are not in the index anymore and exist in the working tree will not be deleted. This behaviour is fundamentally different to ``head.checkout``, i.e. if you want :manpage:`git-checkout(1)`-like behaviour, use ``head.checkout`` instead of ``index.checkout``. z--indexz--forcerrriter_checked_out_filesr@Nc |j}|sy|j}|jt}d}|j D]Y}|j ds|j dsd}d}d} |j |r0 j|dt|  j|n|j |r> j|t||jd j|nR|j | r0 j|dt|   j| nj||D]E} |j | s j|dt|   j| Y\r td d | r.tt|t z } td | y) N)z already existsz is not in the cachez does not exist at stagez is unmergedzgit checkout-index: zgit-checkout-index: z is a directoryzunable to unlink old 'z already exists, no checkout')git-checkout-indexzMSome files could not be checked out from the index due to local modifications)stderrrmrnr rGrrrrrfindr listsetr)rrz stderr_IO stderr_bytesrendingsris_a_dir unlink_issuealready_exists_issuer{ valid_files failed_filesfailed_reasons unknown_liness rO handle_stderrz)IndexFile.checkout..handle_stderrs I$>>+L!((0FG ))+ '=>tWmGn0H#;L+I(}}X.$++D1ACM>,BC&--h76$++D\1BTZZPS_,UV&--l;';<$++D1MC8L4M3M,NO&--.BC%,,T2!A}}Q'$++Ds1vg,>?&--a0 ' 6%&=sFKK"3'=#>\AR#RS #c " rZz--allr as_processFTc34K|]}|jywrwrrs rOrz%IndexFile.checkout..3s?A?sz--stdinr%cVtdgdjjS)Nr~r)r rrm)rrsrOmake_excz$IndexFile.checkout..make_excEs(&(<'Dt'Dc4;;K[K[K]^^rZr/)r)rszWSome files could not be checked out from the index, probably because they didn't exist.)rr2r;rRrcheckout_indexrurTrrr subprocessPIPEr rrrrrorrrwr)r]rr1rrr rval_iterrchecked_out_filesroco_pathpath_is_directoryfolderrrIrrrrrs @@@@@rOcheckoutzIndexFile.checkoutsn{  KK "  3 3 QYHZ3 _c3 n = KK #$F< dE4 (/499==//@@D IIK dD$ '?)<)<)>?I $ * %% LL KK "#'F< *F9 /499==//??D _o _13  6.t/E/Ed/KL$)! 5LL'1.)--dGT8Yin-o%,,W5/ 64 **4t*D $ 1 2$ $? 5 \F!??3/# !%!4!4!65uzz?55f= % A 55dAq(Ihm5n-44Q704- 5 5*# #m "  s%)G(I0A+I-28I-,I-0Jrr=c ,t|j|j|}|s|j|_nC|j}|D]2}|j |} t |d} || |j| <4|j|r|j|d|rC|jjj|jj|d|z|S#t $r! |j =n#t $rYnwxYwYwxYw)a[Reset the index to reflect the tree at the given commit. This will not adjust our HEAD reference by default, as opposed to :meth:`HEAD.reset `. :param commit: Revision, :class:`~git.refs.reference.Reference` or :class:`~git.objects.commit.Commit` specifying the commit we should represent. If you want to specify a tree only, use :meth:`IndexFile.from_tree` and overwrite the default index. :param working_tree: If ``True``, the files in the working tree will reflect the changed index. If ``False``, the working tree will not be touched. Please note that changes to the working copy will be discarded without warning! :param head: If ``True``, the head will be set to the given commit. This is ``False`` by default, but if ``True``, this method behaves like :meth:`HEAD.reset `. :param paths: If given as an iterable of absolute or repository-relative paths, only these will be reset to their state at the given commit-ish. The paths need to exist at the commit, otherwise an exception will be raised. :param kwargs: Additional keyword arguments passed to :manpage:`git-reset(1)`. :note: :meth:`IndexFile.reset`, as opposed to :meth:`HEAD.reset `, will not delete any files in order to maintain a consistent working tree. Instead, it will just check out the files according to their state in the index. If you want :manpage:`git-reset(1)`-like behaviour, use :meth:`HEAD.reset ` instead. :return: self rT)rr1z%s: Updating HEAD)logmsg) r#rrRrTrr rrrr[ set_commitr) r]rrBrr[rnew_instnieror}s rOresetzIndexFile.resetss l:'' 6:#++DL""C --d3#D!,C(+CDLL%   MMTM 2  IINN % %dii&6&6v&>GZ]cGc % d )  LL-# s6C)) D3 DD D  D D  DDotherrr create_patchc |j|jk7rtd|jz||jurt j St|tr|jj|}t|tr7|jdd}| |d<|j|j||fi|S|td|zt| |||fi|S)aDiff this index against the working copy or a :class:`~git.objects.tree.Tree` or :class:`~git.objects.commit.Commit` object. For documentation of the parameters and return values, see :meth:`Diffable.diff `. :note: Will only work with indices that represent the default git index as they have not been initialized with a stream. zECannot call %r on indices that do not represent the default git indexRFz@V@w@#@+@@J7/7/Xh5G7/HU]L^7/7/D"&... . 3=) . XtX6<= .. tSy .bES!5D#9":D"@A % 4( )*XtE)T/4J/K%K L0!u^Xy%HI!eT\^gTgNh!!%%;%N D@ 5#6678  eH112 3 h8&8XeHdNT_4_.`%aab tH~tN33 4, H  n @%Cy%Xt^,% % n% % n  %%T0>B%*JXxhnk.Y(Z[[\JJ J Xc8m4d:; J  J#J n JXXxhi.W(XYYZ h*#80Xxhnk.Y(Z[[\8080 80 c 8080t"LXxhnk.Y(Z[[\LL L eCHo  LLb59%)(,;?;? 11d6lD011 1 dEk" 1 u% 18,,c47818,,c47811 1f>S>T>3=c=@#@   Y^ 260 y%T8H--.y%y% y%  y% tXh'();; < y%y%x39"15 Sfk3./SST8H--. S  S  S SS~ NNMQ"1B H**00 1       1BXtH~uXs]/CTIJ1B1B1B   HMM *1B1BrZr)`r__all__ contextlibrriorrHos.pathrorr*rrrDrF gitdb.basergitdb.dbr git.compatr r git.diffrrgit.excrr r r git.objectsrrrrrgit.objects.utilrgit.utilrrrrrrrrfunrrr r!r"r#r$r%typr&r'rutilr(r)r*r+typingr,r-r.r/r0r1r2r3r4r5r6r7r8r9 git.typesr:r;r<git.refs.referencer=git.repor>rrrcontextmanagerrPDiffablerrrZrOrs 8 6   *WW==)      76UU"( , fc5( )  H3PTVZ?A[,NB 8,,lNBrZ