{"thread":{"id":"6544","subject":"Re: [PATCH] contrib/emacs/vc-git.el: support vc-version-other-window","startedAt":"2007-01-26T10:57:50Z","lastAt":"2007-01-26T10:57:50Z","messageCount":1,"participants":["Alexandre Julliard"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"32718","messageId":"87y7nqukb5.fsf@wine.dyndns.org","threadId":"6544","inReplyTo":"20070125234352.340DACB9F4@localhost.localdomain","subject":"Re: [PATCH] contrib/emacs/vc-git.el: support vc-version-other-window","fromName":"Alexandre Julliard","fromEmail":"julliard@winehq.org","sentAt":"2007-01-26T10:57:50Z","receivedAt":"2007-01-26T10:57:50Z","isPatch":true,"sender":{"key":"julliard@winehq.org","avatar":null},"body":"Sam Vilain <sam.vilain@catalyst.net.nz> writes:\n\n> Currently, the vc-git-checkout function uses `git checkout' to fetch a\n> file from the git repository to the working copy.  However, it is\n> completely ignoring the input argument that specifies the destination\n> file.  `git-checkout' does not support specifying this, so we have to\n> use `git-cat-file', capture the output in a buffer and then save it.\n\nThis looks good, though the code can be made simpler by using\nwith-temp-file to create the file. Also you need to avoid charset\nconversions when reading and writing, and you should use ls-files -z\nto avoid problems with strange file names.\n\nI'd suggest something like this:\n\n\n>From b37cff5399dd94abe3d4e9778cdbf5cee53d46c0 Mon Sep 17 00:00:00 2001\nFrom: Alexandre Julliard <julliard@winehq.org>\nDate: Fri, 26 Jan 2007 11:39:55 +0100\nSubject: [PATCH] vc-git.el: Take into account the destination name in vc-checkout.\n\nThis is necessary for vc-version-other-window. Based on a patch by Sam\nVilain <sam.vilain@catalyst.net.nz>.\n\nSigned-off-by: Alexandre Julliard <julliard@winehq.org>\n---\n contrib/emacs/vc-git.el |   11 ++++++++++-\n 1 files changed, 10 insertions(+), 1 deletions(-)\n\ndiff --git a/contrib/emacs/vc-git.el b/contrib/emacs/vc-git.el\nindex 3eb4bd1..e456ab9 100644\n--- a/contrib/emacs/vc-git.el\n+++ b/contrib/emacs/vc-git.el\n@@ -120,7 +120,16 @@\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 ((fullname (substring\n+                       (vc-git--run-command-string file \"ls-files\" \"-z\" \"--full-name\" \"--\")\n+                       0 -1))\n+            (coding-system-for-read 'no-conversion)\n+            (coding-system-for-write 'no-conversion))\n+        (with-temp-file destfile\n+          (eq 0 (call-process \"git\" nil t nil \"cat-file\" \"blob\"\n+                              (concat (or rev \"HEAD\") \":\" fullname)))))\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.5.0.rc2.gc651\n\n\n\n-- \nAlexandre Julliard\njulliard@winehq.org\n"}]}