@@ -581,10 +581,10 @@ def _preprocess_add_items(self, items):
581
581
return (paths , entries )
582
582
583
583
@git_working_dir
584
- def add (self , items , force = True , fprogress = lambda * args : None , path_rewriter = None ):
584
+ def add (self , items , force = True , fprogress = lambda * args : None , path_rewriter = None ,
585
+ write = True ):
585
586
"""Add files from the working tree, specific blobs or BaseIndexEntries
586
- to the index. The underlying index file will be written immediately, hence
587
- you should provide as many items as possible to minimize the amounts of writes
587
+ to the index.
588
588
589
589
:param items:
590
590
Multiple types of items are supported, types can be mixed within one call.
@@ -653,6 +653,10 @@ def add(self, items, force=True, fprogress=lambda *args: None, path_rewriter=Non
653
653
converted to Entries beforehand and passed to the path_rewriter.
654
654
Please note that entry.path is relative to the git repository.
655
655
656
+ :param write:
657
+ If True, the index will be written once it was altered. Otherwise
658
+ the changes only exist in memory and are not available to git commands.
659
+
656
660
:return:
657
661
List(BaseIndexEntries) representing the entries just actually added.
658
662
@@ -748,11 +752,13 @@ def store_path(filepath):
748
752
# END if there are base entries
749
753
750
754
# FINALIZE
751
- # add the new entries to this instance, and write it
755
+ # add the new entries to this instance
752
756
for entry in entries_added :
753
757
self .entries [(entry .path , 0 )] = IndexEntry .from_base (entry )
754
-
755
- self .write ()
758
+
759
+ if write :
760
+ self .write ()
761
+ # END handle write
756
762
757
763
return entries_added
758
764
0 commit comments