summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Vilain <sam@vilain.net>2007-01-25 23:41:23 (GMT)
committerJunio C Hamano <junkio@cox.net>2007-01-26 03:27:03 (GMT)
commitfd73423f01361f112dbb9972ebce8eabae7dd8b1 (patch)
treed66483ddef4180312f4e6cd02512487600c17a32
parent1b555932cdb7f75239623573cd2ff25fa98ab4e4 (diff)
downloadgit-fd73423f01361f112dbb9972ebce8eabae7dd8b1.zip
git-fd73423f01361f112dbb9972ebce8eabae7dd8b1.tar.gz
git-fd73423f01361f112dbb9972ebce8eabae7dd8b1.tar.bz2
contrib/emacs/vc-git.el: support vc-version-other-window
Currently, the vc-git-checkout function uses `git checkout' to fetch a file from the git repository to the working copy. However, it is completely ignoring the input argument that specifies the destination file. `git-checkout' does not support specifying this, so we have to use `git-cat-file', capture the output in a buffer and then save it. Signed-off-by: Junio C Hamano <junkio@cox.net>
-rw-r--r--contrib/emacs/vc-git.el27
1 files changed, 26 insertions, 1 deletions
diff --git a/contrib/emacs/vc-git.el b/contrib/emacs/vc-git.el
index 3eb4bd1..65c4550 100644
--- a/contrib/emacs/vc-git.el
+++ b/contrib/emacs/vc-git.el
@@ -53,6 +53,10 @@
(let ((name (file-relative-name file)))
(eq 0 (apply #'call-process "git" nil (get-buffer "*Messages") nil (append args (list name))))))
+(defun vc-git--run-command-out (output &rest args)
+ "Run a git command, output to output."
+ (eq 0 (apply #'call-process "git" nil output nil (append args))))
+
(defun vc-git-registered (file)
"Check whether FILE is registered with git."
(with-temp-buffer
@@ -120,7 +124,28 @@
(vc-git--run-command file "commit" "-m" comment "--only" "--")))
(defun vc-git-checkout (file &optional editable rev destfile)
- (vc-git--run-command file "checkout" (or rev "HEAD")))
+ (if destfile
+ (let ((mybuff (get-buffer-create "vc-git-checkout-tmp")))
+ (let ((rv
+ (vc-git--run-command-out
+ mybuff "cat-file" "blob"
+ (concat (or rev "HEAD")
+ ":"
+ (let ((output (vc-git--run-command-string
+ (file-relative-name file)
+ "ls-files" "--full-name")))
+ (string-match "\\(.*\\)" output)
+ (match-string 1 output))
+ )))
+ )
+ (if rv
+ (save-current-buffer
+ (set-buffer mybuff)
+ (set-visited-file-name destfile t)
+ (save-buffer)
+ )
+ rv)))
+ (vc-git--run-command file "checkout" (or rev "HEAD"))))
(defun vc-git-annotate-command (file buf &optional rev)
; FIXME: rev is ignored