willis: update regex to handle new git branch output

Newer git has changed the `git branch` output format to include "detached
from XXX".  Update willis to deal with it.

BUG=None
TEST=`willis` outside of chroot no longer shows uninteresting repos

Change-Id: I90e65dba9f69ec0202ef48244336c750d7c2240a
Reviewed-on: https://gerrit.chromium.org/gerrit/58265
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Tested-by: Bill Richardson <wfrichar@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
diff --git a/host/willis b/host/willis
index ab8f8e2..a785fc6 100755
--- a/host/willis
+++ b/host/willis
@@ -163,14 +163,19 @@
     # Let's get the detached HEAD branch sha1. The branch's string looks as
     # follows:
     #
+    # For versions older than git 1.8.x:
     # `* (no branch) <sha_1> <description>'
+    # Newer versions look like:
+    # `* (detached from <sha_1>) <sha_1> <description>'
     #
     # The asterisk could be not there, the '(no branch)' substring could be
     # enveloped in the color enable/disable escape sequences with spaces
     # potentially before and after the escape sequence.
-    m = re.search('\*? +[^ ]*\(no branch\) *(?:\x1b..)? *([^ ]+) ', branch)
+    m = re.search(
+        '\*? +[^ ]*\((no branch|detached from [^)]*)\) *(?:\x1b..)? *([^ ]+) ',
+        branch)
     if m:
-      branch_sha1 = m.groups(0)[0]
+      branch_sha1 = m.groups(0)[1]
       # Does detached HEAD match the tracking branch?
       detached_head_match = tracking_sha1.startswith(branch_sha1)
       if detached_head_match and len(branches) == 1: