ansible/ansible-modules-core — pull request #441 by leroux (2014-12-03 20:33:46+00:00)
Title: Fix derivation of remote head branch. Fixes #70.

##### Issue Type:

Bugfix Pull Request

##### Ansible Version:

devel

##### Environment:

N/A

##### Summary:

`get_head_branch()` fails to correctly compute the HEAD branch if the branch name contains a slash.

##### Steps To Reproduce:

```
mkdir test-repo
cd test-repo

git init
git commit --allow-empty -m "Empty"
git checkout -b test/hello
git symbolic-ref HEAD refs/heads/test/hello

ansible all -vvvv -i "localhost," -c local -m git -a "repo=. dest=./cloned-test-repo"
```

##### Expected Results:

```
REMOTE_MODULE git repo=. dest=./cloned-test-repo
EXEC ['/bin/sh', '-c', 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1417638703.34-254701010202261 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1417638703.34-254701010202261 && echo $HOME/.ansible/tmp/ansible-tmp-1417638703.34-254701010202261']
PUT /var/folders/17/bkfps9l155v_zhlnnf_8b0040000gn/T/tmpkVCfGl TO /Users/leroux/.ansible/tmp/ansible-tmp-1417638703.34-254701010202261/git
EXEC ['/bin/sh', '-c', u'LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 /usr/bin/python /Users/leroux/.ansible/tmp/ansible-tmp-1417638703.34-254701010202261/git; rm -rf /Users/leroux/.ansible/tmp/ansible-tmp-1417638703.34-254701010202261/ >/dev/null 2>&1']
localhost | success >> {
"after": "aaaf6f9a4d02467fd05b604f25e0f52d5752ba2c",
"before": null,
"changed": true
}
```

##### Actual Results:

```
REMOTE_MODULE git repo=. dest=./cloned-test-repo
EXEC ['/bin/sh', '-c', 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1417635768.98-64434188432060 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1417635768.98-64434188432060 && echo $HOME/.ansible/tmp/ansible-tmp-1417635768.98-64434188432060']
PUT /var/folders/17/bkfps9l155v_zhlnnf_8b0040000gn/T/tmpDFLwXB TO /Users/leroux/.ansible/tmp/ansible-tmp-1417635768.98-64434188432060/git
EXEC ['/bin/sh', '-c', u'LC_CTYPE=en_US.UTF-8 LANG=en_US.UTF-8 /usr/bin/python /Users/leroux/.ansible/tmp/ansible-tmp-1417635768.98-64434188432060/git; rm -rf /Users/leroux/.ansible/tmp/ansible-tmp-1417635768.98-64434188432060/ >/dev/null 2>&1']
localhost | FAILED >> {
"failed": true,
"msg": "Failed to checkout branch hello"
}
```