summaryrefslogtreecommitdiff
path: root/git/test
diff options
context:
space:
mode:
Diffstat (limited to 'git/test')
-rw-r--r--git/test/fixtures/diff_file_with_spaces7
-rw-r--r--git/test/fixtures/diff_initial2
-rw-r--r--git/test/test_diff.py11
3 files changed, 16 insertions, 4 deletions
diff --git a/git/test/fixtures/diff_file_with_spaces b/git/test/fixtures/diff_file_with_spaces
new file mode 100644
index 00000000..a9f0b06c
--- /dev/null
+++ b/git/test/fixtures/diff_file_with_spaces
@@ -0,0 +1,7 @@
+diff --git a/file with spaces b/file with spaces
+new file mode 100644
+index 0000000000000000000000000000000000000000..75c620d7b0d3b0100415421a97f553c979d75174
+--- /dev/null
++++ b/file with spaces
+@@ -0,0 +1 @@
++ohai
diff --git a/git/test/fixtures/diff_initial b/git/test/fixtures/diff_initial
index 6037c677..648d7043 100644
--- a/git/test/fixtures/diff_initial
+++ b/git/test/fixtures/diff_initial
@@ -1,5 +1,3 @@
---- /dev/null
-+++ b/CHANGES
@@ -0,0 +1,7 @@
+=======
+CHANGES
diff --git a/git/test/test_diff.py b/git/test/test_diff.py
index 56e395fd..05f8f3ae 100644
--- a/git/test/test_diff.py
+++ b/git/test/test_diff.py
@@ -76,7 +76,7 @@ class TestDiff(TestBase):
self._assert_diff_format(diffs)
assert_equal(1, len(diffs))
- assert_equal(10, len(diffs[0].diff.splitlines()))
+ assert_equal(8, len(diffs[0].diff.splitlines()))
def test_diff_with_rename(self):
output = StringProcessAdapter(fixture('diff_rename'))
@@ -140,7 +140,8 @@ class TestDiff(TestBase):
# ...and with creating a patch
diff_index = initial_commit.diff(NULL_TREE, create_patch=True)
- assert diff_index[0].b_path == 'CHANGES'
+ assert diff_index[0].a_path is None, repr(diff_index[0].a_path)
+ assert diff_index[0].b_path == 'CHANGES', repr(diff_index[0].b_path)
assert diff_index[0].new_file
assert diff_index[0].diff == fixture('diff_initial')
@@ -156,6 +157,12 @@ class TestDiff(TestBase):
Diff._index_from_patch_format(self.rorepo, diff_proc.stdout)
# END for each fixture
+ def test_diff_with_spaces(self):
+ data = StringProcessAdapter(fixture('diff_file_with_spaces'))
+ diff_index = Diff._index_from_patch_format(self.rorepo, data.stdout)
+ assert diff_index[0].a_path is None, repr(diff_index[0].a_path)
+ assert diff_index[0].b_path == u'file with spaces', repr(diff_index[0].b_path)
+
def test_diff_interface(self):
# test a few variations of the main diff routine
assertion_map = dict()