From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andre Spiegel Newsgroups: gmane.emacs.devel Subject: Rewrite of vc-user-login-name Date: Sun, 22 Jan 2006 17:19:48 +0100 Message-ID: <1137946789.5032.149.camel@localhost> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1137957799 24161 80.91.229.2 (22 Jan 2006 19:23:19 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 22 Jan 2006 19:23:19 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jan 22 20:23:18 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1F0knn-0003pv-VL for ged-emacs-devel@m.gmane.org; Sun, 22 Jan 2006 20:23:05 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1F0kpU-0002Ey-AT for ged-emacs-devel@m.gmane.org; Sun, 22 Jan 2006 14:24:48 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1F0hzA-00004t-Pk for emacs-devel@gnu.org; Sun, 22 Jan 2006 11:22:37 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1F0hz8-0008VF-KY for emacs-devel@gnu.org; Sun, 22 Jan 2006 11:22:36 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1F0hz7-0008UQ-5p for emacs-devel@gnu.org; Sun, 22 Jan 2006 11:22:33 -0500 Original-Received: from [193.113.160.45] (helo=mail.o2.co.uk) by monty-python.gnu.org with esmtp (Exim 4.34) id 1F0i3h-0003gd-Hl for emacs-devel@gnu.org; Sun, 22 Jan 2006 11:27:17 -0500 Original-Received: from [80.185.151.124] (80.185.151.124) by mail.o2.co.uk (7.0.045) id 436B9AEF009E8188 for emacs-devel@gnu.org; Sun, 22 Jan 2006 16:19:50 +0000 Original-To: emacs-devel@gnu.org X-Mailer: Evolution 2.2.3 X-Mailman-Approved-At: Sun, 22 Jan 2006 14:04:21 -0500 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:49400 Archived-At: Here's a patch that closes a long standing issue, removing the need for Tramp to advise vc-user-login-name. I'm not quite sure how to install it, though: should I just remove the advice in tramp-vc.el? Is that guaranteed not to break anything if people simply update from CVS? (Since the argument list changed, the tramp advice no longer works with this patch.) Apart from that, if anybody sees any issues with the new code, feel free to suggest improvements. If I don't hear anything, I'll install it and simply remove the Tramp advice tomorrow. (I have already installed a related patch that makes `vc-user-login-name UID' unnecessary, hence the change in the argument list.) --- vc-hooks.el 20 Aug 2005 09:13:19 +0200 1.176 +++ vc-hooks.el 22 Jan 2006 13:51:14 +0100 @@ -410,14 +410,22 @@ (vc-file-setprop file 'vc-checkout-model (vc-call checkout-model file))))) -(defun vc-user-login-name (&optional uid) - "Return the name under which the user is logged in, as a string. -\(With optional argument UID, return the name of that user.) -This function does the same as function `user-login-name', but unlike -that, it never returns nil. If a UID cannot be resolved, that -UID is returned as a string." - (or (user-login-name uid) - (number-to-string (or uid (user-uid))))) +(defun vc-user-login-name (file) + "Return the name under which the user accesses the given FILE." + (or (and (eq (string-match tramp-file-name-regexp file) 0) + ;; tramp case: execute "whoami" via tramp + (let ((default-directory (file-name-directory file))) + (with-temp-buffer + (if (not (zerop (process-file "whoami" nil t))) + ;; fall through if "whoami" didn't work + nil + ;; remove trailing newline + (delete-region (1- (point-max)) (point-max)) + (buffer-string))))) + ;; normal case + (user-login-name) + ;; if user-login-name is nil, return the UID as a string + (number-to-string (user-uid)))) (defun vc-state (file) "Return the version control state of FILE.