emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/git-commit 3eef7a886c 2/2: Increase consistency among sequ


From: ELPA Syncer
Subject: [nongnu] elpa/git-commit 3eef7a886c 2/2: Increase consistency among sequencer continuation commands
Date: Mon, 20 Nov 2023 12:59:50 -0500 (EST)

branch: elpa/git-commit
commit 3eef7a886cd2269f2135c7a50817fb9f8f44f0ad
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>

    Increase consistency among sequencer continuation commands
    
    If there is only one potential user-error, signal that inside
    an `unless' form, but if there are three branches, use `cond'.
    No more nested `if's and errors that are signaled by the ELSE
    part.
---
 lisp/magit-sequence.el | 44 +++++++++++++++++++++++---------------------
 1 file changed, 23 insertions(+), 21 deletions(-)

diff --git a/lisp/magit-sequence.el b/lisp/magit-sequence.el
index 40d6ee9828..bda3910567 100644
--- a/lisp/magit-sequence.el
+++ b/lisp/magit-sequence.el
@@ -91,21 +91,22 @@
 (defun magit-sequencer-continue ()
   "Resume the current cherry-pick or revert sequence."
   (interactive)
-  (if (magit-sequencer-in-progress-p)
-      (if (magit-anything-unmerged-p)
-          (user-error "Cannot continue due to unresolved conflicts")
-        (magit-run-git-sequencer
-         (if (magit-revert-in-progress-p) "revert" "cherry-pick") 
"--continue"))
-    (user-error "No cherry-pick or revert in progress")))
+  (cond
+   ((not (magit-sequencer-in-progress-p))
+    (user-error "No cherry-pick or revert in progress"))
+   ((magit-anything-unmerged-p)
+    (user-error "Cannot continue due to unresolved conflicts"))
+   ((magit-run-git-sequencer
+     (if (magit-revert-in-progress-p) "revert" "cherry-pick") "--continue"))))
 
 ;;;###autoload
 (defun magit-sequencer-skip ()
   "Skip the stopped at commit during a cherry-pick or revert sequence."
   (interactive)
-  (if (magit-sequencer-in-progress-p)
-      (progn (magit-call-git "reset" "--hard")
-             (magit-sequencer-continue))
-    (user-error "No cherry-pick or revert in progress")))
+  (unless (magit-sequencer-in-progress-p)
+    (user-error "No cherry-pick or revert in progress"))
+  (magit-call-git "reset" "--hard")
+  (magit-sequencer-continue))
 
 ;;;###autoload
 (defun magit-sequencer-abort ()
@@ -489,28 +490,29 @@ without prompting."
 (defun magit-am-continue ()
   "Resume the current patch applying sequence."
   (interactive)
-  (if (magit-am-in-progress-p)
-      (if (magit-anything-unstaged-p t)
-          (user-error "Cannot continue due to unstaged changes")
-        (magit-run-git-sequencer "am" "--continue"))
-    (user-error "Not applying any patches")))
+  (cond
+   ((not (magit-am-in-progress-p))
+    (user-error "Not applying any patches"))
+   ((magit-anything-unstaged-p t)
+    (user-error "Cannot continue due to unstaged changes"))
+   ((magit-run-git-sequencer "am" "--continue"))))
 
 ;;;###autoload
 (defun magit-am-skip ()
   "Skip the stopped at patch during a patch applying sequence."
   (interactive)
-  (if (magit-am-in-progress-p)
-      (magit-run-git-sequencer "am" "--skip")
-    (user-error "Not applying any patches")))
+  (unless (magit-am-in-progress-p)
+    (user-error "Not applying any patches"))
+  (magit-run-git-sequencer "am" "--skip"))
 
 ;;;###autoload
 (defun magit-am-abort ()
   "Abort the current patch applying sequence.
 This discards all changes made since the sequence started."
   (interactive)
-  (if (magit-am-in-progress-p)
-      (magit-run-git "am" "--abort")
-    (user-error "Not applying any patches")))
+  (unless (magit-am-in-progress-p)
+    (user-error "Not applying any patches"))
+  (magit-run-git "am" "--abort"))
 
 (defun magit-am-in-progress-p ()
   (file-exists-p (expand-file-name "rebase-apply/applying" (magit-gitdir))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]