puppetlabs/puppetlabs-vcsrepo — pull request #42 by xgoat (2012-11-19 01:21:40+00:00)
Title: Fix cloning of git repos when the cwd is inaccessible by the clone's owner

`git clone` doesn't like being run with a working directory that it
cannot access -- even if it is not being asked to do anything with
that directory. For example, the following will fail:

% pwd
/root
% echo $USER
root
% su somebody -c "git clone git://somewhere /tmp/test"
fatal: Could not change back to '/root': Permission denied

This meant that if vcsrepo was cloning a repository as a user other
than root, and puppet's working directory was inaccessible by that
user, then the clone would fail.

This patch adjusts vcsrepo to change working directory to `/` before
running `git clone`. The working directory is then reverted in order
to avoid any issues arising due to relative paths elsewhere.