bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#21166: 24.4; vc-mode and git error on newly added file to new reposi


From: Dmitry Gutov
Subject: bug#21166: 24.4; vc-mode and git error on newly added file to new repository
Date: Fri, 31 Jul 2015 20:44:16 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:40.0) Gecko/20100101 Thunderbird/40.0

On 07/31/2015 08:27 PM, Ed Avis wrote:
I guess you don't have to add an extra process call but just check for this 
error message, and if so, show the diff as from an empty tree.

That's a good point, but doing an extra process call depending on the result of the first is also non-trivial here, because the first call is often asynchronous, and we handle those in a not particularly composable way.

For instance, this patch doesn't work reliably:

diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 9522328..b556de1 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -1032,13 +1032,18 @@ or BRANCH^ (where \"^\" can be repeated)."
                command
                "--exit-code"
                (append (vc-switches 'git 'diff)
-                       (list "-p" (or rev1 "HEAD") rev2 "--")))
+                       (list "-p" rev1 rev2 "--")))
       (vc-git-command (or buffer "*vc-diff*") 1 files
                       "difftool" "--exit-code" "--no-prompt" "-x"
                       (concat "diff "
                               (mapconcat 'identity
                                          (vc-switches nil 'diff) " "))
-                      rev1 rev2 "--"))))
+                      rev1 rev2 "--"))
+    (vc-run-delayed
+      (when (looking-at "fatal: bad revision 'HEAD'")
+        (let ((inhibit-read-only t))
+          (erase-buffer)
+ (vc-git-diff files "4b825dc642cb6eb9a060e54bf8d69288fbee4904" rev2 buffer async))))))

 (defun vc-git-revision-table (_files)
   ;; What about `files'?!?  --Stef






reply via email to

[Prev in Thread] Current Thread [Next in Thread]