summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2014-09-02 01:26:14 -0400
committerKyle Meyer <kyle@kyleam.com>2014-09-02 01:26:14 -0400
commitd76f7e7ac8dd5ced9bde43a72676a1043af01afd (patch)
tree89fe1b66a3c184613bfcf02851731ea7f0a3ed17 /lisp
parent2316a1c4c4599690bd88916a8cf0b166a0de0ff2 (diff)
downloademacs.d-d76f7e7ac8dd5ced9bde43a72676a1043af01afd.tar.gz
Add magit-branch-and-checkout-from-current
Bind to 'c' in popup menu, and rebind magit-branch from 'c' to 'C'.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/init-git.el14
1 files changed, 14 insertions, 0 deletions
diff --git a/lisp/init-git.el b/lisp/init-git.el
index 57f8620..bed87c1 100644
--- a/lisp/init-git.el
+++ b/lisp/init-git.el
@@ -40,6 +40,15 @@ Useful for non-source code repos (e.g., Org mode note files)."
(magit-list-remote-branch-names))))
(magit-run-git "checkout" "-t" remote-branch))
+(defun km/magit-branch-and-checkout-from-current (branch)
+ "Create and checkout BRANCH at current branch.
+This is equivalent to running `magit-branch-and-checkout' with
+START-POINT set to the current branch.
+
+\(git checkout -b BRANCH)"
+ (interactive (list (magit-read-string "Branch name")))
+ (magit-run-git "checkout" "-b" branch))
+
(defun km/magit-backup-branch ()
"Create a backup branch for the current branch.
\(git branch b/<current-branch>\)"
@@ -78,6 +87,11 @@ Useful for non-source code repos (e.g., Org mode note files)."
?t "Local tracking" 'km/magit-checkout-local-tracking)
(magit-define-popup-action 'magit-branch-popup
?s "Backup current branch" 'km/magit-backup-branch)
+ (magit-define-popup-action 'magit-branch-popup
+ ?C "Create" 'magit-branch)
+ (magit-define-popup-action 'magit-branch-popup
+ ?c "Create & checkout from current"
+ 'km/magit-branch-and-checkout-from-current)
(setq magit-branch-popup-defaults
(delete "--track" magit-branch-popup-defaults)))