Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork940
Adding to the index of a bare repository.#131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
2 commits Select commitHold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
84 changes: 44 additions & 40 deletionsgit/index/base.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -562,7 +562,48 @@ def _preprocess_add_items(self, items): | ||
# END for each item | ||
return (paths, entries) | ||
@git_working_dir | ||
def _store_path(self, filepath, fprogress): | ||
"""Store file at filepath in the database and return the base index entry""" | ||
st = os.lstat(filepath)# handles non-symlinks as well | ||
stream = None | ||
if S_ISLNK(st.st_mode): | ||
stream = StringIO(os.readlink(filepath)) | ||
else: | ||
stream = open(filepath, 'rb') | ||
# END handle stream | ||
fprogress(filepath, False, filepath) | ||
istream = self.repo.odb.store(IStream(Blob.type, st.st_size, stream)) | ||
fprogress(filepath, True, filepath) | ||
return BaseIndexEntry((stat_mode_to_index_mode(st.st_mode), | ||
istream.binsha, 0, to_native_path_linux(filepath))) | ||
@git_working_dir | ||
def _entries_for_paths(self, paths, path_rewriter, fprogress): | ||
entries_added = list() | ||
if path_rewriter: | ||
for path in paths: | ||
abspath = os.path.abspath(path) | ||
gitrelative_path = abspath[len(self.repo.working_tree_dir)+1:] | ||
blob = Blob(self.repo, Blob.NULL_BIN_SHA, | ||
stat_mode_to_index_mode(os.stat(abspath).st_mode), | ||
to_native_path_linux(gitrelative_path)) | ||
entries.append(BaseIndexEntry.from_blob(blob)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. The path_rewriter case is not handled properly anymore. Will look into this. | ||
# END for each path | ||
del(paths[:]) | ||
# END rewrite paths | ||
# HANDLE PATHS | ||
assert len(entries_added) == 0 | ||
added_files = list() | ||
for filepath in self._iter_expand_paths(paths): | ||
entries_added.append(self._store_path(filepath, fprogress)) | ||
# END for each filepath | ||
# END path handling | ||
return entries_added | ||
def add(self, items, force=True, fprogress=lambda *args: None, path_rewriter=None, | ||
write=True): | ||
"""Add files from the working tree, specific blobs or BaseIndexEntries | ||
@@ -651,47 +692,10 @@ def add(self, items, force=True, fprogress=lambda *args: None, path_rewriter=Non | ||
# sort the entries into strings and Entries, Blobs are converted to entries | ||
# automatically | ||
# paths can be git-added, for everything else we use git-update-index | ||
paths, entries = self._preprocess_add_items(items) | ||
entries_added = list() | ||
if paths: | ||
entries_added.extend(self._entries_for_paths(paths, path_rewriter, fprogress)) | ||
# HANDLE ENTRIES | ||
if entries: | ||
@@ -706,7 +710,7 @@ def store_path(filepath): | ||
if null_entries_indices: | ||
for ei in null_entries_indices: | ||
null_entry = entries[ei] | ||
new_entry =self._store_path(null_entry.path, fprogress) | ||
# update null entry | ||
entries[ei] = BaseIndexEntry((null_entry.mode, new_entry.binsha, null_entry.stage, null_entry.path)) | ||
34 changes: 34 additions & 0 deletionsgit/test/test_index.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.