Commits

Anonymous committed 67a7838

fixup magit

Comments (0)

Files changed (4)

+magit-0.8.2

.emacs.d/magit/etc/emacs/site-start.d/50magit.el

-;;; Autoloads for magit
-
-(autoload 'magit-status "magit" nil t)

.emacs.d/magit/share/emacs/site-lisp/magit.el

-;;; magit.el -- control Git from Emacs.
-
-;; Copyright (C) 2008 Alex Ott.
-;; Copyright (C) 2008, 2009, 2010 Alexey Voinov.
-;; Copyright (C) 2010 Ben Walton.
-;; Copyright (C) 2008 Daniel Farina.
-;; Copyright (C) 2010 David Abrahams.
-;; Copyright (C) 2009 David Wallin.
-;; Copyright (C) 2009, 2010 Hannu Koivisto.
-;; Copyright (C) 2009 Ian Eure.
-;; Copyright (C) 2009 Jesse Alama.
-;; Copyright (C) 2009 John Wiegley.
-;; Copyright (C) 2010 Leo.
-;; Copyright (C) 2008, 2009 Marcin Bachry.
-;; Copyright (C) 2008, 2009 Marius Vollmer.
-;; Copyright (C) 2010 Mark Hepburn.
-;; Copyright (C) 2010 Moritz Bunkus.
-;; Copyright (C) 2010 Nathan Weizenbaum.
-;; Copyright (C) 2009 Pavel Holejsovsky.
-;; Copyright (C) 2009, 2010 Phil Jackson.
-;; Copyright (C) 2010 Ramkumar Ramachandra.
-;; Copyright (C) 2009 René Stadler.
-;; Copyright (C) 2010 Roger Crew.
-;; Copyright (C) 2009, 2010 Rémi Vanicat.
-;; Copyright (C) 2009 Steve Purcell.
-;; Copyright (C) 2010 Ævar Arnfjörð Bjarmason.
-;; Copyright (C) 2010 Óscar Fuentes.
-
-;; Author: Marius Vollmer <marius.vollmer@nokia.com>
-;; Maintainer: Phil Jackson <phil@shellarchive.co.uk>
-;; Version: 0.8.2
-;; Keywords: tools
-
-;;
-;; Magit is free software; you can redistribute it and/or modify it
-;; under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
-;;
-;; Magit is distributed in the hope that it will be useful, but WITHOUT
-;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-;; or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
-;; License for more details.
-;;
-;; You should have received a copy of the GNU General Public License
-;; along with Magit.  If not, see <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-
-;; Invoking the magit-status function will show a buffer with the
-;; status of the current git repository and its working tree.  That
-;; buffer offers key bindings for manipulating the status in simple
-;; ways.
-;;
-;; The status buffer mainly shows the difference between the working
-;; tree and the index, and the difference between the index and the
-;; current HEAD.  You can add individual hunks from the working tree
-;; to the index, and you can commit the index.
-;;
-;; See the Magit User Manual for more information.
-
-;;; Code:
-
-(eval-when-compile (require 'cl))
-(require 'log-edit)
-(require 'easymenu)
-(require 'diff-mode)
-
-;;; Code:
-(defgroup magit nil
-  "Controlling Git from Emacs."
-  :prefix "magit-"
-  :group 'tools)
-
-(defcustom magit-git-executable "git"
-  "The name of the Git executable."
-  :group 'magit
-  :type 'string)
-
-(defcustom magit-git-standard-options '("--no-pager")
-  "Standard options when running Git."
-  :group 'magit
-  :type '(repeat string))
-
-(defcustom magit-repo-dirs nil
-  "Directories containing Git repositories.
-Magit will look into these directories for Git repositories and
-offer them as choices for `magit-status'."
-  :group 'magit
-  :type '(repeat string))
-
-(defcustom magit-repo-dirs-depth 3
-  "The maximum depth to look for Git repos.
-When looking for a Git repository below the directories in `magit-repo-dirs',
-Magit will only descend this many levels deep."
-  :group 'magit
-  :type 'integer)
-
-(defcustom magit-save-some-buffers t
-  "Non-nil means that \\[magit-status] will save modified buffers before running.
-Setting this to t will ask which buffers to save, setting it to 'dontask will
-save all modified buffers without asking."
-  :group 'magit
-  :type '(choice (const :tag "Never" nil)
-		 (const :tag "Ask" t)
-		 (const :tag "Save without asking" dontask)))
-
-(defcustom magit-commit-all-when-nothing-staged 'ask
-  "Determines what \\[magit-log-edit] does when nothing is staged.
-Setting this to nil will make it do nothing, setting it to t will
-arrange things so that the actual commit command will use the \"--all\" option,
-setting it to 'ask will first ask for confirmation whether to do this,
-and setting it to 'ask-stage will cause all changes to be staged,
-after a confirmation."
-  :group 'magit
-  :type '(choice (const :tag "No" nil)
-		 (const :tag "Always" t)
-		 (const :tag "Ask" ask)
-		 (const :tag "Ask to stage everything" ask-stage)))
-
-(defcustom magit-commit-signoff nil
-  "When performing git commit adds --signoff."
-  :group 'magit
-  :type 'boolean)
-
-(defcustom magit-log-cutoff-length 100
-  "The maximum number of commits to show in the log and whazzup buffers."
-  :group 'magit
-  :type 'integer)
-
-(defcustom magit-log-infinite-length 99999
-  "Number of log used to show as maximum for `magit-log-cutoff-length'."
-  :group 'magit
-  :type 'integer)
-
-(defcustom magit-process-popup-time -1
-  "Popup the process buffer if a command takes longer than this many seconds."
-  :group 'magit
-  :type '(choice (const :tag "Never" -1)
-		 (const :tag "Immediately" 0)
-		 (integer :tag "After this many seconds")))
-
-(defcustom magit-revert-item-confirm nil
-  "Require acknowledgment before reverting an item."
-  :group 'magit
-  :type 'boolean)
-
-(defcustom magit-log-edit-confirm-cancellation nil
-  "Require acknowledgment before canceling the log edit buffer."
-  :group 'magit
-  :type 'boolean)
-
-(defcustom magit-remote-ref-format 'branch-then-remote
-  "What format to use for autocompleting refs, in pariticular for remotes.
-
-Autocompletion is used by functions like `magit-checkout',
-`magit-interactive-rebase' and others which offer branch name
-completion.
-
-The value 'name-then-remote means remotes will be of the
-form \"name (remote)\", while the value 'remote-slash-name
-means that they'll be of the form \"remote/name\". I.e. something that's
-listed as \"remotes/upstream/next\" by \"git branch -l -a\"
-will be \"upstream/next\"."
-  :group 'magit
-  :type '(choice (const :tag "name (remote)" branch-then-remote)
-                 (const :tag "remote/name" remote-slash-branch)))
-
-(defcustom magit-process-connection-type (not (eq system-type 'cygwin))
-  "Connection type used for the git process.
-
-nil mean pipe, it is usually faster and more efficient, and work on cygwin.
-t mean pty, it enable magit to prompt for passphrase when needed."
-  :group 'magit
-  :type 'boolean)
-
-(defface magit-header
-  '((t))
-  "Face for generic header lines.
-
-Many Magit faces inherit from this one by default."
-  :group 'magit)
-
-(defface magit-section-title
-  '((t :weight bold :inherit magit-header))
-  "Face for section titles."
-  :group 'magit)
-
-(defface magit-branch
-  '((t :weight bold :inherit magit-header))
-  "Face for the current branch."
-  :group 'magit)
-
-(defface magit-diff-file-header
-  '((t :inherit magit-header))
-  "Face for diff file header lines."
-  :group 'magit)
-
-(defface magit-diff-hunk-header
-  '((t :slant italic :inherit magit-header))
-  "Face for diff hunk header lines."
-  :group 'magit)
-
-(defface magit-diff-add
-  '((((class color) (background light))
-     :foreground "blue1")
-    (((class color) (background dark))
-     :foreground "white"))
-  "Face for lines in a diff that have been added."
-  :group 'magit)
-
-(defface magit-diff-none
-  '((t))
-  "Face for lines in a diff that are unchanged."
-  :group 'magit)
-
-(defface magit-diff-del
-  '((((class color) (background light))
-     :foreground "red")
-    (((class color) (background dark))
-     :foreground "OrangeRed"))
-  "Face for lines in a diff that have been deleted."
-  :group 'magit)
-
-(defface magit-log-graph
-  '((((class color) (background light))
-     :foreground "grey11")
-    (((class color) (background dark))
-     :foreground "grey30"))
-  "Face for the graph element of the log output."
-  :group 'magit)
-
-(defface magit-log-sha1
-  '((((class color) (background light))
-     :foreground "firebrick")
-    (((class color) (background dark))
-     :foreground "tomato"))
-  "Face for the sha1 element of the log output."
-  :group 'magit)
-
-(defface magit-log-message
-  '((t))
-  "Face for the message element of the log output."
-  :group 'magit)
-
-(defface magit-item-highlight
-  '((((class color) (background light))
-     :background "gray95")
-    (((class color) (background dark))
-     :background "dim gray"))
-  "Face for highlighting the current item."
-  :group 'magit)
-
-(defface magit-item-mark
-  '((((class color) (background light))
-     :foreground "red")
-    (((class color) (background dark))
-     :foreground "orange"))
-  "Face for highlighting marked item."
-  :group 'magit)
-
-(defface magit-log-tag-label
-  '((((class color) (background light))
-     :background "LightGoldenRod")
-    (((class color) (background dark))
-     :background "DarkGoldenRod"))
-  "Face for git tag labels shown in log buffer."
-  :group 'magit)
-
-(defface magit-log-head-label-bisect-good
-  '((((class color) (background light))
-     :box t
-     :background "light green"
-     :foreground "dark olive green")
-    (((class color) (background dark))
-     :box t
-     :background "light green"
-     :foreground "dark olive green"))
-  "Face for good bisect refs"
-  :group 'magit)
-
-(defface magit-log-head-label-bisect-bad
-  '((((class color) (background light))
-     :box t
-     :background "IndianRed1"
-     :foreground "IndianRed4")
-    (((class color) (background dark))
-     :box t
-     :background "IndianRed1"
-     :foreground "IndianRed4"))
-  "Face for bad bisect refs"
-  :group 'magit)
-
-(defface magit-log-head-label-remote
-  '((((class color) (background light))
-     :box t
-     :background "Grey85"
-     :foreground "OliveDrab4")
-    (((class color) (background dark))
-     :box t
-     :background "Grey11"
-     :foreground "DarkSeaGreen2"))
-  "Face for remote branch head labels shown in log buffer."
-  :group 'magit)
-
-(defface magit-log-head-label-tags
-  '((((class color) (background light))
-     :box t
-     :background "LemonChiffon1"
-     :foreground "goldenrod4")
-    (((class color) (background dark))
-     :box t
-     :background "LemonChiffon1"
-     :foreground "goldenrod4"))
-  "Face for tag labels shown in log buffer."
-  :group 'magit)
-
-(defvar magit-completing-read 'completing-read
-  "Function to be called when requesting input from the user.")
-
-(defvar magit-read-rev-history nil
-  "The history of inputs to `magit-read-rev'.")
-
-(defvar magit-omit-untracked-dir-contents nil
-  "When non-nil magit will only list an untracked directory, not its contents.")
-
-(defface magit-log-head-label-local
-  '((((class color) (background light))
-     :box t
-     :background "Grey85"
-     :foreground "LightSkyBlue4")
-    (((class color) (background dark))
-     :box t
-     :background "Grey13"
-     :foreground "LightSkyBlue1"))
-  "Face for local branch head labels shown in log buffer."
-  :group 'magit)
-
-;;; Macros
-
-(defmacro magit-with-refresh (&rest body)
-  (declare (indent 0))
-  `(magit-refresh-wrapper (lambda () ,@body)))
-
-(eval-when-compile
-  (when (< emacs-major-version 23)
-    (defvar line-move-visual nil)))
-
-;;; Compatibilities
-
-(if (functionp 'start-file-process)
-    (defalias 'magit-start-process 'start-file-process)
-    (defalias 'magit-start-process 'start-process))
-
-;;; Utilities
-
-(defvar magit-submode nil)
-(make-variable-buffer-local 'magit-submode)
-(put 'magit-submode 'permanent-local t)
-
-(defun magit-use-region-p ()
-  (if (fboundp 'use-region-p)
-      (use-region-p)
-    (and transient-mark-mode mark-active)))
-
-(defun magit-goto-line (line)
-  "Like `goto-line' but doesn't set the mark."
-  (save-restriction
-    (widen)
-    (goto-char 1)
-    (forward-line (1- line))))
-
-(defun magit-trim-line (str)
-  (if (string= str "")
-      nil
-    (if (equal (elt str (- (length str) 1)) ?\n)
-	(substring str 0 (- (length str) 1))
-      str)))
-
-(defun magit-split-lines (str)
-  (if (string= str "")
-      nil
-    (let ((lines (nreverse (split-string str "\n"))))
-      (if (string= (car lines) "")
-	  (setq lines (cdr lines)))
-      (nreverse lines))))
-
-(defun magit-git-insert (args)
-  (apply #'process-file
-	 magit-git-executable
-	 nil (list t nil) nil
-	 (append magit-git-standard-options args)))
-
-(defun magit-git-output (args)
-  (with-output-to-string
-    (with-current-buffer
-        standard-output
-      (magit-git-insert args))))
-
-(defun magit-git-string (&rest args)
-  (magit-trim-line (magit-git-output args)))
-
-(defun magit-git-lines (&rest args)
-  (magit-split-lines (magit-git-output args)))
-
-(defun magit-git-exit-code (&rest args)
-  (apply #'process-file magit-git-executable nil nil nil
-	 (append magit-git-standard-options args)))
-
-(defun magit-file-lines (file)
-  (when (file-exists-p file)
-    (with-temp-buffer
-      (insert-file-contents file)
-      (let ((rev (nreverse (split-string (buffer-string) "\n"))))
-	(nreverse (if (equal (car rev) "")
-		      (cdr rev)
-		    rev))))))
-
-(defun magit-write-file-lines (file lines)
-  (with-temp-buffer
-    (dolist (l lines)
-      (insert l "\n"))
-    (write-file file)))
-
-(defun magit-concat-with-delim (delim seqs)
-  (cond ((null seqs)
-	 nil)
-	((null (cdr seqs))
-	 (car seqs))
-	(t
-	 (concat (car seqs) delim (magit-concat-with-delim delim (cdr seqs))))))
-
-(defun magit-get (&rest keys)
-  (magit-git-string "config" (magit-concat-with-delim "." keys)))
-
-(defun magit-get-all (&rest keys)
-  (magit-git-lines "config" "--get-all" (magit-concat-with-delim "." keys)))
-
-(defun magit-set (val &rest keys)
-  (if val
-      (magit-git-string "config" (magit-concat-with-delim "." keys) val)
-    (magit-git-string "config" "--unset" (magit-concat-with-delim "." keys))))
-
-(defun magit-remove-conflicts (alist)
-  (let ((dict (make-hash-table :test 'equal))
-	(result nil))
-    (dolist (a alist)
-      (puthash (car a) (cons (cdr a) (gethash (car a) dict))
-	       dict))
-    (maphash (lambda (key value)
-	       (if (= (length value) 1)
-		   (push (cons key (car value)) result)
-		 (let ((sub (magit-remove-conflicts
-			     (mapcar (lambda (entry)
-				       (let ((dir (directory-file-name
-						   (substring entry 0 (- (length key))))))
-					 (cons (concat (file-name-nondirectory dir) "/" key)
-					       entry)))
-				     value))))
-		   (setq result (append result sub)))))
-	     dict)
-    result))
-
-(defun magit-git-repo-p (dir)
-  (file-exists-p (expand-file-name ".git" dir)))
-
-(defun magit-list-repos* (dir level)
-  (if (magit-git-repo-p dir)
-      (list dir)
-    (apply #'append
-	   (mapcar (lambda (entry)
-		     (unless (or (string= (substring entry -3) "/..")
-				 (string= (substring entry -2) "/."))
-		       (magit-list-repos* entry (+ level 1))))
-		   (and (file-directory-p dir)
-			(< level magit-repo-dirs-depth)
-			(directory-files dir t nil t))))))
-
-(defun magit-list-repos (dirs)
-  (magit-remove-conflicts
-   (apply #'append
-	  (mapcar (lambda (dir)
-		    (mapcar #'(lambda (repo)
-				(cons (file-name-nondirectory repo)
-				      repo))
-			    (magit-list-repos* dir 0)))
-		  dirs))))
-
-(defun magit-get-top-dir (cwd)
-  (let ((cwd (expand-file-name (file-truename cwd))))
-    (when (file-directory-p cwd)
-      (let* ((default-directory cwd)
-             (cdup (magit-git-string "rev-parse" "--show-cdup")))
-        (when cdup
-          (file-name-as-directory (expand-file-name cdup cwd)))))))
-
-(defun magit-get-ref (ref)
-  (magit-git-string "symbolic-ref" "-q" ref))
-
-(defun magit-get-current-branch ()
-  (let* ((head (magit-get-ref "HEAD"))
-	 (pos (and head (string-match "^refs/heads/" head))))
-    (if pos
-	(substring head 11)
-      nil)))
-
-(defun magit-get-current-remote ()
-  "Return the name of the remote for the current branch.
-If there is no current branch, or no remote for that branch,
-return nil."
-  (let* ((branch (magit-get-current-branch))
-         (remote (and branch (magit-get "branch" branch "remote"))))
-    (if (string= remote "") nil remote)))
-
-(defun magit-ref-exists-p (ref)
-  (= (magit-git-exit-code "show-ref" "--verify" ref) 0))
-
-(defun magit-read-top-dir (rawp)
-  (if (and (not rawp) magit-repo-dirs)
-      (let* ((repos (magit-list-repos magit-repo-dirs))
-	     (reply (funcall magit-completing-read "Git repository: "
-				     (magit-list-repos magit-repo-dirs))))
-	(file-name-as-directory
-	 (cdr (assoc reply repos))))
-    (file-name-as-directory
-     (read-directory-name "Git repository: "
-			  (or (magit-get-top-dir default-directory)
-			      default-directory)))))
-
-(defun magit-rev-parse (ref)
-  "Return the SHA hash for REF."
-  (magit-git-string "rev-parse" ref))
-
-(defun magit-ref-ambiguous-p (ref)
-  "Return whether or not REF is ambiguous."
-  ;; If REF is ambiguous, rev-parse just prints errors,
-  ;; so magit-git-string returns nil.
-  (not (magit-git-string "rev-parse" "--abbrev-ref" ref)))
-
-(defun magit-name-rev (rev)
-  "Return a human-readable name for REV.
-Unlike git name-rev, this will remove tags/ and remotes/ prefixes
-if that can be done unambiguously.  In addition, it will filter
-out revs involving HEAD."
-  (when rev
-    (let ((name (magit-git-string "name-rev" "--no-undefined" "--name-only" rev)))
-      ;; There doesn't seem to be a way of filtering HEAD out from name-rev,
-      ;; so we have to do it manually.
-      ;; HEAD-based names are too transient to allow.
-      (when (string-match "^\\(.*\\<HEAD\\)\\([~^].*\\|$\\)" name)
-        (let ((head-ref (match-string 1 name))
-              (modifier (match-string 2 name)))
-          ;; Sometimes when name-rev gives a HEAD-based name,
-          ;; rev-parse will give an actual branch or remote name.
-          (setq name (concat (magit-git-string "rev-parse" "--abbrev-ref" head-ref)
-                             modifier))
-          ;; If rev-parse doesn't give us what we want, just use the SHA.
-          (when (or (null name) (string-match-p "\\<HEAD\\>" name))
-            (setq name (magit-rev-parse rev)))))
-      (setq rev (or name rev))
-      (when (string-match "^\\(?:tags\\|remotes\\)/\\(.*\\)" rev)
-        (let ((plain-name (match-string 1 rev)))
-          (unless (magit-ref-ambiguous-p plain-name)
-            (setq rev plain-name))))
-      rev)))
-
-(defun magit-put-line-property (prop val)
-  (put-text-property (line-beginning-position) (line-beginning-position 2)
-		     prop val))
-
-(defun magit-format-commit (commit format)
-  (magit-git-string "log" "--max-count=1"
-		    (concat "--pretty=format:" format)
-		    commit))
-
-(defun magit-current-line ()
-  (buffer-substring-no-properties (line-beginning-position)
-				  (line-end-position)))
-
-(defun magit-insert-region (beg end buf)
-  (let ((text (buffer-substring-no-properties beg end)))
-    (with-current-buffer buf
-      (insert text))))
-
-(defun magit-insert-current-line (buf)
-  (let ((text (buffer-substring-no-properties
-	       (line-beginning-position) (line-beginning-position 2))))
-    (with-current-buffer buf
-      (insert text))))
-
-(defun magit-file-uptodate-p (file)
-  (eq (magit-git-exit-code "diff" "--quiet" "--" file) 0))
-
-(defun magit-anything-staged-p ()
-  (not (eq (magit-git-exit-code "diff" "--quiet" "--cached") 0)))
-
-(defun magit-everything-clean-p ()
-  (and (not (magit-anything-staged-p))
-       (eq (magit-git-exit-code "diff" "--quiet") 0)))
-
-(defun magit-commit-parents (commit)
-  (cdr (split-string (magit-git-string "rev-list" "-1" "--parents" commit))))
-
-;; XXX - let the user choose the parent
-
-(defun magit-choose-parent-id (commit op)
-  (let* ((parents (magit-commit-parents commit)))
-    (if (> (length parents) 1)
-	(error "Can't %s merge commits" op)
-      nil)))
-
-;;; Revisions and ranges
-
-(defun magit-list-interesting-refs ()
-  (let ((refs ()))
-    (dolist (line (magit-git-lines "show-ref"))
-      (if (string-match "[^ ]+ +\\(.*\\)" line)
-	  (let ((ref (match-string 1 line)))
-	    (cond ((string-match "refs/heads/\\(.*\\)" ref)
-		   (let ((branch (match-string 1 ref)))
-		     (push (cons branch branch) refs)))
-		  ((string-match "refs/tags/\\(.*\\)" ref)
-		   (push (cons (format
-                                (if (eq magit-remote-ref-format 'branch-then-remote)
-                                    "%s (tag)" "%s")
-                                (match-string 1 ref))
-                               ref)
-			 refs))
-		  ((string-match "refs/remotes/\\([^/]+\\)/\\(.+\\)" ref)
-		   (push (cons (if (eq magit-remote-ref-format 'branch-then-remote)
-                                   (format "%s (%s)"
-                                           (match-string 2 ref)
-                                           (match-string 1 ref))
-                                 (format "%s/%s"
-				       (match-string 1 ref)
-				       (match-string 2 ref)))
-			       ref)
-			 refs))))))
-    refs))
-
-(defun magit-read-rev (prompt &optional def)
-  (let* ((prompt (if def
-		     (format "%s (default %s): " prompt def)
-		   (format "%s: " prompt)))
-	 (interesting-refs (magit-list-interesting-refs))
-	 (reply (funcall magit-completing-read prompt interesting-refs
-				 nil nil nil 'magit-read-rev-history def))
-	 (rev (or (cdr (assoc reply interesting-refs)) reply)))
-    (if (string= rev "")
-	nil
-      rev)))
-
-(defun magit-read-rev-range (op &optional def-beg def-end)
-  (let ((beg (magit-read-rev (format "%s start" op)
-			     def-beg)))
-    (if (not beg)
-	nil
-      (let ((end (magit-read-rev (format "%s end" op) def-end)))
-	(cons beg end)))))
-
-(defun magit-rev-to-git (rev)
-  (or rev
-      (error "No revision specified"))
-  (if (string= rev ".")
-      (magit-marked-commit)
-    rev))
-
-(defun magit-rev-range-to-git (range)
-  (or range
-      (error "No revision range specified"))
-  (if (stringp range)
-      range
-    (if (cdr range)
-	(format "%s..%s"
-		(magit-rev-to-git (car range))
-		(magit-rev-to-git (cdr range)))
-      (format "%s" (magit-rev-to-git (car range))))))
-
-(defun magit-rev-describe (rev)
-  (or rev
-      (error "No revision specified"))
-  (if (string= rev ".")
-      "mark"
-    (magit-name-rev rev)))
-
-(defun magit-rev-range-describe (range things)
-  (or range
-      (error "No revision range specified"))
-  (if (stringp range)
-      (format "%s in %s" things range)
-    (if (cdr range)
-	(format "%s from %s to %s" things
-		(magit-rev-describe (car range))
-		(magit-rev-describe (cdr range)))
-      (format "%s at %s" things (magit-rev-describe (car range))))))
-
-(defun magit-default-rev ()
-  (or (magit-name-rev (magit-commit-at-point t))
-      (let ((branch (magit-guess-branch)))
-	(if branch
-	    (if (string-match "^refs/\\(.*\\)" branch)
-		(match-string 1 branch)
-		branch)))))
-
-(defun magit-read-remote (&optional prompt def)
-  "Read the name of a remote.
-PROMPT is used as the prompt, and defaults to \"Remote\".
-DEF is the default value, and defaults to the value of `magit-get-current-branch'."
-  (let* ((prompt (or prompt "Remote"))
-         (def (or def (magit-get-current-remote)))
-         (prompt (if def
-		     (format "%s (default %s): " prompt def)
-		   (format "%s: " prompt)))
-	 (remotes (magit-git-lines "remote"))
-	 (reply (funcall magit-completing-read prompt remotes
-				 nil nil nil nil def)))
-    (if (string= reply "") nil reply)))
-
-;;; Sections
-
-;; A buffer in magit-mode is organized into hierarchical sections.
-;; These sections are used for navigation and for hiding parts of the
-;; buffer.
-;;
-;; Most sections also represent the objects that Magit works with,
-;; such as files, diffs, hunks, commits, etc.  The 'type' of a section
-;; identifies what kind of object it represents (if any), and the
-;; parent and grand-parent, etc provide the context.
-
-(defstruct magit-section
-  parent title beginning end children hidden type info
-  needs-refresh-on-show)
-
-(defvar magit-top-section nil
-  "The top section of the current buffer.")
-(make-variable-buffer-local 'magit-top-section)
-(put 'magit-top-section 'permanent-local t)
-
-(defvar magit-old-top-section nil)
-
-(defvar magit-section-hidden-default nil)
-
-(defun magit-new-section (title type)
-  "Create a new section with title TITLE and type TYPE in current buffer.
-
-If not `magit-top-section' exist, the new section will be the new top-section
-otherwise, the new-section will be a child of the current top-section.
-
-If TYPE is nil, the section won't be highlighted."
-  (let* ((s (make-magit-section :parent magit-top-section
-				:title title
-				:type type
-				:hidden magit-section-hidden-default))
-	 (old (and magit-old-top-section
-		   (magit-find-section (magit-section-path s)
-				       magit-old-top-section))))
-    (if magit-top-section
-	(push s (magit-section-children magit-top-section))
-	(setq magit-top-section s))
-    (if old
-	(setf (magit-section-hidden s) (magit-section-hidden old)))
-    s))
-
-(defun magit-cancel-section (section)
-  "Delete the section SECTION."
-  (delete-region (magit-section-beginning section)
-		 (magit-section-end section))
-  (let ((parent (magit-section-parent section)))
-    (if parent
-	(setf (magit-section-children parent)
-	      (delq section (magit-section-children parent)))
-	(setq magit-top-section nil))))
-
-(defmacro magit-with-section (title type &rest body)
-  "Create a new section of title TITLE and type TYPE and evaluate BODY there.
-
-Sections create into BODY will be child of the new section.
-BODY must leave point at the end of the created section.
-
-If TYPE is nil, the section won't be highlighted."
-  (declare (indent 2))
-  (let ((s (make-symbol "*section*")))
-    `(let* ((,s (magit-new-section ,title ,type))
-	    (magit-top-section ,s))
-       (setf (magit-section-beginning ,s) (point))
-       ,@body
-       (setf (magit-section-end ,s) (point))
-       (setf (magit-section-children ,s)
-	     (nreverse (magit-section-children ,s)))
-       ,s)))
-
-(defun magit-set-section-info (info &optional section)
-  (setf (magit-section-info (or section magit-top-section)) info))
-
-(defun magit-set-section-needs-refresh-on-show (flag &optional section)
-  (setf (magit-section-needs-refresh-on-show
-	 (or section magit-top-section))
-	flag))
-
-(defmacro magit-create-buffer-sections (&rest body)
-  "Empty current buffer of text and magit's section, and then evaluate BODY."
-  (declare (indent 0))
-  `(let ((inhibit-read-only t))
-     (erase-buffer)
-     (let ((magit-old-top-section magit-top-section))
-       (setq magit-top-section nil)
-       ,@body
-       (when (null magit-top-section)
-	 (magit-with-section 'top nil
-	   (insert "(empty)\n")))
-       (magit-propertize-section magit-top-section)
-       (magit-section-set-hidden magit-top-section
-				 (magit-section-hidden magit-top-section)))))
-
-(defun magit-propertize-section (section)
-  "Add text-property needed for SECTION."
-  (put-text-property (magit-section-beginning section)
-		     (magit-section-end section)
-		     'magit-section section)
-  (dolist (s (magit-section-children section))
-    (magit-propertize-section s)))
-
-(defun magit-find-section (path top)
-  "Find the section at the path PATH in subsection of section TOP."
-  (if (null path)
-      top
-    (let ((secs (magit-section-children top)))
-      (while (and secs (not (equal (car path)
-				   (magit-section-title (car secs)))))
-	(setq secs (cdr secs)))
-      (and (car secs)
-	   (magit-find-section (cdr path) (car secs))))))
-
-(defun magit-section-path (section)
-  "Return the path of SECTION."
-  (if (not (magit-section-parent section))
-      '()
-    (append (magit-section-path (magit-section-parent section))
-	    (list (magit-section-title section)))))
-
-;; Dead code:
-(defun magit-find-section-at (pos secs)
-  "Return the section at POS in SECS."
-  ;; Could use the text-property
-  (while (and secs
-	      (not (and (<= (magit-section-beginning (car secs)) pos)
-			(<  pos (magit-section-end (car secs))))))
-    (setq secs (cdr secs)))
-  (if secs
-      (or (magit-find-section-at pos (magit-section-children (car secs)))
-	  (car secs))
-    nil))
-
-(defun magit-find-section-after (pos secs)
-  "Find the first section that begins after POS in the list SECS."
-  (while (and secs
-	      (not (> (magit-section-beginning (car secs)) pos)))
-    (setq secs (cdr secs)))
-  (car secs))
-
-(defun magit-find-section-before (pos secs)
-  "Find the last section that begins before POS in the list SECS."
-  (let ((prev nil))
-    (while (and secs
-		(not (> (magit-section-beginning (car secs)) pos)))
-      (setq prev (car secs))
-      (setq secs (cdr secs)))
-    prev))
-
-(defun magit-current-section ()
-  "Return the magit section at point."
-  (or (get-text-property (point) 'magit-section)
-      magit-top-section))
-
-(defun magit-insert-section (section-title-and-type
-			     buffer-title washer cmd &rest args)
-  "Run CMD and put its result in a new section.
-
-SECTION-TITLE-AND-TYPE is either a string that is the title of the section
-or (TITLE . TYPE) where TITLE is the title of the section and TYPE is its type.
-
-If there is no type, or if type is nil, the section won't be highlighted.
-
-BUFFER-TITLE is the inserted title of the section
-
-WASHER is a function that will be run after CMD.
-The buffer will be narrowed to the inserted text.
-It should add sectioning as needed for magit interaction
-
-CMD is an external command that will be run with ARGS as arguments"
-  (let* ((body-beg nil)
-	 (section-title (if (consp section-title-and-type)
-			    (car section-title-and-type)
-			  section-title-and-type))
-	 (section-type (if (consp section-title-and-type)
-			   (cdr section-title-and-type)
-			 nil))
-	 (section
-	  (magit-with-section section-title section-type
-	    (if buffer-title
-		(insert (propertize buffer-title 'face 'magit-section-title)
-			"\n"))
-	    (setq body-beg (point))
-	    (apply 'process-file cmd nil t nil args)
-	    (if (not (eq (char-before) ?\n))
-		(insert "\n"))
-	    (if washer
-		(save-restriction
-		  (narrow-to-region body-beg (point))
-		  (goto-char (point-min))
-		  (funcall washer)
-		  (goto-char (point-max)))))))
-    (if (= body-beg (point))
-	(magit-cancel-section section)
-      (insert "\n"))
-    section))
-
-(defun magit-git-section (section-title-and-type
-			  buffer-title washer &rest args)
-  "Run git and put its result in a new section.
-
-see `magit-insert-section' for meaning of the arguments"
-  (apply #'magit-insert-section
-	 section-title-and-type
-	 buffer-title
-	 washer
-	 magit-git-executable
-	 (append magit-git-standard-options args)))
-
-(defun magit-next-section (section)
-  "Return the section that is after SECTION."
-  (let ((parent (magit-section-parent section)))
-    (if parent
-	(let ((next (cadr (memq section
-				(magit-section-children parent)))))
-	  (or next
-	      (magit-next-section parent))))))
-
-(defun magit-goto-next-section ()
-  "Go to the next magit section."
-  (interactive)
-  (let* ((section (magit-current-section))
-	 (next (or (and (not (magit-section-hidden section))
-			(magit-section-children section)
-			(magit-find-section-after (point)
-						  (magit-section-children
-						   section)))
-		   (magit-next-section section))))
-
-    (if next
-	(progn
-	  (goto-char (magit-section-beginning next))
-	  (if (memq magit-submode '(log reflog))
-	      (magit-show-commit next))
-	  (if (not (magit-section-hidden next))
-	      (let ((offset (- (line-number-at-pos
-				(magit-section-beginning next))
-			       (line-number-at-pos
-				(magit-section-end next)))))
-		(if (< offset (window-height))
-		    (recenter offset)))))
-      (message "No next section"))))
-
-(defun magit-prev-section (section)
-  "Return the section that is before SECTION."
-  (let ((parent (magit-section-parent section)))
-    (if parent
-	(let ((prev (cadr (memq section
-				(reverse (magit-section-children parent))))))
-	  (cond (prev
-		 (while (and (not (magit-section-hidden prev))
-			     (magit-section-children prev))
-		   (setq prev (car (reverse (magit-section-children prev)))))
-		 prev)
-		(t
-		 parent))))))
-
-(defun magit-goto-previous-section ()
-  "Goto the previous magit section."
-  (interactive)
-  (let ((section (magit-current-section)))
-    (cond ((= (point) (magit-section-beginning section))
-	   (let ((prev (magit-prev-section (magit-current-section))))
-	     (if prev
-		 (progn
-		   (if (memq magit-submode '(log reflog))
-		       (magit-show-commit (or prev section)))
-		   (goto-char (magit-section-beginning prev)))
-	       (message "No previous section"))))
-	  (t
-	   (let ((prev (magit-find-section-before (point)
-						  (magit-section-children
-						   section))))
-	     (if (memq magit-submode '(log reflog))
-		 (magit-show-commit (or prev section)))
-	     (goto-char (magit-section-beginning (or prev section))))))))
-
-(defun magit-goto-parent-section ()
-  "Goto the parent section."
-  (interactive)
-  (let ((parent (magit-section-parent (magit-current-section))))
-    (when parent
-      (goto-char (magit-section-beginning parent)))))
-
-(defun magit-goto-section (path)
-  "Goto the section describe by PATH."
-  (let ((sec (magit-find-section path magit-top-section)))
-    (if sec
-	(goto-char (magit-section-beginning sec))
-      (message "No such section"))))
-
-(defun magit-for-all-sections (func &optional top)
-  "Run FUNC on TOP and recursively on all its children.
-
-Default value for TOP is `magit-top-section'"
-  (let ((section (or top magit-top-section)))
-    (when section
-      (funcall func section)
-      (dolist (c (magit-section-children section))
-	(magit-for-all-sections func c)))))
-
-(defun magit-section-set-hidden (section hidden)
-  "Hide SECTION if HIDDEN is not nil, show it otherwise."
-  (setf (magit-section-hidden section) hidden)
-  (if (and (not hidden)
-	   (magit-section-needs-refresh-on-show section))
-      (magit-refresh)
-    (let ((inhibit-read-only t)
-	  (beg (save-excursion
-		 (goto-char (magit-section-beginning section))
-		 (forward-line)
-		 (point)))
-	  (end (magit-section-end section)))
-      (put-text-property beg end 'invisible hidden))
-    (if (not hidden)
-	(dolist (c (magit-section-children section))
-	  (magit-section-set-hidden c (magit-section-hidden c))))))
-
-(defun magit-section-any-hidden (section)
-  "Return true if SECTION or any of its children is hidden."
-  (or (magit-section-hidden section)
-      (let ((kids (magit-section-children section)))
-	(while (and kids (not (magit-section-any-hidden (car kids))))
-	  (setq kids (cdr kids)))
-	kids)))
-
-(defun magit-section-collapse (section)
-  "Show SECTION and hide all its children."
-  (dolist (c (magit-section-children section))
-    (setf (magit-section-hidden c) t))
-  (magit-section-set-hidden section nil))
-
-(defun magit-section-expand (section)
-  "Show SECTION and all its children."
-  (dolist (c (magit-section-children section))
-    (setf (magit-section-hidden c) nil))
-  (magit-section-set-hidden section nil))
-
-(defun magit-section-expand-all-aux (section)
-  "Show recursively all SECTION's children."
-  (dolist (c (magit-section-children section))
-    (setf (magit-section-hidden c) nil)
-    (magit-section-expand-all-aux c)))
-
-(defun magit-section-expand-all (section)
-  "Show SECTION and all its children."
-  (magit-section-expand-all-aux section)
-  (magit-section-set-hidden section nil))
-
-(defun magit-section-hideshow (flag-or-func)
-  "Show or hide current section depending on FLAG-OR-FUNC.
-
-If FLAG-OR-FUNC is a function, it will be ran on current section
-IF FLAG-OR-FUNC is a Boolean value, the section will be hidden if its true, shown otherwise"
-  (let ((section (magit-current-section)))
-    (when (magit-section-parent section)
-      (goto-char (magit-section-beginning section))
-      (if (functionp flag-or-func)
-	  (funcall flag-or-func section)
-	  (magit-section-set-hidden section flag-or-func)))))
-
-(defun magit-show-section ()
-  "Show current section."
-  (interactive)
-  (magit-section-hideshow nil))
-
-(defun magit-hide-section ()
-  "Hide current section."
-  (interactive)
-  (magit-section-hideshow t))
-
-(defun magit-collapse-section ()
-  "Hide all subsection of current section."
-  (interactive)
-  (magit-section-hideshow #'magit-section-collapse))
-
-(defun magit-expand-section ()
-  "Show all subsection of current section."
-  (interactive)
-  (magit-section-hideshow #'magit-section-expand))
-
-(defun magit-toggle-file-section ()
-  "Like `magit-toggle-section' but toggle at file granularity."
-  (interactive)
-  (when (eq 'hunk (first (magit-section-context-type (magit-current-section))))
-    (magit-goto-parent-section))
-  (magit-toggle-section))
-
-(defun magit-toggle-section ()
-  "Toggle hidden status of current section."
-  (interactive)
-  (magit-section-hideshow
-   (lambda (s)
-     (magit-section-set-hidden s (not (magit-section-hidden s))))))
-
-(defun magit-expand-collapse-section ()
-  "Toggle hidden status of subsections of current section."
-  (interactive)
-  (magit-section-hideshow
-   (lambda (s)
-     (cond ((magit-section-any-hidden s)
-	    (magit-section-expand-all s))
-	   (t
-	    (magit-section-collapse s))))))
-
-(defun magit-cycle-section ()
-  "Cycle between expanded, hidden and collapsed state for current section.
-
-Hidden: only the first line of the section is shown
-Collapsed: only the first line of the subsection is shown
-Expanded: everything is shown."
-  (interactive)
-  (magit-section-hideshow
-   (lambda (s)
-     (cond ((magit-section-hidden s)
-	    (magit-section-collapse s))
-	   ((notany #'magit-section-hidden (magit-section-children s))
-	    (magit-section-set-hidden s t))
-	   (t
-	    (magit-section-expand s))))))
-
-(defun magit-section-lineage (s)
-  "Return list of parent, grand-parents... for section S."
-  (when s
-    (cons s (magit-section-lineage (magit-section-parent s)))))
-
-(defun magit-section-show-level (section level threshold path)
-  (magit-section-set-hidden section (>= level threshold))
-  (when (< level threshold)
-    (if path
-	(magit-section-show-level (car path) (1+ level) threshold (cdr path))
-	(dolist (c (magit-section-children section))
-	  (magit-section-show-level c (1+ level) threshold nil)))))
-
-(defun magit-show-level (level all)
-  "Show section whose level is less than LEVEL, hide the others.
-If ALL is non nil, do this in all sections,
-otherwise do it only on ancestors and descendants of current section."
-  (magit-with-refresh
-    (if all
-	(magit-section-show-level magit-top-section 0 level nil)
-      (let ((path (reverse (magit-section-lineage (magit-current-section)))))
-	(magit-section-show-level (car path) 0 level (cdr path))))))
-
-(defun magit-show-only-files ()
-  "Show section that are files, but not there subsection.
-
-Do this in on ancestors and descendants of current section."
-  (interactive)
-  (if (eq magit-submode 'status)
-      (call-interactively 'magit-show-level-2)
-    (call-interactively 'magit-show-level-1)))
-
-(defun magit-show-only-files-all ()
-  "Show section that are files, but not there subsection.
-
-Do this for all sections"
-  (interactive)
-  (if (eq magit-submode 'status)
-      (call-interactively 'magit-show-level-2-all)
-    (call-interactively 'magit-show-level-1-all)))
-
-(defmacro magit-define-level-shower-1 (level all)
-  "Define an interactive function to show function of level LEVEL.
-
-If ALL is non nil, this function will affect all section,
-otherwise it will affect only ancestors and descendants of current section."
-  (let ((fun (intern (format "magit-show-level-%s%s"
-			     level (if all "-all" ""))))
-	(doc (format "Show sections on level %s." level)))
-    `(defun ,fun ()
-       ,doc
-       (interactive)
-       (magit-show-level ,level ,all))))
-
-(defmacro magit-define-level-shower (level)
-  "Define two interactive function to show function of level LEVEL.
-one for all, one for current lineage."
-  `(progn
-     (magit-define-level-shower-1 ,level nil)
-     (magit-define-level-shower-1 ,level t)))
-
-(defmacro magit-define-section-jumper (sym title)
-  "Define an interactive function to go to section SYM.
-
-TITLE is the displayed title of the section."
-  (let ((fun (intern (format "magit-jump-to-%s" sym)))
-	(doc (format "Jump to section `%s'." title)))
-    `(defun ,fun ()
-       ,doc
-       (interactive)
-       (magit-goto-section '(,sym)))))
-
-(defvar magit-highlight-overlay nil)
-
-(defvar magit-highlighted-section nil)
-
-(defun magit-highlight-section ()
-  "Highlight current section if it have a type."
-  (let ((section (magit-current-section)))
-    (when (not (eq section magit-highlighted-section))
-      (setq magit-highlighted-section section)
-      (if (not magit-highlight-overlay)
-	  (let ((ov (make-overlay 1 1)))
-	    (overlay-put ov 'face 'magit-item-highlight)
-	    (setq magit-highlight-overlay ov)))
-      (if (and section (magit-section-type section))
-	  (move-overlay magit-highlight-overlay
-			(magit-section-beginning section)
-			(magit-section-end section)
-			(current-buffer))
-	(delete-overlay magit-highlight-overlay)))))
-
-(defun magit-section-context-type (section)
-  (if (null section)
-      '()
-    (let ((c (or (magit-section-type section)
-		 (if (symbolp (magit-section-title section))
-		     (magit-section-title section)))))
-      (if c
-	  (cons c (magit-section-context-type
-		   (magit-section-parent section)))
-	'()))))
-
-(defun magit-prefix-p (prefix list)
-  ;;; Very schemish...
-  (or (null prefix)
-      (if (eq (car prefix) '*)
-	  (or (magit-prefix-p (cdr prefix) list)
-	      (and (not (null list))
-		   (magit-prefix-p prefix (cdr list))))
-	(and (not (null list))
-	     (equal (car prefix) (car list))
-	     (magit-prefix-p (cdr prefix) (cdr list))))))
-
-(defmacro magit-section-case (head &rest clauses)
-  "Make different action depending of current section.
-
-HEAD is (SECTION INFO &optional OPNAME),
-  SECTION will be bind to the current section,
-  INFO will be bind to the info's of the current section,
-  OPNAME is a string that will be used to describe current action,
-
-CLAUSES is a list of CLAUSE, each clause is (SECTION-TYPE &BODY)
-where SECTION-TYPE describe section where BODY will be run."
-  (declare (indent 1))
-  (let ((section (car head))
-	(info (cadr head))
-	(type (make-symbol "*type*"))
-	(context (make-symbol "*context*"))
-	(opname (caddr head)))
-    `(let* ((,section (magit-current-section))
-	    (,info (magit-section-info ,section))
-	    (,type (magit-section-type ,section))
-	    (,context (magit-section-context-type ,section)))
-       (cond ,@(mapcar (lambda (clause)
-			 (if (eq (car clause) t)
-			     clause
-			   (let ((prefix (reverse (car clause)))
-				 (body (cdr clause)))
-			     `((magit-prefix-p ',prefix ,context)
-			       ,@body))))
-		       clauses)
-	     ,@(if opname
-		   `(((not ,type)
-		      (error "Nothing to %s here" ,opname))
-		     (t
-		      (error "Can't %s a %s"
-			     ,opname
-			     (or (get ,type 'magit-description)
-				 ,type)))))))))
-
-(defmacro magit-section-action (head &rest clauses)
-  (declare (indent 1))
-  `(magit-with-refresh
-     (magit-section-case ,head ,@clauses)))
-
-(defun magit-wash-sequence (func)
-  "Run FUNC until end of buffer is reached.
-
-FUNC should leave point at the end of the modified region"
-  (while (and (not (eobp))
-	      (funcall func))))
-
-;;; Running commands
-
-(defun magit-set-mode-line-process (str)
-  (let ((pr (if str (concat " " str) "")))
-    (save-excursion
-      (magit-for-all-buffers (lambda ()
-			       (setq mode-line-process pr))))))
-
-(defun magit-process-indicator-from-command (comps)
-  (if (magit-prefix-p (cons magit-git-executable magit-git-standard-options)
-		      comps)
-      (setq comps (nthcdr (+ (length magit-git-standard-options) 1) comps)))
-  (cond ((or (null (cdr comps))
-	     (not (member (car comps) '("remote"))))
-	 (car comps))
-	(t
-	 (concat (car comps) " " (cadr comps)))))
-
-(defvar magit-process nil)
-(defvar magit-process-client-buffer nil)
-(defvar magit-process-buffer-name "*magit-process*"
-  "Buffer name for running git commands.")
-
-(defun magit-run* (cmd-and-args
-		   &optional logline noerase noerror nowait input)
-  (if (and magit-process
-	   (get-buffer magit-process-buffer-name))
-      (error "Git is already running"))
-  (let ((cmd (car cmd-and-args))
-	(args (cdr cmd-and-args))
-	(dir default-directory)
-	(buf (get-buffer-create magit-process-buffer-name))
-	(successp nil))
-    (magit-set-mode-line-process
-     (magit-process-indicator-from-command cmd-and-args))
-    (setq magit-process-client-buffer (current-buffer))
-    (with-current-buffer buf
-      (view-mode 1)
-      (set (make-local-variable 'view-no-disable-on-exit) t)
-      (setq view-exit-action
-	    (lambda (buffer)
-	      (with-current-buffer buffer
-		(bury-buffer))))
-      (setq buffer-read-only t)
-      (let ((inhibit-read-only t))
-	(setq default-directory dir)
-	(if noerase
-	    (goto-char (point-max))
-	  (erase-buffer))
-	(insert "$ " (or logline
-			 (magit-concat-with-delim " " cmd-and-args))
-		"\n")
-	(cond (nowait
-	       (setq magit-process
-		     (let ((process-connection-type magit-process-connection-type))
-		       (apply 'magit-start-process cmd buf cmd args)))
-	       (set-process-sentinel magit-process 'magit-process-sentinel)
-	       (set-process-filter magit-process 'magit-process-filter)
-	       (when input
-		 (with-current-buffer input
-		   (process-send-region magit-process
-					(point-min) (point-max)))
-		 (process-send-eof magit-process)
-		 (sit-for 0.1 t))
-	       (cond ((= magit-process-popup-time 0)
-		      (pop-to-buffer (process-buffer magit-process)))
-		     ((> magit-process-popup-time 0)
-		      (run-with-timer
-		       magit-process-popup-time nil
-		       (function
-			(lambda (buf)
-			  (with-current-buffer buf
-			    (when magit-process
-			      (display-buffer (process-buffer magit-process))
-			      (goto-char (point-max))))))
-		       (current-buffer))))
-	       (setq successp t))
-	      (input
-	       (with-current-buffer input
-		 (setq default-directory dir)
-		 (setq magit-process
-		       (apply 'magit-start-process cmd buf cmd args))
-		 (set-process-filter magit-process 'magit-process-filter)
-		 (process-send-region magit-process
-				      (point-min) (point-max))
-		 (process-send-eof magit-process)
-		 (while (equal (process-status magit-process) 'run)
-		   (sit-for 0.1 t))
-		 (setq successp
-		       (equal (process-exit-status magit-process) 0))
-		 (setq magit-process nil))
-	       (magit-set-mode-line-process nil)
-	       (magit-need-refresh magit-process-client-buffer))
-	      (t
-	       (setq successp
-		     (equal (apply 'process-file cmd nil buf nil args) 0))
-	       (magit-set-mode-line-process nil)
-	       (magit-need-refresh magit-process-client-buffer))))
-      (or successp
-	  noerror
-	  (error "Git failed"))
-      successp)))
-
-(defun magit-process-sentinel (process event)
-  (let ((msg (format "Git %s." (substring event 0 -1)))
-	(successp (string-match "^finished" event)))
-    (with-current-buffer (process-buffer process)
-      (let ((inhibit-read-only t))
-	(goto-char (point-max))
-	(insert msg "\n")
-	(message msg)))
-    (setq magit-process nil)
-    (magit-set-mode-line-process nil)
-    (magit-refresh-buffer magit-process-client-buffer)))
-
-(defun magit-password (proc string)
-  "Checks if git/ssh asks for a password and ask the user for it."
-  (when (or (string-match "^Enter passphrase for key '\\\(.*\\\)': $" string)
-	    (string-match "^\\\(.*\\\)'s password:" string))
-    (process-send-string proc
-                         (concat (read-passwd
-                                  (format "Password for '%s': " (match-string 1 string))
-                                  nil) "\n"))))
-
-(defun magit-process-filter (proc string)
-  (save-current-buffer
-    (set-buffer (process-buffer proc))
-    (let ((inhibit-read-only t))
-      (magit-password proc string)
-      (goto-char (process-mark proc))
-      ;; Find last ^M in string.  If one was found, ignore everything
-      ;; before it and delete the current line.
-      (let ((ret-pos (length string)))
-	(while (and (>= (setq ret-pos (1- ret-pos)) 0)
-		    (/= ?\r (aref string ret-pos))))
-	(cond ((>= ret-pos 0)
-	       (goto-char (line-beginning-position))
-	       (delete-region (point) (line-end-position))
-	       (insert (substring string (+ ret-pos 1))))
-	      (t
-	       (insert string))))
-      (set-marker (process-mark proc) (point)))))
-
-(defun magit-run (cmd &rest args)
-  (magit-with-refresh
-    (magit-run* (cons cmd args))))
-
-(defun magit-run-git (&rest args)
-  (magit-with-refresh
-    (magit-run* (append (cons magit-git-executable
-			      magit-git-standard-options)
-			args))))
-
-(defun magit-run-with-input (input cmd &rest args)
-  (magit-with-refresh
-    (magit-run* (cons cmd args) nil nil nil nil input)))
-
-(defun magit-run-git-with-input (input &rest args)
-  (magit-with-refresh
-    (magit-run* (append (cons magit-git-executable
-			      magit-git-standard-options)
-			args)
-		nil nil nil nil input)))
-
-(defun magit-run-git-async (&rest args)
-  (message "Running %s %s" magit-git-executable (mapconcat 'identity args " "))
-  (magit-run* (append (cons magit-git-executable
-			    magit-git-standard-options)
-		      args)
-	      nil nil nil t))
-
-(defun magit-run-async-with-input (input cmd &rest args)
-  (magit-run* (cons cmd args) nil nil nil t input))
-
-(defun magit-display-process ()
-  "Display output from most recent git command."
-  (interactive)
-  (unless (get-buffer magit-process-buffer-name)
-    (error "No Git commands have run"))
-  (display-buffer magit-process-buffer-name))
-
-;;; Mode
-
-;; We define individual functions (instead of using lambda etc) so
-;; that the online help can show something meaningful.
-
-(magit-define-section-jumper untracked "Untracked files")
-(magit-define-section-jumper unstaged  "Unstaged changes")
-(magit-define-section-jumper staged    "Staged changes")
-(magit-define-section-jumper unpushed  "Unpushed commits")
-(magit-define-section-jumper svn-unpushed  "Unpushed commits (SVN)")
-
-(magit-define-level-shower 1)
-(magit-define-level-shower 2)
-(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 "N r") 'magit-svn-rebase)
-    (define-key map (kbd "N c") 'magit-svn-dcommit)
-    (define-key map (kbd "N f") 'magit-svn-find-rev)
-    (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)
-    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)
-    map))
-
-(easy-menu-define magit-mode-menu magit-mode-map
-  "Magit menu"
-  '("Magit"
-    ["Refresh" magit-refresh t]
-    ["Refresh all" magit-refresh-all t]
-    "---"
-    ["Stage" magit-stage-item t]
-    ["Stage all" magit-stage-all t]
-    ["Unstage" magit-unstage-item t]
-    ["Unstage all" magit-unstage-all t]
-    ["Commit" magit-log-edit t]
-    ["Add log entry" magit-add-log t]
-    ["Tag" magit-tag t]
-    ["Annotated tag" magit-annotated-tag t]
-    "---"
-    ["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]
-    "---"
-    ["Cherry pick" magit-cherry-pick-item t]
-    ["Apply" magit-apply-item t]
-    ["Revert" magit-revert-item t]
-    "---"
-    ["Ignore" magit-ignore-item t]
-    ["Ignore locally" magit-ignore-item-locally t]
-    ["Discard" magit-discard-item t]
-    ["Reset head" magit-reset-head t]
-    ["Reset working tree" magit-reset-working-tree t]
-    ["Stash" magit-stash t]
-    ["Snapshot" magit-stash-snapshot t]
-    "---"
-    ["Switch branch" magit-checkout t]
-    ["Create branch" magit-create-branch 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]
-    ("Git SVN"
-     ["Rebase" magit-svn-rebase (magit-svn-enabled)]
-     ["Commit" magit-svn-dcommit (magit-svn-enabled)]
-     )
-    ("Rewrite"
-     ["Start" magit-rewrite-start t]
-     ["Stop" magit-rewrite-stop t]
-     ["Finish" magit-rewrite-finish t]
-     ["Abort" magit-rewrite-abort t]
-     ["Set used" magit-rewrite-set-used t]
-     ["Set unused" magit-rewrite-set-unused t])
-    "---"
-    ["Push" magit-push t]
-    ["Pull" magit-pull t]
-    ["Remote update" magit-remote-update t]
-    "---"
-    ["Display Git output" magit-display-process t]
-    ["Quit Magit" quit-window t]))
-
-(defvar magit-mode-hook nil "Hook run by `magit-mode'.")
-
-(put 'magit-mode 'mode-class 'special)
-
-(defvar magit-refresh-function nil)
-(make-variable-buffer-local 'magit-refresh-function)
-(put 'magit-refresh-function 'permanent-local t)
-
-(defvar magit-refresh-args nil)
-(make-variable-buffer-local 'magit-refresh-args)
-(put 'magit-refresh-args 'permanent-local t)
-
-(defvar last-point)
-
-(defun magit-remember-point ()
-  (setq last-point (point)))
-
-(defun magit-invisible-region-end (pos)
-  (while (and (not (= pos (point-max))) (invisible-p pos))
-    (setq pos (next-char-property-change pos)))
-  pos)
-
-(defun magit-invisible-region-start (pos)
-  (while (and (not (= pos (point-min))) (invisible-p pos))
-    (setq pos (1- (previous-char-property-change pos))))
-  pos)
-
-(defun magit-correct-point-after-command ()
-  "Move point outside of invisible regions.
-
-Emacs often leaves point in invisible regions, it seems.  To fix
-this, we move point ourselves and never let Emacs do its own
-adjustments.
-
-When point has to be moved out of an invisible region, it can be
-moved to its end or its beginning.  We usually move it to its
-end, except when that would move point back to where it was
-before the last command."
-  (if (invisible-p (point))
-      (let ((end (magit-invisible-region-end (point))))
-	(goto-char (if (= end last-point)
-		       (magit-invisible-region-start (point))
-		     end))))
-  (setq disable-point-adjustment t))
-
-(defun magit-post-command-hook ()
-  (magit-correct-point-after-command)
-  (magit-highlight-section))
-
-(defun magit-mode ()
-  "Review the status of a git repository and act on it.
-
-Please see the manual for a complete description of Magit.
-
-\\{magit-mode-map}"
-  (kill-all-local-variables)
-  (buffer-disable-undo)
-  (setq buffer-read-only t)
-  (make-local-variable 'line-move-visual)
-  (setq major-mode 'magit-mode
-	mode-name "Magit"
-	mode-line-process ""
-	truncate-lines t
-	line-move-visual nil)
-  (add-hook 'pre-command-hook #'magit-remember-point nil t)
-  (add-hook 'post-command-hook #'magit-post-command-hook t t)
-  (use-local-map magit-mode-map)
-  (run-mode-hooks 'magit-mode-hook))
-
-(defun magit-mode-init (dir submode refresh-func &rest refresh-args)
-  (setq default-directory dir
-	magit-submode submode
-	magit-refresh-function refresh-func
-	magit-refresh-args refresh-args)
-  (magit-mode)
-  (magit-refresh-buffer))
-
-(defun magit-find-buffer (submode &optional dir)
-  (let ((topdir (magit-get-top-dir (or dir default-directory))))
-    (dolist (buf (buffer-list))
-      (if (with-current-buffer buf
-	    (and default-directory
-		 (equal (expand-file-name default-directory) topdir)
-		 (eq major-mode 'magit-mode)
-		 (eq magit-submode submode)))
-	  (return buf)))))
-
-(defun magit-find-status-buffer (&optional dir)
-  (magit-find-buffer 'status dir))
-
-(defun magit-for-all-buffers (func &optional dir)
-  (dolist (buf (buffer-list))
-    (with-current-buffer buf
-      (if (and (eq major-mode 'magit-mode)
-	       (or (null dir)
-		   (equal default-directory dir)))
-	  (funcall func)))))
-
-(defun magit-refresh-buffer (&optional buffer)
-  (with-current-buffer (or buffer (current-buffer))
-    (let* ((old-line (line-number-at-pos))
-	   (old-section (magit-current-section))
-	   (old-path (and old-section
-			  (magit-section-path (magit-current-section))))
-	   (section-line (and old-section
-			      (count-lines
-			       (magit-section-beginning old-section)
-			       (point)))))
-      (if magit-refresh-function
-	  (apply magit-refresh-function
-		 magit-refresh-args))
-      (magit-refresh-marked-commits-in-buffer)
-      (let ((s (and old-path (magit-find-section old-path magit-top-section))))
-	(cond (s
-	       (goto-char (magit-section-beginning s))
-	       (forward-line section-line))
-	      (t
-	       (magit-goto-line old-line)))
-	(dolist (w (get-buffer-window-list (current-buffer)))
-	  (set-window-point w (point)))
-	(magit-highlight-section)))))
-
-(defun magit-string-has-prefix-p (string prefix)
-  (eq (compare-strings string nil (length prefix) prefix nil nil) t))
-
-(defun magit-revert-buffers (dir &optional ignore-modtime)
-  (dolist (buffer (buffer-list))
-    (when (and buffer
-	       (buffer-file-name buffer)
-	       (magit-string-has-prefix-p (buffer-file-name buffer) dir)
-	       (or ignore-modtime (not (verify-visited-file-modtime buffer)))
-	       (not (buffer-modified-p buffer)))
-      (with-current-buffer buffer
-	(ignore-errors
-	  (revert-buffer t t nil))))))
-
-(defun magit-update-vc-modeline (dir)
-  "Update the modeline for buffers representable by magit."
-  (dolist (buffer (buffer-list))
-    (when (and buffer
-	       (buffer-file-name buffer)
-	       (magit-string-has-prefix-p (buffer-file-name buffer) dir))
-      (with-current-buffer buffer
-	(ignore-errors
-	  (vc-find-file-hook))))))
-
-(defvar magit-refresh-needing-buffers nil)
-(defvar magit-refresh-pending nil)
-
-(defun magit-refresh-wrapper (func)
-  (if magit-refresh-pending
-      (funcall func)
-    (let* ((dir default-directory)
-	   (status-buffer (magit-find-buffer 'status dir))
-	   (magit-refresh-needing-buffers nil)
-	   (magit-refresh-pending t))
-      (unwind-protect
-	  (funcall func)
-	(when magit-refresh-needing-buffers
-	  (magit-revert-buffers dir)
-	  (dolist (b (adjoin status-buffer
-			     magit-refresh-needing-buffers))
-	    (magit-refresh-buffer b)))))))
-
-(defun magit-need-refresh (&optional buffer)
-  (let ((buffer (or buffer (current-buffer))))
-    (when (not (memq buffer magit-refresh-needing-buffers))
-      (setq magit-refresh-needing-buffers
-	    (cons buffer magit-refresh-needing-buffers)))))
-
-(defun magit-refresh ()
-  "Refresh current buffer to match repository state.
-Also revert every unmodified buffer visiting files
-in the corresponding directory."
-  (interactive)
-  (magit-with-refresh
-    (magit-need-refresh)))
-
-(defun magit-refresh-all ()
-  "Refresh all magit buffers to match respective repository states.
-Also revert every unmodified buffer visiting files
-in the corresponding directories."
-  (interactive)
-  (magit-for-all-buffers #'magit-refresh-buffer default-directory))
-
-;;; Untracked files
-
-(defun magit-wash-untracked-file ()
-  (if (looking-at "^? \\(.*\\)$")
-      (let ((file (match-string-no-properties 1)))
-	(delete-region (point) (+ (line-end-position) 1))
-	(magit-with-section file 'file
-	  (magit-set-section-info file)
-	  (insert "\t" file "\n"))
-	t)
-    nil))
-
-(defun magit-wash-untracked-files ()
-  ;; Setting magit-old-top-section to nil speeds up washing: no time
-  ;; is wasted looking up the old visibility, which doesn't matter for
-  ;; untracked files.
-  ;;
-  ;; XXX - speed this up in a more general way.
-  ;;
-  (let ((magit-old-top-section nil))
-    (magit-wash-sequence #'magit-wash-untracked-file)))
-
-(defun magit-insert-untracked-files ()
-  (apply 'magit-git-section