Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add '-z' on top of '--raw' to avoid path name mangling#1101

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

Closed
Byron wants to merge2 commits intomasterfrommore-robust-git-diff
Closed
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletionsgit/diff.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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
Expand DownExpand Up@@ -483,7 +484,7 @@ def handle_diff_line(line):
if not line.startswith(":"):
return

meta, _, path = line[1:].partition('\t')
meta, _, path = line[1:].partition('\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
Expand All@@ -510,11 +511,11 @@ def handle_diff_line(line):
new_file = True
elif change_type == 'C':
copied_file = True
a_path, b_path = path.split('\t', 1)
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('\t', 1)
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
Expand Down
12 changes: 8 additions & 4 deletionstest/test_diff.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,6 +26,10 @@
import os.path as osp


def to_raw(input):
return input.replace(b'\t', b'\x00')


@ddt.ddt
class TestDiff(TestBase):

Expand DownExpand Up@@ -112,7 +116,7 @@ def test_diff_with_rename(self):
self.assertEqual(diff.raw_rename_to, b'm\xc3\xbcller')
assert isinstance(str(diff), str)

output = StringProcessAdapter(fixture('diff_rename_raw'))
output = StringProcessAdapter(to_raw(fixture('diff_rename_raw')))
diffs = Diff._index_from_raw_format(self.rorepo, output)
self.assertEqual(len(diffs), 1)
diff = diffs[0]
Expand All@@ -137,7 +141,7 @@ def test_diff_with_copied_file(self):
self.assertTrue(diff.b_path, 'test2.txt')
assert isinstance(str(diff), str)

output = StringProcessAdapter(fixture('diff_copied_mode_raw'))
output = StringProcessAdapter(to_raw(fixture('diff_copied_mode_raw')))
diffs = Diff._index_from_raw_format(self.rorepo, output)
self.assertEqual(len(diffs), 1)
diff = diffs[0]
Expand DownExpand Up@@ -165,7 +169,7 @@ def test_diff_with_change_in_type(self):
self.assertIsNotNone(diff.new_file)
assert isinstance(str(diff), str)

output = StringProcessAdapter(fixture('diff_change_in_type_raw'))
output = StringProcessAdapter(to_raw(fixture('diff_change_in_type_raw')))
diffs = Diff._index_from_raw_format(self.rorepo, output)
self.assertEqual(len(diffs), 1)
diff = diffs[0]
Expand All@@ -175,7 +179,7 @@ def test_diff_with_change_in_type(self):
self.assertEqual(len(list(diffs.iter_change_type('T'))), 1)

def test_diff_of_modified_files_not_added_to_the_index(self):
output = StringProcessAdapter(fixture('diff_abbrev-40_full-index_M_raw_no-color'))
output = StringProcessAdapter(to_raw(fixture('diff_abbrev-40_full-index_M_raw_no-color')))
diffs = Diff._index_from_raw_format(self.rorepo, output)

self.assertEqual(len(diffs), 1, 'one modification')
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp