Skip to content

Commit 91725f0

Browse files
committed
index.add does not need the git clt anymore
1 parent 0fdf6c3 commit 91725f0

File tree

2 files changed

+9
-24
lines changed

2 files changed

+9
-24
lines changed

lib/git/index/base.py

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,6 @@ def _preprocess_add_items(self, items):
643643
# END for each item
644644
return (paths, entries)
645645

646-
@default_index
647646
def add(self, items, force=True, fprogress=lambda *args: None, path_rewriter=None):
648647
"""Add files from the working tree, specific blobs or BaseIndexEntries
649648
to the index. The underlying index file will be written immediately, hence
@@ -734,7 +733,9 @@ def add(self, items, force=True, fprogress=lambda *args: None, path_rewriter=Non
734733
for path in paths:
735734
abspath = os.path.abspath(path)
736735
gitrelative_path = abspath[len(self.repo.working_tree_dir)+1:]
737-
blob = Blob(self.repo, Blob.NULL_HEX_SHA, os.stat(abspath).st_mode, gitrelative_path)
736+
blob = Blob(self.repo, Blob.NULL_HEX_SHA,
737+
self._stat_mode_to_index_mode(os.stat(abspath).st_mode),
738+
gitrelative_path)
738739
entries.append(BaseIndexEntry.from_blob(blob))
739740
# END for each path
740741
del(paths[:])
@@ -754,7 +755,8 @@ def store_path(filepath):
754755
istream = self.repo.odb.store(IStream(Blob.type, st.st_size, stream))
755756
fprogress(filepath, True, filepath)
756757

757-
return BaseIndexEntry((st.st_mode, istream.sha, 0, filepath))
758+
return BaseIndexEntry((self._stat_mode_to_index_mode(st.st_mode),
759+
istream.sha, 0, filepath))
758760
# END utility method
759761

760762

@@ -799,36 +801,21 @@ def store_path(filepath):
799801
# END for each entry
800802
# END handle path rewriting
801803

802-
# feed pure entries to stdin
803-
proc = self.repo.git.update_index(index_info=True, istream=subprocess.PIPE, as_process=True)
804-
lem1 = len(entries)-1
804+
# just go through the remaining entries and provide progress info
805805
for i, entry in enumerate(entries):
806806
progress_sent = i in null_entries_indices
807807
if not progress_sent:
808808
fprogress(entry.path, False, entry)
809-
810-
proc.stdin.write(str(entry))
811-
812-
# the last entry is not \n terminated, as it exepcts to read
813-
# another entry then and would block. Hence we skip the last one
814-
if i != lem1:
815-
proc.stdin.write('\n')
816-
proc.stdin.flush()
817-
# END skip last newline
818-
819-
if not progress_sent:
820809
fprogress(entry.path, True, entry)
810+
# END handle progress
821811
# END for each enty
822-
self._flush_stdin_and_wait(proc, ignore_stdout=True)
823812
entries_added.extend(entries)
824813
# END if there are base entries
825814

826815
# FINALIZE
827816
# add the new entries to this instance, and write it
828817
for entry in entries_added:
829818
self.entries[(entry.path, 0)] = IndexEntry.from_base(entry)
830-
831-
# finally write the changed index
832819
self.write()
833820

834821
return entries_added

lib/git/index/typ.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,13 @@ def size(self):
137137
return self[10]
138138

139139
@classmethod
140-
def from_base(cls, base, actual_value=False):
140+
def from_base(cls, base):
141141
"""
142142
:return:
143143
Minimal entry as created from the given BaseIndexEntry instance.
144144
Missing values will be set to null-like values
145145
146-
:param base: Instance of type BaseIndexEntry
147-
:param actual_value: if set, instead of writing 0 values for fields that
148-
don't exist in the BaseEntry, the actual values will be written in."""
146+
:param base: Instance of type BaseIndexEntry"""
149147
time = pack(">LL", 0, 0)
150148
return IndexEntry((base.mode, base.sha, base.flags, base.path, time, time, 0, 0, 0, 0, 0))
151149

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy