[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] vc-git-revert: Execute commands from FILE's `vc-git-root'.
From: |
Dominique Quatravaux |
Subject: |
[PATCH] vc-git-revert: Execute commands from FILE's `vc-git-root'. |
Date: |
Fri, 7 Dec 2012 10:18:12 +0100 |
"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
- [PATCH] vc-git-revert: Execute commands from FILE's `vc-git-root'.,
Dominique Quatravaux <=