aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndré Spiegel2006-01-25 18:54:26 +0000
committerAndré Spiegel2006-01-25 18:54:26 +0000
commit8d2b9c1aade7864678439ad107d3ef763ff3b086 (patch)
tree01b937e24baba46c8164a105abc079127e30b643
parentd1efee22033bff7c7d22d5eda93eee14e7796a8c (diff)
downloademacs-8d2b9c1aade7864678439ad107d3ef763ff3b086.tar.gz
emacs-8d2b9c1aade7864678439ad107d3ef763ff3b086.zip
(vc-user-login-name): Rewritten to handle access via Tramp.
-rw-r--r--lisp/vc-hooks.el24
1 files changed, 16 insertions, 8 deletions
diff --git a/lisp/vc-hooks.el b/lisp/vc-hooks.el
index 5872e2f1990..1c1f0844303 100644
--- a/lisp/vc-hooks.el
+++ b/lisp/vc-hooks.el
@@ -410,14 +410,22 @@ For registered files, the possible values are:
410 (vc-file-setprop file 'vc-checkout-model 410 (vc-file-setprop file 'vc-checkout-model
411 (vc-call checkout-model file))))) 411 (vc-call checkout-model file)))))
412 412
413(defun vc-user-login-name (&optional uid) 413(defun vc-user-login-name (file)
414 "Return the name under which the user is logged in, as a string. 414 "Return the name under which the user accesses the given FILE."
415\(With optional argument UID, return the name of that user.) 415 (or (and (eq (string-match tramp-file-name-regexp file) 0)
416This function does the same as function `user-login-name', but unlike 416 ;; tramp case: execute "whoami" via tramp
417that, it never returns nil. If a UID cannot be resolved, that 417 (let ((default-directory (file-name-directory file)))
418UID is returned as a string." 418 (with-temp-buffer
419 (or (user-login-name uid) 419 (if (not (zerop (process-file "whoami" nil t)))
420 (number-to-string (or uid (user-uid))))) 420 ;; fall through if "whoami" didn't work
421 nil
422 ;; remove trailing newline
423 (delete-region (1- (point-max)) (point-max))
424 (buffer-string)))))
425 ;; normal case
426 (user-login-name)
427 ;; if user-login-name is nil, return the UID as a string
428 (number-to-string (user-uid))))
421 429
422(defun vc-state (file) 430(defun vc-state (file)
423 "Return the version control state of FILE. 431 "Return the version control state of FILE.