From 8460d4db78fcaa2bf8c08407de355954611ccb15 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sun, 7 Sep 2008 22:51:42 +0300 Subject: [PATCH] Rewrite aborting. (R) --- magit.el | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/magit.el b/magit.el index ba57df8a..286c2c8e 100644 --- a/magit.el +++ b/magit.el @@ -273,11 +273,15 @@ Many Magit faces inherit from this one by default." (magit-commit-at-point t)) (defun magit-file-uptodate-p (file) - (eq (magit-shell-exit-code "git diff --quiet %s" file) 0)) + (eq (magit-shell-exit-code "git diff --quiet -- %s" file) 0)) (defun magit-anything-staged-p () (not (eq (magit-shell-exit-code "git diff --quiet --cached") 0))) +(defun magit-everything-clean-p () + (and (not (magit-anything-staged-p)) + (eq (magit-shell-exit-code "git diff --quiet") 0))) + ;;; Sections ;; A buffer in magit-mode isorganized into hierarchical sections. @@ -1286,6 +1290,18 @@ Please see the manual for a complete description of Magit. "\n")))) (insert "\n")))) +(defun magit-rewrite-abort () + (interactive) + (let* ((info (magit-read-rewrite-info)) + (orig (cadr (assq 'orig info)))) + (or info + (error "No rewrite in progress.")) + (or (magit-everything-clean-p) + (error "You have uncommitted changes. Abort aborted.")) + (when (yes-or-no-p "Abort rewrite? ") + (magit-write-rewrite-info nil) + (magit-run "git" "reset" "--hard" orig)))) + ;;; Updating, pull, and push (defun magit-remote-update ()