Merge branch 'master' into issue-20

This commit is contained in:
Timo Juhani Lindfors 2010-09-14 22:36:03 +03:00
commit 1a06c8a862
7 changed files with 710 additions and 514 deletions

View file

@ -1,6 +1,6 @@
VERSION=0.8.2
PREFIX=/usr/local
ELS=magit.el magit-svn.el magit-topgit.el
ELS=magit.el magit-svn.el magit-topgit.el magit-key-mode.el
ELCS=$(ELS:.el=.elc)
DIST_FILES=$(ELS) Makefile magit.texi README.md magit.spec.in magit-pkg.el.in 50magit.el
@ -18,9 +18,10 @@ magit.spec: magit.spec.in
magit-pkg.el: magit-pkg.el.in
sed -e s/@VERSION@/$(VERSION)/ < $< > $@
magit.elc: magit.el
magit-svn.elc: magit-svn.el
magit-topgit.elc: magit-topgit.el
magit.elc:
magit-key-mode.elc:
magit-svn.elc:
magit-topgit.elc:
magit.info:
# yuck - this needs cleaning up a bit...

View file

@ -25,6 +25,17 @@ Emacs should be able to find it. Then add
to your `.emacs` file.
Magit also now supports extensions:
### git-svn
`(require 'magit-svn)` - integrates with git-svn. Hit 'N' to see your
options.
### git-topgit
`(require 'magit-topgit)` - integrates with topgit.
Getting started
---------------
@ -48,9 +59,9 @@ Magit's website is currently hosted [on GitHub][website].
Development
-----------
Magit was started by Marius Vollmer and is currently maintained by
Phil Jackson. For a full list of contributors have a look at
`magit.el` in the source distribution.
Magit was started by Marius Vollmer. Phil Jackson is the lead
developer. For a full list of contributors have a look at `magit.el`
in the source distribution.
Magit's canonical source repository is currently
[hosted on GitHub][development].

359
magit-key-mode.el Normal file
View file

@ -0,0 +1,359 @@
(require 'assoc)
(defvar magit-key-mode-key-maps '()
"This will be filled lazily with proper `define-key' built
keymaps as they're reqeusted.")
(defvar magit-key-mode-buf-name "*magit-key*"
"Name of the buffer.")
(defvar magit-key-mode-current-args '()
"Will contain the arguments to be passed to git.")
(defvar magit-key-mode-current-options '()
"Will contain the arguments to be passed to git.")
(defvar magit-log-mode-window-conf nil
"Will hold the pre-menu configuration of magit.")
(defvar magit-key-mode-groups
'((logging
(actions
("l" "Short" magit-log)
("L" "Long" magit-log-long)
("h" "Reflog" magit-reflog)
("H" "Reflog on head" magit-reflog-head))
(switches
("-m" "Only merge commits" "--merges")
("-f" "First parent" "--first-parent")
("-i" "Case insesnitive patterns" "-i")
("-a" "All" "--all"))
(arguments
("=b" "Branches" "--branches" read-from-minibuffer)
("=a" "Author" "--author" read-from-minibuffer)
("=g" "Grep" "--grep" read-from-minibuffer)))
(running
(actions
("!" "Command from root" magit-shell-command)
(":" "Git command" magit-git-command)))
(committing
(actions
("c" "Commit" magit-log-edit-commit))
(switches
("-s" "Signoff" "--signoff")
("-am" "Amend" "--amend")
("-al" "All" "--all"))
("-e" "Allow empty" "--allow-empty")
(arguments
("=au" "Author" "--author" read-from-minibuffer)))
(fetching
(actions
("f" "Fetch" magit-fetch)
("r" "Remote update" magit-remote-update)))
(pushing
(actions
("p" "Push" magit-push))
(switches
("-d" "Dry run" "-n")))
(pulling
(actions
("p" "Pull" magit-pull))
(switches
("-r" "Rebase" "--rebase")))
(branching
(actions
("V" "Branch manager" magit-show-branches)
("B" "Create" magit-create-branch)
("m" "Move" magit-move-branch)
("d" "Delete" magit-delete-branch)
("c" "Checkout" magit-checkout)))
(tagging
(actions
("t" "Lightweight" magit-tag)
("T" "Annotated" magit-annotated-tag))
(switches
("-f" "Force" "-f")))
(stashing
(actions
("s" "Save" magit-stash)
("S" "Snapshot" magit-stash-snapshot))
(switches
("-k" "Keep index" "--keep-index")))
(merging
(actions
("m" "Merge" magit-merge))
(switches
("-nf" "No fast-forward" "--no-ff")
("-nc" "No commit" "--no-commit")
("-sq" "Squash" "--squash"))
(arguments
("-st" "Strategy" "--strategy" read-from-minibuffer)))
(rewriting
(actions
("b" "Begin" magit-rewrite-start)
("s" "Stop" magit-rewrite-stop)
("a" "Abort" magit-rewrite-abort)
("f" "Finish" magit-rewrite-finish)
("*" "Set unused" magit-rewrite-set-unused)
("." "Set used" magit-rewrite-set-used))))
"Holds the key, help, function mapping for the log-mode. If you
modify this make sure you reset `magit-key-mode-key-maps' to
nil.")
(defun magit-key-mode-add-group (name)
"Add a new group to `magit-key-mode-key-maps'."
(unless (assoc name magit-key-mode-groups)
(push (list name '(actions)) magit-key-mode-groups)))
(defun magit-key-mode-update-group (for-group thing &rest args)
"Abstraction for setting values in `magit-key-mode-key-maps'."
(let* ((options (magit-key-mode-options-for-group for-group))
(things (assoc thing options)))
(if (cdr things)
(setcdr (cdr things) (cons args (cddr things)))
(setcdr things (list args)))
(setq magit-key-mode-key-maps nil)
things))
(defun magit-key-mode-insert-argument (for-group key desc arg read-func)
"Add a new binding (KEY) in FOR-GROUP which will use READ-FUNC
to receive input to apply to argument ARG git is run. DESC should
be a brief description of the binding."
(magit-key-mode-update-group for-group 'arguments key desc arg read-func))
(defun magit-key-mode-insert-switch (for-group key desc switch)
"Add a new binding (KEY) in FOR-GROUP which will add SWITCH to git's
commandline when it runs. DESC should be a brief description of
the binding."
(magit-key-mode-update-group for-group 'switches key desc switch))
(defun magit-key-mode-insert-action (for-group key desc func)
"Add a new binding (KEY) in FOR-GROUP which will run command
FUNC. DESC should be a brief description of the binding."
(magit-key-mode-update-group for-group 'actions key desc func))
(defun magit-key-mode-options-for-group (for-group)
"Retrieve the options (switches, commands and arguments) for
the group FOR-GROUP."
(or (cdr (assoc for-group magit-key-mode-groups))
(error "Unknown group '%s'" for-group)))
(defun magit-key-mode-build-keymap (for-group)
"Construct a normal looking keymap for the key mode to use and
put it in magit-key-mode-key-maps for fast lookup."
(let* ((options (magit-key-mode-options-for-group for-group))
(actions (cdr (assoc 'actions options)))
(switches (cdr (assoc 'switches options)))
(arguments (cdr (assoc 'arguments options))))
(let ((map (make-sparse-keymap)))
;; all maps should 'quit' with C-g
(define-key map (kbd "C-g") (lambda ()
(interactive)
(magit-key-mode-command nil)))
(when actions
(dolist (k actions)
(define-key map (car k) `(lambda ()
(interactive)
(magit-key-mode-command ',(nth 2 k))))))
(when switches
(dolist (k switches)
(define-key map (car k) `(lambda ()
(interactive)
(magit-key-mode-add-option
',for-group
,(nth 2 k))))))
(when arguments
(dolist (k arguments)
(define-key map (car k) `(lambda ()
(interactive)
(magit-key-mode-add-argument
',for-group
,(nth 2 k)
',(nth 3 k))))))
(aput 'magit-key-mode-key-maps for-group map)
map)))
(defun magit-key-mode-command (func)
(let ((args '()))
;; why can't maphash return a list?!
(maphash (lambda (k v)
(push (concat k "=" (shell-quote-argument v)) args))
magit-key-mode-current-args)
(let ((magit-custom-options (append args magit-key-mode-current-options)))
(set-window-configuration magit-log-mode-window-conf)
(when func
(call-interactively func))
(magit-key-mode-kill-buffer))))
(defvar magit-key-mode-current-args nil
"A hash-table of current argument set (which will eventually
make it to the git command-line).")
(defun debug-args ()
(interactive)
(maphash (lambda (k v) (print (format "%s: %s" k v))) magit-key-mode-current-args))
(defun magit-key-mode-add-argument (for-group arg-name input-func)
(let ((input (funcall input-func (concat arg-name ": "))))
(puthash arg-name input magit-key-mode-current-args)
(magit-key-mode-redraw for-group)))
(defvar magit-key-mode-current-options '()
"Current option set (which will eventually make it to the git
command-line).")
(defun magit-key-mode-add-option (for-group option-name)
"Toggles the appearance of OPTION-NAME in
`magit-key-mode-current-options'."
(if (not (member option-name magit-key-mode-current-options))
(add-to-list 'magit-key-mode-current-options option-name)
(setq magit-key-mode-current-options
(delete option-name magit-key-mode-current-options)))
(magit-key-mode-redraw for-group))
(defun magit-key-mode-kill-buffer ()
(interactive)
(kill-buffer magit-key-mode-buf-name))
(defvar magit-log-mode-window-conf nil
"Pre-popup window configuration.")
(defun magit-key-mode (for-group &optional original-opts)
"Mode for magit key selection."
(interactive)
;; save the window config to restore it as was (no need to make this
;; buffer local)
(setq magit-log-mode-window-conf
(current-window-configuration))
;; setup the mode, draw the buffer
(let ((buf (get-buffer-create magit-key-mode-buf-name)))
(delete-other-windows)
(split-window-vertically)
(other-window 1)
(switch-to-buffer buf)
(kill-all-local-variables)
(set (make-local-variable
'magit-key-mode-current-options)
original-opts)
(set (make-local-variable
'magit-key-mode-current-args)
(make-hash-table))
(magit-key-mode-redraw for-group)))
(defun magit-key-mode-redraw (for-group)
"(re)draw the magit key buffer."
(let ((buffer-read-only nil))
(erase-buffer)
(make-local-variable 'font-lock-defaults)
(use-local-map
(or (cdr (assoc for-group magit-key-mode-key-maps))
(magit-key-mode-build-keymap for-group)))
(magit-key-mode-draw for-group)
(delete-trailing-whitespace)
(setq mode-name "magit-key-mode" major-mode 'magit-key-mode))
(setq buffer-read-only t)
(goto-char (point-min))
(fit-window-to-buffer))
(defun magit-key-mode-draw-header (header)
"Draw a header with the correct face."
(insert (propertize header 'face 'font-lock-keyword-face)))
(defun magit-key-mode-draw-args (args)
"Draw the args part of the menu."
(when args
(magit-key-mode-draw-header "Args\n")
(dolist (argument args)
(insert
(format " %s: (%s) %s %s\n"
(propertize
(car argument)
'face 'font-lock-builtin-face)
(nth 1 argument)
(nth 2 argument)
(propertize
(gethash (nth 2 argument) magit-key-mode-current-args "")
'face 'widget-field))))))
(defun magit-key-mode-draw-switches (switches)
"Draw the switches part of the menu."
(when switches
(let ((switch-strs (mapcar
(lambda (s)
(let ((option (nth 2 s)))
(format " %s: %s (%s)"
(propertize (car s)
'face 'font-lock-builtin-face)
(nth 1 s)
(if (member option magit-key-mode-current-options)
(propertize
option
'face 'font-lock-warning-face)
option))))
switches)))
(magit-key-mode-draw-header "Switches\n")
(magit-key-mode-draw-in-cols switch-strs))))
(defun magit-key-mode-draw-actions (actions)
"Draw the actions part of the menu."
(when actions
(let ((action-strs (mapcar
(lambda (a)
(format
" %s: %s"
(propertize (car a)
'face 'font-lock-builtin-face)
(nth 1 a)))
actions)))
(magit-key-mode-draw-header "Actions\n")
(magit-key-mode-draw-in-cols action-strs))))
(defun magit-key-mode-draw-in-cols (strings)
"Given a list of strings, print in columns (using `insert')."
(let ((longest-act (apply 'max (mapcar 'length strings))))
(while strings
(let ((str (car strings)))
(let ((padding (make-string (- (+ longest-act 3) (length str)) ? )))
(insert str)
(if (and (> (+ (current-column) longest-act) (window-width))
(cdr strings))
(insert "\n")
(insert padding))))
(setq strings (cdr strings))))
(insert "\n"))
(defun magit-key-mode-draw (for-group)
"Function used to draw actions, switches and parameters."
(let* ((options (magit-key-mode-options-for-group for-group))
(switches (cdr (assoc 'switches options)))
(arguments (cdr (assoc 'arguments options)))
(actions (cdr (assoc 'actions options))))
(magit-key-mode-draw-switches switches)
(magit-key-mode-draw-args arguments)
(magit-key-mode-draw-actions actions)))
(defun magit-key-mode-generate (sym)
"Generate the key-group menu for SYM"
(let ((opts (magit-key-mode-options-for-group sym)))
(eval
`(defun ,(intern (concat "magit-key-mode-popup-" (symbol-name sym))) nil
,(concat "Key menu for " (symbol-name sym))
(interactive)
(magit-key-mode (quote ,sym))))))
;; create the interactive functions for the key mode popups
(mapc (lambda (g)
(magit-key-mode-generate (car g)))
magit-key-mode-groups)
(provide 'magit-key-mode)

View file

@ -156,13 +156,6 @@ If USE-CACHE is non nil, use the cached information."
(when (magit-svn-enabled)
(magit-run-git-async "svn" "fetch")))
(define-prefix-command 'magit-svn-prefix 'magit-svn-map)
(define-key magit-svn-map (kbd "r") 'magit-svn-rebase)
(define-key magit-svn-map (kbd "c") 'magit-svn-dcommit)
(define-key magit-svn-map (kbd "f") 'magit-svn-remote-update)
(define-key magit-svn-map (kbd "s") 'magit-svn-find-rev)
(define-key magit-mode-map (kbd "N") 'magit-svn-prefix)
(easy-menu-define magit-svn-extension-menu
nil
"Git SVN extension menu"
@ -179,5 +172,16 @@ If USE-CACHE is non nil, use the cached information."
(add-hook 'magit-remote-string-hook 'magit-svn-remote-string)
;; add the group and its keys
(magit-key-mode-add-group 'svn)
(magit-key-mode-insert-action 'svn "r" "Rebase" 'magit-svn-rebase)
(magit-key-mode-insert-action 'svn "c" "DCommit" 'magit-svn-dcommit)
(magit-key-mode-insert-action 'svn "f" "Fetch" 'magit-svn-remote-update)
(magit-key-mode-insert-action 'svn "s" "Find rev" 'magit-svn-find-rev)
;; generate and bind the menu popup function
(magit-key-mode-generate 'svn)
(define-key magit-mode-map (kbd "N") 'magit-key-mode-popup-svn)
(provide 'magit-svn)
;;; magit-svn.el ends here

View file

@ -1,11 +1,6 @@
;;; magit-topgit.el --- topgit plug-in for Magit
;; Copyright (C) 2008, 2009 Marius Vollmer
;; Copyright (C) 2008 Linh Dang
;; Copyright (C) 2008 Alex Ott
;; Copyright (C) 2008 Marcin Bachry
;; Copyright (C) 2009 Alexey Voinov
;; Copyright (C) 2009 John Wiegley
;; Copyright (C) 2010 Nathan Weizenbaum
;; Copyright (C) 2010 Yann Hodique
;;
;; Magit is free software; you can redistribute it and/or modify it

730
magit.el
View file

@ -66,6 +66,9 @@
;;; Code:
;; magit core
(require 'magit-key-mode)
(eval-when-compile (require 'cl))
(require 'log-edit)
(require 'easymenu)
@ -320,6 +323,9 @@ Many Magit faces inherit from this one by default."
"Face for tag labels shown in log buffer."
:group 'magit)
(defvar magit-custom-options '()
"List of custom options to pass git. Do not customise this.")
(defvar magit-completing-read 'completing-read
"Function to be called when requesting input from the user.")
@ -341,6 +347,155 @@ Many Magit faces inherit from this one by default."
"Face for local branch head labels shown in log buffer."
:group 'magit)
(defface magit-menu-selected-option
'((((class color) (background light))
:foreground "red")
(((class color) (background dark))
:foreground "orange"))
"Face for selected options on magit's menu"
:group 'magit)
(defvar magit-mode-map
(let ((map (make-keymap)))
(suppress-keymap map t)
(define-key map (kbd "n") 'magit-goto-next-section)
(define-key map (kbd "p") 'magit-goto-previous-section)
(define-key map (kbd "TAB") 'magit-toggle-section)
(define-key map (kbd "<backtab>") 'magit-expand-collapse-section)
(define-key map (kbd "1") 'magit-show-level-1)
(define-key map (kbd "2") 'magit-show-level-2)
(define-key map (kbd "3") 'magit-show-level-3)
(define-key map (kbd "4") 'magit-show-level-4)
(define-key map (kbd "M-1") 'magit-show-level-1-all)
(define-key map (kbd "M-2") 'magit-show-level-2-all)
(define-key map (kbd "M-3") 'magit-show-level-3-all)
(define-key map (kbd "M-4") 'magit-show-level-4-all)
(define-key map (kbd "M-h") 'magit-show-only-files)
(define-key map (kbd "M-H") 'magit-show-only-files-all)
(define-key map (kbd "M-s") 'magit-show-level-4)
(define-key map (kbd "M-S") 'magit-show-level-4-all)
(define-key map (kbd "<M-left>") 'magit-goto-parent-section)
(define-key map (kbd "g") 'magit-refresh)
(define-key map (kbd "G") 'magit-refresh-all)
(define-key map (kbd "?") 'magit-describe-item)
(define-key map (kbd "!") 'magit-key-mode-popup-running)
(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)
(define-key map (kbd "C-w") 'magit-copy-item-as-kill)
(define-key map (kbd "R") 'magit-rebase-step)
(define-key map (kbd "t") 'magit-key-mode-popup-tagging)
(define-key map (kbd "r") 'magit-key-mode-popup-rewriting)
(define-key map (kbd "P") 'magit-key-mode-popup-pushing)
(define-key map (kbd "f") 'magit-key-mode-popup-fetching)
(define-key map (kbd "b") 'magit-key-mode-popup-branching)
(define-key map (kbd "F") 'magit-key-mode-popup-pulling)
(define-key map (kbd "l") 'magit-key-mode-popup-logging)
(define-key map (kbd "$") 'magit-display-process)
(define-key map (kbd "c") 'magit-log-edit)
(define-key map (kbd "E") 'magit-interactive-rebase)
(define-key map (kbd "q") 'quit-window)
map))
(defvar magit-commit-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "a") 'magit-apply-item)
(define-key map (kbd "A") 'magit-cherry-pick-item)
(define-key map (kbd "v") 'magit-revert-item)
map))
(defvar magit-status-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "-") 'magit-diff-smaller-hunks)
(define-key map (kbd "+") 'magit-diff-larger-hunks)
(define-key map (kbd "0") 'magit-diff-default-hunks)
(define-key map (kbd "s") 'magit-stage-item)
(define-key map (kbd "S") 'magit-stage-all)
(define-key map (kbd "u") 'magit-unstage-item)
(define-key map (kbd "U") 'magit-unstage-all)
(define-key map (kbd "i") 'magit-ignore-item)
(define-key map (kbd "I") 'magit-ignore-item-locally)
(define-key map (kbd ".") 'magit-mark-item)
(define-key map (kbd "=") 'magit-diff-with-mark)
(define-key map (kbd "d") 'magit-diff-working-tree)
(define-key map (kbd "D") 'magit-diff)
(define-key map (kbd "a") 'magit-apply-item)
(define-key map (kbd "A") 'magit-cherry-pick-item)
(define-key map (kbd "v") 'magit-revert-item)
(define-key map (kbd "b") 'magit-key-mode-popup-branching)
(define-key map (kbd "m") 'magit-key-mode-popup-merging)
(define-key map (kbd "k") 'magit-discard-item)
(define-key map (kbd "e") 'magit-interactive-resolve-item)
(define-key map (kbd "C") 'magit-add-log)
(define-key map (kbd "x") 'magit-reset-head)
(define-key map (kbd "X") 'magit-reset-working-tree)
(define-key map (kbd "z") 'magit-key-mode-popup-stashing)
map))
(defvar magit-stash-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "-") 'magit-diff-smaller-hunks)
(define-key map (kbd "+") 'magit-diff-larger-hunks)
(define-key map (kbd "0") 'magit-diff-default-hunks)
(define-key map (kbd "a") 'magit-apply-item)
(define-key map (kbd "A") 'magit-cherry-pick-item)
(define-key map (kbd "v") 'magit-revert-item)
map))
(defvar magit-log-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd ".") 'magit-mark-item)
(define-key map (kbd "=") 'magit-diff-with-mark)
(define-key map (kbd "d") 'magit-diff-working-tree)
(define-key map (kbd "D") 'magit-diff)
(define-key map (kbd "a") 'magit-apply-item)
(define-key map (kbd "A") 'magit-cherry-pick-item)
(define-key map (kbd "v") 'magit-revert-item)
(define-key map (kbd "b") 'magit-key-mode-popup-branching)
(define-key map (kbd "m") 'magit-key-mode-popup-merging)
(define-key map (kbd "x") 'magit-reset-head)
(define-key map (kbd "e") 'magit-log-show-more-entries)
(define-key map (kbd "l") 'magit-key-mode-popup-logging)
map))
(defvar magit-reflog-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd ".") 'magit-mark-item)
(define-key map (kbd "=") 'magit-diff-with-mark)
(define-key map (kbd "d") 'magit-diff-working-tree)
(define-key map (kbd "D") 'magit-diff)
(define-key map (kbd "a") 'magit-apply-item)
(define-key map (kbd "A") 'magit-cherry-pick-item)
(define-key map (kbd "v") 'magit-revert-item)
(define-key map (kbd "x") 'magit-reset-head)
map))
(defvar magit-diff-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "-") 'magit-diff-smaller-hunks)
(define-key map (kbd "+") 'magit-diff-larger-hunks)
(define-key map (kbd "0") 'magit-diff-default-hunks)
(define-key map (kbd "a") 'magit-apply-item)
(define-key map (kbd "A") 'magit-cherry-pick-item)
(define-key map (kbd "v") 'magit-revert-item)
map))
(defvar magit-wazzup-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd ".") 'magit-mark-item)
(define-key map (kbd "=") 'magit-diff-with-mark)
(define-key map (kbd "d") 'magit-diff-working-tree)
(define-key map (kbd "D") 'magit-diff)
(define-key map (kbd "a") 'magit-apply-item)
(define-key map (kbd "A") 'magit-cherry-pick-item)
(define-key map (kbd "v") 'magit-revert-item)
(define-key map (kbd "b") 'magit-key-mode-popup-branching)
(define-key map (kbd "m") 'magit-key-mode-popup-merging)
(define-key map (kbd "x") 'magit-reset-head)
(define-key map (kbd "i") 'magit-ignore-item)
map))
;;; Macros
(defmacro magit-with-refresh (&rest body)
@ -1586,169 +1741,9 @@ FUNC should leave point at the end of the modified region"
(magit-define-level-shower 3)
(magit-define-level-shower 4)
(defvar magit-mode-map
(let ((map (make-keymap)))
(suppress-keymap map t)
(define-key map (kbd "n") 'magit-goto-next-section)
(define-key map (kbd "p") 'magit-goto-previous-section)
(define-key map (kbd "TAB") 'magit-toggle-section)
(define-key map (kbd "<backtab>") 'magit-expand-collapse-section)
(define-key map (kbd "1") 'magit-show-level-1)
(define-key map (kbd "2") 'magit-show-level-2)
(define-key map (kbd "3") 'magit-show-level-3)
(define-key map (kbd "4") 'magit-show-level-4)
(define-key map (kbd "M-1") 'magit-show-level-1-all)
(define-key map (kbd "M-2") 'magit-show-level-2-all)
(define-key map (kbd "M-3") 'magit-show-level-3-all)
(define-key map (kbd "M-4") 'magit-show-level-4-all)
(define-key map (kbd "M-h") 'magit-show-only-files)
(define-key map (kbd "M-H") 'magit-show-only-files-all)
(define-key map (kbd "M-s") 'magit-show-level-4)
(define-key map (kbd "M-S") 'magit-show-level-4-all)
(define-key map (kbd "<M-left>") 'magit-goto-parent-section)
(define-key map (kbd "g") 'magit-refresh)
(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)
(define-key map (kbd "C-w") 'magit-copy-item-as-kill)
(define-key map (kbd "R") 'magit-rebase-step)
(define-key map (kbd "r s") 'magit-rewrite-start)
(define-key map (kbd "r t") 'magit-rewrite-stop)
(define-key map (kbd "r a") 'magit-rewrite-abort)
(define-key map (kbd "r f") 'magit-rewrite-finish)
(define-key map (kbd "r *") 'magit-rewrite-set-unused)
(define-key map (kbd "r .") 'magit-rewrite-set-used)
(define-key map (kbd "P") 'magit-push)
(define-key map (kbd "f") 'magit-remote-update)
(define-key map (kbd "F") 'magit-pull)
(define-key map (kbd "c") 'magit-log-edit)
(define-key map (kbd "l") 'magit-log)
(define-key map (kbd "L") 'magit-log-long)
(define-key map (kbd "h") 'magit-reflog-head)
(define-key map (kbd "H") 'magit-reflog)
(define-key map (kbd "w") 'magit-wazzup)
(define-key map (kbd "$") 'magit-display-process)
(define-key map (kbd "E") 'magit-interactive-rebase)
(define-key map (kbd "V") 'magit-show-branches)
(define-key map (kbd "q") 'quit-window)
map))
(defvar magit-commit-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "a") 'magit-apply-item)
(define-key map (kbd "A") 'magit-cherry-pick-item)
(define-key map (kbd "v") 'magit-revert-item)
map))
(defvar magit-status-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "-") 'magit-diff-smaller-hunks)
(define-key map (kbd "+") 'magit-diff-larger-hunks)
(define-key map (kbd "0") 'magit-diff-default-hunks)
(define-key map (kbd "s") 'magit-stage-item)
(define-key map (kbd "S") 'magit-stage-all)
(define-key map (kbd "u") 'magit-unstage-item)
(define-key map (kbd "U") 'magit-unstage-all)
(define-key map (kbd "i") 'magit-ignore-item)
(define-key map (kbd "I") 'magit-ignore-item-locally)
(define-key map (kbd ".") 'magit-mark-item)
(define-key map (kbd "=") 'magit-diff-with-mark)
(define-key map (kbd "d") 'magit-diff-working-tree)
(define-key map (kbd "D") 'magit-diff)
(define-key map (kbd "a") 'magit-apply-item)
(define-key map (kbd "A") 'magit-cherry-pick-item)
(define-key map (kbd "v") 'magit-revert-item)
(define-key map (kbd "b") 'magit-checkout)
(define-key map (kbd "B") 'magit-create-branch)
(define-key map (kbd "m") 'magit-manual-merge)
(define-key map (kbd "M") 'magit-automatic-merge)
(define-key map (kbd "k") 'magit-discard-item)
(define-key map (kbd "e") 'magit-interactive-resolve-item)
(define-key map (kbd "C") 'magit-add-log)
(define-key map (kbd "x") 'magit-reset-head)
(define-key map (kbd "X") 'magit-reset-working-tree)
(define-key map (kbd "t") 'magit-tag)
(define-key map (kbd "T") 'magit-annotated-tag)
(define-key map (kbd "z") 'magit-stash)
(define-key map (kbd "Z") 'magit-stash-snapshot)
map))
(defvar magit-stash-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "-") 'magit-diff-smaller-hunks)
(define-key map (kbd "+") 'magit-diff-larger-hunks)
(define-key map (kbd "0") 'magit-diff-default-hunks)
(define-key map (kbd "a") 'magit-apply-item)
(define-key map (kbd "A") 'magit-cherry-pick-item)
(define-key map (kbd "v") 'magit-revert-item)
map))
(defvar magit-log-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd ".") 'magit-mark-item)
(define-key map (kbd "=") 'magit-diff-with-mark)
(define-key map (kbd "d") 'magit-diff-working-tree)
(define-key map (kbd "D") 'magit-diff)
(define-key map (kbd "a") 'magit-apply-item)
(define-key map (kbd "s") 'magit-log-grep)
(define-key map (kbd "A") 'magit-cherry-pick-item)
(define-key map (kbd "v") 'magit-revert-item)
(define-key map (kbd "b") 'magit-checkout)
(define-key map (kbd "B") 'magit-create-branch)
(define-key map (kbd "m") 'magit-manual-merge)
(define-key map (kbd "M") 'magit-automatic-merge)
(define-key map (kbd "x") 'magit-reset-head)
(define-key map (kbd "e") 'magit-log-show-more-entries)
(define-key map (kbd "l") 'magit-log)
(define-key map (kbd "L") 'magit-log-long)
(define-key map (kbd "h") 'magit-reflog-head)
(define-key map (kbd "H") 'magit-reflog)
(define-key map (kbd "t") 'magit-tag)
(define-key map (kbd "T") 'magit-annotated-tag)
map))
(defvar magit-reflog-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd ".") 'magit-mark-item)
(define-key map (kbd "=") 'magit-diff-with-mark)
(define-key map (kbd "d") 'magit-diff-working-tree)
(define-key map (kbd "D") 'magit-diff)
(define-key map (kbd "a") 'magit-apply-item)
(define-key map (kbd "A") 'magit-cherry-pick-item)
(define-key map (kbd "v") 'magit-revert-item)
(define-key map (kbd "x") 'magit-reset-head)
map))
(defvar magit-diff-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "-") 'magit-diff-smaller-hunks)
(define-key map (kbd "+") 'magit-diff-larger-hunks)
(define-key map (kbd "0") 'magit-diff-default-hunks)
(define-key map (kbd "a") 'magit-apply-item)
(define-key map (kbd "A") 'magit-cherry-pick-item)
(define-key map (kbd "v") 'magit-revert-item)
map))
(defvar magit-wazzup-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd ".") 'magit-mark-item)
(define-key map (kbd "=") 'magit-diff-with-mark)
(define-key map (kbd "d") 'magit-diff-working-tree)
(define-key map (kbd "D") 'magit-diff)
(define-key map (kbd "a") 'magit-apply-item)
(define-key map (kbd "A") 'magit-cherry-pick-item)
(define-key map (kbd "v") 'magit-revert-item)
(define-key map (kbd "b") 'magit-checkout)
(define-key map (kbd "B") 'magit-create-branch)
(define-key map (kbd "m") 'magit-manual-merge)
(define-key map (kbd "M") 'magit-automatic-merge)
(define-key map (kbd "x") 'magit-reset-head)
(define-key map (kbd "i") 'magit-ignore-item)
map))
(defun magit-true (prompt)
"Dummy function for turning on options on menu."
t)
(easy-menu-define magit-mode-menu magit-mode-map
"Magit menu"
@ -1767,10 +1762,7 @@ FUNC should leave point at the end of the modified region"
"---"
["Diff working tree" magit-diff-working-tree t]
["Diff" magit-diff t]
["Log" magit-log t]
["Long Log" magit-log-long t]
["Reflog head" magit-reflog-head t]
["Reflog" magit-reflog t]
["Log..." magit-log-menu t]
"---"
["Cherry pick" magit-cherry-pick-item t]
["Apply" magit-apply-item t]
@ -1784,10 +1776,8 @@ FUNC should leave point at the end of the modified region"
["Stash" magit-stash t]
["Snapshot" magit-stash-snapshot t]
"---"
["Switch branch" magit-checkout t]
["Create branch" magit-create-branch t]
["Branch..." magit-checkout t]
["Merge" magit-automatic-merge t]
["Merge (no commit)" magit-manual-merge t]
["Interactive resolve" magit-interactive-resolve-item t]
["Rebase" magit-rebase-step t]
("Rewrite"
@ -2486,9 +2476,7 @@ insert a line to tell how to insert more of them"
"-p" commit)))
(define-minor-mode magit-commit-mode
"Minor mode to view a git commit.
\\{magit-commit-mode-map}"
"Minor mode to view git commit"
:group magit
:init-value ()
:lighter ()
@ -2663,9 +2651,7 @@ insert a line to tell how to insert more of them"
(magit-run* (list "git" "init"))))))
(define-minor-mode magit-status-mode
"Minor mode for looking at git status.
\\{magit-status-mode-map}"
"Minor mode for looking at git status"
:group magit
:init-value ()
:lighter ()
@ -2806,8 +2792,31 @@ Fails if working tree or staging area contain uncommitted changes.
(if (and branch (not (string= branch ""))
parent)
(magit-run-git "checkout" "-b"
branch
(magit-rev-to-git parent))))
branch
(append
magit-custom-options
(magit-rev-to-git parent)))))
(defun magit-delete-branch (branch)
"Asks for a branch and deletes it.
If the branch is the current one, offers to switch to `master' first.
\('git branch -d BRANCH')."
(interactive (list (magit-read-rev "Branch to delete" (magit-default-rev))))
(when (and branch (string= branch (magit-get-current-branch)))
(if (y-or-n-p "Cannot delete current branch. Switch to master first?")
(magit-checkout "master")
(setq branch nil)))
(when branch
(magit-run-git "branch" "-d" (append magit-custom-options
(magit-rev-to-git branch)))))
(defun magit-move-branch (old new)
"Renames or moves a branch.
If the branch is the current one, offers to switch to `master' first.
\('git branch -m OLD NEW')."
(interactive (list (magit-read-rev "Old name" (magit-default-rev))
(magit-read-rev "New name" (magit-default-rev))))
(magit-run-git "branch" "-m" (magit-rev-to-git old) new))
;;; Merging
@ -2818,28 +2827,19 @@ Fails if working tree or staging area contain uncommitted changes.
((commit) (substring info 0 8))
((wazzup) info)))
(defun magit-manual-merge (revision)
(defun magit-merge (revision)
"Merge REVISION into the current 'HEAD'; leave changes uncommitted.
With a prefix-arg, the merge will be squashed.
\('git merge --no-commit [--squash|--no-ff] REVISION')."
(interactive
(list (magit-read-rev (concat "Manually merge"
(when current-prefix-arg
" (squashed)"))
(magit-guess-branch))))
(list (magit-read-rev (concat
"Merge"
(magit-guess-branch)))))
(if revision
(magit-run-git "merge" "--no-commit"
(if current-prefix-arg
"--squash"
"--no-ff")
(magit-rev-to-git revision))))
(magit-define-command automatic-merge (revision)
"Merge REVISION into the current 'HEAD'; commit unless merge fails.
\('git merge REVISION')."
(interactive (list (magit-read-rev "Merge" (magit-guess-branch))))
(if revision
(magit-run-git "merge" (magit-rev-to-git revision))))
(apply 'magit-run-git
"merge"
(magit-rev-to-git revision)
magit-custom-options)))
;;; Rebasing
@ -3042,28 +3042,26 @@ Uncomitted changes in both working tree and staging area are lost.
;;; Updating, pull, and push
(magit-define-command remote-update (&optional remote)
"Update REMOTE. If nil, update all remotes.
(magit-define-command fetch ()
"Run fetch."
(interactive)
(magit-run-git-async "fetch" (magit-read-remote)))
When called interactively, update the current remote unless a
prefix arg is given. With prefix arg, prompt for a remote and
update it."
(interactive (list (when current-prefix-arg (magit-read-remote))))
(cond
(remote (magit-run-git-async "fetch" remote))
(t (magit-run-git-async "remote" "update"))))
(magit-define-command remote-update ()
"Update all remotes."
(interactive)
(magit-run-git-async "remote" "update"))
(magit-define-command pull (&optional rebase)
"Run git pull against the current remote. With a prefix arg
will run pull with --rebase."
(interactive "P")
(magit-define-command pull ()
"Run git pull against the current remote."
(interactive)
(let* ((branch (magit-get-current-branch))
(config-branch (and branch (magit-get "branch" branch "merge")))
(merge-branch (or config-branch
(merge-branch (or (and config-branch (not current-prefix-arg))
(magit-read-rev (format "Pull from")))))
(if (and branch (not config-branch))
(magit-set merge-branch "branch" branch "merge"))
(apply 'magit-run-git-async `("pull" "-v" ,@(and rebase '("--rebase"))))))
(apply 'magit-run-git-async "pull" "-v" magit-custom-options)))
(eval-when-compile (require 'pcomplete))
@ -3108,10 +3106,11 @@ typing and automatically refreshes the status buffer."
(if (and (not branch-remote)
(not current-prefix-arg))
(magit-set push-remote "branch" branch "remote"))
(magit-run-git-async "push" "-v" push-remote
(if ref-branch
(format "%s:%s" branch ref-branch)
branch))
(apply 'magit-run-git-async "push" "-v" push-remote
(if ref-branch
(format "%s:%s" branch ref-branch)
branch)
magit-custom-options)
;; Although git will automatically set up the remote,
;; it doesn't set up the branch to merge (at least as of Git 1.6.6.1),
;; so we have to do that manually.
@ -3120,17 +3119,14 @@ typing and automatically refreshes the status buffer."
;;; Log edit mode
(defvar magit-log-edit-mode-hook nil "Hook run by `magit-log-edit-mode'.")
(defvar magit-log-edit-mode-hook nil
"Hook run by `magit-log-edit-mode'.")
(defvar magit-log-edit-buffer-name "*magit-edit-log*"
"Buffer name for composing commit messages.")
(defvar magit-log-edit-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "C-c C-c") 'magit-log-edit-commit)
(define-key map (kbd "C-c C-a") 'magit-log-edit-toggle-amending)
(define-key map (kbd "C-c C-s") 'magit-log-edit-toggle-signoff)
(define-key map (kbd "C-c C-e") 'magit-log-edit-toggle-allow-empty)
(define-key map (kbd "M-p") 'log-edit-previous-comment)
(define-key map (kbd "M-n") 'log-edit-next-comment)
(define-key map (kbd "C-c C-k") 'magit-log-edit-cancel-log-message)
@ -3168,136 +3164,46 @@ Prefix arg means justify as well."
(goto-char (point-max))
(insert str "\n")))
(defconst magit-log-header-end "-- End of Magit header --\n")
(defun magit-log-edit-get-fields ()
(let ((buf (get-buffer magit-log-edit-buffer-name))
(result nil))
(if buf
(with-current-buffer buf
(goto-char (point-min))
(while (looking-at "^\\([A-Za-z0-9-_]+\\): *\\(.*\\)$")
(setq result (acons (intern (downcase (match-string 1)))
(match-string 2)
result))
(forward-line))
(if (not (looking-at (regexp-quote magit-log-header-end)))
(setq result nil))))
(nreverse result)))
(defun magit-log-edit-set-fields (fields)
(let ((buf (get-buffer-create magit-log-edit-buffer-name)))
(with-current-buffer buf
(goto-char (point-min))
(if (search-forward-regexp (format "^\\([A-Za-z0-9-_]+:.*\n\\)*%s"
(regexp-quote magit-log-header-end))
nil t)
(delete-region (match-beginning 0) (match-end 0)))
(goto-char (point-min))
(when fields
(while fields
(insert (capitalize (symbol-name (caar fields))) ": "
(cdar fields) "\n")
(setq fields (cdr fields)))
(insert magit-log-header-end)))))
(defun magit-log-edit-set-field (name value)
(let* ((fields (magit-log-edit-get-fields))
(cell (assq name fields)))
(cond (cell
(if value
(rplacd cell value)
(setq fields (delq cell fields))))
(t
(if value
(setq fields (append fields (list (cons name value)))))))
(magit-log-edit-set-fields fields)))
(defun magit-log-edit-get-field (name)
(cdr (assq name (magit-log-edit-get-fields))))
(defun magit-log-edit-toggle-field (name default)
"Toggle the log-edit field named NAME.
If it's currently unset, set it to DEFAULT (t or nil).
Return nil if the field is toggled off, and non-nil if it's
toggled on. When it's toggled on for the first time, return
'first."
(let* ((fields (magit-log-edit-get-fields))
(cell (assq name fields)) yesp)
(if cell
(progn
(setq yesp (equal (cdr cell) "yes"))
(rplacd cell (if yesp "no" "yes")))
(setq fields (acons name (if default "yes" "no") fields))
(setq yesp (if default 'first)))
(magit-log-edit-set-fields fields)
yesp))
(defun magit-log-edit-setup-author-env (author)
(cond (author
;; XXX - this is a bit strict, probably.
(or (string-match "\\(.*\\) <\\(.*\\)>, \\(.*\\)" author)
(error "Can't parse author string"))
;; Shucks, setenv destroys the match data.
(let ((name (match-string 1 author))
(email (match-string 2 author))
(date (match-string 3 author)))
(setenv "GIT_AUTHOR_NAME" name)
(setenv "GIT_AUTHOR_EMAIL" email)
(setenv "GIT_AUTHOR_DATE" date)))
(t
(setenv "GIT_AUTHOR_NAME")
(setenv "GIT_AUTHOR_EMAIL")
(setenv "GIT_AUTHOR_DATE"))))
(defun magit-log-edit-push-to-comment-ring (comment)
(when (or (ring-empty-p log-edit-comment-ring)
(not (equal comment (ring-ref log-edit-comment-ring 0))))
(not (equal comment (ring-ref log-edit-comment-ring 0))))
(ring-insert log-edit-comment-ring comment)))
(defun magit-log-edit-apply-tag (name rev)
(let ((commit-buf (current-buffer)))
(with-current-buffer (magit-find-buffer 'status default-directory)
(magit-run-git-with-input (current-buffer) "tag" name "-a" "-F" "-" rev))
(erase-buffer)
(bury-buffer)
(magit-update-vc-modeline default-directory)
(when magit-pre-log-edit-window-configuration
(set-window-configuration magit-pre-log-edit-window-configuration)
(setq magit-pre-log-edit-window-configuration nil))))
(defun magit-log-edit-commit ()
"Finish edits and create new commit object.
\('git commit ...')"
(interactive)
(let* ((fields (magit-log-edit-get-fields))
(amend (equal (cdr (assq 'amend fields)) "yes"))
(allow-empty (equal (cdr (assq 'allow-empty fields)) "yes"))
(commit-all (equal (cdr (assq 'commit-all fields)) "yes"))
(sign-off-field (assq 'sign-off fields))
(sign-off (if sign-off-field
(equal (cdr sign-off-field) "yes")
magit-commit-signoff))
(tag-rev (cdr (assq 'tag-rev fields)))
(tag-name (cdr (assq 'tag-name fields)))
(author (cdr (assq 'author fields))))
(magit-log-edit-push-to-comment-ring (buffer-string))
(magit-log-edit-setup-author-env author)
(magit-log-edit-set-fields nil)
(magit-log-edit-cleanup)
(if (= (buffer-size) 0)
(insert "(Empty description)\n"))
(let ((commit-buf (current-buffer)))
(with-current-buffer (magit-find-buffer 'status default-directory)
(cond (tag-name
(magit-run-git-with-input commit-buf "tag" tag-name "-a" "-F" "-" tag-rev))
(t
(apply #'magit-run-async-with-input commit-buf
magit-git-executable
(append magit-git-standard-options
(list "commit" "-F" "-")
(if (and commit-all (not allow-empty)) '("--all") '())
(if amend '("--amend") '())
(if allow-empty '("--allow-empty"))
(if sign-off '("--signoff") '())))))))
(erase-buffer)
(bury-buffer)
(when (file-exists-p ".git/MERGE_MSG")
(delete-file ".git/MERGE_MSG"))
(magit-update-vc-modeline default-directory)
(when magit-pre-log-edit-window-configuration
(set-window-configuration magit-pre-log-edit-window-configuration)
(setq magit-pre-log-edit-window-configuration nil))))
(magit-log-edit-push-to-comment-ring (buffer-string))
(magit-log-edit-cleanup)
(if (= (buffer-size) 0)
(insert "(Empty description)\n"))
(let ((commit-buf (current-buffer)))
(with-current-buffer (magit-find-buffer 'status default-directory)
(apply #'magit-run-async-with-input commit-buf
magit-git-executable
(append
magit-git-standard-options
'("commit" "-F" "-")
magit-custom-options))))
(erase-buffer)
(bury-buffer)
(when (file-exists-p ".git/MERGE_MSG")
(delete-file ".git/MERGE_MSG"))
(magit-update-vc-modeline default-directory)
(when magit-pre-log-edit-window-configuration
(set-window-configuration magit-pre-log-edit-window-configuration)
(setq magit-pre-log-edit-window-configuration nil)))
(defun magit-log-edit-cancel-log-message ()
"Abort edits and erase commit message being composed."
@ -3311,34 +3217,27 @@ toggled on. When it's toggled on for the first time, return
(set-window-configuration magit-pre-log-edit-window-configuration)
(setq magit-pre-log-edit-window-configuration nil))))
(defun magit-log-edit-toggle-amending ()
"Toggle whether this will be an amendment to the previous commit.
\(i.e., whether eventual commit does 'git commit --amend')"
(interactive)
(when (eq (magit-log-edit-toggle-field 'amend t) 'first)
(magit-log-edit-append
(magit-format-commit "HEAD" "%s%n%n%b"))))
(defun magit-log-edit-toggle-signoff ()
"Toggle whether this commit will include a signoff.
\(i.e., whether eventual commit does 'git commit --signoff')"
(interactive)
(magit-log-edit-toggle-field 'sign-off (not magit-commit-signoff)))
(defun magit-log-edit-toggle-allow-empty ()
"Toggle whether this commit is allowed to be empty.
This means that the eventual commit does 'git commit --allow-empty'."
(interactive)
(magit-log-edit-toggle-field 'allow-empty t))
(defun magit-pop-to-log-edit (operation)
(defun magit-pop-to-log-edit (operation &optional options)
(let ((dir default-directory)
(buf (get-buffer-create magit-log-edit-buffer-name)))
(setq magit-pre-log-edit-window-configuration
(current-window-configuration))
(pop-to-buffer buf)
(when (file-exists-p ".git/MERGE_MSG")
(insert-file-contents ".git/MERGE_MSG"))
(case operation
('tagging
(let ((name (cdr (assoc 'name options)))
(rev (cdr (assoc 'rev options))))
(setq header-line-format
(format "For tag %s on %s" name rev))
(define-key magit-log-edit-mode-map (kbd "C-c C-c")
`(lambda ()
(interactive)
(magit-log-edit-apply-tag ,name ,rev)))))
('committing
(when (file-exists-p ".git/MERGE_MSG")
(insert-file-contents ".git/MERGE_MSG"))
(define-key magit-log-edit-mode-map (kbd "C-c C-c")
'magit-key-mode-popup-committing)))
(setq default-directory dir)
(magit-log-edit-mode)
(message "Type C-c C-c to %s (C-c C-k to cancel)." operation)))
@ -3346,23 +3245,10 @@ This means that the eventual commit does 'git commit --allow-empty'."
(defun magit-log-edit ()
(interactive)
(cond ((magit-rebase-info)
(if (y-or-n-p "Rebase in progress. Continue it? ")
(magit-run-git "rebase" "--continue")))
(t
(when (and magit-commit-all-when-nothing-staged
(not (magit-anything-staged-p)))
(cond ((eq magit-commit-all-when-nothing-staged 'ask-stage)
(if (and (not (magit-everything-clean-p))
(y-or-n-p "Nothing staged. Stage everything now? "))
(magit-stage-all)))
((not (magit-log-edit-get-field 'commit-all))
(magit-log-edit-set-field
'commit-all
(if (or (eq magit-commit-all-when-nothing-staged t)
(y-or-n-p
"Nothing staged. Commit all unstaged changes? "))
"yes" "no")))))
(magit-pop-to-log-edit "commit"))))
(if (y-or-n-p "Rebase in progress. Continue it? ")
(magit-run-git "rebase" "--continue")))
(t
(magit-pop-to-log-edit 'committing))))
(defun magit-add-log ()
(interactive)
@ -3434,9 +3320,8 @@ Tag will point to the current 'HEAD'."
(list
(read-string "Tag name: ")
(magit-read-rev "Place tag on: " (or (magit-default-rev) "HEAD"))))
(magit-log-edit-set-field 'tag-name name)
(magit-log-edit-set-field 'tag-rev rev)
(magit-pop-to-log-edit "tag"))
(magit-pop-to-log-edit 'tagging (list (cons 'name name)
(cons 'rev rev))))
;;; Stashing
@ -3490,9 +3375,7 @@ With prefix argument, changes in staging area are kept.
(defvar magit-currently-shown-stash nil)
(define-minor-mode magit-stash-mode
"Minor mode for looking at a git stash.
\\{magit-stash-mode-map}"
"Minor mode for looking at git status"
:group magit
:init-value ()
:lighter ()
@ -3555,10 +3438,7 @@ With prefix argument, changes in staging area are kept.
(magit-format-commit commit "Reverting \"%s\"")))
(t
(magit-log-edit-append
(magit-format-commit commit "%s%n%n%b"))
(magit-log-edit-set-field
'author
(magit-format-commit commit "%an <%ae>, %ai")))))
(magit-format-commit commit "%s%n%n%b")))))
success))
(defun magit-apply-item ()
@ -3578,10 +3458,7 @@ With prefix argument, changes in staging area are kept.
((diff)
(magit-apply-diff-item item))
((stash)
(apply 'magit-run-git `("stash"
"apply"
,@(when current-prefix-arg '("--index"))
,info)))))
(magit-run-git "stash" "apply" info))))
(defun magit-cherry-pick-item ()
(interactive)
@ -3592,10 +3469,7 @@ With prefix argument, changes in staging area are kept.
((commit)
(magit-apply-commit info t))
((stash)
(apply 'magit-run-git `("stash"
"pop"
,@(when current-prefix-arg '("--index"))
,info)))))
(magit-run-git "stash" "pop" info))))
(defun magit-revert-item ()
(interactive)
@ -3664,9 +3538,7 @@ With a non numeric prefix ARG, show all entries"
"--"))))
(define-minor-mode magit-log-mode
"Minor mode for looking at git log.
\\{magit-log-mode-map}"
"Minor mode for looking at git status"
:group magit
:init-value ()
:lighter ()
@ -3689,32 +3561,10 @@ With a non numeric prefix ARG, show all entries"
"--pretty=oneline" args)
(magit-log-mode t)))
(defun magit-log-all (&optional arg)
"Display the state of all refs in the log output."
(interactive "P")
(magit-display-log arg "--all"))
(defun magit-log-first-parent (&optional arg)
"Display the log buffer excluding anything more than first
level commits."
(interactive "P")
(magit-display-log arg "--first-parent"))
(defun magit-log (&optional arg)
"View and act upon the output of git log."
(interactive "P")
(magit-display-log arg))
(defun magit-log-grep (str)
"Search for regexp specified by STR in the commit log."
(interactive "sGrep in commit log: ")
(let ((topdir (magit-get-top-dir default-directory)))
(switch-to-buffer magit-log-grep-buffer-name)
(magit-mode-init topdir 'log #'magit-refresh-log-buffer "HEAD"
"--pretty=oneline"
(list "-E"
(format "--grep=%s" (shell-quote-argument str))))
(magit-log-mode t)))
(apply 'magit-display-log arg magit-custom-options))
(magit-define-command log-long (&optional arg)
(interactive "P")
@ -3722,7 +3572,8 @@ level commits."
(magit-read-rev-range "Long log" "HEAD")
"HEAD"))
(topdir (magit-get-top-dir default-directory))
(args (list (magit-rev-range-to-git range))))
(args (append (list (magit-rev-range-to-git range))
magit-custom-options)))
(switch-to-buffer magit-log-buffer-name)
(magit-mode-init topdir 'log #'magit-refresh-log-buffer range
"--stat" args)
@ -3747,9 +3598,7 @@ This is only non-nil in reflog buffers.")
args)))
(define-minor-mode magit-reflog-mode
"Minor mode for looking at git reflog.
\\{magit-reflog-mode-map}"
"Minor mode for looking at git status"
:group magit
:init-value ()
:lighter ()
@ -3780,9 +3629,7 @@ This is only non-nil in reflog buffers.")
"diff" (magit-diff-U-arg) args)))
(define-minor-mode magit-diff-mode
"Minor mode for looking at a git diff.
\\{magit-diff-mode-map}"
"Minor mode for looking at git status"
:group magit
:init-value ()
:lighter ()
@ -3883,9 +3730,7 @@ This is only meaningful in wazzup buffers.")
(magit-set-section-info ref section))))))))))
(define-minor-mode magit-wazzup-mode
"Minor mode for looking at commits that could be merged from other branches.
\\{magit-wazzup-mode-map}"
"Minor mode for looking at git status"
:group magit
:init-value ()
:lighter ()
@ -4160,18 +4005,6 @@ With prefix force the removal even it it hasn't been merged."
(apply 'magit-run-git (remq nil args))
(magit-show-branches))))
(defun magit-branches-window-manual-merge ()
"Merge the branch at point manually."
(interactive)
(magit-manual-merge (magit--branch-name-at-point))
(magit-show-branches))
(defun magit-branches-window-automatic-merge ()
"Merge the branch at point automatically."
(interactive)
(magit-automatic-merge (magit--branch-name-at-point))
(magit-show-branches))
(defvar magit-branches-buffer-name "*magit-branches*")
(defun magit--is-branch-at-point-remote()
@ -4212,7 +4045,8 @@ With prefix force the removal even it it hasn't been merged."
(setq default-directory topdir)))
(let ((inhibit-read-only t)
(branches (mapcar 'magit--branch-view-details
(magit-git-lines "branch" "-va"))))
(apply 'magit-git-lines "branch" "-va"
magit-custom-options))))
(erase-buffer)
(insert
(mapconcat

View file

@ -324,7 +324,7 @@ that point is in.
@node History
@chapter History
To show the repository history of your current head, type @kbd{l}. A
To show the repository history of your current head, type @kbd{l l}. A
new buffer will be shown that displays the history in a terse form.
The first paragraph of each commit message is displayed, next to a
representation of the relationships between commits.
@ -333,7 +333,7 @@ Giving a prefix argument to @kbd{l} will ask for the starting and end
point of the history. This can be used to show the commits that are
in one branch, but not in another, for example.
Typing @kbd{L} (or @kbd{C-u L}) will show the log in a more verbose
Typing @kbd{l L} (or @kbd{l C-u L}) will show the log in a more verbose
form.
Magit will show only @code{magit-log-cutoff-length} entries. @kbd{e}
@ -386,13 +386,13 @@ To grep the history press @kbd{s}.
@node Reflogs
@chapter Reflogs
You can use @kbd{h} and @kbd{H} to browse your @emph{reflog}, the
You can use @kbd{l h} and @kbd{l H} to browse your @emph{reflog}, the
local history of changes made to your repository heads. Typing
@kbd{H} will ask for a head, while @kbd{h} will show the reflog of
@kbd{H} will ask for a head, while @kbd{l h} will show the reflog of
@code{HEAD}.
The resulting buffer is just like the buffer produced by @kbd{l} and
@kbd{L} that shows the commit history.
The resulting buffer is just like the buffer produced by @kbd{l l} and
@kbd{l L} that shows the commit history.
@node Diffing
@chapter Diffing
@ -412,12 +412,12 @@ Typing @kbd{v} will apply the selected changes in reverse.
@node Tagging
@chapter Tagging
Typing @kbd{t} will make a lighweight tag. Typing @kbd{T} will make a
annotated tag. It will put you in the normal @code{*magit-log-edit}
buffer for writing commit messages, but typing @kbd{C-c C-c} in it
will make the tag instead. This is controlled by the @code{Tag} field
that will be added to the @code{*magit-log-edit*} buffer. You can
edit it, if you like.
Typing @kbd{t t} will make a lighweight tag. Typing @kbd{t T} will
make a annotated tag. It will put you in the normal
@code{*magit-log-edit} buffer for writing commit messages, but typing
@kbd{C-c C-c} in it will make the tag instead. This is controlled by
the @code{Tag} field that will be added to the @code{*magit-log-edit*}
buffer. You can edit it, if you like.
@node Resetting
@chapter Resetting
@ -455,15 +455,15 @@ using @kbd{X}.
@node Stashing
@chapter Stashing
You can create a new stash with @kbd{z}. Your stashes will be listed
You can create a new stash with @kbd{z z}. Your stashes will be listed
in the status buffer, and you can apply them with @kbd{a} and pop them
with @kbd{A}. To drop a stash, use @kbd{k}.
With a prefix argument, both @kbd{a} and @kbd{A} will attempt to
reinstate the index as well as the working tree from the stash.
Typing @kbd{Z} will create a stash just like @kbd{z}, but will leave
the changes in your working tree and index.
Typing @kbd{z Z} will create a stash just like @kbd{z z}, but will
leave the changes in your working tree and index.
You can visit and show stashes in the usual way: Typing @kbd{SPC} and
@kbd{DEL} will pop up a buffer with the description of the stash and
@ -473,7 +473,7 @@ scroll it, typing @kbd{RET} will move point into that buffer.
@chapter Branching
The current branch is indicated in the header of the status buffer.
You can switch to a different branch by typing @kbd{b}. This will
You can switch to a different branch by typing @kbd{b c}. This will
immediately checkout the branch into your working copy, so you
shouldn't have any local modifications when switching branches.
@ -481,13 +481,13 @@ If you try to switch to a remote branch, Magit will offer to create a
local tracking branch for it instead. This way, you can easily start
working on new branches that have appeared in a remote repository.
Similar to @kbd{x}, typing @kbd{b} while point is at a commit
description will offer that commit as the default to switch to.
This will result in a detached head.
Typing @kbd{b c} while point is at a commit description will offer
that commit as the default to switch to. This will result in a
detached head.
To create a new branch and switch to it immediately, type @kbd{B}.
To create a new branch and switch to it immediately, type @kbd{b B}.
Typing @kbd{V} will list the local and remote branches in a new buffer
Typing @kbd{b V} will list the local and remote branches in a new buffer
called @code{*magit-branches*} from which you can work with them. See
@ref{The branch list} for more details.
@ -504,10 +504,10 @@ Typing @kbd{k} will delete the branch in the current line, and
@kbd{C-u k} deletes it even if it hasn't been merged into the current
local branch. Deleting works for both local and remote branches.
You can merge the branch in the current line by typing @kbd{m} for a
manual merge and @kbd{M} for an automatic merge.
You can merge the branch in the current line by typing @kbd{m m} for a
manual merge and @kbd{m m} for an automatic merge.
With @kbd{RET} or @kbd{b} you can check out the branch in the current
With @kbd{RET} or @kbd{b b} you can check out the branch in the current
line.
Typing @kbd{$} shows the @code{*magit-process*} buffer which contains
@ -544,20 +544,12 @@ manual merge will apply all changes to your working tree and staging
area, but will not commit them, while a automatic merge will go ahead
and commit them immediately.
Type @kbd{m} to initiate a manual merge, and type @kbd{M} for a
automatic merge.
Type @kbd{m m} to initiate merge.
A manual merge is useful when carefully merging a new feature that you
want to review and test before even committing it. An automatic merge
is appropriate when you are on a feature branch and want to catch up
with the master, say. If you would like to squash the merge (have git
avoid creating a merge commit) then use a prefix argument with the
command (@kbd{C-U m}).
After initiating a manual merge, the header of the status buffer will
remind you that the next commit will be a merge commit (with more than
one parent). If you want to abort a manual merge, just do a hard
reset to HEAD with @kbd{X}.
After initiating a merge, the header of the status buffer might remind
you that the next commit will be a merge commit (with more than one
parent). If you want to abort a manual merge, just do a hard reset to
HEAD with @kbd{X}.
Merges can fail if the two branches you merge want to introduce
conflicting changes. In that case, the automatic merge stops before the
@ -655,20 +647,20 @@ it, like from any other diff.
@node Pushing and Pulling
@chapter Pushing and Pulling
Magit will run @code{git push} when you type @kbd{P}. If you give a
prefix argument to @kbd{P}, you will be prompted for the repository to
Magit will run @code{git push} when you type @kbd{P p}. If you give a
prefix argument to @kbd{P p}, you will be prompted for the repository to
push to. When no default remote repository has been configured yet for
the current branch, you will be prompted as well. Typing @kbd{P} will
the current branch, you will be prompted as well. Typing @kbd{P p} will
only push the current branch to the remote. In other words, it will run
@code{git push <remote> <branch>}. The branch will be created in the
remote if it doesn't exist already. The local branch will be configured
so that it pulls from the new remote branch.
Typing @kbd{f} will run @code{git remote update}. With a prefix arg,
it will prompt for the name of the remote to update. Typing @kbd{F}
will run @code{git pull} (with a prefix arg will pull with
@code{--rebase}). When you don't have a default branch configured to
be pulled into the current one, you will be asked for it.
Typing @kbd{f f} will run @code{git remote update}. With a prefix
arg, it will prompt for the name of the remote to update. Typing
@kbd{F p} will run @code{git pull}. When you don't have a default
branch configured to be pulled into the current one, you will be asked
for it.
If there is a default remote repository for the current branch, Magit
will show that repository in the status buffer header.
@ -682,7 +674,7 @@ reset your current head to one of them with @kbd{x}, for example.
When the remote branch has changes that are not in the current branch,
Magit shows them in a section called @emph{Unpulled changes}. Typing
@kbd{F} will merge them into the current branch.
@kbd{f f} will merge them into the current branch.
@node Interfacing with Subversion
@chapter Interfacing with Subversion