Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
826d5b7b
Commit
826d5b7b
authored
Jun 22, 2017
by
Robert Speicher
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'fix/properly-encode-gitaly-diffs' into 'master'
Encode Gitaly diff patches properly See merge request !12368
parents
8fe5602c
5b092d21
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
2 deletions
+13
-2
lib/gitlab/git/diff.rb
lib/gitlab/git/diff.rb
+1
-1
lib/gitlab/gitaly_client/diff_stitcher.rb
lib/gitlab/gitaly_client/diff_stitcher.rb
+4
-1
spec/lib/gitlab/git/diff_spec.rb
spec/lib/gitlab/git/diff_spec.rb
+8
-0
No files found.
lib/gitlab/git/diff.rb
View file @
826d5b7b
...
@@ -318,7 +318,7 @@ module Gitlab
...
@@ -318,7 +318,7 @@ module Gitlab
end
end
def
init_from_gitaly
(
diff
)
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
)
@new_path
=
encode!
(
diff
.
to_path
.
dup
)
@old_path
=
encode!
(
diff
.
from_path
.
dup
)
@old_path
=
encode!
(
diff
.
from_path
.
dup
)
@a_mode
=
diff
.
old_mode
.
to_s
(
8
)
@a_mode
=
diff
.
old_mode
.
to_s
(
8
)
...
...
lib/gitlab/gitaly_client/diff_stitcher.rb
View file @
826d5b7b
...
@@ -13,7 +13,10 @@ module Gitlab
...
@@ -13,7 +13,10 @@ module Gitlab
@rpc_response
.
each
do
|
diff_msg
|
@rpc_response
.
each
do
|
diff_msg
|
if
current_diff
.
nil?
if
current_diff
.
nil?
diff_params
=
diff_msg
.
to_h
.
slice
(
*
GitalyClient
::
Diff
::
FIELDS
)
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
)
current_diff
=
GitalyClient
::
Diff
.
new
(
diff_params
)
else
else
...
...
spec/lib/gitlab/git/diff_spec.rb
View file @
826d5b7b
...
@@ -175,6 +175,14 @@ EOT
...
@@ -175,6 +175,14 @@ EOT
expect
(
diff
).
to
be_too_large
expect
(
diff
).
to
be_too_large
end
end
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
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