From 3096eafb8abdff0e561f8ec430ceb4b1bc1f7258 Mon Sep 17 00:00:00 2001 From: Nathan Weizenbaum Date: Sun, 6 Jun 2010 04:31:00 -0700 Subject: [PATCH] Bind : to run Git commands directly. I chose : as the binding for similarity with M-:. --- magit.el | 18 ++++++++++++++++++ magit.texi | 9 +++++++++ 2 files changed, 27 insertions(+) diff --git a/magit.el b/magit.el index 5008ddcb..bea54553 100644 --- a/magit.el +++ b/magit.el @@ -1448,6 +1448,7 @@ FUNC should leave point at the end of the modified region" (define-key map (kbd "G") 'magit-refresh-all) (define-key map (kbd "?") 'magit-describe-item) (define-key map (kbd "!") 'magit-shell-command) + (define-key map (kbd ":") 'magit-git-command) (define-key map (kbd "RET") 'magit-visit-item) (define-key map (kbd "SPC") 'magit-show-item-or-scroll-up) (define-key map (kbd "DEL") 'magit-show-item-or-scroll-down) @@ -2965,6 +2966,23 @@ Uncomitted changes in both working tree and staging area are lost. (magit-process-popup-time 0)) (magit-run* args nil nil nil t))) +(defun magit-git-command (command) + "Perform arbitrary Git COMMAND. + +Similar to `magit-shell-command', but involves slightly less +typing and automatically refreshes the status buffer." + (interactive "sgit ") + (require 'pcomplete) + (let ((args (car (with-temp-buffer + (insert command) + (pcomplete-parse-buffer-arguments)))) + (magit-process-popup-time 0)) + (magit-with-refresh + (magit-run* (append (cons magit-git-executable + magit-git-standard-options) + args) + nil nil nil t)))) + (defun magit-read-remote (prompt def) (funcall magit-completing-read (if def (format "%s (default %s): " prompt def) diff --git a/magit.texi b/magit.texi index b7555e50..f6f46795 100644 --- a/magit.texi +++ b/magit.texi @@ -49,6 +49,7 @@ as an extension to Emacs. * Rewriting:: * Pushing and Pulling:: * Interfacing with Subversion:: +* Using Git Directly:: @end menu @node Introduction @@ -683,4 +684,12 @@ limited to the path of the remote Subversion repository. With a prefix (@kbd{C-u N f} the user will also be prompted for a branch to search in. +@node Using Git Directly +@chapter Using Git Directly + +For situations when Magit doesn't do everything you need, you can run +raw Git commands using @kbd{:}. This will prompt for a Git command, run +it, and refresh the status buffer. The output can be viewed by typing +@kbd{$}. + @bye