Skip to content

Isolate Dir.chdir to a new process, or mutex #372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 15 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 8 additions & 21 deletions lib/git/lib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class GitExecuteError < StandardError
class Lib

@@semaphore = Mutex.new
@@config_semaphore = Mutex.new

def initialize(base = nil, logger = nil)
@git_dir = nil
Expand Down Expand Up @@ -442,35 +441,23 @@ def config_remote(name)
end

def config_get(name)
@@config_semaphore.synchronize do
do_get = lambda do |path|
command('config', ['--get', name])
end

if @git_dir
Dir.chdir(@git_dir, &do_get)
else
do_get.call
end
do_get = lambda do |path|
command('config', ['--get', name])
end

do_get.call(@git_dir)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not 💯 this will work, but tests pass. Seems like we might need to pass the path to the config command.

end

def global_config_get(name)
command('config', ['--global', '--get', name], false)
end

def config_list
@@config_semaphore.synchronize do
build_list = lambda do |path|
parse_config_list command_lines('config', ['--list'])
end

if @git_dir
Dir.chdir(@git_dir, &build_list)
else
build_list.call
end
build_list = lambda do |path|
parse_config_list command_lines('config', ['--list'])
end

build_list.call(@git_dir)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, I think we need to utilize the path variable in the config command if it exists

end

def global_config_list
Expand Down