]> git.eshelyaron.com Git - emacs.git/commitdiff
Check if the file exists on disk before producing the revert diff
authorDmitry Gutov <dgutov@yandex.ru>
Thu, 26 Nov 2015 15:15:28 +0000 (17:15 +0200)
committerDmitry Gutov <dgutov@yandex.ru>
Thu, 26 Nov 2015 15:15:43 +0000 (17:15 +0200)
* lisp/vc/vc-dispatcher.el (vc-buffer-sync): Check if the file
exists on disk (bug#20558).

lisp/vc/vc-dispatcher.el

index ec55867fcfe0ad007c294dfcb623d6089cb16a2d..b8593e30a5471c915dee2d00fe0ed4239107f014 100644 (file)
@@ -580,12 +580,20 @@ editing!"
 (defun vc-buffer-sync (&optional not-urgent)
   "Make sure the current buffer and its working file are in sync.
 NOT-URGENT means it is ok to continue if the user says not to save."
-  (when (buffer-modified-p)
-    (if (or vc-suppress-confirm
-           (y-or-n-p (format "Buffer %s modified; save it? " (buffer-name))))
-       (save-buffer)
-      (unless not-urgent
-       (error "Aborted")))))
+  (let (missing)
+    (when (cond
+           ((buffer-modified-p))
+           ((not (file-exists-p buffer-file-name))
+            (setq missing t)))
+      (if (or vc-suppress-confirm
+              (y-or-n-p (format "Buffer %s %s; save it? "
+                                (buffer-name)
+                                (if missing
+                                    "is missing on disk"
+                                  "modified"))))
+          (save-buffer)
+        (unless not-urgent
+          (error "Aborted"))))))
 
 ;; Command closures