Skip to content
Snippets Groups Projects
Commit e1a155f6 authored by Jacob Vosmaer's avatar Jacob Vosmaer
Browse files

Remove use of posix-spawn chdir:

The posix-spawn gem's `chdir:` option is not thread-safe.
parent 4b5521c3
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -22,6 +22,7 @@ We patched existing grit library to use it inside GitLab
* Added Gemfile
* Ruby 2.0 support
* Automatically set the `--work-tree=` option for Git
* Remove `chdir:` option from Grit::Git#native
* and much more small fixes
 
 
Loading
Loading
Loading
Loading
@@ -320,7 +320,6 @@ module Grit
input = options.delete(:input)
timeout = options.delete(:timeout); timeout = true if timeout.nil?
base = options.delete(:base); base = true if base.nil?
chdir = options.delete(:chdir)
 
# build up the git process argv
argv = []
Loading
Loading
@@ -337,7 +336,6 @@ module Grit
process =
Child.new(env, *(argv + [{
:input => input,
:chdir => chdir,
:timeout => (Grit::Git.git_timeout if timeout == true),
:max => (Grit::Git.git_max_size if timeout == true)
}]))
Loading
Loading
Loading
Loading
@@ -116,7 +116,7 @@ module Grit
# compares the index and the working directory
def diff_files
hsh = {}
@base.git.diff_files(chdir: @base.working_dir).split("\n").each do |line|
@base.git.diff_files({}).split("\n").each do |line|
(info, file) = line.split("\t")
(mode_src, mode_dest, sha_src, sha_dest, type) = info.split
hsh[file] = {:path => file, :mode_file => mode_src.to_s[1, 7], :mode_index => mode_dest,
Loading
Loading
@@ -128,7 +128,7 @@ module Grit
# compares the index and the repository
def diff_index(treeish)
hsh = {}
@base.git.diff_index({chdir: @base.working_dir}, treeish).split("\n").each do |line|
@base.git.diff_index({}, treeish).split("\n").each do |line|
(info, file) = line.split("\t")
(mode_src, mode_dest, sha_src, sha_dest, type) = info.split
hsh[file] = {:path => file, :mode_repo => mode_src.to_s[1, 7], :mode_index => mode_dest,
Loading
Loading
@@ -139,7 +139,7 @@ module Grit
 
def ls_files
hsh = {}
lines = @base.git.ls_files({chdir: @base.working_dir, :stage => true})
lines = @base.git.ls_files({:stage => true})
lines.split("\n").each do |line|
(info, file) = line.split("\t")
(mode, sha, stage) = info.split
Loading
Loading
Loading
Loading
@@ -88,7 +88,7 @@ class TestGit < Test::Unit::TestCase
args = [
{ 'A' => 'B' },
Grit::Git.git_binary, "--git-dir=#{@git.git_dir}", "help", "-a",
{:input => nil, :chdir => nil, :timeout => Grit::Git.git_timeout, :max => Grit::Git.git_max_size}
{:input => nil, :timeout => Grit::Git.git_timeout, :max => Grit::Git.git_max_size}
]
p = Grit::Git::Child.new(*args)
Grit::Git::Child.expects(:new).with(*args).returns(p)
Loading
Loading
Loading
Loading
@@ -26,9 +26,9 @@ class TestIndexStatus < Test::Unit::TestCase
end
 
def test_status
Git.any_instance.expects(:diff_index).with({chdir: GRIT_REPO}, 'HEAD').returns(fixture('diff_index'))
Git.any_instance.expects(:diff_files).with({chdir: GRIT_REPO}).returns(fixture('diff_files'))
Git.any_instance.expects(:ls_files).with({chdir: GRIT_REPO, stage: true}).returns(fixture('ls_files'))
Git.any_instance.expects(:diff_index).with({}, 'HEAD').returns(fixture('diff_index'))
Git.any_instance.expects(:diff_files).with({}).returns(fixture('diff_files'))
Git.any_instance.expects(:ls_files).with({stage: true}).returns(fixture('ls_files'))
status = @r.status
stat = status['lib/grit/repo.rb']
assert_equal stat.sha_repo, "71e930d551c413a123f43e35c632ea6ba3e3705e"
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment