RiotGames/berkshelf — pull request #629 by sethvargo (2013-06-11 06:15:43+00:00)
Title: cached relative path of git repo broken in 2.0.1

Running into this problem working with cookbooks stored in a shared git repo using berkshelf 2.0.1, related to running git commands in the subdirectory without git data.

when specifying a relative cookbook path in a git repo, i.e.
``` bash
cookbook "foo", git: "git@github.com/user/chef-repo.git", rel: "cookbooks/foo"
```
the first `berks install` command works, but once the cookbook is cached berkshelf errors out that no repository exists on subsequent `berks install` commands:
``` bash
Failed to download 'foo' from git: 'git@github.com/user/chef-repo.git' with branch: 'master' at ref: 'xxxxxxxxxx'
An error occurred during Git execution:

fatal: Not a git repository (or any of the parent directories): .git
```

It looks like the logic is: when the cookbook `foo` is not cached, clone `chef-repo` to tmp_path, then copy the relative cookbook directory `foo` to `~/.berkshelf/cookbooks/foo-xxxxx` (see: [git_location.rb](https://github.com/RiotGames/berkshelf/blob/v2.0.1/lib/berkshelf/locations/git_location.rb#L61-L75))

subsequent berkshelf runs try to get the HEAD ref string by `cd ~/.berkshelf/cookbooks/foo-xxxx` and running `git rev-parse HEAD`, which fails because `foo` is not a git repo, it's a copied subdirectory out of the `chef-repo` git repo

the point that it errors out is in [git_location.rb](https://github.com/RiotGames/berkshelf/blob/v2.0.1/lib/berkshelf/locations/git_location.rb#L57) which breaks when the `git rev-parse HEAD` command is run in [git.rb](https://github.com/RiotGames/berkshelf/blob/v2.0.1/lib/berkshelf/git.rb#L63-L64)

This worked in 1.4 when validation was that the cookbook is [cached](https://github.com/RiotGames/berkshelf/blob/v1.4.5/lib/berkshelf/locations/git_location.rb#L58)