Rewrite aborting. (R)

This commit is contained in:
Marius Vollmer 2008-09-07 22:51:42 +03:00
parent 8897b0552c
commit 8460d4db78

View file

@ -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 ()