summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2020-04-16 23:28:42 -0400
committerKyle Meyer <kyle@kyleam.com>2020-04-16 23:54:15 -0400
commitb708f92f3e7e498aff8f57fc97d0d38606e9c822 (patch)
tree974d6b3078e13473f026c4c2450e1306d58cbe11
parente2a3dc40dc5bb408ab0f311ee4927d8dda433b71 (diff)
downloademacs.d-b708f92f3e7e498aff8f57fc97d0d38606e9c822.tar.gz
km/magit-branch-backup-current: Allow non-interactive suffix arg
This will make it easier to create commands for common ones.
-rw-r--r--lisp/km-magit.el25
1 files changed, 12 insertions, 13 deletions
diff --git a/lisp/km-magit.el b/lisp/km-magit.el
index 0cfbf2c..7f339cd 100644
--- a/lisp/km-magit.el
+++ b/lisp/km-magit.el
@@ -220,25 +220,24 @@ START-POINT set to the current branch.
(error "bug: version re should always match"))))
(km/magit-branch-get-set branch suffix)))))
-(defun km/magit-branch-backup-current (&optional choose-suffix)
+(defun km/magit-branch-backup-current (&optional suffix)
"Create a backup branch for the current branch.
Name it as '<current-branch>__v<n>', where <n> is incremented
to form a refname that doesn't already exist. With the prefix
-argument CHOOSE-SUFFIX, prompt for a suffix to use instead of
+argument SUFFIX, prompt for a suffix to use instead of
'v'."
- (interactive "P")
- (let ((current (or (magit-get-current-branch)
- (user-error "No current branch"))))
+ (interactive (list (and current-prefix-arg
+ (magit-read-string-ns "Backup suffix"))))
+ (setq suffix (or suffix "v"))
+ (let* ((current (or (magit-get-current-branch)
+ (user-error "No current branch")))
+ (versions (km/magit-branch--get-versions current suffix)))
(magit-run-git
"branch" "--copy"
- (let* ((suffix (if choose-suffix
- (magit-read-string-ns "Backup suffix")
- "v"))
- (versions (km/magit-branch--get-versions current suffix)))
- (format "%s__%s%d"
- current
- suffix
- (if (null versions) 1 (1+ (apply #'max versions))))))))
+ (format "%s__%s%d"
+ current
+ suffix
+ (if (null versions) 1 (1+ (apply #'max versions)))))))
(defun km/magit-branch-archive (branches)
"Move BRANCHES from refs/heads/ to refs/archive/."