git.el: Avoid a lisp error when there's no current branch (detached HEAD).
[gitweb.git] / contrib / emacs / git.el
index be44e06c452818651d57f07ebb1288e62680794f..abc799a28714652075501f12e18ff44e90a5f023 100644 (file)
@@ -664,9 +664,11 @@ Return the list of files that haven't been handled."
     (ewoc-set-hf status
                  (format "Directory:  %s\nBranch:     %s\nHead:       %s%s\n"
                          default-directory
-                         (if (string-match "^refs/heads/" branch)
-                             (substring branch (match-end 0))
-                           branch)
+                         (if branch
+                             (if (string-match "^refs/heads/" branch)
+                                 (substring branch (match-end 0))
+                               branch)
+                           "none (detached HEAD)")
                          head
                          (if merge-heads
                              (concat "\nMerging:    "