From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dominique Quatravaux Newsgroups: gmane.emacs.devel Subject: [PATCH] vc-git-revert: Execute commands from FILE's `vc-git-root'. Date: Fri, 7 Dec 2012 10:18:12 +0100 Message-ID: <1354871892-3498-1-git-send-email-domq@google.com> NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1354894032 32695 80.91.229.3 (7 Dec 2012 15:27:12 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 7 Dec 2012 15:27:12 +0000 (UTC) Cc: Dominique Quatravaux , fishchman@google.com To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Dec 07 16:27:24 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Tgzpa-00018T-C4 for ged-emacs-devel@m.gmane.org; Fri, 07 Dec 2012 16:27:14 +0100 Original-Received: from localhost ([::1]:50260 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TgzpO-0000QH-21 for ged-emacs-devel@m.gmane.org; Fri, 07 Dec 2012 10:27:02 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:40009) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tgu4e-0000Qb-7J for emacs-devel@gnu.org; Fri, 07 Dec 2012 04:18:32 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tgu4b-0000Th-QE for emacs-devel@gnu.org; Fri, 07 Dec 2012 04:18:24 -0500 Original-Received: from mail-gh0-f201.google.com ([209.85.160.201]:48013) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tgu4b-0000Tb-J3 for emacs-devel@gnu.org; Fri, 07 Dec 2012 04:18:21 -0500 Original-Received: by mail-gh0-f201.google.com with SMTP id z19so21054ghb.0 for ; Fri, 07 Dec 2012 01:18:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=+V+2DBxRY9WYWMYoxco1OyvO6z23RlqGfqJ4EgSFEGE=; b=VhqGX7CrWyJALQTj6eRqKJz1K9z2pnKHZTNplmJjJdEEwmoxW/tvfftGO2rnxEJHGR mZ8By0GvrpZMG6h1TOoFon/Hob9+fnUjWgT3xODgz0D9zU8HiDn3qDWoGED6w4vdCOa8 TgDcjps6tbT54ulxHqDgZ/yiw6U22uCw/hFef0SzxWz3HOyIcoN67pb+WlDy4CFr/CV/ 8qXeiKREHvPr8Lmw2iF4rAK8t0EM/kxicdtyUsVUa+lZlVe2ju7DBGvO8NZZf9eyZtF1 fURYO3ax98K7JutWgdOUpTA8/D1W0XcfwMBksuDNeAIxqLB0Eud7HENypPm/fERoUOQ0 obiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=+V+2DBxRY9WYWMYoxco1OyvO6z23RlqGfqJ4EgSFEGE=; b=ICi3TEOpTKhM19ywpvurQSx2kgLnT83/zKFZfM+imQrgdUnPwWSN5Llw8J8r4Bs0GF OmkXwRWp+ke3qM3+Pjw4eS8+VqAQ3+qDorBgb44P40Qiu1EuUa77Kwrl6JO7+D2f8ULD 4AL5rP9ANAtfwTrnl+y7OqMGmouqpByJMkdAvUpXqc3/hZmiG20sDGUusRTcHgcNJb0X UVPwL1ih9PC+jYGuP2r8HBZaP1Hi5nfmcYt0kq8MnFfnaEL0TW7A0He9+9CiM3Dmyvqq 85aG03/kUknUXyhoe5rlVVIO9s4hNI/sXiioMmpSdDtY5DQimdOprtTTeSOmB3ZOeGkq F1iA== Original-Received: by 10.236.83.235 with SMTP id q71mr3215574yhe.5.1354871900446; Fri, 07 Dec 2012 01:18:20 -0800 (PST) Original-Received: from wpzn3.hot.corp.google.com (216-239-44-65.google.com [216.239.44.65]) by gmr-mx.google.com with ESMTPS id r6si919230yhc.7.2012.12.07.01.18.20 (version=TLSv1/SSLv3 cipher=AES128-SHA); Fri, 07 Dec 2012 01:18:20 -0800 (PST) Original-Received: from alliance-maui.zrh.corp.google.com (alliance-maui.zrh.corp.google.com [172.28.204.12]) by wpzn3.hot.corp.google.com (Postfix) with ESMTP id 259EE100047; Fri, 7 Dec 2012 01:18:20 -0800 (PST) Original-Received: by alliance-maui.zrh.corp.google.com (Postfix, from userid 71297) id 83D611E0322; Fri, 7 Dec 2012 10:18:19 +0100 (CET) X-Mailer: git-send-email 1.7.7.3 X-Gm-Message-State: ALoCoQn/jSZsHtCOtMD2OYVvZdhYRJhdVk8+fxygxsaWL3umKFlI9zkkivcztfre9d2DFPA/+KeSee3YjCvRDXoZxEPfnrqMh6V2zcqeZFz5UMsZ3TKQqMm++Twga1cqWaC3X7SgTJZ68WZwePd51Go60abt5/TBvyjnYFuZBoEhC+CzMLk6OTebqMjIGb0NfmsR2O6bpomUEDMMwF5286ywpIHhl3/DVw== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.160.201 X-Mailman-Approved-At: Fri, 07 Dec 2012 10:27:01 -0500 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:155337 Archived-At: "git checkout -q --" only works from a directory that is in the same Git repository as the target file. `vc-git-command' runs the command from buffer *vc*, in which the `default-directory' may be unsuitable depending on the circumstances in which *vc* was created. --- lisp/vc/vc-git.el | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 08b48fa..5683cab 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -677,10 +677,12 @@ It is based on `log-edit-mode', and has Git-specific extensions.") (defun vc-git-revert (file &optional contents-done) "Revert FILE to the version stored in the git repository." - (if contents-done - (vc-git-command nil 0 file "update-index" "--") - (vc-git-command nil 0 file "reset" "-q" "--") - (vc-git-command nil nil file "checkout" "-q" "--"))) + (with-temp-buffer + (cd (vc-git-root file)) + (if contents-done + (vc-git-command (current-buffer) 0 file "update-index" "--") + (vc-git-command (current-buffer) 0 file "reset" "-q" "--") + (vc-git-command (current-buffer) nil file "checkout" "-q" "--")))) (defvar vc-git-error-regexp-alist '(("^ \\(.+\\) |" 1 nil nil 0)) -- 1.7.7.3