diff options
author | Dmitry Gutov <dgutov@yandex.ru> | 2015-11-26 17:15:28 +0200 |
---|---|---|
committer | Dmitry Gutov <dgutov@yandex.ru> | 2015-11-26 17:15:43 +0200 |
commit | 02cd9cb8afd9510e3bdb20ce7148d1b9a6aa9d12 (patch) | |
tree | 7372f67964e4be0caebf6f825ea365f4072176ce /lisp/vc/vc-dispatcher.el | |
parent | 5d93a89e805baa2f29941fd801e48235f6c1a6b6 (diff) | |
download | emacs-02cd9cb8afd9510e3bdb20ce7148d1b9a6aa9d12.tar.gz |
Check if the file exists on disk before producing the revert diff
* lisp/vc/vc-dispatcher.el (vc-buffer-sync): Check if the file
exists on disk (bug#20558).
Diffstat (limited to 'lisp/vc/vc-dispatcher.el')
-rw-r--r-- | lisp/vc/vc-dispatcher.el | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/lisp/vc/vc-dispatcher.el b/lisp/vc/vc-dispatcher.el index ec55867fcfe..b8593e30a54 100644 --- a/lisp/vc/vc-dispatcher.el +++ b/lisp/vc/vc-dispatcher.el @@ -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 |