def in_work_tree(path)
      tmp_dir = path == :tmp
      path = Dir.mktmpdir if tmp_dir
      old_work_tree = ENV['GIT_WORK_TREE']
      ENV['GIT_WORK_TREE'] = path
      Dir.chdir(path) { yield path }
      ENV['GIT_WORK_TREE'] = old_work_tree
      FileUtils.rm_rf path, :secure => true if tmp_dir
    end
def in_work_tree(path)
      tmp_dir = path == :tmp
      path = Dir.mktmpdir if tmp_dir
      old_work_tree = ENV['GIT_WORK_TREE']
      ENV['GIT_WORK_TREE'] = path
      Dir.chdir(path) { yield path }
      ENV['GIT_WORK_TREE'] = old_work_tree
      FileUtils.rm_rf path, :secure => true if tmp_dir
    end
Run a block of code with +$GIT_WORK_TREE+ set to a specified path

 This executes a block of code while the environment variable
 +$GIT_WORK_TREE+ is set to a specified path or alternatively the path of
 a temporary directory.

 @param [String, :tmp] path A path or +:tmp+ which will create a temporary
        directory that will be removed afterwards
 @yield [path] The code inside this block will be executed with
        +$GIT_WORK_TREE+ set
 @yieldparam [String] path The absolute path used for +$GIT_WORK_TREE+