unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: Ed Avis <eda@waniasset.com>, 21166@debbugs.gnu.org
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	[thread overview]
Message-ID: <55BBB3F0.30709@yandex.ru> (raw)
In-Reply-To: <7E039918541B4C4183BFDB8F015C743032E5C672@WCL-EXCH02.wcl.local>

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	other threads:[~2015-07-31 17:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-31 14:43 bug#21166: 24.4; vc-mode and git error on newly added file to new repository Ed Avis
2015-07-31 17:25 ` Dmitry Gutov
2015-07-31 17:27   ` Ed Avis
2015-07-31 17:44     ` Dmitry Gutov [this message]
2015-08-04 14:58       ` Ed Avis
2020-08-25  9:04         ` Lars Ingebrigtsen
2020-10-11  3:07           ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55BBB3F0.30709@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=21166@debbugs.gnu.org \
    --cc=eda@waniasset.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).