Commit 350a0edc authored by Remi Vanicat's avatar Remi Vanicat

Imported Upstream version 2.4.1

parent 64cc41f9
Magit v2.3.1 Release Notes
==========================
Released 11 November 2015 by Jonas Bernoulli.
This is a bugfix release.
* `magit-stash-drop' now shows a message with the hash of the dropped
stash to make it easier to recover from dropping the wrong stash.
* `magit-revert-buffers' now avoids needlessly connecting to unrelated
hosts. It first checks whether a given file is on the same host as
the repository, and only if that is so it checks whether the file is
located inside the repository, using `file-in-directory-p', which,
for Tramp files, requires connecting to the remote host.
* `magit-commit-message-buffer' no longer hangs when a symlink to the
repository is involved.
This release also contains various documentation fixes and code
clean-ups.
Authors
-------
10 Jonas Bernoulli
3 Noam Postavsky
2 Kyle Meyer
1 Carl Lieberman
1 David L. Rager
1 Syohei Yoshida
Magit v2.4.1 Release Notes
==========================
Updates since v2.4.0
--------------------
* Added new utility function `magit-rev-abbrev', `magit-ref-p', and
`magit-tag-p'.
Fixes since v2.4.0
------------------
* When determining the emacsclient executable most suitable for the
current emacs instance, With-Editor ignored any executable that is
actually named "emacsclient-snapshot".
* When determining the most suitable git executable, an error occured
if "Git for Windows 1.x" is used and an cygpath executable is
available.
* An error occured when refreshing the status buffer when there is a
new, staged but not yet committed, submodule.
This release also contains typofixes.
Authors
-------
9 Jonas Bernoulli
4 Kyle Meyer
1 Noam Postavsky
......@@ -65,6 +65,7 @@ Contributors
- Brandon W Maister <quodlibetor@gmail.com>
- Brian Warner <warner@lothar.com>
- Bryan Shell <bryan.shell@orbitz.com>
- Carl Lieberman <liebermancarl@gmail.com>
- Chris Bernard <cebernard@gmail.com>
- Chris Done <chrisdone@gmail.com>
- Chris Moore <dooglus@gmail.com>
......@@ -82,6 +83,7 @@ Contributors
- Dan LaManna <dan.lamanna@gmail.com>
- David Abrahams <dave@boostpro.com>
- David Hull <david.hull@openx.com>
- David L. Rager <ragerdl@gmail.com>
- David Wallin <david.wallin@gmail.com>
- Dennis Paskorz <dennis@walltowall.com>
- Divye Kapoor <divye@google.com>
......@@ -145,8 +147,10 @@ Contributors
- Matus Goljer <dota.keys@gmail.com>
- Michael Fogleman <michaelwfogleman@gmail.com>
- Michael Griffiths <mikey@cich.li>
- Michael Heerdegen <michael_heerdegen@web.de>
- Michal Sojka <sojkam1@fel.cvut.cz>
- Miles Bader <miles@gnu.org>
- Miloš Mošić <mosic.milos@gmail.com>
- Mitchel Humpherys <mitch.special@gmail.com>
- Moritz Bunkus <moritz@bunkus.org>
- Natalie Weizenbaum <nex342@gmail.com>
......@@ -180,7 +184,7 @@ Contributors
- Prathamesh Sonpatki <csonpatki@gmail.com>
- rabio <rabiodev@o2.pl>
- Rafael Laboissiere <rafael@laboissiere.net>
- Raimon Grau <raimonster@gmail.com>
- Raimon Grau <raimon@3scale.net>
- Ramkumar Ramachandra <artagnon@gmail.com>
- Remco van 't Veer <rwvtveer@xs4all.nl>
- Rémi Vanicat <vanicat@debian.org>
......@@ -210,6 +214,7 @@ Contributors
- Steven Vancoillie <steven.vancoillie@runbox.com>
- Steve Purcell <steve@sanityinc.com>
- Suhail Shergill <suhailshergill@gmail.com>
- Sylvain Rousseau <thisirs@gmail.com>
- Syohei Yoshida <syohex@gmail.com>
- Takafumi Arakaki <aka.tkf@gmail.com>
- Teemu Likonen <tlikonen@iki.fi>
......@@ -233,3 +238,4 @@ Contributors
- Yann Hodique <yann.hodique@gmail.com>
- York Zhao <gtdplatform@gmail.com>
- Yuichi Higashi <aaa707b@gmail.com>
- Zach Latta <zach@zachlatta.com>
......@@ -3,10 +3,7 @@ include ../default.mk
MAKEINFO ?= makeinfo
INSTALL_INFO ?= $(shell \
hash ginstall-info 2> /dev/null\
&& printf ginstall-info\
|| printf install-info)
INSTALL_INFO ?= $(shell command -v ginstall-info || printf install-info)
DOC_LOAD_PATH ?= -L ../../dash -L ../../org/lisp -L ../../ox-texinfo+
......@@ -39,7 +36,7 @@ info: $(INFOPAGES) dir
%.info: %.texi
@printf "Generating $@\n"
@$(MAKEINFO) $< -o $@
@$(MAKEINFO) --no-split $< -o $@
dir: magit.info magit-popup.info with-editor.info
@printf "Generating dir\n"
......@@ -62,7 +59,7 @@ clean:
authors: AUTHORS.md
AUTHORS.md:
@printf "Generating AUTHORS.md..."
@test -d $(TOP).git \
@test -e $(TOP).git \
&& (printf "$$AUTHORS_HEADER\n" > $@ \
&& git log --pretty=format:'- %aN <%aE>' | sort -u >> $@ \
&& printf "done\n" ; ) \
......
......@@ -15,7 +15,7 @@ suffix commands.
@end ifnottex
@quotation
Copyright (C) 2015 Jonas Bernoulli <jonas@@bernoul.li>
Copyright (C) 2015-2016 Jonas Bernoulli <jonas@@bernoul.li>
You can redistribute this document and/or modify it under the terms
of the GNU General Public License as published by the Free Software
......@@ -37,7 +37,7 @@ General Public License for more details.
@finalout
@titlepage
@title Magit-Popup User Manual
@subtitle for version 2.3
@subtitle for version 2.4
@author Jonas Bernoulli
@page
@vskip 0pt plus 1filll
......@@ -369,6 +369,28 @@ Like @code{magit-define-popup-action}, but modifies the value of the
@code{:sequence-actions} property instead of @code{:actions}.
@end defun
@defun magit-define-popup-variable popup key desc command formatter &optional at prepend
In POPUP, define KEY as COMMAND.
POPUP is a popup command defined using @code{magit-define-popup}. COMMAND
is a command which calls @code{magit-popup-set-variable}. FORMATTER is a
function which calls @code{magit-popup-format-variable}. These two
functions have to be called with the same arguments.
KEY is a character representing the event used interactively call
the COMMAND.
DESC is the variable or a representation thereof. It's not actually
used for anything.
COMMAND is inserted after all other commands already defined for
POPUP, unless optional PREPEND is non-nil, in which case it is
placed first. If optional AT is non-nil then it should be the KEY
of another command already defined for POPUP, the command is then
placed before or after AT, depending on PREPEND."
@end defun
@defun magit-change-popup-key popup type from to
In POPUP, bind TO to what FROM was bound to. TYPE is one of
......@@ -444,6 +466,14 @@ argument is used. See @ref{Customizing existing popups,Customizing existing pop
The Emacs package used to display man-pages, one of @code{man} or @code{woman}.
@end defopt
@defopt magit-popup-display-buffer-action
The option controls how the window used to display a popup buffer is
created. Popup buffers are displayed using @code{display-buffer} with the
value of this option as ACTION argument. You can also set this to
nil and instead add an entry to @code{display-buffer-alist}.
@end defopt
To emphasize the default action by making it bold use this:
@lisp
......@@ -479,19 +509,19 @@ infix arguments, and then also one of its suffix commands.
'magit-commands
:man-page "git-tag"
:switches '((?a "Annotate" "--annotate")
(?s "Sign" "--sign")
(?f "Force" "--force"))
(?s "Sign" "--sign")
(?f "Force" "--force"))
:actions '((?t "Create" magit-tag)
(?k "Delete" magit-tag-delete)
(?p "Prune" magit-tag-prune))
(?k "Delete" magit-tag-delete)
(?p "Prune" magit-tag-prune))
:default-action 'magit-tag)
;;;###autoload
(defun magit-tag (name rev &optional args)
"Create a new tag with the given NAME at REV."
(interactive (list (magit-read-tag "Tag name")
(magit-read-branch-or-commit "Place tag on")
(magit-tag-arguments)))
(magit-read-branch-or-commit "Place tag on")
(magit-tag-arguments)))
(magit-run-git-with-editor "tag" args name rev))
@end lisp
......@@ -615,6 +645,14 @@ VALUE is a list whose members have the form (KEY DESC OPTION
READER), see @code{magit-define-popup-option} for details.
@item
@code{:variables}
Git variables which can be set from the popup. VALUE is a list
whose members have the form (KEY DESC COMMAND FORMATTER), see
@code{magit-define-popup-variable} for details.
@item
@code{:default-arguments}
......@@ -623,16 +661,6 @@ by default) and options with there default values, as in
"--OPT~OPTVAL\".
@item
@code{:man-page}
The name of the manpage to be displayed when the user requests
help for an argument.
@end itemize
When MODE is @code{magit-popup-sequence-mode}, then the following keywords
are also meaningful:
@itemize
@item
@code{:sequence-predicate}
......@@ -646,6 +674,29 @@ When this function returns non-nil, then the popup uses
The actions which can be invoked from the popup, when
@code{:sequence-predicate} returns non-nil.
@item
@code{:setup-function}
When this function is specified, then it is used instead of
@code{magit-popup-default-setup}.
@item
@code{:refresh-function}
When this function is specified, then it is used instead of
calling @code{magit-popup-insert-section} three times with symbols
@code{magit-popup-switch-button}, @code{magit-popup-option-button}, and finally
@code{magit-popup-action-button} as argument.
@item
@code{:man-page}
The name of the manpage to be displayed when the user requests
help for an argument.
@end itemize
@end defmac
......
This diff is collapsed.
......@@ -25,7 +25,7 @@ don't use Magit or another package which uses it internally.
@end ifnottex
@quotation
Copyright (C) 2015 Jonas Bernoulli <jonas@@bernoul.li>
Copyright (C) 2015-2016 Jonas Bernoulli <jonas@@bernoul.li>
You can redistribute this document and/or modify it under the terms
of the GNU General Public License as published by the Free Software
......@@ -47,7 +47,7 @@ General Public License for more details.
@finalout
@titlepage
@title With-Editor User Manual
@subtitle for version 2.3
@subtitle for version 2.4
@author Jonas Bernoulli
@page
@vskip 0pt plus 1filll
......@@ -237,7 +237,7 @@ Some variants of this function exist; these two forms are equivalent:
@lisp
(add-hook 'shell-mode-hook
(apply-partially 'with-editor-export-editor "GIT_EDITOR"))
(apply-partially 'with-editor-export-editor "GIT_EDITOR"))
(add-hook 'shell-mode-hook 'with-editor-export-git-editor)
@end lisp
......
......@@ -47,6 +47,7 @@ help:
$(info make authors - regenerate AUTHORS.md)
$(info make dist - create tarballs)
$(info make elpa - create elpa tarballs)
$(info make marmalade - upload to marmalade)
$(info make VERSION=... bump-version)
$(info make VERSION=... melpa-post-release)
$(info - - fixup version strings)
......@@ -87,7 +88,7 @@ test-interactive:
(ert t))"
magit: clean-lisp
@$(EMACSBIN) -Q $(LOAD_PATH) --eval "(progn\
@$(EMACSBIN) -Q $(LOAD_PATH) --debug-init --eval "(progn\
(require 'magit)\
(global-set-key \"\\C-xg\" 'magit-status)\
(tool-bar-mode 0)\
......@@ -259,7 +260,8 @@ endef
#'
export set_manual_version
bump-version:
bump-version: bump-version-1 texi
bump-version-1:
@$(BATCH) --eval "(progn\
(setq async-version \"$(ASYNC_VERSION)\")\
(setq dash-version \"$(DASH_VERSION)\")\
......@@ -271,3 +273,4 @@ melpa-post-release:
(setq async-version \"$(ASYNC_MELPA_SNAPSHOT)\")\
(setq dash-version \"$(DASH_MELPA_SNAPSHOT)\")\
$$set_package_requires)"
git commit -a -m "reset Package-Requires for Melpa"
......@@ -6,8 +6,9 @@
<b>
When something doesn't work as expected, then please first consult the
<a href="http://magit.vc/manual/magit/FAQ.html">FAQ</a> and ask a
search engine. If that doesn't solve your problem, then please ask for help on
<a href="http://emacs.stackexchange.com/questions/tagged/magit"> Emacs.Stackexchange</a>.
search engine. If that doesn't solve your problem, then please ask for help on the
<a href="http://emacs.stackexchange.com/questions/tagged/magit">Emacs Stackexchange site</a>
or the <a href="https://gitter.im/magit/magit">Gitter chat</a>.
</b>
</p>
***
......@@ -52,18 +53,17 @@
Support
=======
**When something doesn't work as expected then please first see the
[FAQ][faq].** Then also try the list of [open issues][issues] and use
When something doesn't work as expected then please first see the
[FAQ][faq]. Then also try the list of [open issues][issues] and use
the search box at the top of that page to find older related issues.
You should also consult the [manual][manual] and ask a general-purpose
search engine.
If everything else fails then ask for help on the
**[Emacs Stackexchange site][forum]**, the
[mailing list][list], or the
[Gitter chat][chat].
If that doesn't answer your question, then ask for help on the
**[Emacs Stackexchange site][forum]**, the [mailing list][list], or
the [Gitter chat][chat].
**Please do NOT use the Github issue tracker for support requests.**
**Please do NOT use the GitHub issue tracker for support requests.**
**We only use it for feature requests and bug reports.**
Contributing
......
......@@ -30,6 +30,7 @@ ELS += magit-popup.el
ELS += magit-utils.el
ELS += magit-section.el
ELS += magit-git.el
ELS += magit-autorevert.el
ELS += magit-mode.el
ELS += magit-process.el
ELS += magit-core.el
......@@ -71,7 +72,10 @@ ifeq "$(DASH_DIR)" ""
DASH_DIR = $(TOP)../dash
endif
CYGPATH := $(shell cygpath --version 2>/dev/null)
SYSTYPE := $(shell $(EMACSBIN) -Q --batch --eval "(princ system-type)")
ifeq ($(SYSTYPE), windows-nt)
CYGPATH := $(shell cygpath --version 2>/dev/null)
endif
ifdef CYGPATH
LOAD_PATH ?= -L $(TOP)/lisp -L $(shell cygpath --mixed $(DASH_DIR))
......
......@@ -14,6 +14,7 @@ magit-mode.elc: magit-section.elc magit-git.elc
magit-popup.elc:
magit-process.elc: with-editor.elc magit-utils.elc magit-section.elc \
magit-git.elc magit-mode.elc
magit-autorevert.elc: magit-git.elc magit-process.elc
magit-core.elc: magit-utils.elc magit-section.elc magit-git.elc \
magit-mode.elc magit-popup.elc magit-process.elc
magit-diff.elc: git-commit.elc magit-core.elc
......@@ -61,6 +62,18 @@ magit-version.el:
magit-autoloads.el: $(ELS)
@printf "Generating $@\n"
@$(RM) $@
@printf ";;; $@ --- automatically extracted autoloads\n" >> $@
@printf ";;\n" >> $@
@printf ";;; Code:\n" >> $@ >> $@
@printf "(add-to-list 'load-path (directory-file-name (or (file-name-directory #$$) (car load-path))))\n" >> $@
@printf " \n" >> $@
@printf ";; Local Variables:\n" >> $@
@printf ";; version-control: never\n" >> $@
@printf ";; no-byte-compile: t\n" >> $@
@printf ";; no-update-autoloads: t\n" >> $@
@printf ";; End:\n" >> $@
@printf ";;; $@ ends here\n" >> $@
@$(BATCH) --eval "(progn\
(fset 'message (lambda (&rest _)))\
(setq make-backup-files nil)\
......
;;; git-commit.el --- Edit Git commit messages -*- lexical-binding: t; -*-
;; Copyright (C) 2010-2015 The Magit Project Contributors
;; Copyright (C) 2010-2016 The Magit Project Contributors
;;
;; You should have received a copy of the AUTHORS.md file which
;; lists all contributors. If not, see http://magit.vc/authors.
......@@ -11,7 +11,7 @@
;; Marius Vollmer <marius.vollmer@gmail.com>
;; Maintainer: Jonas Bernoulli <jonas@bernoul.li>
;; Package-Requires: ((emacs "24.4") (dash "2.12.1") (with-editor "2.3.1"))
;; Package-Requires: ((emacs "24.4") (dash "2.12.1") (with-editor "2.4.1"))
;; Keywords: git tools vc
;; Homepage: https://github.com/magit/magit
......@@ -176,7 +176,7 @@ The major mode configured here is turned on by the minor mode
"Hook run at the end of `git-commit-setup'."
:group 'git-commit
:type 'hook
:options '(magit-revert-buffers
:options '(
git-commit-save-message
git-commit-setup-changelog-support
git-commit-turn-on-auto-fill
......
;;; git-rebase.el --- Edit Git rebase files
;;; git-rebase.el --- Edit Git rebase files -*- lexical-binding: t -*-
;; Copyright (C) 2010-2015 The Magit Project Contributors
;; Copyright (C) 2010-2016 The Magit Project Contributors
;;
;; You should have received a copy of the AUTHORS.md file which
;; lists all contributors. If not, see http://magit.vc/authors.
......@@ -145,6 +145,7 @@
"Keymap for Git-Rebase mode.")
(put 'git-rebase-reword :advertised-binding "r")
(put 'git-rebase-move-line-up :advertised-binding (kbd "M-p"))
(easy-menu-define git-rebase-mode-menu git-rebase-mode-map
"Git-Rebase mode menu"
......@@ -214,29 +215,79 @@
(forward-line)))
(ding)))
(defun git-rebase-move-line-up ()
"Move the current commit (or command) up."
(interactive)
(goto-char (line-beginning-position))
(if (bobp)
(ding)
(when (looking-at git-rebase-line)
(let ((inhibit-read-only t))
(transpose-lines 1))
(forward-line -2))))
(defun git-rebase-move-line-down ()
"Move the current commit (or command) down."
(interactive)
(goto-char (line-beginning-position))
(when (and (looking-at git-rebase-line)
(save-excursion
(forward-line)
(looking-at git-rebase-line)))
(forward-line)
(let ((inhibit-read-only t))
(transpose-lines 1))
(forward-line -1)))
(defun git-rebase-line-p (&optional pos)
(save-excursion
(when pos (goto-char pos))
(goto-char (line-beginning-position))
(looking-at-p git-rebase-line)))
(defun git-rebase-region-bounds ()
(when (use-region-p)
(let ((beg (save-excursion (goto-char (region-beginning))
(line-beginning-position)))
(end (save-excursion (goto-char (region-end))
(line-end-position))))
(when (and (git-rebase-line-p beg)
(git-rebase-line-p end))
(list beg (1+ end))))))
(defun git-rebase-move-line-down (n)
"Move the current commit (or command) N lines down.
If N is negative, move the commit up instead. With an active
region, move all the lines that the region touches, not just the
current line."
(interactive "p")
(-let* (((beg end) (or (git-rebase-region-bounds)
(list (line-beginning-position)
(1+ (line-end-position)))))
(pt-offset (- (point) beg))
(mark-offset (and mark-active (- (mark) beg))))
(save-restriction
(narrow-to-region
(point-min)
(1+ (save-excursion
(goto-char (point-min))
(while (re-search-forward git-rebase-line nil t))
(point))))
(if (or (and (< n 0) (= beg (point-min)))
(and (> n 0) (= end (point-max)))
(> end (point-max)))
(ding)
(goto-char (if (< n 0) beg end))
(forward-line n)
(atomic-change-group
(let ((inhibit-read-only t))
(insert (delete-and-extract-region beg end)))
(let ((new-beg (- (point) (- end beg))))
(when (use-region-p)
(setq deactivate-mark nil)
(set-mark (+ new-beg mark-offset)))
(goto-char (+ new-beg pt-offset))))))))
(defun git-rebase-move-line-up (n)
"Move the current commit (or command) N lines up.
If N is negative, move the commit down instead. With an active
region, move all the lines that the region touches, not just the
current line."
(interactive "p")
(git-rebase-move-line-down (- n)))
(defun git-rebase-highlight-region (start end window rol)
(let ((inhibit-read-only t)
(deactivate-mark nil)
(bounds (git-rebase-region-bounds)))
(mapc #'delete-overlay magit-section-highlight-overlays)
(when bounds
(magit-section-make-overlay (car bounds) (cadr bounds)
'magit-section-heading-selection))
(if (and bounds (not magit-keep-region-overlay))
(funcall (default-value 'redisplay-unhighlight-region-function) rol)
(funcall (default-value 'redisplay-highlight-region-function)
start end window rol))))
(defun git-rebase-unhighlight-region (rol)
(mapc #'delete-overlay magit-section-highlight-overlays)
(funcall (default-value 'redisplay-unhighlight-region-function) rol))
(defun git-rebase-kill-line ()
"Kill the current action line."
......@@ -329,6 +380,8 @@ running 'man git-rebase' at the command line) for details."
(when git-rebase-confirm-cancel
(add-hook 'with-editor-cancel-query-functions
'git-rebase-cancel-confirm nil t))
(setq-local redisplay-highlight-region-function 'git-rebase-highlight-region)
(setq-local redisplay-unhighlight-region-function 'git-rebase-unhighlight-region)
(add-hook 'with-editor-pre-cancel-hook 'git-rebase-autostash-save nil t)
(add-hook 'with-editor-post-cancel-hook 'git-rebase-autostash-apply nil t))
......@@ -370,15 +423,17 @@ By default, this is the same except for the \"pick\" command."
(substitute-command-keys (format "\\[%s]" (car it)))
(cdr it))))
(while (re-search-forward "^#\\( ?\\)\\([^,],\\) \\([^ ]+\\) = " nil t)
(replace-match " " t t nil 1)
(let ((cmd (intern (concat "git-rebase-" (match-string 3)))))
(replace-match
(format "%-8s"
(mapconcat #'key-description
(--filter (not (eq (elt it 0) 'menu-bar))
(reverse (where-is-internal cmd)))
", "))
t t nil 2)))))))
(if (not (fboundp cmd))
(delete-region (line-beginning-position) (1+ (line-end-position)))
(replace-match " " t t nil 1)
(replace-match
(format "%-8s"
(mapconcat #'key-description
(--filter (not (eq (elt it 0) 'menu-bar))
(reverse (where-is-internal cmd)))
", "))
t t nil 2))))))))
(add-hook 'git-rebase-mode-hook 'git-rebase-mode-show-keybindings t)
......
;;; magit-apply.el --- apply Git diffs
;;; magit-apply.el --- apply Git diffs -*- lexical-binding: t -*-
;; Copyright (C) 2010-2015 The Magit Project Contributors
;; Copyright (C) 2010-2016 The Magit Project Contributors
;;
;; You should have received a copy of the AUTHORS.md file which
;; lists all contributors. If not, see http://magit.vc/authors.
......@@ -35,10 +35,12 @@
(require 'magit-wip)
;; For `magit-apply'
(declare-function magit-anti-stage 'magit-rockstar)
(declare-function magit-am-popup 'magit-sequence)
;; For `magit-discard-files'
(declare-function magit-checkout-stage 'magit)
(declare-function magit-checkout-read-stage 'magit)
(defvar auto-revert-verbose)
(require 'dired)
......@@ -162,18 +164,17 @@ With a prefix argument and if necessary, attempt a 3-way merge."
"Add the change at point to the staging area."
(interactive)
(--when-let (magit-apply--get-selection)
(let ((inhibit-magit-revert t))
(pcase (list (magit-diff-type) (magit-diff-scope))
(`(untracked ,_) (magit-stage-untracked))
(`(unstaged region) (magit-apply-region it "--cached"))
(`(unstaged hunk) (magit-apply-hunk it "--cached"))
(`(unstaged hunks) (magit-apply-hunks it "--cached"))
(`(unstaged file) (magit-stage-1 "-u" (list (magit-section-value it))))
(`(unstaged files) (magit-stage-1 "-u" (magit-region-values)))
(`(unstaged list) (magit-stage-1 "-u"))
(`(staged ,_) (user-error "Already staged"))
(`(committed ,_) (user-error "Cannot stage committed changes"))
(`(undefined ,_) (user-error "Cannot stage this change"))))))
(pcase (list (magit-diff-type) (magit-diff-scope))
(`(untracked ,_) (magit-stage-untracked))
(`(unstaged region) (magit-apply-region it "--cached"))
(`(unstaged hunk) (magit-apply-hunk it "--cached"))
(`(unstaged hunks) (magit-apply-hunks it "--cached"))
(`(unstaged file) (magit-stage-1 "-u" (list (magit-section-value it))))
(`(unstaged files) (magit-stage-1 "-u" (magit-region-values)))
(`(unstaged list) (magit-stage-1 "-u"))
(`(staged ,_) (user-error "Already staged"))
(`(committed ,_) (user-error "Cannot stage committed changes"))
(`(undefined ,_) (user-error "Cannot stage this change")))))
;;;###autoload
(defun magit-stage-file (file)
......@@ -211,7 +212,9 @@ ignored) files.
(defun magit-stage-1 (arg &optional files)
(magit-wip-commit-before-change files " before stage")
(magit-run-git-no-revert "add" arg (if files (cons "--" files) "."))
(magit-run-git "add" arg (if files (cons "--" files) "."))
(when magit-auto-revert-mode
(mapc #'magit-turn-on-auto-revert-mode-if-desired files))
(magit-wip-commit-after-apply files " after stage"))
(defun magit-stage-untracked ()
......@@ -227,14 +230,15 @@ ignored) files.
(push file plain)))
(magit-wip-commit-before-change files " before stage")
(when plain
(magit-run-git-no-revert "add" "--" plain))
(magit-run-git "add" "--" plain)
(when magit-auto-revert-mode
(mapc #'magit-turn-on-auto-revert-mode-if-desired plain)))
(dolist (repo repos)
(let ((inhibit-magit-revert t))
(save-excursion
(goto-char (magit-section-start
(magit-get-section
`((file . ,repo) (untracked) (status)))))
(call-interactively 'magit-submodule-add))))
(save-excursion
(goto-char (magit-section-start
(magit-get-section
`((file . ,repo) (untracked) (status)))))
(call-interactively 'magit-submodule-add)))
(magit-wip-commit-after-apply files " after stage")))
;;;; Unstage
......@@ -243,18 +247,19 @@ ignored) files.
"Remove the change at point from the staging area."
(interactive)
(--when-let (magit-apply--get-selection)
(let ((inhibit-magit-revert t))
(pcase (list (magit-diff-type) (magit-diff-scope))
(`(untracked ,_) (user-error "Cannot unstage untracked changes"))
(`(unstaged ,_) (user-error "Already unstaged"))
(`(staged region) (magit-apply-region it "--reverse" "--cached"))
(`(staged hunk) (magit-apply-hunk it "--reverse" "--cached"))
(`(staged hunks) (magit-apply-hunks it "--reverse" "--cached"))
(`(staged file) (magit-unstage-1 (list (magit-section-value it))))
(`(staged files) (magit-unstage-1 (magit-region-values)))
(`(staged list) (magit-unstage-all))
(`(committed ,_) (user-error "Cannot unstage committed changes"))
(`(undefined ,_) (user-error "Cannot unstage this change"))))))
(pcase (list (magit-diff-type) (magit-diff-scope))
(`(untracked ,_) (user-error "Cannot unstage untracked changes"))
(`(unstaged ,_) (user-error "Already unstaged"))
(`(staged region) (magit-apply-region it "--reverse" "--cached"))
(`(staged hunk) (magit-apply-hunk it "--reverse" "--cached"))
(`(staged hunks) (magit-apply-hunks it "--reverse" "--cached"))
(`(staged file) (magit-unstage-1 (list (magit-section-value it))))
(`(staged files) (magit-unstage-1 (magit-region-values)))
(`(staged list) (magit-unstage-all))
(`(committed ,_) (if (bound-and-true-p magit-unstage-use-anti-stage)
(magit-anti-stage)
(user-error "Cannot unstage committed changes")))
(`(undefined ,_) (user-error "Cannot unstage this change")))))
;;;###autoload
(defun magit-unstage-file (file)
......@@ -501,14 +506,13 @@ without requiring confirmation."
(magit-reverse-files (list section) args))
(defun magit-reverse-files (sections args)
(cl-destructuring-bind (binaries sections)
(let ((binaries (magit-staged-binary-files)))
(--separate (member (magit-section-value it) binaries) sections))
(let ((files (mapcar #'magit-section-value sections)))
(when (magit-confirm-files 'reverse files)
(if (= (length sections) 1)
(magit-apply-diff (car sections) "--reverse" args)
(magit-apply-diffs sections "--reverse" args))))
(-let [(binaries sections)
(let ((bs (magit-staged-binary-files)))
(--separate (member (magit-section-value it) bs) sections))]
(when (magit-confirm-files 'reverse (mapcar #'magit-section-value sections))
(if (= (length sections) 1)
(magit-apply-diff (car sections) "--reverse" args)
(magit-apply-diffs sections "--reverse" args)))
(when binaries
(user-error "Cannot reverse binary files"))))
......
;;; magit-autorevert.el --- revert buffers when files in Git repositories change -*- lexical-binding: t -*-
;; Copyright (C) 2010-2016 The Magit Project Contributors
;;