diff options
author | Gustav HÃ¥llberg <gustav@virtutech.com> | 2009-12-04 08:55:02 +0100 |
---|---|---|
committer | Karl Wiberg <kha@treskal.com> | 2009-12-04 08:55:05 +0100 |
commit | 6c2d4962aa5811c49d5ffa1fbcf4772af94df427 (patch) | |
tree | f53ae5cc2d4d6b0164b552a02a8c9b8c950c35bf | |
parent | 7f972e9b1e84a63547d97386ec3f1d0f89110e87 (diff) | |
download | stgit-6c2d4962aa5811c49d5ffa1fbcf4772af94df427.tar.gz |
stgit.el: Make stg undo/redo --hard ask for confirmation with dirty index/worktree
Signed-off-by: Gustav HÃ¥llberg <gustav@virtutech.com>
-rw-r--r-- | contrib/stgit.el | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/contrib/stgit.el b/contrib/stgit.el index 1352af2..f2fe021 100644 --- a/contrib/stgit.el +++ b/contrib/stgit.el @@ -2050,18 +2050,29 @@ deepest patch had before the squash." (interactive) (describe-function 'stgit-mode)) +(defun stgit-undo-or-redo (redo hard) + "Run stg undo or, if REDO is non-nil, stg redo. + +If HARD is non-nil, use the --hard flag." + (stgit-assert-mode) + (let ((cmd (if redo "redo" "undo"))) + (stgit-capture-output nil + (if arg + (when (or (and (stgit-index-empty-p) + (stgit-work-tree-empty-p)) + (y-or-n-p (format "Hard %s may overwrite index/work tree changes. Continue? " + cmd))) + (stgit-run cmd "--hard")) + (stgit-run cmd)))) + (stgit-reload)) + (defun stgit-undo (&optional arg) "Run stg undo. With prefix argument, run it with the --hard flag. See also `stgit-redo'." (interactive "P") - (stgit-assert-mode) - (stgit-capture-output nil - (if arg - (stgit-run "undo" "--hard") - (stgit-run "undo"))) - (stgit-reload)) + (stgit-undo-or-redo nil arg)) (defun stgit-redo (&optional arg) "Run stg redo. @@ -2069,12 +2080,7 @@ With prefix argument, run it with the --hard flag. See also `stgit-undo'." (interactive "P") - (stgit-assert-mode) - (stgit-capture-output nil - (if arg - (stgit-run "redo" "--hard") - (stgit-run "redo"))) - (stgit-reload)) + (stgit-undo-or-redo t arg)) (defun stgit-refresh (&optional arg) "Run stg refresh. |