From 04b55e8ea93f4016f3ff109529d8e26b367c2dfb Mon Sep 17 00:00:00 2001 From: Saba Saba Date: Thu, 9 Feb 2023 12:26:21 -0500 Subject: [PATCH] Factored out common pattern into toggle-without-config --- git-repl.cl | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/git-repl.cl b/git-repl.cl index 58b36e8..d30907e 100644 --- a/git-repl.cl +++ b/git-repl.cl @@ -48,6 +48,11 @@ ,@body (pop-config)))) +(defmacro toggle-without-config (without-config &body body) + `(if ,without-config + (without-config-do ,@body) + ,@body)) + (defun add-quotes (text) (format nil "\"~a\"" text)) @@ -194,10 +199,7 @@ (defun-public checkout (revision &key (without-config nil)) "Checks out the specified revision. If :without-config is set to T (default is NIL), stashes your configuration before the checkout and pops the stash afterwards." - (if without-config - (without-config-do - (git "checkout" revision)) - (git "checkout" revision))) + (toggle-without-config without-config (git "checkout" revision))) (defun-public reset-branch (revision &key (mode 'mixed) (without-config nil)) "Performs a reset to the specified revision. @@ -208,10 +210,7 @@ ((eq mode 'mixed) "--mixed") ((eq mode 'hard) "--hard") (t (error "Mode must be either 'soft, 'mixed, or 'hard"))))) - (if without-config - (without-config-do - (git "reset" mode-string revision)) - (git "reset" mode-string revision)))) + (toggle-without-config without-config (git "reset" mode-string revision)))) (defun-public mergetool () "Executes the mergetool configured with git" -- 2.20.1