diff options
author | Stan Hu <stanhu@gmail.com> | 2018-02-19 08:45:51 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-02-19 08:48:49 +0300 |
commit | 8d32dfef9b7eefe3d48dc63398315ba41879329c (patch) | |
tree | 1b42dbc18144454d1c9e8e7708806cb2cbd7e437 /lib | |
parent | 557db7e635c70bf68a15f7029014301013b30070 (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.rb | 1 |
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 |