aboutsummaryrefslogtreecommitdiff
path: root/lisp/magit-git.el
diff options
context:
space:
mode:
authorJonas Bernoulli <jonas@bernoul.li>2025-08-22 20:55:39 +0200
committerJonas Bernoulli <jonas@bernoul.li>2025-08-22 20:55:39 +0200
commit67a662022eb5e00ad0c281255c308ab5fce28985 (patch)
treedaaaf79911f4e18e8b9f1effa4f13d483db99a6f /lisp/magit-git.el
parent1c48327a067c41f78f35cc65bdbf3067f1d3d25d (diff)
Avoid t condition in final match-all cond clause
If there is a single BODY form in the final clause, we can just use that as the CONDITION instead (because the value of that is returned if the BODY is empty). I've been gravitating towards that style for a long time, but because I realize that this is not without issue and that there are certainly those that would find this practice questionable, I refrained from updating existing code until now. The main problem with dropping the `t' is that it is not always immediately obvious if one is looking at (cond ... ((foo bar))) or (cond ... ((foo) (bar))) That's why I still use `t' when the single BODY form is too long and/or complex, despite fitting on one line. In this case from `magit-log-move-to-revision', for example, I was on the fence: (cond ... ((apply #'magit-log-all-branches (magit-log-arguments)))) (It's worth noting that the same issue also occurs when reading non-final-catch-all clauses.) On the other hand, the single BODY form can also be complex *enough* to allow using it as the CONDITION, without that being hard to parse. E.g., when it spans multiple lines, and indentation keeps increasing, and/or when BODY is a `let' from or similar. Used like this, `cond' becomes more similar to `or' in certain situations, but even then they still behave differently, consider: (or (and CONDITION maybe-nil) ...) vs (cond (CONDITION maybe-nil) ...)
Diffstat (limited to 'lisp/magit-git.el')
-rw-r--r--lisp/magit-git.el5
1 files changed, 2 insertions, 3 deletions
diff --git a/lisp/magit-git.el b/lisp/magit-git.el
index b35431b..10296b5 100644
--- a/lisp/magit-git.el
+++ b/lisp/magit-git.el
@@ -697,7 +697,7 @@ values of `magit-remote-git-executable' and `exec-path'.\n"))
((save-match-data
(and (string-match magit--git-version-regexp output)
(match-str 1 output))))
- (t output)))))
+ (output)))))
(defun magit-debug-git-executable ()
"Display a buffer with information about `magit-git-executable'.
@@ -2424,8 +2424,7 @@ and this option only controls what face is used.")
(magit--propertize-face
name '(magit-branch-upstream
magit-branch-local)))))
- (t
- (push (concat push name) combined)))))
+ ((push (concat push name) combined)))))
(cond-let
((or upstream (not target)))
((member target remotes)