From 3b71710827bc3fbf620174e81d5c16a6389fe9b5 Mon Sep 17 00:00:00 2001
From: Emilien Kenler <ekenler@wizcorp.jp>
Date: Mon, 3 Aug 2015 17:12:47 +0900
Subject: [PATCH] ansible.utils._git_repo_info() now supports branch names with
 slashes

---
 lib/ansible/cli/__init__.py | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/lib/ansible/cli/__init__.py b/lib/ansible/cli/__init__.py
index 12ba8f8900..f3e6df0ed7 100644
--- a/lib/ansible/cli/__init__.py
+++ b/lib/ansible/cli/__init__.py
@@ -393,16 +393,20 @@ class CLI(object):
                 except (IOError, AttributeError):
                     return ''
             f = open(os.path.join(repo_path, "HEAD"))
-            branch = f.readline().split('/')[-1].rstrip("\n")
+            line = f.readline().rstrip("\n")
+            if line.startswith("ref:"):
+                branch_path = os.path.join(repo_path, line[5:])
+            else:
+                branch_path = None
             f.close()
-            branch_path = os.path.join(repo_path, "refs", "heads", branch)
-            if os.path.exists(branch_path):
+            if branch_path and os.path.exists(branch_path):
+                branch = '/'.join(line.split('/')[2:])
                 f = open(branch_path)
                 commit = f.readline()[:10]
                 f.close()
             else:
                 # detached HEAD
-                commit = branch[:10]
+                commit = line[:10]
                 branch = 'detached HEAD'
                 branch_path = os.path.join(repo_path, "HEAD")