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

Appearance settings

Commit 14cef2b

Browse filesBrowse files
jelmerempty
authored andcommitted
Avoid stripping newlines in blob data.
(cherry picked from commit ccca12ee26e40fb4c4df2d77154ed496144569b9)
1 parent d3ce120 commit 14cef2b
Copy full SHA for 14cef2b

4 files changed

+13-4Lines changed: 13 additions & 4 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/git/blob.py‎

Copy file name to clipboardExpand all lines: lib/git/blob.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def data(self):
5757
Returns
5858
str
5959
"""
60-
self.data_stored = self.data_stored or self.repo.git.cat_file(self.id, **{'p': True})
60+
self.data_stored = self.data_stored or self.repo.git.cat_file(self.id, **{'p': True, 'with_raw_output': True})
6161
return self.data_stored
6262

6363
@property
Collapse file

‎test/fixtures/cat_file_blob_nl‎

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hello world
Collapse file

‎test/git/test_blob.py‎

Copy file name to clipboardExpand all lines: test/git/test_blob.py
+10-2Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,15 @@ def test_should_return_blob_contents(self, git):
1818
blob = Blob(self.repo, **{'id': 'abc'})
1919
assert_equal("Hello world", blob.data)
2020
assert_true(git.called)
21-
assert_equal(git.call_args, (('cat_file', 'abc'), {'p': True}))
21+
assert_equal(git.call_args, (('cat_file', 'abc'), {'p': True, 'with_raw_output': True}))
22+
23+
@patch(Git, '_call_process')
24+
def test_should_return_blob_contents_with_newline(self, git):
25+
git.return_value = fixture('cat_file_blob_nl')
26+
blob = Blob(self.repo, **{'id': 'abc'})
27+
assert_equal("Hello world\n", blob.data)
28+
assert_true(git.called)
29+
assert_equal(git.call_args, (('cat_file', 'abc'), {'p': True, 'with_raw_output': True}))
2230

2331
@patch(Git, '_call_process')
2432
def test_should_cache_data(self, git):
@@ -28,7 +36,7 @@ def test_should_cache_data(self, git):
2836
blob.data
2937
assert_true(git.called)
3038
assert_equal(git.call_count, 1)
31-
assert_equal(git.call_args, (('cat_file', 'abc'), {'p': True}))
39+
assert_equal(git.call_args, (('cat_file', 'abc'), {'p': True, 'with_raw_output': True}))
3240

3341
@patch(Git, '_call_process')
3442
def test_should_return_file_size(self, git):
Collapse file

‎test/git/test_repo.py‎

Copy file name to clipboardExpand all lines: test/git/test_repo.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def test_blob(self, git):
107107
assert_equal("Hello world", blob.data)
108108

109109
assert_true(git.called)
110-
assert_equal(git.call_args, (('cat_file', 'abc'), {'p': True}))
110+
assert_equal(git.call_args, (('cat_file', 'abc'), {'p': True, 'with_raw_output': True}))
111111

112112
@patch(Repo, '__init__')
113113
@patch(Git, '_call_process')

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.