Subject: 25.0.50; vc.el with RCS: `vc-master-name' returns nil where it shouldn't

From: Simon Leinen <[email-masked]>
Date: Wed, 26 Nov 2014 18:50:16 +0100

When I start ./src/emacs -Q freshly compiled from the Git source (with
the vc-filewise autoload patches included in my last report) and try to
open a file under RCS, I get an error

  Wrong type argument: stringp, nil

with a backtrace such as this:

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  file-exists-p(nil)
  vc-insert-file(nil "^[0-9]")
  vc-rcs-fetch-master-state("/Users/leinen/public_html/private/log.html" nil)
  vc-rcs-state("/Users/leinen/public_html/private/log.html")
  vc-rcs-state-heuristic("/Users/leinen/public_html/private/log.html")
  apply(vc-rcs-state-heuristic "/Users/leinen/public_html/private/log.html")
  vc-call-backend(RCS state-heuristic "/Users/leinen/public_html/private/log.html")
  vc-state-refresh("/Users/leinen/public_html/private/log.html" RCS)
  vc-state("/Users/leinen/public_html/private/log.html" RCS)
  vc-default-mode-line-string(RCS "/Users/leinen/public_html/private/log.html")
  apply(vc-default-mode-line-string RCS "/Users/leinen/public_html/private/log.html")
  vc-call-backend(RCS mode-line-string "/Users/leinen/public_html/private/log.html")
  vc-mode-line("/Users/leinen/public_html/private/log.html" RCS)
  vc-find-file-hook()
  run-hooks(find-file-hook)
  after-find-file(nil t)
  find-file-noselect-1(#<buffer log.html> "~/public_html/private/log.html" nil nil "~/www/html/misc/leinen/private/log.html" (18988536 16777220))
  find-file-noselect("~/public_html/private/log.html" nil nil t)
  find-file("~/public_html/private/log.html" t)

`vc-rcs-fetch-master-state' uses `vc-master-name' (in vc-filewise.el) to
find the master filename for the visited file.

`vc-master-name' calls the 'registered method for the file's backend
(the symbol `RCS' in this case), which is successful, and then returns
the file's `vc-name' property.  But that property isn't set anywhere.

I found that the function `vc-filewise-registered' also claims to check
whether a file is registered, and it sets the `vc-name' property on the
file.  So that looks more suitable to use.  It also does other things
that I don't quite understand.  Anyway, the following patch prevents the
error for me, and lets me edit and check in/out RCS-managed files again.
-- 
Simon.

diff --git a/lisp/vc/vc-filewise.el b/lisp/vc/vc-filewise.el
index bc8a8de..4a05c98 100644
--- a/lisp/vc/vc-filewise.el
+++ b/lisp/vc/vc-filewise.el
@@ -41,7 +41,7 @@ If the file is not registered, or the master name is not known, return nil."
       ;; vc-BACKEND-registered explicitly
       (let ((backend (vc-backend file)))
 	(if (and backend
-		 (vc-call-backend backend 'registered file))
+		 (vc-filewise-registered backend file))
 	    (vc-file-getprop file 'vc-name)))))
 
 (defun vc-rename-master (oldmaster newfile templates)