progrium/gitreceive — pull request #18 by philippbosch (2013-10-25 06:42:08+00:00)
Title: Fix issue with single quotes surrounding repo name

The changes in fe6f338 lead to an issue where the repo name would end up being surrounded by single quotes (e.g. `'reponame.git'`) and thus causing errors like this when pushing:

```
$ git push remote master
fatal: 'reponame.git' does not appear to be a git repository
fatal: Could not read from remote repository.
```

The cause for the issue is that – at least in my setup – `SSH_ORIGINAL_COMMAND` is set to `git-receive-pack 'reponame.git'` .

The proposed fix aims to do two things:

1. **The perl bit**: replace all single quotes that are not preceded by a backslash (`\`). The reasoning behind this is that if the actual repo name contains a single quote (e.g. `foo'bar`) the `SSH_ORIGINAL_COMMAND` looks like `git-receive-pack 'foo'\''bar'`.

2. **The sed bit**: if the actual repo name contained a single quote (e.g. `foo'bar`) the `RECEIVE_REPO` would end up as `foo\'bar`. So we unescape all escaped single quotes.

Tested successfully with the following repo names:

- `foo`
- `foo'bar`
- `foo'bar'baz`
- `foo'bar\baz`

More details in #16.

Fixes parts of the problem described in [#261](https://github.com/progrium/dokku/issues/261#issuecomment-27046939).