diff options
author | Alexandre Julliard <julliard@winehq.org> | 2008-02-07 13:51:20 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-02-08 00:13:18 -0800 |
commit | 928323af6b761e8b1c33ce98e67c2f56fd1b7997 (patch) | |
tree | 30ef35a1510b0a33ede7cdfb2dff5489c031caf9 /contrib/emacs | |
parent | git.el: Added a command to amend a commit. (diff) | |
download | tgif-928323af6b761e8b1c33ce98e67c2f56fd1b7997.tar.xz |
git.el: Check for existing buffers on revert.
Refuse to revert a file if it is modified in an existing buffer but
not saved. On success, revert the buffers that contains the files that
have been reverted.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib/emacs')
-rw-r--r-- | contrib/emacs/git.el | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/contrib/emacs/git.el b/contrib/emacs/git.el index 5519ed107a..e1058b9a99 100644 --- a/contrib/emacs/git.el +++ b/contrib/emacs/git.el @@ -1033,11 +1033,19 @@ Return the list of files that haven't been handled." ('deleted (push (git-fileinfo->name info) modified)) ('unmerged (push (git-fileinfo->name info) modified)) ('modified (push (git-fileinfo->name info) modified)))) + ;; check if a buffer contains one of the files and isn't saved + (dolist (file (append added modified)) + (let ((buffer (get-file-buffer file))) + (when (and buffer (buffer-modified-p buffer)) + (error "Buffer %s is modified. Please kill or save modified buffers before reverting." (buffer-name buffer))))) (when added (apply #'git-call-process-env nil nil "update-index" "--force-remove" "--" added)) (when modified (apply #'git-call-process-env nil nil "checkout" "HEAD" modified)) (git-update-status-files (append added modified) 'uptodate) + (dolist (file (append added modified)) + (let ((buffer (get-file-buffer file))) + (when buffer (with-current-buffer buffer (revert-buffer t t t))))) (git-success-message "Reverted" (git-get-filenames files))))) (defun git-resolve-file () |