schacon/ruby-git — pull request #195 by mbishop-fiksu (2014-11-28 11:31:38+00:00)
Title: Removed all `Dir.chdir` calls from private use

When writing command-line tools that use ruby-git to interface with git, there are often ways to achieve better performance by running git query commands in parallel. This is unworkable with `ruby-git` given it's extensive use of the non-thread-safe `Dir.chdir` call. With all implicit calls to `Dir.chdir` removed, `ruby-git` is one step closer to being usable amongst threads.

From the [`Dir.chdir` documentation](http://www.ruby-doc.org/core-2.1.5/Dir.html#method-c-chdir):

> The return value of chdir is the value of the block. chdir blocks can be nested, but in a multi-threaded program an error will be raised if a thread attempts to open a chdir block while another thread has one open.