BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
7ff35720
Commit
7ff35720
authored
Jun 22, 2017
by
Robert Speicher
Committed by
kushalpandya
Jun 26, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge branch 'fix/properly-encode-gitaly-diffs' into 'master'
Encode Gitaly diff patches properly See merge request !12368
parent
8eee00c9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
2 deletions
+13
-2
diff.rb
lib/gitlab/git/diff.rb
+1
-1
diff_stitcher.rb
lib/gitlab/gitaly_client/diff_stitcher.rb
+4
-1
diff_spec.rb
spec/lib/gitlab/git/diff_spec.rb
+8
-0
No files found.
lib/gitlab/git/diff.rb
View file @
7ff35720
...
...
@@ -319,7 +319,7 @@ module Gitlab
end
def
init_from_gitaly
(
diff
)
@diff
=
diff
.
patch
if
diff
.
respond_to?
(
:patch
)
@diff
=
encode!
(
diff
.
patch
)
if
diff
.
respond_to?
(
:patch
)
@new_path
=
encode!
(
diff
.
to_path
.
dup
)
@old_path
=
encode!
(
diff
.
from_path
.
dup
)
@a_mode
=
diff
.
old_mode
.
to_s
(
8
)
...
...
lib/gitlab/gitaly_client/diff_stitcher.rb
View file @
7ff35720
...
...
@@ -13,7 +13,10 @@ module Gitlab
@rpc_response
.
each
do
|
diff_msg
|
if
current_diff
.
nil?
diff_params
=
diff_msg
.
to_h
.
slice
(
*
GitalyClient
::
Diff
::
FIELDS
)
diff_params
[
:patch
]
=
diff_msg
.
raw_patch_data
# gRPC uses frozen strings by default, and we need to have an unfrozen string as it
# gets processed further down the line. So we unfreeze the first chunk of the patch
# in case it's the only chunk we receive for this diff.
diff_params
[
:patch
]
=
diff_msg
.
raw_patch_data
.
dup
current_diff
=
GitalyClient
::
Diff
.
new
(
diff_params
)
else
...
...
spec/lib/gitlab/git/diff_spec.rb
View file @
7ff35720
...
...
@@ -175,6 +175,14 @@ EOT
expect
(
diff
).
to
be_too_large
end
end
context
'when the patch passed is not UTF-8-encoded'
do
let
(
:raw_patch
)
{
@raw_diff_hash
[
:diff
].
encode
(
Encoding
::
ASCII_8BIT
)
}
it
'encodes diff patch to UTF-8'
do
expect
(
diff
.
diff
.
encoding
).
to
eq
(
Encoding
::
UTF_8
)
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment