unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Dominique Quatravaux <domq@google.com>
To: emacs-devel@gnu.org
Cc: Dominique Quatravaux <domq@google.com>, fishchman@google.com
Subject: [PATCH] vc-git-revert: Execute commands from FILE's `vc-git-root'.
Date: Fri,  7 Dec 2012 10:18:12 +0100	[thread overview]
Message-ID: <1354871892-3498-1-git-send-email-domq@google.com> (raw)

"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




             reply	other threads:[~2012-12-07  9:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-07  9:18 Dominique Quatravaux [this message]
     [not found] <1354872033-4313-1-git-send-email-domq@google.com>
     [not found] ` <1354872033-4313-2-git-send-email-domq@google.com>
2012-12-11 10:08   ` [PATCH] vc-git-revert: Execute commands from FILE's `vc-git-root' Dominique Quatravaux

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1354871892-3498-1-git-send-email-domq@google.com \
    --to=domq@google.com \
    --cc=emacs-devel@gnu.org \
    --cc=fishchman@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).