From 03329dbfc33ba3058401fff41c7f495dacb49190 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sun, 7 Jun 2009 21:42:20 +0300 Subject: [PATCH] Only discard staged diffs for files that don't have unstaged changes. The unstaged changes will be discarded, too, which might be unexpected. * magit.el (magit-discard-item): Here. --- magit.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/magit.el b/magit.el index b5d6fb3c..75668776 100644 --- a/magit.el +++ b/magit.el @@ -41,6 +41,8 @@ ;; - Showing tags. ;; - Visiting from staged hunks doesn't always work since the line ;; numbers don't refer to the working tree. Fix that somehow. +;; - Figure out how to discard staged changes for files that also have +;; unstaged changes. ;; - Get current defun from removed lines in a diff ;; - Amending commits other than HEAD. ;; - 'Subsetting', only looking at a subset of all files. @@ -2977,7 +2979,9 @@ Prefix arg means justify as well." ((unstaged diff) (magit-discard-diff item nil)) ((staged diff) - (magit-discard-diff item t)) + (if (magit-file-uptodate-p (magit-diff-item-file item)) + (magit-discard-diff item t) + (error "Can't discard staged changes to this file. Please unstage it first."))) ((hunk) (error "Can't discard this hunk")) ((diff)