From 11d40d38c809df93956b4dbad7a3be0722d066ff Mon Sep 17 00:00:00 2001 From: Stephen Leake Date: Fri, 24 Jul 2015 11:01:16 -0500 Subject: [PATCH] Handle vc-mtn error more gently * lisp/vc/vc-mtn.el (vc-mtn-mode-line-string): return "" when branch is nil --- lisp/vc/vc-mtn.el | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/lisp/vc/vc-mtn.el b/lisp/vc/vc-mtn.el index 93bd1f6a83f..944a83ebc69 100644 --- a/lisp/vc/vc-mtn.el +++ b/lisp/vc/vc-mtn.el @@ -179,15 +179,18 @@ switches." (defun vc-mtn-mode-line-string (file) "Return a string for `vc-mode-line' to put in the mode line for FILE." (let ((branch (vc-mtn-workfile-branch file))) - (dolist (rule vc-mtn-mode-line-rewrite) - (if (string-match (car rule) branch) - (setq branch (replace-match (cdr rule) t nil branch)))) - (format "Mtn%c%s" - (pcase (vc-state file) - ((or `up-to-date `needs-update) ?-) - (`added ?@) - (_ ?:)) - branch))) + (if branch + (progn + (dolist (rule vc-mtn-mode-line-rewrite) + (if (string-match (car rule) branch) + (setq branch (replace-match (cdr rule) t nil branch)))) + (format "Mtn%c%s" + (pcase (vc-state file) + ((or `up-to-date `needs-update) ?-) + (`added ?@) + (_ ?:)) + branch)) + ""))) (defun vc-mtn-register (files &optional _comment) (vc-mtn-command nil 0 files "add")) -- 2.39.2