Make magit 2.1 the official magit version for spacemacs

This commit is contained in:
syl20bnr 2015-07-02 00:36:26 -04:00
parent f603eece3f
commit d04ed6dc25
6 changed files with 189 additions and 286 deletions

4
.gitmodules vendored
View File

@ -16,7 +16,3 @@
[submodule "spacemacs/extensions/spray"]
path = spacemacs/extensions/spray
url = https://github.com/syl20bnr/spray
[submodule "contrib/!source-control/git/extensions/magit-next"]
path = contrib/!source-control/git/extensions/magit-next
url = https://github.com/magit/magit
branch = next

View File

@ -106,6 +106,7 @@ Git commands (start with ~g~):
- Git time machine is provided by [[https://github.com/pidu/git-timemachine][git-timemachine]].
- Git last commit message per line is provided by [[https://github.com/syohex/emacs-git-messenger][git-messenger]].
** Magit
=Spacemacs= uses [[http://magit.github.io/][magit]] to manage Git repositories.
@ -115,43 +116,42 @@ To open a =status buffer=, type in a buffer of a Git repository: ~SPC g s~
~hjkl~ navigation is enabled in all Magit buffers. The default Magit keys
on ~hjkl~ (if they exist) are remapped on ~HJKL~.
Here are the often used bindings inside a =status buffer=:
Here are the often used bindings inside a =status buffer=, please note that
the following key bindings are valid in Vim editing style, in Emacs editing
style you can refer directly to the magit manual:
| Key Binding | Description |
|-------------+-----------------------------------------------------|
| ~/~ | evil-search |
| ~$~ | open =command output buffer= |
| ~c c~ | open a =commit message buffer= |
| ~b b~ | checkout a branch |
| ~b c~ | create a branch |
| ~b v~ | open the =branch manager buffer= |
| ~f f~ | fetch changes |
| ~F -r F~ | pull and rebase |
| ~h~ | go left |
| ~j~ | go down |
| ~C-j~ | goto next magit section |
| ~k~ | go up |
| ~K~ | discard changes |
| ~C-k~ | goto previous magit section |
| ~l~ | go right |
| ~L l~ | open =log buffer= |
| ~n~ | next search occurrence |
| ~C-n~ | goto next magit section |
| ~N~ | previous search occurrence _or_ SVN sub-menu |
| ~P P~ | push |
| ~C-p~ | goto previous magit section |
| ~q~ | quit |
| ~s~ | on a file or hunk in a diff: stage the file or hunk |
| ~+~ | on a hunk: increase hunk size |
| ~-~ | on a hunk: decrease hunk size |
| ~S~ | stage all |
| ~TAB~ | on a file: expand/collapse diff |
| ~u~ | on a staged file: unstage |
| ~U~ | unstage all staged files |
| ~v~ | go to =visual state= |
| ~V~ | go to =visual-line state= |
| ~C-v~ | revert item at point |
| ~z z~ | stash changes |
| Key Binding | Description |
|------------------+-----------------------------------------------------|
| ~/~ | evil-search |
| ~$~ | open =command output buffer= |
| ~c c~ | open a =commit message buffer= |
| ~b b~ | checkout a branch |
| ~b c~ | create a branch |
| ~f f~ | fetch changes |
| ~C-f -r F~ | pull and rebase |
| ~h~ | go left |
| ~j~ | go down |
| ~C-S-j~ or ~C-n~ | goto next magit section |
| ~k~ | go up |
| ~K~ | discard changes |
| ~C-S-k~ or ~C-p~ | goto previous magit section |
| ~l~ | go right |
| ~L l~ | open =log buffer= |
| ~n~ | next search occurrence |
| ~N~ | previous search occurrence _or_ SVN sub-menu |
| ~P P~ | push |
| ~q~ | quit |
| ~s~ | on a file or hunk in a diff: stage the file or hunk |
| ~+~ | on a hunk: increase hunk size |
| ~-~ | on a hunk: decrease hunk size |
| ~S~ | stage all |
| ~TAB~ | on a file: expand/collapse diff |
| ~u~ | on a staged file: unstage |
| ~U~ | unstage all staged files |
| ~v~ | go to =visual state= |
| ~V~ | go to =visual-line state= |
| ~C-v~ | revert item at point |
| ~z z~ | stash changes |
** Commit message edition buffer
@ -211,10 +211,10 @@ message.
the history of a public repository, but if you are *sure* that you are the
only one to work on a repository it is ok - i.e. in your fork).
- Add upstream remote (the parent repository you have forked):
- ~b v~ to open the =branch manager buffer=
- ~M~ to open the =remote popup=
- ~a~ to add a remote, type the name (i.e. =upstream=) and the URL
- Pull changes from upstream (the parent repository you have forked) and push:
- ~F -r C-u F~ and choose =upstream= or the name you gave to it
- ~C-f -r C-u F~ and choose =upstream= or the name you gave to it
- ~P P~ to push the commit to =origin=
** Git time machine
@ -230,3 +230,5 @@ message.
| ~p~ | show previous commit |
| ~q~ | leave micro-state and git timemachine |
| ~Y~ | copy current commit hash |
# LocalWords: unpulled

View File

@ -17,6 +17,3 @@
(defvar git-magit-status-fullscreen nil
"If non nil magit-status buffer is displayed in fullscreen.")
(defvar git-use-magit-next nil
"If non nil magit next branch will be used.")

View File

@ -1,139 +0,0 @@
;;; extensions.el --- Git Layer Extensions File for Spacemacs
;;
;; Copyright (c) 2012-2014 Sylvain Benner
;; Copyright (c) 2014-2015 Sylvain Benner & Contributors
;;
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
(setq git-post-extensions '())
(when git-use-magit-next
(setq git-post-extensions '(magit-next)))
(defun git/init-magit-next ()
(use-package magit
:if git-use-magit-next
:commands (magit-status
magit-blame-mode
magit-log
magit-commit)
:init
(progn
(add-to-list 'load-path (format "%smagit-next/lisp/"
(configuration-layer/get-layer-property
'git :ext-dir)))
(setq magit-completing-read-function 'magit-builtin-completing-read)
(add-hook 'git-commit-mode-hook 'fci-mode)
;; On Windows, we must use Git GUI to enter username and password
;; See: https://github.com/magit/magit/wiki/FAQ#windows-cannot-push-via-https
(when (eq window-system 'w32)
(setenv "GIT_ASKPASS" "git-gui--askpass"))
(defun spacemacs/magit-diff-head ()
"Execute `magit-diff' against current HEAD."
(interactive)
(magit-diff "HEAD"))
(evil-leader/set-key
"gb" 'magit-blame-mode
"gl" 'magit-log
"gL" 'magit-log-buffer-file
"gs" 'magit-status
"gd" 'spacemacs/magit-diff-head
"gC" 'magit-commit))
:config
(progn
;; mode maps
(spacemacs|evilify-map magit-mode-map)
(spacemacs|evilify-map magit-status-mode-map
:mode magit-status-mode)
(spacemacs|evilify-map magit-refs-mode-map
:mode magit-refs-mode)
(spacemacs|evilify-map magit-blame-mode-map
:mode magit-blame-mode)
(spacemacs|evilify-map magit-diff-mode-map
:mode magit-diff-mode)
(spacemacs|evilify-map magit-log-read-revs-map
:mode magit-log-read-revs)
(spacemacs|evilify-map magit-log-mode-map
:mode magit-log-mode)
(spacemacs|evilify-map magit-log-select-mode-map
:mode magit-log-select-mode)
(spacemacs|evilify-map magit-cherry-mode-map
:mode magit-cherry-mode)
(spacemacs|evilify-map magit-reflog-mode-map
:mode magit-reflog-mode)
(spacemacs|evilify-map magit-process-mode-map
:mode magit-process-mode)
(spacemacs|evilify-map git-rebase-mode-map
:mode git-rebase-mode
:bindings
"J" 'git-rebase-move-line-down
"K" 'git-rebase-move-line-up
"u" 'git-rebase-undo
"y" 'git-rebase-insert)
;; default state for additional modes
(dolist (mode '(magit-popup-mode
magit-popup-sequence-mode))
(add-to-list 'evil-emacs-state-modes mode))
(spacemacs/evilify-configure-default-state 'magit-revision-mode)
;; section maps
(spacemacs|evilify-map magit-tag-section-map)
(spacemacs|evilify-map magit-untracked-section-map)
(spacemacs|evilify-map magit-branch-section-map)
(spacemacs|evilify-map magit-remote-section-map)
(spacemacs|evilify-map magit-file-section-map)
(spacemacs|evilify-map magit-hunk-section-map)
(spacemacs|evilify-map magit-unstaged-section-map)
(spacemacs|evilify-map magit-staged-section-map)
(spacemacs|evilify-map magit-commit-section-map)
(spacemacs|evilify-map magit-module-commit-section-map)
(spacemacs|evilify-map magit-unpulled-section-map)
(spacemacs|evilify-map magit-unpushed-section-map)
(spacemacs|evilify-map magit-stashes-section-map)
(spacemacs|evilify-map magit-stash-section-map)
;; full screen magit-status
(when git-magit-status-fullscreen
(setq magit-restore-window-configuration t)
(setq magit-status-buffer-switch-function
(lambda (buffer)
(pop-to-buffer buffer)
(delete-other-windows))))
;; rebase mode
(evil-leader/set-key-for-mode 'git-rebase-mode
"mcc" 'git-rebase-server-edit
"mk" 'git-rebase-abort)
;; commit mode
(evil-leader/set-key-for-mode 'git-commit-mode
"mcc" 'git-commit-commit
"mk" 'git-commit-abort)
;; whitespace
(defun magit-toggle-whitespace ()
(interactive)
(if (member "-w" (if (derived-mode-p 'magit-diff-mode)
magit-refresh-args
magit-diff-section-arguments))
(magit-dont-ignore-whitespace)
(magit-ignore-whitespace)))
(defun magit-ignore-whitespace ()
(interactive)
(add-to-list (if (derived-mode-p 'magit-diff-mode)
'magit-refresh-args 'magit-diff-section-arguments) "-w")
(magit-refresh))
(defun magit-dont-ignore-whitespace ()
(interactive)
(setq magit-diff-options
(remove "-w"
(if (derived-mode-p 'magit-diff-mode)
magit-refresh-args
magit-diff-section-arguments))) (magit-refresh))
(define-key magit-status-mode-map (kbd "C-S-w")
'magit-toggle-whitespace))))

@ -1 +0,0 @@
Subproject commit 4bfc8690db5f865de03049ce621de25140bbc678

View File

@ -18,29 +18,19 @@
git-messenger
git-timemachine
helm-gitignore
smeargle))
(unless git-use-magit-next
(push 'magit git-packages)
;; not compatible with magit-next
(push 'magit-svn git-packages)
(push 'git-commit-mode git-packages)
(push 'git-rebase-mode git-packages)
(push 'magit-gitflow git-packages))
magit
;; not compatible with magit 2.1 at the time of release
;; magit-gitflow
;; not compatible with magit 2.1 at the time of release
;; magit-svn
smeargle
))
(defun git/init-helm-gitignore ()
(use-package helm-gitignore
:defer t
:init (evil-leader/set-key "gI" 'helm-gitignore)))
(defun git/init-git-commit-mode ()
(use-package git-commit-mode
:defer t
:config
(evil-leader/set-key-for-mode 'git-commit-mode
"mcc" 'git-commit-commit
"mk" 'git-commit-abort)))
(defun git/init-git-messenger ()
(use-package git-messenger
:defer t
@ -48,20 +38,6 @@
(evil-leader/set-key
"gm" 'git-messenger:popup-message)))
(defun git/init-git-rebase-mode ()
(use-package git-rebase-mode
:defer t
:config
(progn
(evilify git-rebase-mode git-rebase-mode-map
"J" 'git-rebase-move-line-down
"K" 'git-rebase-move-line-up
"u" 'git-rebase-undo
"y" 'git-rebase-insert)
(evil-leader/set-key-for-mode 'git-rebase-mode
"mcc" 'git-rebase-server-edit
"mk" 'git-rebase-abort))))
(defun git/init-git-timemachine ()
(use-package git-timemachine
:defer t
@ -108,15 +84,17 @@
(defun git/init-magit ()
(use-package magit
:if (null git-use-magit-next)
:defer t
:commands (magit-status
magit-blame-mode
magit-log
magit-commit)
:init
(progn
(setq magit-last-seen-setup-instructions "1.4.0"
magit-completing-read-function 'magit-ido-completing-read)
(add-to-list 'load-path (format "%smagit-next/lisp/"
(configuration-layer/get-layer-property
'git :ext-dir)))
(setq magit-completing-read-function 'magit-builtin-completing-read)
(add-hook 'git-commit-mode-hook 'fci-mode)
;; must enable auto-fill-mode again because somehow fci-mode disable it
(add-hook 'git-commit-mode-hook 'auto-fill-mode)
;; On Windows, we must use Git GUI to enter username and password
;; See: https://github.com/magit/magit/wiki/FAQ#windows-cannot-push-via-https
(when (eq window-system 'w32)
@ -130,87 +108,157 @@
(evil-leader/set-key
"gb" 'magit-blame-mode
"gl" 'magit-log
"gL" 'magit-file-log
"gL" 'magit-log-buffer-file
"gs" 'magit-status
"gd" 'spacemacs/magit-diff-head
"gC" 'magit-commit)
(evilify magit-commit-mode magit-commit-mode-map
(kbd "C-j") 'magit-goto-next-section
(kbd "C-k") 'magit-goto-previous-section
(kbd "C-n") 'magit-goto-next-section
(kbd "C-p") 'magit-goto-previous-section
(kbd "C-v") 'magit-revert-item)
(evilify magit-log-mode magit-log-mode-map
(kbd "C-j") 'magit-goto-next-section
(kbd "C-k") 'magit-goto-previous-section
(kbd "C-n") 'magit-goto-next-section
(kbd "C-p") 'magit-goto-previous-section
(kbd "C-v") 'magit-revert-item)
(evilify magit-process-mode magit-process-mode-map
(kbd "C-j") 'magit-goto-next-section
(kbd "C-k") 'magit-goto-previous-section
(kbd "C-n") 'magit-goto-next-section
(kbd "C-p") 'magit-goto-previous-section
(kbd "C-v") 'magit-revert-item)
(evilify magit-branch-manager-mode magit-branch-manager-mode-map
"K" 'magit-discard-item
"L" 'magit-key-mode-popup-logging
(kbd "C-j") 'magit-goto-next-section
(kbd "C-k") 'magit-goto-previous-section
(kbd "C-n") 'magit-goto-next-section
(kbd "C-p") 'magit-goto-previous-section
(kbd "C-v") 'magit-revert-item)
(evilify magit-status-mode magit-status-mode-map
"K" 'magit-discard-item
"L" 'magit-key-mode-popup-logging
"H" 'magit-key-mode-popup-diff-options
(kbd "C-j") 'magit-goto-next-section
(kbd "C-k") 'magit-goto-previous-section
(kbd "C-n") 'magit-goto-next-section
(kbd "C-p") 'magit-goto-previous-section
(kbd "C-v") 'magit-revert-item)
(evilify magit-diff-mode magit-diff-mode-map
"K" 'magit-discard-item
"L" 'magit-key-mode-popup-logging
"H" 'magit-key-mode-popup-diff-options
(kbd "C-j") 'magit-goto-next-section
(kbd "C-k") 'magit-goto-previous-section
(kbd "C-n") 'magit-goto-next-section
(kbd "C-p") 'magit-goto-previous-section
(kbd "C-v") 'magit-revert-item))
"gC" 'magit-commit))
:config
(progn
(spacemacs|hide-lighter magit-auto-revert-mode)
;; seems to be necessary at the time of release
(require 'git-rebase)
;; mode maps
(spacemacs|evilify-map magit-mode-map)
(spacemacs|evilify-map magit-status-mode-map
:mode magit-status-mode
:bindings
(kbd "C-S-j") 'magit-section-forward
(kbd "C-S-k") 'magit-section-backward
(kbd "C-n") 'magit-section-forward
(kbd "C-p") 'magit-section-backward)
(spacemacs|evilify-map magit-refs-mode-map
:mode magit-refs-mode
:bindings
(kbd "C-S-j") 'magit-section-forward
(kbd "C-S-k") 'magit-section-backward
(kbd "C-n") 'magit-section-forward
(kbd "C-p") 'magit-section-backward)
(spacemacs|evilify-map magit-blame-mode-map
:mode magit-blame-mode
:bindings
(kbd "C-S-j") 'magit-section-forward
(kbd "C-S-k") 'magit-section-backward
(kbd "C-n") 'magit-section-forward
(kbd "C-p") 'magit-section-backward)
(spacemacs|evilify-map magit-diff-mode-map
:mode magit-diff-mode
:bindings
(kbd "C-S-j") 'magit-section-forward
(kbd "C-S-k") 'magit-section-backward
(kbd "C-n") 'magit-section-forward
(kbd "C-p") 'magit-section-backward)
(spacemacs|evilify-map magit-log-read-revs-map
:mode magit-log-read-revs
:bindings
(kbd "C-S-j") 'magit-section-forward
(kbd "C-S-k") 'magit-section-backward
(kbd "C-n") 'magit-section-forward
(kbd "C-p") 'magit-section-backward)
(spacemacs|evilify-map magit-log-mode-map
:mode magit-log-mode
:bindings
(kbd "C-S-j") 'magit-section-forward
(kbd "C-S-k") 'magit-section-backward
(kbd "C-n") 'magit-section-forward
(kbd "C-p") 'magit-section-backward)
(spacemacs|evilify-map magit-log-select-mode-map
:mode magit-log-select-mode
:bindings
(kbd "C-S-j") 'magit-section-forward
(kbd "C-S-k") 'magit-section-backward
(kbd "C-n") 'magit-section-forward
(kbd "C-p") 'magit-section-backward)
(spacemacs|evilify-map magit-cherry-mode-map
:mode magit-cherry-mode
:bindings
(kbd "C-S-j") 'magit-section-forward
(kbd "C-S-k") 'magit-section-backward
(kbd "C-n") 'magit-section-forward
(kbd "C-p") 'magit-section-backward)
(spacemacs|evilify-map magit-reflog-mode-map
:mode magit-reflog-mode
:bindings
(kbd "C-S-j") 'magit-section-forward
(kbd "C-S-k") 'magit-section-backward
(kbd "C-n") 'magit-section-forward
(kbd "C-p") 'magit-section-backward)
(spacemacs|evilify-map magit-process-mode-map
:mode magit-process-mode
:bindings
(kbd "C-S-j") 'magit-section-forward
(kbd "C-S-k") 'magit-section-backward
(kbd "C-n") 'magit-section-forward
(kbd "C-p") 'magit-section-backward)
(spacemacs|evilify-map git-rebase-mode-map
:mode git-rebase-mode
:bindings
(kbd "C-S-j") 'magit-section-forward
(kbd "C-S-k") 'magit-section-backward
(kbd "C-n") 'magit-section-forward
(kbd "C-p") 'magit-section-backward
"J" 'git-rebase-move-line-down
"K" 'git-rebase-move-line-up
"u" 'git-rebase-undo
"y" 'git-rebase-insert)
;; default state for additional modes
(dolist (mode '(magit-popup-mode
magit-popup-sequence-mode))
(add-to-list 'evil-emacs-state-modes mode))
(spacemacs/evilify-configure-default-state 'magit-revision-mode)
;; section maps
(spacemacs|evilify-map magit-tag-section-map)
(spacemacs|evilify-map magit-untracked-section-map)
(spacemacs|evilify-map magit-branch-section-map)
(spacemacs|evilify-map magit-remote-section-map)
(spacemacs|evilify-map magit-file-section-map)
(spacemacs|evilify-map magit-hunk-section-map)
(spacemacs|evilify-map magit-unstaged-section-map)
(spacemacs|evilify-map magit-staged-section-map)
(spacemacs|evilify-map magit-commit-section-map)
(spacemacs|evilify-map magit-module-commit-section-map)
(spacemacs|evilify-map magit-unpulled-section-map)
(spacemacs|evilify-map magit-unpushed-section-map)
(spacemacs|evilify-map magit-stashes-section-map)
(spacemacs|evilify-map magit-stash-section-map)
;; full screen magit-status
(when git-magit-status-fullscreen
(defadvice magit-status (around magit-fullscreen activate)
(window-configuration-to-register :magit-fullscreen)
ad-do-it
(delete-other-windows))
(setq magit-restore-window-configuration t)
(setq magit-status-buffer-switch-function
(lambda (buffer)
(pop-to-buffer buffer)
(delete-other-windows))))
(defun magit-quit-session ()
"Restores the previous window configuration and kills the magit buffer"
(interactive)
(kill-buffer)
(jump-to-register :magit-fullscreen))
(define-key magit-status-mode-map (kbd "q") 'magit-quit-session))
;; rebase mode
(evil-leader/set-key-for-mode 'git-rebase-mode
"mcc" 'git-rebase-server-edit
"mk" 'git-rebase-abort)
;; commit mode
(evil-leader/set-key-for-mode 'git-commit-mode
"mcc" 'git-commit-commit
"mk" 'git-commit-abort)
;; whitespace
(defun magit-toggle-whitespace ()
(interactive)
(if (member "-w" magit-diff-options)
(if (member "-w" (if (derived-mode-p 'magit-diff-mode)
magit-refresh-args
magit-diff-section-arguments))
(magit-dont-ignore-whitespace)
(magit-ignore-whitespace)))
(defun magit-ignore-whitespace ()
(interactive)
(add-to-list 'magit-diff-options "-w")
(add-to-list (if (derived-mode-p 'magit-diff-mode)
'magit-refresh-args 'magit-diff-section-arguments) "-w")
(magit-refresh))
(defun magit-dont-ignore-whitespace ()
(interactive)
(setq magit-diff-options (remove "-w" magit-diff-options))
(magit-refresh))
(define-key magit-status-mode-map (kbd "W") 'magit-toggle-whitespace))))
(setq magit-diff-options
(remove "-w"
(if (derived-mode-p 'magit-diff-mode)
magit-refresh-args
magit-diff-section-arguments))) (magit-refresh))
(define-key magit-status-mode-map (kbd "C-S-w")
'magit-toggle-whitespace))))
(defun git/init-magit-gitflow ()
(use-package magit-gitflow