summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lisp/init-git.el13
1 files changed, 13 insertions, 0 deletions
diff --git a/lisp/init-git.el b/lisp/init-git.el
index 69dc888..c9bd73c 100644
--- a/lisp/init-git.el
+++ b/lisp/init-git.el
@@ -149,6 +149,17 @@ without requiring confirmation.
branches))))))
(magit-run-git "checkout" "-t" remote-branch))
+(defun km/magit-branch-rename (old new &optional force)
+ "Like `magit-branch-rename', but use old branch as initial prompt."
+ (interactive
+ (let ((branch (magit-read-local-branch "Rename branch")))
+ (list branch
+ (magit-read-string-ns (format "Rename branch '%s' to" branch)
+ branch)
+ current-prefix-arg)))
+ (unless (string= old new)
+ (magit-run-git-no-revert "branch" (if force "-M" "-m") old new)))
+
(defun km/magit-delete-previous-branch (&optional force)
"Delete previous branch.
\n(git branch -d @{-1})"
@@ -661,6 +672,8 @@ show tags by default."
(magit-define-popup-action 'magit-branch-popup
?p "Checkout previous" 'km/magit-checkout-previous-branch)
(magit-define-popup-action 'magit-branch-popup
+ ?r "Rename branch" 'km/magit-branch-rename)
+(magit-define-popup-action 'magit-branch-popup
?s "Backup current branch" 'km/magit-backup-branch)
(magit-define-popup-action 'magit-branch-popup
?t "Local tracking" 'km/magit-checkout-local-tracking)