Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork940
Add '-z' on top of '--raw' to avoid path name mangling#1102
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
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
99 changes: 50 additions & 49 deletionsgit/diff.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 |
---|---|---|
@@ -108,6 +108,7 @@ def diff(self, other=Index, paths=None, create_patch=False, **kwargs): | ||
args.append("-p") | ||
else: | ||
args.append("--raw") | ||
args.append("-z") | ||
# in any way, assure we don't see colored output, | ||
# fixes https://github.com/gitpython-developers/GitPython/issues/172 | ||
@@ -478,55 +479,55 @@ def _index_from_raw_format(cls, repo, proc): | ||
index = DiffIndex() | ||
def handle_diff_line(lines): | ||
lines =lines.decode(defenc) | ||
for line in lines.split(':')[1:]: | ||
Byron marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
meta, _, path = line.partition('\x00') | ||
path =path.rstrip('\x00') | ||
old_mode, new_mode, a_blob_id, b_blob_id, _change_type = meta.split(None, 4) | ||
# Change type can be R100 | ||
# R: status letter | ||
# 100: score (in case of copy and rename) | ||
change_type = _change_type[0] | ||
score_str = ''.join(_change_type[1:]) | ||
score = int(score_str) if score_str.isdigit() else None | ||
path = path.strip() | ||
a_path = path.encode(defenc) | ||
b_path = path.encode(defenc) | ||
deleted_file = False | ||
new_file = False | ||
copied_file = False | ||
rename_from = None | ||
rename_to = None | ||
# NOTE: We cannot conclude from the existence of a blob to change type | ||
# as diffs with the working do not have blobs yet | ||
if change_type == 'D': | ||
b_blob_id = None | ||
deleted_file = True | ||
elif change_type == 'A': | ||
a_blob_id = None | ||
new_file = True | ||
elif change_type == 'C': | ||
copied_file = True | ||
a_path, b_path = path.split('\x00', 1) | ||
a_path = a_path.encode(defenc) | ||
b_path = b_path.encode(defenc) | ||
elif change_type == 'R': | ||
a_path, b_path = path.split('\x00', 1) | ||
a_path = a_path.encode(defenc) | ||
b_path = b_path.encode(defenc) | ||
rename_from, rename_to = a_path, b_path | ||
elif change_type == 'T': | ||
# Nothing to do | ||
pass | ||
# END add/remove handling | ||
diff = Diff(repo, a_path, b_path, a_blob_id, b_blob_id, old_mode, new_mode, | ||
new_file, deleted_file, copied_file, rename_from, rename_to, | ||
'', change_type, score) | ||
index.append(diff) | ||
handle_process_output(proc, handle_diff_line, None, finalize_process, decode_streams=False) | ||
12 changes: 8 additions & 4 deletionstest/test_diff.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.