{"thread":{"id":"6536","subject":"[PATCH] contrib/emacs/vc-git.el: support vc-version-other-window","startedAt":"2007-01-25T23:41:23Z","lastAt":"2007-01-25T23:41:23Z","messageCount":1,"participants":["Sam Vilain"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"32672","messageId":"20060126.manual2@vilain.net","threadId":"6536","inReplyTo":null,"subject":"[PATCH] contrib/emacs/vc-git.el: support vc-version-other-window","fromName":"Sam Vilain","fromEmail":"sam@vilain.net","sentAt":"2007-01-25T23:41:23Z","receivedAt":"2007-01-25T23:41:23Z","isPatch":true,"sender":{"key":"sam@vilain.net","avatar":"https://gravatar.com/avatar/8fc840ca854dbf6f7065b4335e3b934951c1dca3b11db688e95e471901f8f4a8?d=mp&s=160"},"body":"Currently, the vc-git-checkout function uses `git checkout' to fetch a\nfile from the git repository to the working copy.  However, it is\ncompletely ignoring the input argument that specifies the destination\nfile.  `git-checkout' does not support specifying this, so we have to\nuse `git-cat-file', capture the output in a buffer and then save it.\n---\n contrib/emacs/vc-git.el |   27 ++++++++++++++++++++++++++-\n 1 files changed, 26 insertions(+), 1 deletions(-)\n\n(this is a second re-send, the original patch got dropped, probably\nbecause it had an unsubscribed sender) \n\ndiff --git a/contrib/emacs/vc-git.el b/contrib/emacs/vc-git.el\nindex 8b63619..35a0e76 100644\n--- a/contrib/emacs/vc-git.el\n+++ b/contrib/emacs/vc-git.el\n@@ -53,6 +53,10 @@\n   (let ((name (file-relative-name file)))\n     (eq 0 (apply #'call-process \"git\" nil (get-buffer \"*Messages\") nil (append args (list name))))))\n \n+(defun vc-git--run-command-out (output &rest args)\n+  \"Run a git command, output to output.\"\n+  (eq 0 (apply #'call-process \"git\" nil output nil (append args))))\n+\n (defun vc-git-registered (file)\n   \"Check whether FILE is registered with git.\"\n   (with-temp-buffer\n@@ -119,7 +123,28 @@\n     (vc-git--run-command file \"commit\" \"-m\" comment \"--only\" \"--\")))\n \n (defun vc-git-checkout (file &optional editable rev destfile)\n-  (vc-git--run-command file \"checkout\" (or rev \"HEAD\")))\n+  (if destfile\n+      (let ((mybuff (get-buffer-create \"vc-git-checkout-tmp\")))\n+\t(let ((rv\n+\t       (vc-git--run-command-out\n+\t\tmybuff \"cat-file\" \"blob\"\n+\t\t(concat (or rev \"HEAD\")\n+\t\t\t\":\"\n+\t\t\t(let ((output (vc-git--run-command-string\n+\t\t\t\t       (file-relative-name file)\n+\t\t\t\t       \"ls-files\" \"--full-name\")))\n+\t\t\t  (string-match \"\\\\(.*\\\\)\" output)\n+\t\t\t  (match-string 1 output))\n+\t\t\t)))\n+\t      )\n+\t  (if rv\n+\t      (save-current-buffer\n+\t\t(set-buffer mybuff)\n+\t\t(set-visited-file-name destfile t)\n+\t\t(save-buffer)\n+\t\t)\n+\t    rv)))\n+    (vc-git--run-command file \"checkout\" (or rev \"HEAD\"))))\n \n (defun vc-git-annotate-command (file buf &optional rev)\n   ; FIXME: rev is ignored\n-- \n1.4.4.1.g6a1a-dirty\n"}]}