Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-02-19 08:45:51 +0300
committerStan Hu <stanhu@gmail.com>2018-02-19 08:48:49 +0300
commit8d32dfef9b7eefe3d48dc63398315ba41879329c (patch)
tree1b42dbc18144454d1c9e8e7708806cb2cbd7e437 /lib
parent557db7e635c70bf68a15f7029014301013b30070 (diff)
Fix squash rebase not working when diff contained encoded data
When the applied diff contains UTF-8 or some other encoded data, the diff returned back from the git process may be in ASCII-8BIT format. Writing this data to stdin may fail if the data because stdin expects this data to be in UTF-8. By switching the output to binmode, we ensure that the diff will always be written as-is. Closes gitlab-org/gitlab-ee#4960
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/git/repository.rb1
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb
index 5f014e43c6f..a10bc0dd32b 100644
--- a/lib/gitlab/git/repository.rb
+++ b/lib/gitlab/git/repository.rb
@@ -2195,6 +2195,7 @@ module Gitlab
# Apply diff of the `diff_range` to the worktree
diff = run_git!(%W(diff --binary #{diff_range}))
run_git!(%w(apply --index), chdir: squash_path, env: env) do |stdin|
+ stdin.binmode
stdin.write(diff)
end