diff options
author | Alexandre Julliard <julliard@winehq.org> | 2008-11-23 14:25:50 +0100 |
---|---|---|
committer | Alexandre Julliard <julliard@winehq.org> | 2009-02-07 13:48:54 +0100 |
commit | 811b10c746a63d1818d52c9ecbf247d9a3891597 (patch) | |
tree | 8142dfd92691b203a42a3ebc60e74e9841dfae17 /contrib | |
parent | c375e9d04cbcaaca7ae459437d185eda0a4472b4 (diff) | |
download | git-811b10c746a63d1818d52c9ecbf247d9a3891597.tar.gz git-811b10c746a63d1818d52c9ecbf247d9a3891597.tar.xz |
git.el: Add a command to create a new branch.
Prompts for a branch name, create a new branch at HEAD and switch to
it. Bound to C-c C-b by default.
Based on a patch by RĂ©mi Vanicat <vanicat@debian.org>.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/emacs/git.el | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/contrib/emacs/git.el b/contrib/emacs/git.el index 5ce9bf19a..6727ff54b 100644 --- a/contrib/emacs/git.el +++ b/contrib/emacs/git.el @@ -1383,6 +1383,18 @@ Use a prefix arg if git should merge while checking out." (when (apply #'git-call-process-display-error "checkout" args) (git-update-status-files)))) +(defun git-branch (branch) + "Create a branch from the current HEAD and switch to it." + (interactive (list (git-read-commit-name "Branch: "))) + (unless git-status (error "Not in git-status buffer.")) + (if (git-rev-parse (concat "refs/heads/" branch)) + (if (yes-or-no-p (format "Branch %s already exists, replace it? " branch)) + (and (git-call-process-display-error "branch" "-f" branch) + (git-call-process-display-error "checkout" branch)) + (message "Canceled.")) + (git-call-process-display-error "checkout" "-b" branch)) + (git-refresh-ewoc-hf git-status)) + (defun git-amend-commit () "Undo the last commit on HEAD, and set things up to commit an amended version of it." @@ -1498,6 +1510,7 @@ amended version of it." (define-key map "\M-\C-?" 'git-unmark-all) ; the commit submap (define-key commit-map "\C-a" 'git-amend-commit) + (define-key commit-map "\C-b" 'git-branch) (define-key commit-map "\C-o" 'git-checkout) ; the diff submap (define-key diff-map "b" 'git-diff-file-base) @@ -1520,6 +1533,7 @@ amended version of it." ["Refresh" git-refresh-status t] ["Commit" git-commit-file t] ["Checkout..." git-checkout t] + ["New Branch..." git-branch t] ("Merge" ["Next Unmerged File" git-next-unmerged-file t] ["Prev Unmerged File" git-prev-unmerged-file t] |