From 4342c6c7ff704e0cf198ff66972bbc87849edfad Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Sun, 11 Dec 2022 13:23:55 +0100 Subject: [PATCH] update magit and magit-section Signed-off-by: Andreas Gerler --- elpa/magit-20220116.1908/AUTHORS.md | 382 -------- elpa/magit-20220116.1908/magit-bookmark.el | 209 ----- elpa/magit-20220116.1908/magit-imenu.el | 253 ------ elpa/magit-20220518.2359/AUTHORS.md | 386 ++++++++ .../LICENSE | 0 .../dir | 0 .../git-rebase.el | 182 ++-- .../magit-apply.el | 161 ++-- .../magit-autoloads.el | 430 ++++----- .../magit-autorevert.el | 31 +- .../magit-base.el} | 213 ++--- .../magit-bisect.el | 31 +- .../magit-blame.el | 227 +++-- elpa/magit-20220518.2359/magit-bookmark.el | 131 +++ .../magit-branch.el | 51 +- .../magit-bundle.el | 15 +- .../magit-clone.el | 57 +- .../magit-commit.el | 128 +-- .../magit-core.el | 20 +- .../magit-diff.el | 752 +++++++++------- .../magit-ediff.el | 387 +++++--- .../magit-extras.el | 308 ++++--- .../magit-fetch.el | 18 +- .../magit-files.el | 41 +- .../magit-git.el | 559 +++++++----- .../magit-gitignore.el | 17 +- .../magit-log.el | 324 ++++--- .../magit-margin.el | 65 +- .../magit-merge.el | 23 +- .../magit-mode.el | 481 ++++++---- .../magit-notes.el | 53 +- .../magit-obsolete.el | 23 +- .../magit-patch.el | 31 +- .../magit-pkg.el | 13 +- .../magit-process.el | 96 +- .../magit-pull.el | 27 +- .../magit-push.el | 47 +- .../magit-reflog.el | 26 +- .../magit-refs.el | 78 +- .../magit-remote.el | 33 +- .../magit-repos.el | 258 ++++-- .../magit-reset.el | 17 +- .../magit-sequence.el | 91 +- .../magit-sparse-checkout.el | 170 ++++ .../magit-stash.el | 78 +- .../magit-status.el | 110 +-- .../magit-submodule.el | 111 ++- .../magit-subtree.el | 19 +- .../magit-tag.el | 56 +- .../magit-transient.el | 86 +- .../magit-wip.el | 38 +- .../magit-worktree.el | 25 +- .../magit.el | 270 +++--- .../magit.info | 851 +++++++++++------- .../dir | 0 .../magit-section-autoloads.el | 4 +- .../magit-section-pkg.el | 5 +- .../magit-section.el | 829 ++++++++++++----- .../magit-section.info | 45 +- 59 files changed, 5359 insertions(+), 4013 deletions(-) delete mode 100644 elpa/magit-20220116.1908/AUTHORS.md delete mode 100644 elpa/magit-20220116.1908/magit-bookmark.el delete mode 100644 elpa/magit-20220116.1908/magit-imenu.el create mode 100644 elpa/magit-20220518.2359/AUTHORS.md rename elpa/{magit-20220116.1908 => magit-20220518.2359}/LICENSE (100%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/dir (100%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/git-rebase.el (83%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit-apply.el (87%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit-autoloads.el (87%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit-autorevert.el (90%) rename elpa/{magit-20220116.1908/magit-utils.el => magit-20220518.2359/magit-base.el} (90%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit-bisect.el (91%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit-blame.el (84%) create mode 100644 elpa/magit-20220518.2359/magit-bookmark.el rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit-branch.el (96%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit-bundle.el (90%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit-clone.el (86%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit-commit.el (87%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit-core.el (88%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit-diff.el (85%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit-ediff.el (53%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit-extras.el (80%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit-fetch.el (92%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit-files.el (94%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit-git.el (85%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit-gitignore.el (92%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit-log.el (87%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit-margin.el (81%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit-merge.el (94%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit-mode.el (78%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit-notes.el (82%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit-obsolete.el (84%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit-patch.el (92%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit-pkg.el (55%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit-process.el (94%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit-pull.el (88%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit-push.el (91%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit-reflog.el (89%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit-refs.el (92%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit-remote.el (94%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit-repos.el (62%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit-reset.el (90%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit-sequence.el (94%) create mode 100644 elpa/magit-20220518.2359/magit-sparse-checkout.el rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit-stash.el (88%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit-status.el (90%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit-submodule.el (90%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit-subtree.el (91%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit-tag.el (79%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit-transient.el (70%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit-wip.el (92%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit-worktree.el (89%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit.el (77%) rename elpa/{magit-20220116.1908 => magit-20220518.2359}/magit.info (95%) rename elpa/{magit-section-20220101.841 => magit-section-20220513.1429}/dir (100%) rename elpa/{magit-section-20220101.841 => magit-section-20220513.1429}/magit-section-autoloads.el (79%) rename elpa/{magit-section-20220101.841 => magit-section-20220513.1429}/magit-section-pkg.el (60%) rename elpa/{magit-section-20220101.841 => magit-section-20220513.1429}/magit-section.el (71%) rename elpa/{magit-section-20220101.841 => magit-section-20220513.1429}/magit-section.info (85%) diff --git a/elpa/magit-20220116.1908/AUTHORS.md b/elpa/magit-20220116.1908/AUTHORS.md deleted file mode 100644 index 44343b63..00000000 --- a/elpa/magit-20220116.1908/AUTHORS.md +++ /dev/null @@ -1,382 +0,0 @@ -Authors -======= - -The following people have contributed to Magit, including the -libraries `git-commit.el`, `magit-popup.el`, and `with-editor.el` -which are distributed as separate Elpa packages. - -For statistics see https://magit.vc/stats/authors.html. - -Names below are sorted alphabetically. - -Author ------- - -- Marius Vollmer - -Maintainer ----------- - -- Jonas Bernoulli - -Developers ----------- - -- Kyle Meyer -- Noam Postavsky - -Retired Maintainers and Developers ----------------------------------- - -- Nicolas Dudebout -- Peter J. Weisberg -- Pieter Praet -- Phil Jackson -- Rémi Vanicat -- Yann Hodique - -Contributors ------------- - -- Aaron Culich -- Aaron Madlon-Kay -- Abdo Roig-Maranges -- Adam Benanti <0entropy@protonmail.com> -- Adam Kruszewski -- Adam Porter -- Adam Spiers -- Adeodato Simó -- Ævar Arnfjörð Bjarmason -- Alan Falloon -- Alban Gruin -- Aleksey Uimanov -- Alexander Gramiak -- Alexander Miller -- Alex Branham -- Alex Dunn -- Alexey Voinov -- Alex Kost -- Alex Ott -- Allen Li -- Andreas Fuchs -- Andreas Liljeqvist -- Andreas Rottmann -- Andrei Chițu -- Andrew Eggenberger -- Andrew Kirkpatrick -- Andrew Psaltis -- Andrew Schwartzmeyer -- Andrey Smirnov -- Andriy Kmit' -- Andy Sawyer -- Aria Edmonds -- Arialdo Martini -- Arnau Roig Ninerola -- Ashlynn Anderson -- Barak A. Pearlmutter -- Bar Magal -- Bart Bakker -- Basil L. Contovounesios -- Bastian Beischer -- Bastian Beranek -- Benjamin Motz -- Ben North -- Ben Walton -- Bob Uhl -- Boruch Baum -- Bradley Wright -- Brandon W Maister -- Brian Leung -- Brian Warner -- Bryan Shell -- Buster Copley -- Carl Lieberman -- Chillar Anand -- Chris Bernard -- Chris Done -- Chris LaRose -- Chris Moore -- Chris Ring -- Chris Shoemaker -- Christian Dietrich -- Christian Kluge -- Christophe Junke -- Christopher Monsanto -- Clément Pit-Claudel -- Cornelius Mika -- Craig Andera -- Dale Hagglund -- Damien Cassou -- Dan Davison -- Dan Erikson -- Daniel Brockman -- Daniel Farina -- Daniel Fleischer -- Daniel Gröber -- Daniel Hackney -- Daniel Kraus -- Daniel Mai -- Daniel Martín -- Daniel Nagy -- Dan LaManna -- Danny Zhu -- Dato Simó -- David Abrahams -- David Ellison -- David Hull -- David L. Rager -- David Wallin -- Dean Kariniemi <8913263+d3k4r@users.noreply.github.com> -- Dennis Paskorz -- Divye Kapoor -- Dominique Quatravaux -- Duianto Vebotci -- Eli Barzilay -- Eric Davis -- Eric -- Eric Prud'hommeaux -- Eric Schulte -- Erik Anderson -- Evan Torrie -- Evgkeni Sampelnikof -- Eyal Lotem -- Fabian Wiget -- Felix Geller -- Felix Yan -- Feng Li -- Florian Ragwitz -- Franklin Delehelle -- Frédéric Giquel -- Fritz Grabo -- Fritz Stelzer -- Geoff Shannon -- George Kadianakis -- Graham Clark -- Graham Dobbins -- Greg A. Woods -- Greg Lucas -- Gregory Heytings -- Greg Sexton -- Guillaume Martres -- Hannu Koivisto -- Hans-Peter Deifel -- Hussein Ait-Lahcen -- Ian Eure -- Ian Milligan -- Ilya Grigoriev -- Ingmar Sittl -- Ingo Lohmar -- Ioan-Adrian Ratiu -- Ivan Brennan -- Jan Tatarik -- Jasper St. Pierre -- Jeff Bellegarde -- Jeff Dairiki -- Jeremy Meng -- Jesse Alama -- Jim Blandy -- Joakim Jalap -- Johannes Altmanninger -- Johann Klähn -- John Mastro -- John Morris -- John Wiegley -- Jonas Bernoulli -- Jonas Galvão Xavier -- Jonathan Arnett -- Jonathan del Strother -- Jonathan Leech-Pepin -- Jonathan Roes -- Jonathon McKitrick -- Jon Vanderwijk -- Jordan Galby -- Jordan Greenberg -- Josh Elsasser -- Josiah Schwab -- Julien Danjou -- Justin Burkett -- Justin Caratzas -- Justin Guenther -- Justin Thomas -- Kan-Ru Chen -- Kenny Ballou -- Keshav Kini -- Kevin Brubeck Unhammer -- Kevin J. Foley -- Kévin Le Gouguec -- Kimberly Wolk -- Knut Olav Bøhmer -- Kyle Meyer -- Laurent Laffont -- Laverne Schrock -- Leandro Facchinetti -- Lele Gaifax -- Leo Liu -- Leonardo Etcheverry -- Leo Vivier -- Lingchao Xin -- Lin Sun -- Li-Yun Chang -- Lluís Vilanova -- Loic Dachary -- Louis Roché -- Luís Oliveira -- Luke Amdor -- Magnus Malm -- Mak Kolybabi -- Manuel Vázquez Acosta -- Marcel Wolf -- Marc Herbert -- Marcin Bachry -- Marco Craveiro -- Marco Wahl -- Marc Sherry -- Marian Schubert -- Mario Rodas -- Marius Vollmer -- Mark Hepburn -- Mark Karpov -- Mark Oteiza -- Martin Joerg -- Martin Polden -- Matthew Fluet -- Matthew Kraai -- Matthieu Hauglustaine -- Matus Goljer -- Maxim Cournoyer -- Michael Fogleman -- Michael Griffiths -- Michael Heerdegen -- Michal Sojka -- Miciah Masters -- Miles Bader -- Miloš Mošić -- Mitchel Humpherys -- Moritz Bunkus -- Naoya Yamashita -- Natalie Weizenbaum -- Nguyễn Tuấn Anh -- Nic Ferier -- Nick Alcock -- Nick Alexander -- Nick Dimiduk -- Nicklas Lindgren -- Nicolas Dudebout -- Nicolas Petton -- Nicolas Richard -- Nikolay Martynov -- Noam Postavsky -- N. Troy de Freitas -- Ola x Nilsson -- Ole Arndt -- Oleh Krehel -- Orivej Desh -- Óscar Fuentes -- Pancho Horrillo -- Paul Stadig -- Pavel Holejsovsky -- Pekka Pessi -- Peter Eisentraut -- Peter Jaros -- Peter J. Weisberg -- Peter Vasil -- Philippe Cavalaria -- Philippe Vaucher -- Philipp Fehre -- Philipp Haselwarter -- Philipp Stephani -- Philip Weaver -- Phil Jackson -- Phil Sainty -- Pierre Neidhardt -- Pieter Praet -- Prathamesh Sonpatki -- Pritam Baral -- rabio -- Radon Rosborough -- Rafael Laboissiere -- Raimon Grau -- Ramkumar Ramachandra -- Remco van 't Veer -- Rémi Vanicat -- René Stadler -- Richard Kim -- Robert Boone -- Robin Green -- Roey Darwish Dror -- Roger Crew -- Romain Francoise -- Ron Parker -- Roy Crihfield -- Rüdiger Sonderfeld -- Russell Black -- Ryan C. Thompson -- Sam Cedarbaum -- Samuel Bronson -- Samuel W. Flint -- Sanjoy Das -- Sean Allred -- Sean Bryant -- Sean Whitton -- Sebastian Wiesner -- Sébastien Gross -- Seong-Kook Shin -- Sergey Pashinin -- Sergey Vinokurov -- Servilio Afre Puentes -- Siavash Askari Nasr -- Silent Sphere -- Simon Pintarelli -- Štěpán Němec -- Steven Chow -- Steven E. Harris -- Steven Thomas -- Steven Vancoillie -- Steve Purcell -- Suhail Shergill -- Sylvain Rousseau -- Syohei Yoshida -- Szunti -- Takafumi Arakaki -- Tassilo Horn -- TEC -- Teemu Likonen -- Teruki Shigitani -- Thierry Volpiatto -- Thomas A Caswell -- Thomas Fini Hansen -- Thomas Frössman -- Thomas Jost -- Thomas Riccardi -- Tibor Simko -- Timo Juhani Lindfors -- Tim Perkins -- Tim Wraight -- Ting-Yu Lin -- Tom Feist -- Toon Claes -- Topi Miettinen -- Troy Hinckley -- Tsuyoshi Kitamoto -- Tunc Uzlu -- Vineet Naik -- Vitaly Ostashov -- Vladimir Panteleev -- Vladimir Sedach -- Wei Huang -- Wilfred Hughes -- Win Treese -- Wojciech Siewierski -- Wouter Bolsterlee -- Xavier Noria -- Xu Chunyang -- Yann Herklotz -- Yann Hodique -- Ynilu -- York Zhao -- Yuichi Higashi -- Yuri Khan -- Zach Latta -- zakora -- Zhu Zihao -- zilongshanren diff --git a/elpa/magit-20220116.1908/magit-bookmark.el b/elpa/magit-20220116.1908/magit-bookmark.el deleted file mode 100644 index b65b3ace..00000000 --- a/elpa/magit-20220116.1908/magit-bookmark.el +++ /dev/null @@ -1,209 +0,0 @@ -;;; magit-bookmark.el --- bookmark support for Magit -*- lexical-binding: t -*- - -;; Copyright (C) 2010-2022 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. - -;; Author: Jonas Bernoulli -;; Maintainer: Jonas Bernoulli - -;; Inspired by an earlier implementation by Yuri Khan. - -;; SPDX-License-Identifier: GPL-3.0-or-later - -;; 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: - -;; Support for bookmarks for most Magit buffers. - -;;; Code: - -(require 'magit) -(require 'bookmark) - -;;; Core - -(defun magit--make-bookmark () - "Create a bookmark for the current Magit buffer. -Input values are the major-mode's `magit-bookmark-name' method, -and the buffer-local values of the variables referenced in its -`magit-bookmark-variables' property." - (if (plist-member (symbol-plist major-mode) 'magit-bookmark-variables) - ;; `bookmark-make-record-default's return value does not match - ;; (NAME . ALIST), even though it is used as the default value - ;; of `bookmark-make-record-function', which states that such - ;; functions must do that. See #4356. - (let ((bookmark (cons nil (bookmark-make-record-default 'no-file)))) - (bookmark-prop-set bookmark 'handler 'magit--handle-bookmark) - (bookmark-prop-set bookmark 'mode major-mode) - (bookmark-prop-set bookmark 'filename (magit-toplevel)) - (bookmark-prop-set bookmark 'defaults (list (magit-bookmark-name))) - (dolist (var (get major-mode 'magit-bookmark-variables)) - (bookmark-prop-set bookmark var (symbol-value var))) - (bookmark-prop-set - bookmark 'magit-hidden-sections - (--keep (and (oref it hidden) - (cons (oref it type) - (if (derived-mode-p 'magit-stash-mode) - (replace-regexp-in-string - (regexp-quote magit-buffer-revision) - magit-buffer-revision-hash - (oref it value)) - (oref it value)))) - (oref magit-root-section children))) - bookmark) - (user-error "Bookmarking is not implemented for %s buffers" major-mode))) - -;;;###autoload -(defun magit--handle-bookmark (bookmark) - "Open a bookmark created by `magit--make-bookmark'. -Call the `magit-*-setup-buffer' function of the the major-mode -with the variables' values as arguments, which were recorded by -`magit--make-bookmark'. Ignore `magit-display-buffer-function'." - (let ((buffer (let ((default-directory (bookmark-get-filename bookmark)) - (mode (bookmark-prop-get bookmark 'mode)) - (magit-display-buffer-function #'identity) - (magit-display-buffer-noselect t)) - (apply (intern (format "%s-setup-buffer" - (substring (symbol-name mode) 0 -5))) - (--map (bookmark-prop-get bookmark it) - (get mode 'magit-bookmark-variables)))))) - (set-buffer buffer) ; That is the interface we have to adhere to. - (when-let ((hidden (bookmark-prop-get bookmark 'magit-hidden-sections))) - (with-current-buffer buffer - (dolist (child (oref magit-root-section children)) - (if (member (cons (oref child type) - (oref child value)) - hidden) - (magit-section-hide child) - (magit-section-show child))))) - ;; Compatibility with `bookmark+' package. See #4356. - (when (bound-and-true-p bmkp-jump-display-function) - (funcall bmkp-jump-display-function (current-buffer))) - nil)) - -(cl-defgeneric magit-bookmark-name () - "Return name for bookmark to current buffer." - (format "%s%s" - (substring (symbol-name major-mode) 0 -5) - (if-let ((vars (get major-mode 'magit-bookmark-variables))) - (cl-mapcan (lambda (var) - (let ((val (symbol-value var))) - (if (and val (atom val)) - (list val) - val))) - vars) - ""))) - -;;; Diff -;;;; Diff - -(put 'magit-diff-mode 'magit-bookmark-variables - '(magit-buffer-range-hashed - magit-buffer-typearg - magit-buffer-diff-args - magit-buffer-diff-files)) - -(cl-defmethod magit-bookmark-name (&context (major-mode magit-diff-mode)) - (format "magit-diff(%s%s)" - (pcase (magit-diff-type) - (`staged "staged") - (`unstaged "unstaged") - (`committed magit-buffer-range) - (`undefined - (delq nil (list magit-buffer-typearg magit-buffer-range-hashed)))) - (if magit-buffer-diff-files - (concat " -- " (mapconcat #'identity magit-buffer-diff-files " ")) - ""))) - -;;;; Revision - -(put 'magit-revision-mode 'magit-bookmark-variables - '(magit-buffer-revision-hash - magit-buffer-diff-args - magit-buffer-diff-files)) - -(cl-defmethod magit-bookmark-name (&context (major-mode magit-revision-mode)) - (format "magit-revision(%s %s)" - (magit-rev-abbrev magit-buffer-revision) - (if magit-buffer-diff-files - (mapconcat #'identity magit-buffer-diff-files " ") - (magit-rev-format "%s" magit-buffer-revision)))) - -;;;; Stash - -(put 'magit-stash-mode 'magit-bookmark-variables - '(magit-buffer-revision-hash - magit-buffer-diff-args - magit-buffer-diff-files)) - -(cl-defmethod magit-bookmark-name (&context (major-mode magit-stash-mode)) - (format "magit-stash(%s %s)" - (magit-rev-abbrev magit-buffer-revision) - (if magit-buffer-diff-files - (mapconcat #'identity magit-buffer-diff-files " ") - (magit-rev-format "%s" magit-buffer-revision)))) - -;;; Log -;;;; Log - -(put 'magit-log-mode 'magit-bookmark-variables - '(magit-buffer-revisions - magit-buffer-log-args - magit-buffer-log-files)) - -(cl-defmethod magit-bookmark-name (&context (major-mode magit-log-mode)) - (format "magit-log(%s%s)" - (mapconcat #'identity magit-buffer-revisions " ") - (if magit-buffer-log-files - (concat " -- " (mapconcat #'identity magit-buffer-log-files " ")) - ""))) - -;;;; Cherry - -(put 'magit-cherry-mode 'magit-bookmark-variables - '(magit-buffer-refname - magit-buffer-upstream)) - -(cl-defmethod magit-bookmark-name (&context (major-mode magit-cherry-mode)) - (format "magit-cherry(%s > %s)" - magit-buffer-refname - magit-buffer-upstream)) - -;;;; Reflog - -(put 'magit-reflog-mode 'magit-bookmark-variables - '(magit-buffer-refname)) - -(cl-defmethod magit-bookmark-name (&context (major-mode magit-reflog-mode)) - (format "magit-reflog(%s)" magit-buffer-refname)) - -;;; Misc - -(put 'magit-status-mode 'magit-bookmark-variables nil) - -(put 'magit-refs-mode 'magit-bookmark-variables - '(magit-buffer-upstream - magit-buffer-arguments)) - -(put 'magit-stashes-mode 'magit-bookmark-variables nil) - -(cl-defmethod magit-bookmark-name (&context (major-mode magit-stashes-mode)) - (format "magit-states(%s)" magit-buffer-refname)) - -;;; _ -(provide 'magit-bookmark) -;;; magit-bookmark.el ends here diff --git a/elpa/magit-20220116.1908/magit-imenu.el b/elpa/magit-20220116.1908/magit-imenu.el deleted file mode 100644 index fad04dec..00000000 --- a/elpa/magit-20220116.1908/magit-imenu.el +++ /dev/null @@ -1,253 +0,0 @@ -;;; magit-imenu.el --- Integrate Imenu in magit major modes -*- lexical-binding: t -*- - -;; Copyright (C) 2010-2022 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. - -;; Author: Damien Cassou -;; Maintainer: Jonas Bernoulli - -;; SPDX-License-Identifier: GPL-3.0-or-later - -;; 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: - -;; Emacs' major modes can facilitate navigation in their buffers by -;; supporting Imenu. In such major modes, launching Imenu (M-x imenu) -;; makes Emacs display a list of items (e.g., function definitions in -;; a programming major mode). Selecting an item from this list moves -;; point to this item. - -;; magit-imenu.el adds Imenu support to every major mode in Magit. - -;;; Code: - -(require 'magit) -(require 'git-rebase) - -;;; Core - -(defun magit-imenu--index-function (entry-types menu-types) - "Return an alist of imenu entries in current buffer. - -ENTRY-TYPES is a list of section types to be selected through -`imenu'. - -MENU-TYPES is a list of section types containing elements of -ENTRY-TYPES. Elements of MENU-TYPES are used to categorize -elements of ENTRY-TYPES. - -This function is used as a helper for functions set as -`imenu-create-index-function'." - ;; If `which-function-mode' is active, then the create-index - ;; function is called at the time the major-mode is being enabled. - ;; Modes that derive from `magit-mode' have not populated the buffer - ;; at that time yet, so we have to abort. - (when-let ((section (magit-current-section)) - (entries (make-hash-table :test 'equal))) - (goto-char (point-max)) - (unless (oref section parent) - (forward-line -1)) - (while (magit-section--backward-find - (lambda () - (let* ((section (magit-current-section)) - (type (oref section type)) - (parent (oref section parent)) - (parent-type (oref parent type))) - (and (memq type entry-types) - (memq parent-type menu-types))))) - (let* ((section (magit-current-section)) - (name (buffer-substring-no-properties - (line-beginning-position) - (line-end-position))) - (parent (oref section parent)) - (parent-title (buffer-substring-no-properties - (oref parent start) - (1- (oref parent content))))) - (when (string-match " ([0-9]*)\\'" parent-title) - (setq parent-title (substring parent-title 0 (match-beginning 0)))) - (puthash parent-title - (cons (cons name (point)) - (gethash parent-title entries (list))) - entries))) - (mapcar (lambda (menu-title) - (cons menu-title (gethash menu-title entries))) - (hash-table-keys entries)))) - -;;; Log mode - -;;;###autoload -(defun magit-imenu--log-prev-index-position-function () - "Move point to previous line in current buffer. -This function is used as a value for -`imenu-prev-index-position-function'." - (magit-section--backward-find - (lambda () - (-contains-p '(commit stash) - (oref (magit-current-section) type))))) - -;;;###autoload -(defun magit-imenu--log-extract-index-name-function () - "Return imenu name for line at point. -This function is used as a value for -`imenu-extract-index-name-function'. Point should be at the -beginning of the line." - (save-match-data - (looking-at "\\([^ ]+\\)[ *|]+\\(.+\\)$") - (format "%s: %s" - (match-string-no-properties 1) - (match-string-no-properties 2)))) - -;;; Diff mode - -;;;###autoload -(defun magit-imenu--diff-prev-index-position-function () - "Move point to previous file line in current buffer. -This function is used as a value for -`imenu-prev-index-position-function'." - (magit-section--backward-find - (lambda () - (let ((section (magit-current-section))) - (and (magit-file-section-p section) - (not (equal (oref (oref section parent) type) - 'diffstat))))))) - -;;;###autoload -(defun magit-imenu--diff-extract-index-name-function () - "Return imenu name for line at point. -This function is used as a value for -`imenu-extract-index-name-function'. Point should be at the -beginning of the line." - (buffer-substring-no-properties (line-beginning-position) - (line-end-position))) - -;;; Status mode - -;;;###autoload -(defun magit-imenu--status-create-index-function () - "Return an alist of all imenu entries in current buffer. -This function is used as a value for -`imenu-create-index-function'." - (magit-imenu--index-function - '(file commit stash pullreq issue) - '(unpushed unstaged unpulled untracked staged stashes pullreqs issues))) - -;;; Refs mode - -;;;###autoload -(defun magit-imenu--refs-create-index-function () - "Return an alist of all imenu entries in current buffer. -This function is used as a value for -`imenu-create-index-function'." - (magit-imenu--index-function - '(branch commit tag) - '(local remote tags))) - -;;; Cherry mode - -;;;###autoload -(defun magit-imenu--cherry-create-index-function () - "Return an alist of all imenu entries in current buffer. -This function is used as a value for -`imenu-create-index-function'." - (magit-imenu--index-function - '(commit) - '(cherries))) - -;;; Submodule list mode - -;;;###autoload -(defun magit-imenu--submodule-prev-index-position-function () - "Move point to previous line in magit-submodule-list buffer. -This function is used as a value for -`imenu-prev-index-position-function'." - (unless (bobp) - (forward-line -1))) - -;;;###autoload -(defun magit-imenu--submodule-extract-index-name-function () - "Return imenu name for line at point. -This function is used as a value for -`imenu-extract-index-name-function'. Point should be at the -beginning of the line." - (elt (tabulated-list-get-entry) 0)) - -;;; Repolist mode - -;;;###autoload -(defun magit-imenu--repolist-prev-index-position-function () - "Move point to previous line in magit-repolist buffer. -This function is used as a value for -`imenu-prev-index-position-function'." - (unless (bobp) - (forward-line -1))) - -;;;###autoload -(defun magit-imenu--repolist-extract-index-name-function () - "Return imenu name for line at point. -This function is used as a value for -`imenu-extract-index-name-function'. Point should be at the -beginning of the line." - (let ((entry (tabulated-list-get-entry))) - (format "%s (%s)" - (elt entry 0) - (elt entry (1- (length entry)))))) - -;;; Process mode - -;;;###autoload -(defun magit-imenu--process-prev-index-position-function () - "Move point to previous process in magit-process buffer. -This function is used as a value for -`imenu-prev-index-position-function'." - (magit-section--backward-find - (lambda () - (eq (oref (magit-current-section) type) 'process)))) - -;;;###autoload -(defun magit-imenu--process-extract-index-name-function () - "Return imenu name for line at point. -This function is used as a value for -`imenu-extract-index-name-function'. Point should be at the -beginning of the line." - (buffer-substring-no-properties (line-beginning-position) - (line-end-position))) - -;;; Rebase mode - -;;;###autoload -(defun magit-imenu--rebase-prev-index-position-function () - "Move point to previous commit in git-rebase buffer. -This function is used as a value for -`imenu-prev-index-position-function'." - (catch 'found - (while (not (bobp)) - (git-rebase-backward-line) - (when (git-rebase-line-p) - (throw 'found t))))) - -;;;###autoload -(defun magit-imenu--rebase-extract-index-name-function () - "Return imenu name for line at point. -This function is used as a value for -`imenu-extract-index-name-function'. Point should be at the -beginning of the line." - (buffer-substring-no-properties (line-beginning-position) - (line-end-position))) - -;;; _ -(provide 'magit-imenu) -;;; magit-imenu.el ends here diff --git a/elpa/magit-20220518.2359/AUTHORS.md b/elpa/magit-20220518.2359/AUTHORS.md new file mode 100644 index 00000000..5eba5756 --- /dev/null +++ b/elpa/magit-20220518.2359/AUTHORS.md @@ -0,0 +1,386 @@ +The following people have contributed to Magit, including the +libraries `git-commit.el`, `magit-popup.el`, and `with-editor.el` +which are distributed as separate Elpa packages. + +For statistics see https://magit.vc/stats/magit/authors.html. + +Authors +------- + +- Marius Vollmer +- Jonas Bernoulli + +Active Maintainers +------------------ + +- Jonas Bernoulli +- Kyle Meyer + +Former Maintainers +------------------ + +- Nicolas Dudebout +- Noam Postavsky +- Peter J. Weisberg +- Phil Jackson +- Rémi Vanicat +- Yann Hodique + +All Contributors +---------------- + +- Aaron Culich +- Aaron L. Zeng +- Aaron Madlon-Kay +- Abdo Roig-Maranges +- Adam Benanti +- Adam Kruszewski +- Adam Porter +- Adam Spiers +- Adeodato Simó +- Ævar Arnfjörð Bjarmason +- Alan Falloon +- Alban Gruin +- Aleksey Uimanov +- Alexander Gramiak +- Alexander Miller +- Alex Branham +- Alex Dunn +- Alexey Voinov +- Alex Kost +- Alex Ott +- Allen Li +- Andreas Fuchs +- Andreas Liljeqvist +- Andreas Rottmann +- Andrei Chițu +- Andrew Eggenberger +- Andrew Kirkpatrick +- Andrew Psaltis +- Andrew Schwartzmeyer +- Andrey Smirnov +- Andriy Kmit' +- Andy Sawyer +- Angel de Vicente +- Aria Edmonds +- Arialdo Martini +- Arnau Roig Ninerola +- Ashlynn Anderson +- Barak A. Pearlmutter +- Bar Magal +- Bart Bakker +- Basil L. Contovounesios +- Bastian Beischer +- Bastian Beranek +- Benjamin Motz +- Ben North +- Ben Walton +- Bob Uhl +- Boruch Baum +- Bradley Wright +- Brandon W Maister +- Brennan Vincent +- Brian Leung +- Brian Warner +- Bryan Shell +- Buster Copley +- Cameron Chaparro +- Carl Lieberman +- Chillar Anand +- Chris Bernard +- Chris Done +- Chris LaRose +- Chris Moore +- Chris Ring +- Chris Shoemaker +- Christian Dietrich +- Christian Kluge +- Christophe Junke +- Christopher Monsanto +- Clément Pit-Claudel +- Cornelius Mika +- Craig Andera +- Dale Hagglund +- Damien Cassou +- Dan Davison +- Dan Erikson +- Daniel Brockman +- Daniel Farina +- Daniel Fleischer +- Daniel Gröber +- Daniel Hackney +- Daniel Kraus +- Daniel Mai +- Daniel Martín +- Daniel Nagy +- Dan Kessler +- Dan LaManna +- Danny Zhu +- Dato Simó +- David Abrahams +- David Ellison +- David Hull +- David L. Rager +- David Wallin +- Dean Kariniemi +- Dennis Paskorz +- Divye Kapoor +- Dominique Quatravaux +- Duianto Vebotci +- Eli Barzilay +- Eric +- Eric Davis +- Eric Prud'hommeaux +- Eric Schulte +- Erik Anderson +- Evan Torrie +- Evgkeni Sampelnikof +- Eyal Lotem +- Fabian Wiget +- Felix Geller +- Felix Yan +- Feng Li +- Florian Ragwitz +- Franklin Delehelle +- Frédéric Giquel +- Fritz Grabo +- Fritz Stelzer +- Geoff Shannon +- George Kadianakis +- Géza Herman +- Graham Clark +- Graham Dobbins +- Greg A. Woods +- Greg Lucas +- Gregory Heytings +- Greg Sexton +- Greg Steuck +- Guillaume Martres +- Hannu Koivisto +- Hans-Peter Deifel +- Hussein Ait-Lahcen +- Ian Eure +- Ian Milligan +- Ilya Grigoriev +- Ingmar Sittl +- Ingo Lohmar +- Ioan-Adrian Ratiu +- Ivan Brennan +- Jan Tatarik +- Jasper St. Pierre +- Jean-Louis Giordano +- Jeff Bellegarde +- Jeff Dairiki +- Jeremy Meng +- Jesse Alama +- Jim Blandy +- Joakim Jalap +- Johannes Altmanninger +- Johann Klähn +- John Mastro +- John Morris +- John Wiegley +- Jonas Bernoulli +- Jonas Galvão Xavier +- Jonathan Arnett +- Jonathan del Strother +- Jonathan Leech-Pepin +- Jonathan Roes +- Jonathon McKitrick +- Jon Vanderwijk +- Jordan Galby +- Jordan Greenberg +- Jorge Israel Peña +- Josh Elsasser +- Josiah Schwab +- Julien Danjou +- Justin Burkett +- Justin Caratzas +- Justin Guenther +- Justin Thomas +- Kan-Ru Chen +- Kenny Ballou +- Keshav Kini +- Kevin Brubeck Unhammer +- Kevin J. Foley +- Kévin Le Gouguec +- Kimberly Wolk +- Knut Olav Bøhmer +- Kyle Meyer +- Laurent Laffont +- Laverne Schrock +- Leandro Facchinetti +- Lele Gaifax +- Leo Liu +- Leonardo Etcheverry +- Leo Vivier +- Lingchao Xin +- Lin Sun +- Li-Yun Chang +- Lluís Vilanova +- Loic Dachary +- Louis Roché +- Luís Oliveira +- Luke Amdor +- Magnus Malm +- Mak Kolybabi +- Manuel Vázquez Acosta +- Marcel Wolf +- Marc Herbert +- Marcin Bachry +- Marco Craveiro +- Marco Wahl +- Marc Sherry +- Marian Schubert +- Mario Rodas +- Marius Vollmer +- Mark Hepburn +- Mark Karpov +- Mark Oteiza +- Martin Joerg +- Martin Polden +- Matthew Fluet +- Matthew Kraai +- Matthieu Hauglustaine +- Matus Goljer +- Maxim Cournoyer +- Michael Fogleman +- Michael Griffiths +- Michael Heerdegen +- Michal Sojka +- Miciah Masters +- Miles Bader +- Miloš Mošić +- Mitchel Humpherys +- Moritz Bunkus +- Naoya Yamashita +- Natalie Weizenbaum +- Nguyễn Tuấn Anh +- Nic Ferier +- Nick Alcock +- Nick Alexander +- Nick Dimiduk +- Nicklas Lindgren +- Nicolas Dudebout +- Nicolas Petton +- Nicolas Richard +- Nikolay Martynov +- Noam Postavsky +- N. Troy de Freitas +- Ola x Nilsson +- Ole Arndt +- Oleh Krehel +- Orivej Desh +- Óscar Fuentes +- Pancho Horrillo +- Paul Stadig +- Pavel Holejsovsky +- Pekka Pessi +- Peter Eisentraut +- Peter Jaros +- Peter J. Weisberg +- Peter Vasil +- Philippe Cavalaria +- Philippe Vaucher +- Philipp Fehre +- Philipp Haselwarter +- Philipp Stephani +- Philip Weaver +- Phil Jackson +- Phil Sainty +- Pierre Neidhardt +- Pieter Praet +- Prathamesh Sonpatki +- Pritam Baral +- rabio +- Radon Rosborough +- Rafael Laboissiere +- Raimon Grau +- Ramkumar Ramachandra +- Remco van 't Veer +- Rémi Vanicat +- René Stadler +- Richard Kim +- Robert Boone +- Robert Irelan +- Robin Green +- Roey Darwish Dror +- Roger Crew +- Romain Francoise +- Ron Parker +- Roy Crihfield +- Rüdiger Sonderfeld +- Russell Black +- Ryan C. Thompson +- Sam Cedarbaum +- Samuel Bronson +- Samuel W. Flint +- Sanjoy Das +- Sean Allred +- Sean Bryant +- Sean Whitton +- Sebastian Wiesner +- Sébastien Gross +- Seong-Kook Shin +- Sergey Pashinin +- Sergey Vinokurov +- Servilio Afre Puentes +- Shuguang Sun +- Siavash Askari Nasr +- Silent Sphere +- Simon Pintarelli +- Stefan Kangas +- Štěpán Němec +- Steven Chow +- Steven E. Harris +- Steven Thomas +- Steven Vancoillie +- Steve Purcell +- Suhail Shergill +- Sylvain Rousseau +- Syohei Yoshida +- Szunti +- Takafumi Arakaki +- Tassilo Horn +- TEC +- Teemu Likonen +- Teruki Shigitani +- Thierry Volpiatto +- Thomas A Caswell +- Thomas Fini Hansen +- Thomas Frössman +- Thomas Jost +- Thomas Riccardi +- Tibor Simko +- Timo Juhani Lindfors +- Tim Perkins +- Tim Wraight +- Ting-Yu Lin +- Tom Feist +- Toon Claes +- Topi Miettinen +- Troy Hinckley +- Tsuyoshi Kitamoto +- Tunc Uzlu +- Vineet Naik +- Vitaly Ostashov +- Vladimir Ivanov +- Vladimir Panteleev +- Vladimir Sedach +- Wei Huang +- Wilfred Hughes +- Win Treese +- Wojciech Siewierski +- Wouter Bolsterlee +- Xavier Noria +- Xu Chunyang +- Yann Herklotz +- Yann Hodique +- Ynilu +- York Zhao +- Yuichi Higashi +- Yuri Khan +- Zach Latta +- zakora +- Zhu Zihao +- zilongshanren diff --git a/elpa/magit-20220116.1908/LICENSE b/elpa/magit-20220518.2359/LICENSE similarity index 100% rename from elpa/magit-20220116.1908/LICENSE rename to elpa/magit-20220518.2359/LICENSE diff --git a/elpa/magit-20220116.1908/dir b/elpa/magit-20220518.2359/dir similarity index 100% rename from elpa/magit-20220116.1908/dir rename to elpa/magit-20220518.2359/dir diff --git a/elpa/magit-20220116.1908/git-rebase.el b/elpa/magit-20220518.2359/git-rebase.el similarity index 83% rename from elpa/magit-20220116.1908/git-rebase.el rename to elpa/magit-20220518.2359/git-rebase.el index a893a64d..fa75c190 100644 --- a/elpa/magit-20220116.1908/git-rebase.el +++ b/elpa/magit-20220518.2359/git-rebase.el @@ -1,27 +1,24 @@ -;;; git-rebase.el --- Edit Git rebase files -*- lexical-binding: t -*- +;;; git-rebase.el --- Edit Git rebase files -*- lexical-binding:t -*- -;; Copyright (C) 2010-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Phil Jackson ;; Maintainer: Jonas Bernoulli ;; SPDX-License-Identifier: GPL-3.0-or-later -;; This file 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. - -;; This file 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. - +;; 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 of the License, 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 this file. If not, see . +;; along with Magit. If not, see . ;;; Commentary: @@ -149,35 +146,35 @@ (defvar git-rebase-mode-map (let ((map (make-sparse-keymap))) (set-keymap-parent map special-mode-map) - (define-key map (kbd "C-m") 'git-rebase-show-commit) - (define-key map (kbd "p") 'git-rebase-backward-line) - (define-key map (kbd "n") 'forward-line) - (define-key map (kbd "M-p") 'git-rebase-move-line-up) - (define-key map (kbd "M-n") 'git-rebase-move-line-down) - (define-key map (kbd "c") 'git-rebase-pick) - (define-key map (kbd "k") 'git-rebase-kill-line) - (define-key map (kbd "C-k") 'git-rebase-kill-line) - (define-key map (kbd "b") 'git-rebase-break) - (define-key map (kbd "e") 'git-rebase-edit) - (define-key map (kbd "l") 'git-rebase-label) - (define-key map (kbd "MM") 'git-rebase-merge) - (define-key map (kbd "Mt") 'git-rebase-merge-toggle-editmsg) - (define-key map (kbd "m") 'git-rebase-edit) - (define-key map (kbd "f") 'git-rebase-fixup) - (define-key map (kbd "q") 'undefined) - (define-key map (kbd "r") 'git-rebase-reword) - (define-key map (kbd "w") 'git-rebase-reword) - (define-key map (kbd "s") 'git-rebase-squash) - (define-key map (kbd "t") 'git-rebase-reset) - (define-key map (kbd "x") 'git-rebase-exec) - (define-key map (kbd "y") 'git-rebase-insert) - (define-key map (kbd "z") 'git-rebase-noop) - (define-key map (kbd "SPC") 'git-rebase-show-or-scroll-up) - (define-key map (kbd "DEL") 'git-rebase-show-or-scroll-down) - (define-key map (kbd "C-x C-t") 'git-rebase-move-line-up) - (define-key map [M-up] 'git-rebase-move-line-up) - (define-key map [M-down] 'git-rebase-move-line-down) - (define-key map [remap undo] 'git-rebase-undo) + (define-key map (kbd "C-m") #'git-rebase-show-commit) + (define-key map (kbd "p") #'git-rebase-backward-line) + (define-key map (kbd "n") #'forward-line) + (define-key map (kbd "M-p") #'git-rebase-move-line-up) + (define-key map (kbd "M-n") #'git-rebase-move-line-down) + (define-key map (kbd "c") #'git-rebase-pick) + (define-key map (kbd "k") #'git-rebase-kill-line) + (define-key map (kbd "C-k") #'git-rebase-kill-line) + (define-key map (kbd "b") #'git-rebase-break) + (define-key map (kbd "e") #'git-rebase-edit) + (define-key map (kbd "l") #'git-rebase-label) + (define-key map (kbd "M M") #'git-rebase-merge) + (define-key map (kbd "M t") #'git-rebase-merge-toggle-editmsg) + (define-key map (kbd "m") #'git-rebase-edit) + (define-key map (kbd "f") #'git-rebase-fixup) + (define-key map (kbd "q") #'undefined) + (define-key map (kbd "r") #'git-rebase-reword) + (define-key map (kbd "w") #'git-rebase-reword) + (define-key map (kbd "s") #'git-rebase-squash) + (define-key map (kbd "t") #'git-rebase-reset) + (define-key map (kbd "x") #'git-rebase-exec) + (define-key map (kbd "y") #'git-rebase-insert) + (define-key map (kbd "z") #'git-rebase-noop) + (define-key map (kbd "SPC") #'git-rebase-show-or-scroll-up) + (define-key map (kbd "DEL") #'git-rebase-show-or-scroll-down) + (define-key map (kbd "C-x C-t") #'git-rebase-move-line-up) + (define-key map [M-up] #'git-rebase-move-line-up) + (define-key map [M-down] #'git-rebase-move-line-down) + (define-key map [remap undo] #'git-rebase-undo) map) "Keymap for Git-Rebase mode.") @@ -318,7 +315,7 @@ instance with all nil values is returned." git-rebase-line-regexps))) (git-rebase-action :action-type type - :action (when-let ((action (match-string-no-properties 1))) + :action (and-let* ((action (match-string-no-properties 1))) (or (cdr (assoc action git-rebase-short-options)) action)) :action-options (match-string-no-properties 2) @@ -639,15 +636,15 @@ Like `undo' but works in read-only buffers." (undo arg))) (defun git-rebase--show-commit (&optional scroll) - (let ((disable-magit-save-buffers t)) + (let ((magit--disable-save-buffers t)) (save-excursion (goto-char (line-beginning-position)) (--if-let (with-slots (action-type target) (git-rebase-current-line) (and (eq action-type 'commit) target)) (pcase scroll - (`up (magit-diff-show-or-scroll-up)) - (`down (magit-diff-show-or-scroll-down)) + ('up (magit-diff-show-or-scroll-up)) + ('down (magit-diff-show-or-scroll-down)) (_ (apply #'magit-show-commit it (magit-diff-arguments 'magit-revision-mode)))) (ding))))) @@ -705,11 +702,11 @@ running 'man git-rebase' at the command line) for details." (with-editor-mode 1)) (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) + #'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) (setq imenu-prev-index-position-function #'magit-imenu--rebase-prev-index-position-function) (setq imenu-extract-index-name-function @@ -786,48 +783,79 @@ By default, this is the same except for the \"pick\" command." nil t)) (goto-char (line-beginning-position)) (pcase-dolist (`(,cmd . ,desc) git-rebase-command-descriptions) - (insert (format "%s %-8s %s\n" + (insert (format (propertize "%s %s %s\n" + 'font-lock-face 'font-lock-comment-face) comment-start - (substitute-command-keys (format "\\[%s]" cmd)) + (string-pad + (substitute-command-keys (format "\\[%s]" cmd)) 8) desc))) - (while (re-search-forward (concat git-rebase-comment-re - "\\( ?\\)\\([^\n,],\\) " - "\\([^\n ]+\\) ") - nil t) - (let ((cmd (intern (concat "git-rebase-" (match-string 3))))) - (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 - (--remove (eq (elt it 0) 'menu-bar) - (reverse (where-is-internal - cmd git-rebase-mode-map))) - ", ")) - t t nil 2)))))))) - -(add-hook 'git-rebase-mode-hook 'git-rebase-mode-show-keybindings t) + (while (re-search-forward + (concat git-rebase-comment-re "\\(?:" + "\\( \\.? *\\)\\|" + "\\( +\\)\\([^\n,],\\) \\([^\n ]+\\) \\)") + nil t) + (if (match-string 1) + (replace-match (make-string 10 ?\s) t t nil 1) + (let ((cmd (intern (concat "git-rebase-" (match-string 4))))) + (if (not (fboundp cmd)) + (delete-region (line-beginning-position) + (1+ (line-end-position))) + (add-text-properties (line-beginning-position) + (1+ (line-end-position)) + '(font-lock-face font-lock-comment-face)) + (replace-match " " t t nil 2) + (replace-match + (string-pad + (mapconcat (lambda (key) + (save-match-data + (substitute-command-keys + (format "\\`%s'" (key-description key))))) + (cl-remove-if (lambda (key) (eq (elt key 0) 'menu-bar)) + (reverse (where-is-internal + cmd git-rebase-mode-map))) + ", ") + 8) + t t nil 3))))))))) + +(add-hook 'git-rebase-mode-hook #'git-rebase-mode-show-keybindings t) (defun git-rebase-mode-disable-before-save-hook () (set (make-local-variable 'before-save-hook) nil)) -(add-hook 'git-rebase-mode-hook 'git-rebase-mode-disable-before-save-hook) +(add-hook 'git-rebase-mode-hook #'git-rebase-mode-disable-before-save-hook) ;;;###autoload (defconst git-rebase-filename-regexp "/git-rebase-todo\\'") ;;;###autoload (add-to-list 'auto-mode-alist - (cons git-rebase-filename-regexp 'git-rebase-mode)) + (cons git-rebase-filename-regexp #'git-rebase-mode)) (add-to-list 'with-editor-server-window-alist - (cons git-rebase-filename-regexp 'switch-to-buffer)) + (cons git-rebase-filename-regexp #'switch-to-buffer)) (with-eval-after-load 'recentf (add-to-list 'recentf-exclude git-rebase-filename-regexp)) (add-to-list 'with-editor-file-name-history-exclude git-rebase-filename-regexp) +;;; Imenu Support + +(defun magit-imenu--rebase-prev-index-position-function () + "Move point to previous commit in git-rebase buffer. +Used as a value for `imenu-prev-index-position-function'." + (catch 'found + (while (not (bobp)) + (git-rebase-backward-line) + (when (git-rebase-line-p) + (throw 'found t))))) + +(defun magit-imenu--rebase-extract-index-name-function () + "Return imenu name for line at point. +Point should be at the beginning of the line. This function +is used as a value for `imenu-extract-index-name-function'." + (buffer-substring-no-properties (line-beginning-position) + (line-end-position))) + ;;; _ (provide 'git-rebase) ;;; git-rebase.el ends here diff --git a/elpa/magit-20220116.1908/magit-apply.el b/elpa/magit-20220518.2359/magit-apply.el similarity index 87% rename from elpa/magit-20220116.1908/magit-apply.el rename to elpa/magit-20220518.2359/magit-apply.el index 3edae33c..bd18f78a 100644 --- a/elpa/magit-20220116.1908/magit-apply.el +++ b/elpa/magit-20220518.2359/magit-apply.el @@ -1,19 +1,16 @@ -;;; magit-apply.el --- apply Git diffs -*- lexical-binding: t -*- +;;; magit-apply.el --- Apply Git diffs -*- lexical-binding:t -*- -;; Copyright (C) 2010-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Jonas Bernoulli ;; Maintainer: Jonas Bernoulli ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Magit is free software; you can redistribute it and/or modify it +;; 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. +;; the Free Software Foundation, either version 3 of the License, 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 @@ -21,7 +18,7 @@ ;; 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. +;; along with Magit. If not, see . ;;; Commentary: @@ -50,9 +47,6 @@ (url &optional path name args)) (declare-function magit-submodule-read-name-for-path "magit-submodule" (path &optional prefer-short)) -(declare-function borg--maybe-absorb-gitdir "borg" (pkg)) -(declare-function borg--sort-submodule-sections "borg" (file)) -(declare-function borg-assimilate "borg" (package url &optional partially)) (defvar borg-user-emacs-directory) (cl-eval-when (compile load) @@ -109,9 +103,6 @@ is a member of `magit-post-stage-hook-commands'." :group 'magit-commands :type 'hook) -(defvar magit-post-stage-hook-commands - '(magit-stage magit-stage-file magit-stage-modified)) - (defcustom magit-post-unstage-hook nil "Hook run after unstaging changes. This hook is run by `magit-refresh' if `this-command' @@ -120,9 +111,6 @@ is a member of `magit-post-unstage-hook-commands'." :group 'magit-commands :type 'hook) -(defvar magit-post-unstage-hook-commands - '(magit-unstage magit-unstage-file magit-unstage-all)) - ;;; Commands ;;;; Apply @@ -133,15 +121,15 @@ so causes the change to be applied to the index as well." (interactive (and current-prefix-arg (list "--3way"))) (--when-let (magit-apply--get-selection) (pcase (list (magit-diff-type) (magit-diff-scope)) - (`(,(or `unstaged `staged) ,_) + (`(,(or 'unstaged 'staged) ,_) (user-error "Change is already in the working tree")) - (`(untracked ,(or `file `files)) - (call-interactively 'magit-am)) + (`(untracked ,(or 'file 'files)) + (call-interactively #'magit-am)) (`(,_ region) (magit-apply-region it args)) (`(,_ hunk) (magit-apply-hunk it args)) (`(,_ hunks) (magit-apply-hunks it args)) (`(rebase-sequence file) - (call-interactively 'magit-patch-apply)) + (call-interactively #'magit-patch-apply)) (`(,_ file) (magit-apply-diff it args)) (`(,_ files) (magit-apply-diffs it args))))) @@ -258,9 +246,9 @@ adjusted as \"@@ -10,6 +10,7 @@\" and \"@@ -18,6 +19,7 @@\"." (or (magit-region-sections '(hunk file module) t) (let ((section (magit-current-section))) (pcase (oref section type) - ((or `hunk `file `module) section) - ((or `staged `unstaged `untracked - `stashed-index `stashed-worktree `stashed-untracked) + ((or 'hunk 'file 'module) section) + ((or 'staged 'unstaged 'untracked + 'stashed-index 'stashed-worktree 'stashed-untracked) (oref section children)) (_ (user-error "Cannot apply this, it's not a change")))))) @@ -298,16 +286,16 @@ at point, stage the file but not its content." (`(unstaged region ,_) (magit-apply-region it "--cached")) (`(unstaged hunk ,_) (magit-apply-hunk it "--cached")) (`(unstaged hunks ,_) (magit-apply-hunks it "--cached")) - (`(unstaged file t) (magit-apply-diff it "--cached")) - (`(unstaged files t) (magit-apply-diffs it "--cached")) - (`(unstaged list t) (magit-apply-diffs it "--cached")) - (`(unstaged file nil) (magit-stage-1 "-u" (list (oref it value)))) - (`(unstaged files nil) (magit-stage-1 "-u" (magit-region-values nil t))) - (`(unstaged list nil) (magit-stage-modified)) + ('(unstaged file t) (magit-apply-diff it "--cached")) + ('(unstaged files t) (magit-apply-diffs it "--cached")) + ('(unstaged list t) (magit-apply-diffs it "--cached")) + ('(unstaged file nil) (magit-stage-1 "-u" (list (oref it value)))) + ('(unstaged files nil) (magit-stage-1 "-u" (magit-region-values nil t))) + ('(unstaged list nil) (magit-stage-modified)) (`(staged ,_ ,_) (user-error "Already staged")) (`(committed ,_ ,_) (user-error "Cannot stage committed changes")) (`(undefined ,_ ,_) (user-error "Cannot stage this change"))) - (call-interactively 'magit-stage-file))) + (call-interactively #'magit-stage-file))) ;;;###autoload (defun magit-stage-file (file) @@ -351,9 +339,9 @@ ignored) files." (defun magit-stage-untracked (&optional intent) (let* ((section (magit-current-section)) (files (pcase (magit-diff-scope) - (`file (list (oref section value))) - (`files (magit-region-values nil t)) - (`list (magit-untracked-files)))) + ('file (list (oref section value))) + ('files (magit-region-values nil t)) + ('list (magit-untracked-files)))) plain repos) (dolist (file files) (if (and (not (file-symlink-p file)) @@ -371,27 +359,36 @@ ignored) files." (goto-char (oref (magit-get-section `((file . ,repo) (untracked) (status))) start)) - (let* ((topdir (magit-toplevel)) - (url (let ((default-directory - (file-name-as-directory (expand-file-name repo)))) - (or (magit-get "remote" (magit-get-some-remote) "url") - (concat (file-name-as-directory ".") repo)))) - (package - (and (equal (bound-and-true-p borg-user-emacs-directory) - topdir) - (file-name-nondirectory (directory-file-name repo))))) - (if (and package - (y-or-n-p (format "Also assimilate `%s' drone?" package))) - (borg-assimilate package url) - (magit-submodule-add-1 - url repo (magit-submodule-read-name-for-path repo package)) - (when package - (borg--sort-submodule-sections - (expand-file-name ".gitmodules" topdir)) - (let ((default-directory borg-user-emacs-directory)) - (borg--maybe-absorb-gitdir package))))))) + (when (and (fboundp 'borg-assimilate) + (fboundp 'borg--maybe-absorb-gitdir) + (fboundp 'borg--sort-submodule-sections)) + (let* ((topdir (magit-toplevel)) + (url (let ((default-directory + (file-name-as-directory (expand-file-name repo)))) + (or (magit-get "remote" (magit-get-some-remote) "url") + (concat (file-name-as-directory ".") repo)))) + (package + (and (equal borg-user-emacs-directory topdir) + (file-name-nondirectory (directory-file-name repo))))) + (if (and package + (y-or-n-p (format "Also assimilate `%s' drone?" package))) + (borg-assimilate package url) + (magit-submodule-add-1 + url repo (magit-submodule-read-name-for-path repo package)) + (when package + (borg--sort-submodule-sections + (expand-file-name ".gitmodules" topdir)) + (let ((default-directory borg-user-emacs-directory)) + (borg--maybe-absorb-gitdir package)))))))) (magit-wip-commit-after-apply files " after stage"))) +(defvar magit-post-stage-hook-commands + '(magit-stage magit-stage-file magit-stage-modified)) + +(defun magit-run-post-stage-hook () + (when (memq this-command magit-post-stage-hook-commands) + (magit-run-hook-with-benchmark 'magit-post-stage-hook))) + ;;;; Unstage (defun magit-unstage () @@ -408,12 +405,12 @@ ignored) files." (`(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 t) (magit-apply-diff it "--reverse" "--cached")) - (`(staged files t) (magit-apply-diffs it "--reverse" "--cached")) - (`(staged list t) (magit-apply-diffs it "--reverse" "--cached")) - (`(staged file nil) (magit-unstage-1 (list (oref it value)))) - (`(staged files nil) (magit-unstage-1 (magit-region-values nil t))) - (`(staged list nil) (magit-unstage-all)) + ('(staged file t) (magit-apply-diff it "--reverse" "--cached")) + ('(staged files t) (magit-apply-diffs it "--reverse" "--cached")) + ('(staged list t) (magit-apply-diffs it "--reverse" "--cached")) + ('(staged file nil) (magit-unstage-1 (list (oref it value)))) + ('(staged files nil) (magit-unstage-1 (magit-region-values nil t))) + ('(staged list nil) (magit-unstage-all)) (`(committed ,_ ,_) (if magit-unstage-committed (magit-reverse-in-index) (user-error "Cannot unstage committed changes"))) @@ -463,6 +460,13 @@ without requiring confirmation." (magit-run-git "reset" "HEAD" "--" magit-buffer-diff-files) (magit-wip-commit-after-apply nil " after unstage")) +(defvar magit-post-unstage-hook-commands + '(magit-unstage magit-unstage-file magit-unstage-all)) + +(defun magit-run-post-unstage-hook () + (when (memq this-command magit-post-unstage-hook-commands) + (magit-run-hook-with-benchmark 'magit-post-unstage-hook))) + ;;;; Discard (defun magit-discard () @@ -491,8 +495,8 @@ of a side, then keep that side without prompting." (magit-confirm 'discard "Discard hunk") (let ((file (magit-section-parent-value section))) (pcase (cddr (car (magit-file-status file))) - (`(?U ?U) (magit-smerge-keep-current)) - (_ (magit-discard-apply section 'magit-apply-hunk))))) + ('(?U ?U) (magit-smerge-keep-current)) + (_ (magit-discard-apply section #'magit-apply-hunk))))) (defun magit-discard-apply (section apply) (if (eq (magit-diff-type section) 'unstaged) @@ -511,7 +515,7 @@ of a side, then keep that side without prompting." (magit-confirm 'discard (format "Discard %s hunks from %s" (length sections) (magit-section-parent-value (car sections)))) - (magit-discard-apply-n sections 'magit-apply-hunks)) + (magit-discard-apply-n sections #'magit-apply-hunks)) (defun magit-discard-apply-n (sections apply) (let ((section (car sections))) @@ -543,16 +547,17 @@ of a side, then keep that side without prompting." (`unstaged ?Y) (`untracked ?Z)) (cddr (assoc file status))) - (`(?Z) (dolist (f (magit-untracked-files nil file)) + ('(?Z) (dolist (f (magit-untracked-files nil file)) (push f delete))) - ((or `(?Z ?? ??) `(?Z ?! ?!)) (push file delete)) - ((or `(?Z ?D ? ) `(,_ ?D ?D)) (push file delete)) + ((or '(?Z ?? ??) '(?Z ?! ?!)) (push file delete)) + ('(?Z ?D ? ) (push file delete)) + (`(,_ ?D ?D) (push file resolve)) ((or `(,_ ?U ,_) `(,_ ,_ ?U)) (push file resolve)) (`(,_ ?A ?A) (push file resolve)) (`(?X ?M ,(or ? ?M ?D)) (push section discard)) (`(?Y ,_ ?M ) (push section discard)) - (`(?X ?A ?M ) (push file discard-new)) - (`(?X ?C ?M ) (push file discard-new)) + ('(?X ?A ?M ) (push file discard-new)) + ('(?X ?C ?M ) (push file discard-new)) (`(?X ?A ,(or ? ?D)) (push file delete)) (`(?X ?C ,(or ? ?D)) (push file delete)) (`(?X ?D ,(or ? ?M )) (push file resurrect)) @@ -654,10 +659,10 @@ of a side, then keep that side without prompting." (setq sections (--remove (member (oref it value) binaries) sections))) - (cond ((= (length sections) 1) + (cond ((length= sections 1) (magit-discard-apply (car sections) 'magit-apply-diff)) (sections - (magit-discard-apply-n sections 'magit-apply-diffs))) + (magit-discard-apply-n sections #'magit-apply-diffs))) (when binaries (let ((modified (magit-unstaged-files t))) (setq binaries (--separate (member it modified) binaries))) @@ -689,18 +694,18 @@ so causes the change to be applied to the index as well." (defun magit-reverse-region (section args) (magit-confirm 'reverse "Reverse region") - (magit-reverse-apply section 'magit-apply-region args)) + (magit-reverse-apply section #'magit-apply-region args)) (defun magit-reverse-hunk (section args) (magit-confirm 'reverse "Reverse hunk") - (magit-reverse-apply section 'magit-apply-hunk args)) + (magit-reverse-apply section #'magit-apply-hunk args)) (defun magit-reverse-hunks (sections args) (magit-confirm 'reverse (format "Reverse %s hunks from %s" (length sections) (magit-section-parent-value (car sections)))) - (magit-reverse-apply sections 'magit-apply-hunks args)) + (magit-reverse-apply sections #'magit-apply-hunks args)) (defun magit-reverse-file (section args) (magit-reverse-files (list section) args)) @@ -717,10 +722,10 @@ so causes the change to be applied to the index as well." (--separate (member (oref it value) bs) sections)))) (magit-confirm-files 'reverse (--map (oref it value) sections)) - (cond ((= (length sections) 1) - (magit-reverse-apply (car sections) 'magit-apply-diff args)) + (cond ((length= sections 1) + (magit-reverse-apply (car sections) #'magit-apply-diff args)) (sections - (magit-reverse-apply sections 'magit-apply-diffs args))) + (magit-reverse-apply sections #'magit-apply-diffs args))) (when binaries (user-error "Cannot reverse binary files")))) @@ -786,8 +791,8 @@ a separate commit. A typical workflow would be: (condition-case nil (smerge-match-conflict) (error - (if (eq fn 'smerge-keep-current) - (when (eq this-command 'magit-discard) + (if (eq fn #'smerge-keep-current) + (when (eq this-command #'magit-discard) (re-search-forward smerge-begin-re nil t) (setq fn (magit-read-char-case "Keep side: " t diff --git a/elpa/magit-20220116.1908/magit-autoloads.el b/elpa/magit-20220518.2359/magit-autoloads.el similarity index 87% rename from elpa/magit-20220116.1908/magit-autoloads.el rename to elpa/magit-20220518.2359/magit-autoloads.el index 89dad858..90d46ae0 100644 --- a/elpa/magit-20220116.1908/magit-autoloads.el +++ b/elpa/magit-20220518.2359/magit-autoloads.el @@ -1,4 +1,4 @@ -;;; magit-autoloads.el --- automatically extracted autoloads +;;; magit-autoloads.el --- automatically extracted autoloads -*- lexical-binding: t -*- ;; ;;; Code: @@ -26,9 +26,9 @@ running 'man git-rebase' at the command line) for details. (defconst git-rebase-filename-regexp "/git-rebase-todo\\'") -(add-to-list 'auto-mode-alist (cons git-rebase-filename-regexp 'git-rebase-mode)) +(add-to-list 'auto-mode-alist (cons git-rebase-filename-regexp #'git-rebase-mode)) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "git-rebase" '("git-rebase-"))) +(register-definition-prefixes "git-rebase" '("git-rebase-" "magit-imenu--rebase-")) ;;;*** @@ -81,9 +81,9 @@ Also see info node `(magit)Commands for Buffers Visiting Files'.") (custom-autoload 'magit-define-global-key-bindings "magit" t) -(defun magit-maybe-define-global-key-bindings nil (when magit-define-global-key-bindings (let ((map (current-global-map))) (dolist (elt '(("C-x g" . magit-status) ("C-x M-g" . magit-dispatch) ("C-c M-g" . magit-file-dispatch))) (let ((key (kbd (car elt))) (def (cdr elt))) (unless (or (lookup-key map key) (where-is-internal def (make-sparse-keymap) t)) (define-key map key def))))))) +(defun magit-maybe-define-global-key-bindings (&optional force) (when magit-define-global-key-bindings (let ((map (current-global-map))) (dolist (elt '(("C-x g" . magit-status) ("C-x M-g" . magit-dispatch) ("C-c M-g" . magit-file-dispatch))) (let ((key (kbd (car elt))) (def (cdr elt))) (when (or force (not (or (lookup-key map key) (where-is-internal def (make-sparse-keymap) t)))) (define-key map key def))))))) -(if after-init-time (magit-maybe-define-global-key-bindings) (add-hook 'after-init-hook 'magit-maybe-define-global-key-bindings t)) +(if after-init-time (magit-maybe-define-global-key-bindings) (add-hook 'after-init-hook #'magit-maybe-define-global-key-bindings t)) (autoload 'magit-dispatch "magit" nil t) (autoload 'magit-run "magit" nil t) @@ -135,7 +135,7 @@ and Emacs to it. \(fn &optional PRINT-DEST)" t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit" '("magit-"))) +(register-definition-prefixes "magit" '("magit-")) ;;;*** @@ -170,7 +170,7 @@ without requiring confirmation. (autoload 'magit-unstage-all "magit-apply" "\ Remove all changes from the staging area." t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-apply" '("magit-"))) +(register-definition-prefixes "magit-apply" '("magit-")) ;;;*** @@ -193,16 +193,45 @@ or call the function `magit-auto-revert-mode'.") (autoload 'magit-auto-revert-mode "magit-autorevert" "\ Toggle Auto-Revert mode in all buffers. With prefix ARG, enable Magit-Auto-Revert mode if ARG is positive; -otherwise, disable it. If called from Lisp, enable the mode if -ARG is omitted or nil. +otherwise, disable it. + +If called from Lisp, toggle the mode if ARG is `toggle'. +Enable the mode if ARG is nil, omitted, or is a positive number. +Disable the mode if ARG is a negative number. Auto-Revert mode is enabled in all buffers where `magit-turn-on-auto-revert-mode-if-desired' would do it. + See `auto-revert-mode' for more information on Auto-Revert mode. \(fn &optional ARG)" t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-autorevert" '("auto-revert-buffer" "magit-"))) +(register-definition-prefixes "magit-autorevert" '("auto-revert-buffer" "magit-")) + +;;;*** + +;;;### (autoloads nil "magit-base" "magit-base.el" (0 0 0 0)) +;;; Generated autoloads from magit-base.el + +(autoload 'magit-emacs-Q-command "magit-base" "\ +Show a shell command that runs an uncustomized Emacs with only Magit loaded. +See info node `(magit)Debugging Tools' for more information." t nil) + +(autoload 'Info-follow-nearest-node--magit-gitman "magit-base" "\ + + +\(fn FN &optional FORK)" nil nil) + +(advice-add 'Info-follow-nearest-node :around #'Info-follow-nearest-node--magit-gitman) + +(advice-add 'org-man-export :around #'org-man-export--magit-gitman) + +(autoload 'org-man-export--magit-gitman "magit-base" "\ + + +\(fn FN LINK DESCRIPTION FORMAT)" nil nil) + +(register-definition-prefixes "magit-base" '("magit-")) ;;;*** @@ -256,7 +285,7 @@ bisect run'. \(fn CMDLINE &optional BAD GOOD ARGS)" t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-bisect" '("magit-"))) +(register-definition-prefixes "magit-bisect" '("magit-")) ;;;*** @@ -268,23 +297,7 @@ bisect run'. (autoload 'magit-blame-reverse "magit-blame" nil t) (autoload 'magit-blame "magit-blame" nil t) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-blame" '("magit-"))) - -;;;*** - -;;;### (autoloads nil "magit-bookmark" "magit-bookmark.el" (0 0 0 -;;;;;; 0)) -;;; Generated autoloads from magit-bookmark.el - -(autoload 'magit--handle-bookmark "magit-bookmark" "\ -Open a bookmark created by `magit--make-bookmark'. -Call the `magit-*-setup-buffer' function of the the major-mode -with the variables' values as arguments, which were recorded by -`magit--make-bookmark'. Ignore `magit-display-buffer-function'. - -\(fn BOOKMARK)" nil nil) - -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-bookmark" '("magit--make-bookmark"))) +(register-definition-prefixes "magit-blame" '("magit-")) ;;;*** @@ -450,7 +463,7 @@ and also rename the respective reflog file. \(fn BRANCH)" t nil) (autoload 'magit-branch-configure "magit-branch" nil t) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-branch" '("magit-"))) +(register-definition-prefixes "magit-branch" '("magit-")) ;;;*** @@ -479,7 +492,7 @@ List the refs in FILE. \(fn FILE)" t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-bundle" '("magit-"))) +(register-definition-prefixes "magit-bundle" '("magit-")) ;;;*** @@ -529,7 +542,12 @@ Then show the status buffer for the new repository. \(fn REPOSITORY DIRECTORY ARGS)" t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-clone" '("magit-clone-"))) +(autoload 'magit-clone-sparse "magit-clone" "\ +Clone REPOSITORY into DIRECTORY and create a sparse checkout. + +\(fn REPOSITORY DIRECTORY ARGS)" t nil) + +(register-definition-prefixes "magit-clone" '("magit-clone-")) ;;;*** @@ -640,7 +658,7 @@ Spread modified modules across recent commits. (autoload 'magit-commit-absorb "magit-commit" nil t) (autoload 'magit-commit-autofixup "magit-commit" nil t) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-commit" '("magit-"))) +(register-definition-prefixes "magit-commit" '("magit-")) ;;;*** @@ -722,7 +740,7 @@ for a revision. \(fn REV &optional ARGS FILES MODULE)" t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-diff" '("magit-"))) +(register-definition-prefixes "magit-diff" '("magit-")) ;;;*** @@ -730,13 +748,25 @@ for a revision. ;;; Generated autoloads from magit-ediff.el (autoload 'magit-ediff "magit-ediff" nil) -(autoload 'magit-ediff-resolve "magit-ediff" "\ -Resolve outstanding conflicts in FILE using Ediff. -FILE has to be relative to the top directory of the repository. +(autoload 'magit-ediff-resolve-all "magit-ediff" "\ +Resolve all conflicts in the FILE at point using Ediff. -In the rare event that you want to manually resolve all -conflicts, including those already resolved by Git, use -`ediff-merge-revisions-with-ancestor'. +If there is no file at point or if it doesn't have any unmerged +changes, then prompt for a file. + +See info node `(magit) Ediffing' for more information about this +and alternative commands. + +\(fn FILE)" t nil) + +(autoload 'magit-ediff-resolve-rest "magit-ediff" "\ +Resolve outstanding conflicts in the FILE at point using Ediff. + +If there is no file at point or if it doesn't have any unmerged +changes, then prompt for a file. + +See info node `(magit) Ediffing' for more information about this +and alternative commands. \(fn FILE)" t nil) @@ -810,15 +840,13 @@ stash that were staged. \(fn STASH)" t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-ediff" '("magit-ediff-"))) +(register-definition-prefixes "magit-ediff" '("magit-ediff-")) ;;;*** ;;;### (autoloads nil "magit-extras" "magit-extras.el" (0 0 0 0)) ;;; Generated autoloads from magit-extras.el - -(autoload 'magit-run-git-gui "magit-extras" "\ -Run `git gui' for the current git repository." t nil) + (autoload 'magit-git-mergetool "magit-extras" nil t) (autoload 'magit-run-git-gui-blame "magit-extras" "\ Run `git gui blame' on the given FILENAME and COMMIT. @@ -829,6 +857,9 @@ blame to center around the line point is on. \(fn COMMIT FILENAME &optional LINENUM)" t nil) +(autoload 'magit-run-git-gui "magit-extras" "\ +Run `git gui' for the current git repository." t nil) + (autoload 'magit-run-gitk "magit-extras" "\ Run `gitk' in the current repository." t nil) @@ -1103,7 +1134,7 @@ Abort current operation. Depending on the context, this will abort a merge, a rebase, a patch application, a cherry-pick, a revert, or a bisect." t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-extras" '("magit-"))) +(register-definition-prefixes "magit-extras" '("magit-")) ;;;*** @@ -1142,7 +1173,7 @@ removed on the respective remote." t nil) Fetch from all remotes." t nil) (autoload 'magit-fetch-modules "magit-fetch" nil t) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-fetch" '("magit-"))) +(register-definition-prefixes "magit-fetch" '("magit-")) ;;;*** @@ -1187,14 +1218,14 @@ Checkout FILE from REV. \(fn REV FILE)" t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-files" '("magit-"))) +(register-definition-prefixes "magit-files" '("magit-")) ;;;*** ;;;### (autoloads nil "magit-git" "magit-git.el" (0 0 0 0)) ;;; Generated autoloads from magit-git.el -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-git" '("magit-"))) +(register-definition-prefixes "magit-git" '("magit-")) ;;;*** @@ -1251,95 +1282,7 @@ Call \"git update-index --no-assume-unchanged -- FILE\". \(fn FILE)" t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-gitignore" '("magit-"))) - -;;;*** - -;;;### (autoloads nil "magit-imenu" "magit-imenu.el" (0 0 0 0)) -;;; Generated autoloads from magit-imenu.el - -(autoload 'magit-imenu--log-prev-index-position-function "magit-imenu" "\ -Move point to previous line in current buffer. -This function is used as a value for -`imenu-prev-index-position-function'." nil nil) - -(autoload 'magit-imenu--log-extract-index-name-function "magit-imenu" "\ -Return imenu name for line at point. -This function is used as a value for -`imenu-extract-index-name-function'. Point should be at the -beginning of the line." nil nil) - -(autoload 'magit-imenu--diff-prev-index-position-function "magit-imenu" "\ -Move point to previous file line in current buffer. -This function is used as a value for -`imenu-prev-index-position-function'." nil nil) - -(autoload 'magit-imenu--diff-extract-index-name-function "magit-imenu" "\ -Return imenu name for line at point. -This function is used as a value for -`imenu-extract-index-name-function'. Point should be at the -beginning of the line." nil nil) - -(autoload 'magit-imenu--status-create-index-function "magit-imenu" "\ -Return an alist of all imenu entries in current buffer. -This function is used as a value for -`imenu-create-index-function'." nil nil) - -(autoload 'magit-imenu--refs-create-index-function "magit-imenu" "\ -Return an alist of all imenu entries in current buffer. -This function is used as a value for -`imenu-create-index-function'." nil nil) - -(autoload 'magit-imenu--cherry-create-index-function "magit-imenu" "\ -Return an alist of all imenu entries in current buffer. -This function is used as a value for -`imenu-create-index-function'." nil nil) - -(autoload 'magit-imenu--submodule-prev-index-position-function "magit-imenu" "\ -Move point to previous line in magit-submodule-list buffer. -This function is used as a value for -`imenu-prev-index-position-function'." nil nil) - -(autoload 'magit-imenu--submodule-extract-index-name-function "magit-imenu" "\ -Return imenu name for line at point. -This function is used as a value for -`imenu-extract-index-name-function'. Point should be at the -beginning of the line." nil nil) - -(autoload 'magit-imenu--repolist-prev-index-position-function "magit-imenu" "\ -Move point to previous line in magit-repolist buffer. -This function is used as a value for -`imenu-prev-index-position-function'." nil nil) - -(autoload 'magit-imenu--repolist-extract-index-name-function "magit-imenu" "\ -Return imenu name for line at point. -This function is used as a value for -`imenu-extract-index-name-function'. Point should be at the -beginning of the line." nil nil) - -(autoload 'magit-imenu--process-prev-index-position-function "magit-imenu" "\ -Move point to previous process in magit-process buffer. -This function is used as a value for -`imenu-prev-index-position-function'." nil nil) - -(autoload 'magit-imenu--process-extract-index-name-function "magit-imenu" "\ -Return imenu name for line at point. -This function is used as a value for -`imenu-extract-index-name-function'. Point should be at the -beginning of the line." nil nil) - -(autoload 'magit-imenu--rebase-prev-index-position-function "magit-imenu" "\ -Move point to previous commit in git-rebase buffer. -This function is used as a value for -`imenu-prev-index-position-function'." nil nil) - -(autoload 'magit-imenu--rebase-extract-index-name-function "magit-imenu" "\ -Return imenu name for line at point. -This function is used as a value for -`imenu-extract-index-name-function'. Point should be at the -beginning of the line." nil nil) - -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-imenu" '("magit-imenu--index-function"))) +(register-definition-prefixes "magit-gitignore" '("magit-")) ;;;*** @@ -1355,6 +1298,19 @@ one or more revs read from the minibuffer. \(fn REVS &optional ARGS FILES)" t nil) +(autoload 'magit-log-head "magit-log" "\ +Show log for `HEAD'. + +\(fn &optional ARGS FILES)" t nil) + +(autoload 'magit-log-related "magit-log" "\ +Show log for the current branch, its upstream and its push target. +When the upstream is a local branch, then also show its own +upstream. When `HEAD' is detached, then show log for that, the +previously checked out branch and its upstream and push-target. + +\(fn REVS &optional ARGS FILES)" t nil) + (autoload 'magit-log-other "magit-log" "\ Show log for one or more revs read from the minibuffer. The user can input any revision or revisions separated by a @@ -1364,11 +1320,6 @@ completion candidates. \(fn REVS &optional ARGS FILES)" t nil) -(autoload 'magit-log-head "magit-log" "\ -Show log for `HEAD'. - -\(fn &optional ARGS FILES)" t nil) - (autoload 'magit-log-branches "magit-log" "\ Show log for all local branches and `HEAD'. @@ -1441,14 +1392,14 @@ Show commits in a branch that are not merged in the upstream branch. \(fn HEAD UPSTREAM)" t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-log" '("magit-"))) +(register-definition-prefixes "magit-log" '("magit-")) ;;;*** ;;;### (autoloads nil "magit-margin" "magit-margin.el" (0 0 0 0)) ;;; Generated autoloads from magit-margin.el -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-margin" '("magit-"))) +(register-definition-prefixes "magit-margin" '("magit-")) ;;;*** @@ -1528,14 +1479,17 @@ Abort the current merge operation. \(git merge --abort)" t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-merge" '("magit-"))) +(register-definition-prefixes "magit-merge" '("magit-")) ;;;*** ;;;### (autoloads nil "magit-mode" "magit-mode.el" (0 0 0 0)) ;;; Generated autoloads from magit-mode.el -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-mode" '("disable-magit-save-buffers" "magit-"))) +(autoload 'magit-info "magit-mode" "\ +Visit the Magit manual." t nil) + +(register-definition-prefixes "magit-mode" '("magit-")) ;;;*** @@ -1543,7 +1497,7 @@ Abort the current merge operation. ;;; Generated autoloads from magit-notes.el (autoload 'magit-notes "magit" nil t) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-notes" '("magit-notes-"))) +(register-definition-prefixes "magit-notes" '("magit-notes-")) ;;;*** @@ -1551,7 +1505,7 @@ Abort the current merge operation. ;;;;;; 0)) ;;; Generated autoloads from magit-obsolete.el -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-obsolete" '("magit--magit-popup-warning"))) +(register-definition-prefixes "magit-obsolete" '("magit--magit-popup-warning")) ;;;*** @@ -1596,14 +1550,14 @@ is asked to pull. START has to be reachable from that commit. \(fn URL START END)" t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-patch" '("magit-"))) +(register-definition-prefixes "magit-patch" '("magit-")) ;;;*** ;;;### (autoloads nil "magit-process" "magit-process.el" (0 0 0 0)) ;;; Generated autoloads from magit-process.el -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-process" '("magit-" "tramp-sh-handle-"))) +(register-definition-prefixes "magit-process" '("magit-" "tramp-sh-handle-")) ;;;*** @@ -1618,7 +1572,7 @@ Pull from a branch read in the minibuffer. \(fn SOURCE ARGS)" t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-pull" '("magit-pull-"))) +(register-definition-prefixes "magit-pull" '("magit-pull-")) ;;;*** @@ -1687,7 +1641,7 @@ these Git variables: `push.default', `remote.pushDefault', \(fn REMOTE ARGS)" t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-push" '("magit-"))) +(register-definition-prefixes "magit-push" '("magit-")) ;;;*** @@ -1706,7 +1660,7 @@ Display the reflog of a branch or another ref. (autoload 'magit-reflog-head "magit-reflog" "\ Display the `HEAD' reflog." t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-reflog" '("magit-reflog-"))) +(register-definition-prefixes "magit-reflog" '("magit-reflog-")) ;;;*** @@ -1732,7 +1686,7 @@ Compared with a branch read from the user. \(fn &optional REF ARGS)" t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-refs" '("magit-"))) +(register-definition-prefixes "magit-refs" '("magit-")) ;;;*** @@ -1800,7 +1754,7 @@ refspec. \(fn REMOTE)" t nil) (autoload 'magit-remote-configure "magit-remote" nil t) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-remote" '("magit-"))) +(register-definition-prefixes "magit-remote" '("magit-")) ;;;*** @@ -1813,7 +1767,7 @@ Display a list of repositories. Use the options `magit-repository-directories' to control which repositories are displayed." t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-repos" '("magit-"))) +(register-definition-prefixes "magit-repos" '("magit-")) ;;;*** @@ -1872,7 +1826,7 @@ With a prefix argument reset the working tree otherwise don't. \(fn COMMIT &optional HARD)" t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-reset" '("magit-reset-"))) +(register-definition-prefixes "magit-reset" '("magit-reset-")) ;;;*** @@ -2035,7 +1989,47 @@ Edit the todo list of the current rebase operation." t nil) (autoload 'magit-rebase-abort "magit-sequence" "\ Abort the current rebase operation, restoring the original branch." t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-sequence" '("magit-"))) +(register-definition-prefixes "magit-sequence" '("magit-")) + +;;;*** + +;;;### (autoloads nil "magit-sparse-checkout" "magit-sparse-checkout.el" +;;;;;; (0 0 0 0)) +;;; Generated autoloads from magit-sparse-checkout.el + (autoload 'magit-sparse-checkout "magit-sparse-checkout" nil t) + +(autoload 'magit-sparse-checkout-enable "magit-sparse-checkout" "\ +Convert the working tree to a sparse checkout. + +\(fn &optional ARGS)" t nil) + +(autoload 'magit-sparse-checkout-set "magit-sparse-checkout" "\ +Restrict working tree to DIRECTORIES. +To extend rather than override the currently configured +directories, call `magit-sparse-checkout-add' instead. + +\(fn DIRECTORIES)" t nil) + +(autoload 'magit-sparse-checkout-add "magit-sparse-checkout" "\ +Add DIRECTORIES to the working tree. +To override rather than extend the currently configured +directories, call `magit-sparse-checkout-set' instead. + +\(fn DIRECTORIES)" t nil) + +(autoload 'magit-sparse-checkout-reapply "magit-sparse-checkout" "\ +Reapply the sparse checkout rules to the working tree. +Some operations such as merging or rebasing may need to check out +files that aren't included in the sparse checkout. Call this +command to reset to the sparse checkout state." t nil) + +(autoload 'magit-sparse-checkout-disable "magit-sparse-checkout" "\ +Convert sparse checkout to full checkout. +Note that disabling the sparse checkout does not clear the +configured directories. Call `magit-sparse-checkout-enable' to +restore the previous sparse checkout." t nil) + +(register-definition-prefixes "magit-sparse-checkout" '("magit-sparse-checkout-")) ;;;*** @@ -2095,6 +2089,7 @@ One prefix argument is equivalent to `--include-untracked' while two prefix arguments are equivalent to `--all'. \(fn &optional INCLUDE-UNTRACKED)" t nil) + (autoload 'magit-stash-push "magit-stash" nil t) (autoload 'magit-stash-apply "magit-stash" "\ Apply a stash to the working tree. @@ -2147,7 +2142,7 @@ Show all diffs of a stash in a buffer. \(fn STASH &optional ARGS FILES)" t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-stash" '("magit-"))) +(register-definition-prefixes "magit-stash" '("magit-")) ;;;*** @@ -2201,7 +2196,7 @@ prefix arguments: \(fn &optional DIRECTORY CACHE)" t nil) -(defalias 'magit 'magit-status "\ +(defalias 'magit #'magit-status "\ An alias for `magit-status' for better discoverability. Instead of invoking this alias for `magit-status' using @@ -2233,7 +2228,7 @@ init file: (global-set-key (kbd \"C-x g\") 'magit-status-quick)." t nil) \(fn &optional DIRECTORY)" nil nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-status" '("magit-"))) +(register-definition-prefixes "magit-status" '("magit-")) ;;;*** @@ -2299,7 +2294,7 @@ These sections can be expanded to show the respective commits." nil nil) (autoload 'magit-list-submodules "magit-submodule" "\ Display a list of the current repository's submodules." t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-submodule" '("magit-"))) +(register-definition-prefixes "magit-submodule" '("magit-")) ;;;*** @@ -2339,7 +2334,7 @@ Extract the history of the subtree PREFIX. \(fn PREFIX COMMIT ARGS)" t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-subtree" '("magit-"))) +(register-definition-prefixes "magit-subtree" '("magit-")) ;;;*** @@ -2371,13 +2366,15 @@ Offer to delete tags missing locally from REMOTE, and vice versa. \(fn TAGS REMOTE-TAGS REMOTE)" t nil) (autoload 'magit-tag-release "magit-tag" "\ -Create a release tag. +Create a release tag for `HEAD'. Assume that release tags match `magit-release-tag-regexp'. -First prompt for the name of the new tag using the highest -existing tag as initial input and leaving it to the user to -increment the desired part of the version string. +If `HEAD's message matches `magit-release-commit-regexp', then +base the tag on the version string specified by that. Otherwise +prompt for the name of the new tag using the highest existing +tag as initial input and leaving it to the user to increment the +desired part of the version string. If `--annotate' is enabled, then prompt for the message of the new tag. Base the proposed tag message on the message of the @@ -2389,7 +2386,7 @@ like \"/path/to/foo-bar\". \(fn TAG MSG &optional ARGS)" t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-tag" '("magit-"))) +(register-definition-prefixes "magit-tag" '("magit-")) ;;;*** @@ -2397,32 +2394,7 @@ like \"/path/to/foo-bar\". ;;;;;; 0 0)) ;;; Generated autoloads from magit-transient.el -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-transient" '("magit-"))) - -;;;*** - -;;;### (autoloads nil "magit-utils" "magit-utils.el" (0 0 0 0)) -;;; Generated autoloads from magit-utils.el - -(autoload 'magit-emacs-Q-command "magit-utils" "\ -Show a shell command that runs an uncustomized Emacs with only Magit loaded. -See info node `(magit)Debugging Tools' for more information." t nil) - -(autoload 'Info-follow-nearest-node--magit-gitman "magit-utils" "\ - - -\(fn FN &optional FORK)" nil nil) - -(advice-add 'Info-follow-nearest-node :around 'Info-follow-nearest-node--magit-gitman) - -(autoload 'org-man-export--magit-gitman "magit-utils" "\ - - -\(fn FN LINK DESCRIPTION FORMAT)" nil nil) - -(advice-add 'org-man-export :around 'org-man-export--magit-gitman) - -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-utils" '("magit-"))) +(register-definition-prefixes "magit-transient" '("magit-")) ;;;*** @@ -2442,10 +2414,19 @@ or call the function `magit-wip-mode'.") (autoload 'magit-wip-mode "magit-wip" "\ Save uncommitted changes to work-in-progress refs. -If called interactively, enable Magit-Wip mode if ARG is -positive, and disable it if ARG is zero or negative. If called -from Lisp, also enable the mode if ARG is omitted or nil, and -toggle it if ARG is `toggle'; disable the mode otherwise. +This is a minor mode. If called interactively, toggle the +`Magit-Wip mode' mode. If the prefix argument is positive, +enable the mode, and if it is zero or negative, disable the mode. + +If called from Lisp, toggle the mode if ARG is `toggle'. Enable +the mode if ARG is nil, omitted, or is a positive number. +Disable the mode if ARG is a negative number. + +To check whether the minor mode is enabled in the current buffer, +evaluate `(default-value \\='magit-wip-mode)'. + +The mode's hook is called both when the mode is enabled and when +it is disabled. Whenever appropriate (i.e. when dataloss would be a possibility otherwise) this mode causes uncommitted changes to be committed @@ -2473,12 +2454,17 @@ or call the function `magit-wip-after-save-mode'.") (autoload 'magit-wip-after-save-mode "magit-wip" "\ Toggle Magit-Wip-After-Save-Local mode in all buffers. With prefix ARG, enable Magit-Wip-After-Save mode if ARG is positive; -otherwise, disable it. If called from Lisp, enable the mode if -ARG is omitted or nil. +otherwise, disable it. + +If called from Lisp, toggle the mode if ARG is `toggle'. +Enable the mode if ARG is nil, omitted, or is a positive number. +Disable the mode if ARG is a negative number. Magit-Wip-After-Save-Local mode is enabled in all buffers where `magit-wip-after-save-local-mode-turn-on' would do it. -See `magit-wip-after-save-local-mode' for more information on Magit-Wip-After-Save-Local mode. + +See `magit-wip-after-save-local-mode' for more information on +Magit-Wip-After-Save-Local mode. \(fn &optional ARG)" t nil) @@ -2492,10 +2478,20 @@ for a description of this minor mode.") (autoload 'magit-wip-after-apply-mode "magit-wip" "\ Commit to work-in-progress refs. -If called interactively, enable Magit-Wip-After-Apply mode if ARG -is positive, and disable it if ARG is zero or negative. If -called from Lisp, also enable the mode if ARG is omitted or nil, -and toggle it if ARG is `toggle'; disable the mode otherwise. +This is a minor mode. If called interactively, toggle the +`Magit-Wip-After-Apply mode' mode. If the prefix argument is +positive, enable the mode, and if it is zero or negative, disable +the mode. + +If called from Lisp, toggle the mode if ARG is `toggle'. Enable +the mode if ARG is nil, omitted, or is a positive number. +Disable the mode if ARG is a negative number. + +To check whether the minor mode is enabled in the current buffer, +evaluate `(default-value \\='magit-wip-after-apply-mode)'. + +The mode's hook is called both when the mode is enabled and when +it is disabled. After applying a change using any \"apply variant\" command (apply, stage, unstage, discard, and reverse) commit the @@ -2516,10 +2512,20 @@ for a description of this minor mode.") (autoload 'magit-wip-before-change-mode "magit-wip" "\ Commit to work-in-progress refs before certain destructive changes. -If called interactively, enable Magit-Wip-Before-Change mode if -ARG is positive, and disable it if ARG is zero or negative. If -called from Lisp, also enable the mode if ARG is omitted or nil, -and toggle it if ARG is `toggle'; disable the mode otherwise. +This is a minor mode. If called interactively, toggle the +`Magit-Wip-Before-Change mode' mode. If the prefix argument is +positive, enable the mode, and if it is zero or negative, disable +the mode. + +If called from Lisp, toggle the mode if ARG is `toggle'. Enable +the mode if ARG is nil, omitted, or is a positive number. +Disable the mode if ARG is a negative number. + +To check whether the minor mode is enabled in the current buffer, +evaluate `(default-value \\='magit-wip-before-change-mode)'. + +The mode's hook is called both when the mode is enabled and when +it is disabled. Before invoking a revert command or an \"apply variant\" command (apply, stage, unstage, discard, and reverse) commit the @@ -2549,7 +2555,7 @@ and can be used along-side that function, which is recommended because this function only backs up files that are tracked in a Git repository." nil nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-wip" '("magit-"))) +(register-definition-prefixes "magit-wip" '("magit-")) ;;;*** @@ -2573,12 +2579,12 @@ Move WORKTREE to PATH. \(fn WORKTREE PATH)" t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-worktree" '("magit-"))) +(register-definition-prefixes "magit-worktree" '("magit-")) ;;;*** -;;;### (autoloads nil nil ("magit-core.el" "magit-pkg.el") (0 0 0 -;;;;;; 0)) +;;;### (autoloads nil nil ("magit-bookmark.el" "magit-core.el" "magit-pkg.el") +;;;;;; (0 0 0 0)) ;;;*** diff --git a/elpa/magit-20220116.1908/magit-autorevert.el b/elpa/magit-20220518.2359/magit-autorevert.el similarity index 90% rename from elpa/magit-20220116.1908/magit-autorevert.el rename to elpa/magit-20220518.2359/magit-autorevert.el index c998d7a6..68fc07b2 100644 --- a/elpa/magit-20220116.1908/magit-autorevert.el +++ b/elpa/magit-20220518.2359/magit-autorevert.el @@ -1,19 +1,16 @@ -;;; magit-autorevert.el --- revert buffers when files in repository change -*- lexical-binding: t -*- +;;; magit-autorevert.el --- Revert buffers when files in repository change -*- lexical-binding:t -*- -;; Copyright (C) 2010-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Jonas Bernoulli ;; Maintainer: Jonas Bernoulli ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Magit is free software; you can redistribute it and/or modify it +;; 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. +;; the Free Software Foundation, either version 3 of the License, 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 @@ -21,7 +18,7 @@ ;; 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. +;; along with Magit. If not, see . ;;; Code: @@ -105,18 +102,14 @@ seconds of user inactivity. That is not desirable." (--when-let (find-buffer-visiting file) (with-current-buffer it (magit-turn-on-auto-revert-mode-if-desired))) - (when (and buffer-file-name + (when (and (not auto-revert-mode) ; see #3014 + (not global-auto-revert-mode) ; see #3460 + buffer-file-name (file-readable-p buffer-file-name) - (or (< emacs-major-version 27) - (with-no-warnings - (condition-case nil - (executable-find magit-git-executable t) ; see #3684 - (wrong-number-of-arguments t)))) ; very old 27 built + (compat-executable-find (magit-git-executable) t) (magit-toplevel) (or (not magit-auto-revert-tracked-only) - (magit-file-tracked-p buffer-file-name)) - (not auto-revert-mode) ; see #3014 - (not global-auto-revert-mode)) ; see #3460 + (magit-file-tracked-p buffer-file-name))) (auto-revert-mode 1)))) ;;;###autoload @@ -261,7 +254,7 @@ defaults to nil) for any BUFFER." (auto-revert-set-timer)))) (advice-add 'auto-revert-buffers :around - 'auto-revert-buffers--buffer-list-filter) + #'auto-revert-buffers--buffer-list-filter) ;;; _ (provide 'magit-autorevert) diff --git a/elpa/magit-20220116.1908/magit-utils.el b/elpa/magit-20220518.2359/magit-base.el similarity index 90% rename from elpa/magit-20220116.1908/magit-utils.el rename to elpa/magit-20220518.2359/magit-base.el index 473b7041..4dbfbfef 100644 --- a/elpa/magit-20220116.1908/magit-utils.el +++ b/elpa/magit-20220518.2359/magit-base.el @@ -1,22 +1,16 @@ -;;; magit-utils.el --- various utilities -*- lexical-binding: t; coding: utf-8 -*- +;;; magit-base.el --- Early birds -*- lexical-binding:t; coding:utf-8 -*- -;; Copyright (C) 2010-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Jonas Bernoulli ;; Maintainer: Jonas Bernoulli -;; Contains code from GNU Emacs https://www.gnu.org/software/emacs, -;; released under the GNU General Public License version 3 or later. - ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Magit is free software; you can redistribute it and/or modify it +;; 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. +;; the Free Software Foundation, either version 3 of the License, 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 @@ -24,23 +18,27 @@ ;; 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. +;; along with Magit. If not, see . -;;; Commentary: +;; This file contains code taken from GNU Emacs, which is +;; Copyright (C) 1976-2022 Free Software Foundation, Inc. -;; This library defines several utility functions used by several -;; other libraries which cannot depend on one another (because -;; circular dependencies are not good). Luckily most (all) of these -;; functions have very little (nothing) to do with Git, so we not only -;; have to do this, it even makes sense. +;;; Commentary: -;; Unfortunately there are also some options which are used by several -;; libraries which cannot depend on one another, they are defined here -;; too. +;; This library defines utility functions, options and other things that +;; have to be available early on because they are used by several other +;; libraries, which cannot depend on one another, because that would lead +;; to circular dependencies. ;;; Code: +(defconst magit--minimal-git "2.2.0") +(defconst magit--minimal-emacs "25.1") + (require 'cl-lib) +(require 'compat) +(require 'compat-26) +(require 'compat-27) (require 'dash) (require 'eieio) (require 'seq) @@ -48,6 +46,8 @@ (require 'crm) +(require 'magit-section) + (eval-when-compile (require 'ido)) (declare-function Info-get-token "info" (pos start all &optional errorstring)) @@ -57,11 +57,9 @@ (eval-when-compile (require 'which-func)) (declare-function which-function "which-func" ()) -(defvar magit-wip-before-change-mode) - ;;; Options -(defcustom magit-completing-read-function 'magit-builtin-completing-read +(defcustom magit-completing-read-function #'magit-builtin-completing-read "Function to be called when requesting input from the user. If you have enabled `ivy-mode' or `helm-mode', then you don't @@ -85,6 +83,8 @@ alphabetical order, depending on your version of Ivy." (defcustom magit-dwim-selection '((magit-stash-apply nil t) + (magit-ediff-resolve-all nil t) + (magit-ediff-resolve-rest nil t) (magit-stash-branch nil t) (magit-stash-branch-here nil t) (magit-stash-format-patch nil t) @@ -437,6 +437,45 @@ and delay of your graphical environment or operating system." (const :tag "view manpage using `man'" man) (const :tag "view manpage using `woman'" woman))) +;;; Section Classes + +(defclass magit-commit-section (magit-section) ()) + +(setf (alist-get 'commit magit--section-type-alist) 'magit-commit-section) + +(defclass magit-diff-section (magit-section) () :abstract t) + +(defclass magit-file-section (magit-diff-section) + ((keymap :initform 'magit-file-section-map) + (source :initform nil) + (header :initform nil))) + +(defclass magit-module-section (magit-file-section) + ((keymap :initform 'magit-module-section-map) + (range :initform nil))) + +(defclass magit-hunk-section (magit-diff-section) + ((keymap :initform 'magit-hunk-section-map) + (refined :initform nil) + (combined :initform nil) + (from-range :initform nil) + (from-ranges :initform nil) + (to-range :initform nil) + (about :initform nil))) + +(setf (alist-get 'file magit--section-type-alist) 'magit-file-section) +(setf (alist-get 'module magit--section-type-alist) 'magit-module-section) +(setf (alist-get 'hunk magit--section-type-alist) 'magit-hunk-section) + +(defclass magit-log-section (magit-section) () :abstract t) +(defclass magit-unpulled-section (magit-log-section) ()) +(defclass magit-unpushed-section (magit-log-section) ()) +(defclass magit-unmerged-section (magit-log-section) ()) + +(setf (alist-get 'unpulled magit--section-type-alist) 'magit-unpulled-section) +(setf (alist-get 'unpushed magit--section-type-alist) 'magit-unpushed-section) +(setf (alist-get 'unmerged magit--section-type-alist) 'magit-unmerged-section) + ;;; User Input (defvar helm-completion-in-region-default-sort-fn) @@ -540,7 +579,7 @@ acts similarly to `completing-read', except for the following: (unless (or (bound-and-true-p helm-mode) (bound-and-true-p ivy-mode)) (setq choices (magit--completion-table choices))) - (cl-letf (((symbol-function 'completion-pcm--all-completions))) + (cl-letf (((symbol-function #'completion-pcm--all-completions))) (when (< emacs-major-version 26) (fset 'completion-pcm--all-completions 'magit-completion-pcm--all-completions)) @@ -574,7 +613,7 @@ into a list." (helm-crm-default-separator nil) (ivy-sort-matches-functions-alist nil) (input - (cl-letf (((symbol-function 'completion-pcm--all-completions))) + (cl-letf (((symbol-function #'completion-pcm--all-completions))) (when (< emacs-major-version 26) (fset 'completion-pcm--all-completions 'magit-completion-pcm--all-completions)) @@ -604,8 +643,8 @@ third-party completion frameworks." ;; that string. Use a variable to pass along the raw user ;; input string. aa5f098ab (input nil) - (split-string (symbol-function 'split-string)) - ((symbol-function 'split-string) + (split-string (symbol-function #'split-string)) + ((symbol-function #'split-string) (lambda (string &optional separators omit-nulls trim) (when (and no-split (equal separators crm-separator) @@ -614,10 +653,10 @@ third-party completion frameworks." (funcall split-string string separators omit-nulls trim))) ;; In Emacs 25 this function has a bug, so we use a copy of the ;; version from Emacs 26. bef9c7aa3 - ((symbol-function 'completion-pcm--all-completions) + ((symbol-function #'completion-pcm--all-completions) (if (< emacs-major-version 26) 'magit-completion-pcm--all-completions - (symbol-function 'completion-pcm--all-completions))) + (symbol-function #'completion-pcm--all-completions))) ;; Prevent `BUILT-IN' completion from messing up our existing ;; order of the completion candidates. aa5f098ab (table (magit--completion-table table)) @@ -635,7 +674,7 @@ third-party completion frameworks." (advice-member-p 'consult-completing-read-multiple 'completing-read-multiple)) ;; Our NO-SPLIT hack is not compatible with `CONSULT's - ;; implemenation so fall back to the original function. + ;; implementation so fall back to the original function. ;; #4437 (unwind-protect (progn @@ -673,7 +712,7 @@ back to built-in `completing-read' for now." :error) initial-input hist def))) (defun magit-prompt-with-default (prompt def) - (if (and def (> (length prompt) 2) + (if (and def (length> prompt 2) (string-equal ": " (substring prompt -2))) (format "%s (default %s): " (substring prompt 0 -2) def) prompt)) @@ -681,8 +720,8 @@ back to built-in `completing-read' for now." :error) (defvar magit-minibuffer-local-ns-map (let ((map (make-sparse-keymap))) (set-keymap-parent map minibuffer-local-map) - (define-key map "\s" 'magit-whitespace-disallowed) - (define-key map "\t" 'magit-whitespace-disallowed) + (define-key map "\s" #'magit-whitespace-disallowed) + (define-key map "\t" #'magit-whitespace-disallowed) map)) (defun magit-whitespace-disallowed () @@ -782,9 +821,9 @@ ACTION is a member of option `magit-slow-confirm'." (or (not sitems) items)) ((not sitems) (magit-y-or-n-p prompt action)) - ((= (length items) 1) + ((length= items 1) (and (magit-y-or-n-p prompt action) items)) - ((> (length items) 1) + ((length> items 1) (and (magit-y-or-n-p (concat (mapconcat #'identity items "\n") "\n\n" prompt-n) action) @@ -802,8 +841,9 @@ ACTION is a member of option `magit-slow-confirm'." (defun magit-confirm-make-prompt (action) (let ((prompt (symbol-name action))) - (replace-regexp-in-string - "-" " " (concat (upcase (substring prompt 0 1)) (substring prompt 1))))) + (string-replace "-" " " + (concat (upcase (substring prompt 0 1)) + (substring prompt 1))))) (defun magit-read-number-string (prompt &optional default _history) "Like `read-number' but return value is a string. @@ -836,6 +876,7 @@ See info node `(magit)Debugging Tools' for more information." ((not (equal lib "libgit")) (error "Cannot find mandatory dependency %s" lib))))) '(;; Like `LOAD_PATH' in `default.mk'. + "compat" "dash" "libgit" "transient" @@ -910,38 +951,6 @@ with the text area." (concat (propertize " " 'display '(space :align-to 0)) string))) -(defun magit-face-property-all (face string) - "Return non-nil if FACE is present in all of STRING." - (catch 'missing - (let ((pos 0)) - (while (setq pos (next-single-property-change pos 'font-lock-face string)) - (let ((val (get-text-property pos 'font-lock-face string))) - (unless (if (consp val) - (memq face val) - (eq face val)) - (throw 'missing nil)))) - (not pos)))) - -(defun magit--add-face-text-property (beg end face &optional append object) - "Like `add-face-text-property' but for `font-lock-face'." - (while (< beg end) - (let* ((pos (next-single-property-change beg 'font-lock-face object end)) - (val (get-text-property beg 'font-lock-face object)) - (val (if (listp val) val (list val)))) - (put-text-property beg pos 'font-lock-face - (if append - (append val (list face)) - (cons face val)) - object) - (setq beg pos)))) - -(defun magit--propertize-face (string face) - (propertize string 'face face 'font-lock-face face)) - -(defun magit--put-face (beg end face string) - (put-text-property beg end 'face face string) - (put-text-property beg end 'font-lock-face face string)) - (defun magit--format-spec (format specification) "Like `format-spec' but preserve text properties in SPECIFICATION." (with-temp-buffer @@ -1029,7 +1038,9 @@ and https://github.com/magit/magit/issues/2295." (and (file-directory-p filename) (file-accessible-directory-p filename))) -(when (magit--version>= emacs-version "25.1") +(when (< emacs-major-version 27) + ;; Work around https://debbugs.gnu.org/cgi/bugreport.cgi?bug=21559. + ;; Fixed by cb55ccae8be946f1562d74718086a4c8c8308ee5 in Emacs 27.1. (with-eval-after-load 'vc-git (defun vc-git-conflicted-files (directory) "Return the list of files with conflicts in DIRECTORY." @@ -1104,12 +1115,12 @@ setting `imenu--index-alist' to nil before calling that function." (defun magit-custom-initialize-reset (symbol exp) "Initialize SYMBOL based on EXP. -Set the symbol, using `set-default' (unlike -`custom-initialize-reset' which uses the `:set' function if any.) -The value is either the symbol's current value - (as obtained using the `:get' function), if any, -or the value in the symbol's `saved-value' property if any, -or (last of all) the value of EXP." +Set the value of the variable SYMBOL, using `set-default' +\(unlike `custom-initialize-reset', which uses the `:set' +function if any). The value is either the symbol's current +value (as obtained using the `:get' function), if any, or +the value in the symbol's `saved-value' property if any, or +\(last of all) the value of EXP." (set-default-toplevel-value symbol (condition-case nil @@ -1155,10 +1166,10 @@ or (last of all) the value of EXP." "\\*note[ \n\t]+\\([^:]*\\):\\(:\\|[ \n\t]*(\\)?"))) (if (and node (string-match "^(gitman)\\(.+\\)" node)) (pcase magit-view-git-manual-method - (`info (funcall fn fork)) - (`man (require 'man) + ('info (funcall fn fork)) + ('man (require 'man) (man (match-string 1 node))) - (`woman (require 'woman) + ('woman (require 'woman) (woman (match-string 1 node))) (_ (user-error "Invalid value for `magit-view-git-manual-method'"))) @@ -1166,13 +1177,16 @@ or (last of all) the value of EXP." ;;;###autoload (advice-add 'Info-follow-nearest-node :around - 'Info-follow-nearest-node--magit-gitman) + #'Info-follow-nearest-node--magit-gitman) +;; When making changes here, then also adjust the copy in docs/Makefile. +;;;###autoload +(advice-add 'org-man-export :around #'org-man-export--magit-gitman) ;;;###autoload (defun org-man-export--magit-gitman (fn link description format) (if (and (eq format 'texinfo) - (string-match-p "\\`git" link)) - (replace-regexp-in-string "%s" link " + (string-prefix-p "git" link)) + (string-replace "%s" link " @ifinfo @ref{%s,,,gitman,}. @end ifinfo @@ -1187,10 +1201,6 @@ the %s(1) manpage. ") (funcall fn link description format))) -;;;###autoload -(advice-add 'org-man-export :around - 'org-man-export--magit-gitman) - ;;; Kludges for Package Managers (defun magit--straight-chase-links (filename) @@ -1212,7 +1222,7 @@ See ." (if (fboundp 'with-connection-local-variables) (defalias 'magit--with-connection-local-variables - 'with-connection-local-variables) + #'with-connection-local-variables) (defmacro magit--with-connection-local-variables (&rest body) "Abridged `with-connection-local-variables' for pre Emacs 27 compatibility. Bind shell file name and switch for remote execution. @@ -1220,17 +1230,18 @@ Bind shell file name and switch for remote execution. This kludge provides the minimal functionality required by Magit." `(if (file-remote-p default-directory) - (let* ((vec (tramp-dissect-file-name default-directory)) - (shell-file-name (tramp-get-method-parameter - vec - 'tramp-remote-shell)) - (shell-command-switch (mapconcat - #'identity - (tramp-get-method-parameter - vec - 'tramp-remote-shell-args) - " "))) - (progn ,@body)) + (pcase-let ((`(,shell-file-name ,shell-command-switch) + (with-no-warnings ; about unknown tramp functions + (require 'tramp) + (let ((vec (tramp-dissect-file-name + default-directory))) + (list (tramp-get-method-parameter + vec 'tramp-remote-shell) + (mapconcat #'identity + (tramp-get-method-parameter + vec 'tramp-remote-shell-args) + " ")))))) + ,@body) ,@body))) ;;; Miscellaneous @@ -1259,5 +1270,5 @@ Like `message', except that `message-log-max' is bound to nil." ,@body)))) ;;; _ -(provide 'magit-utils) -;;; magit-utils.el ends here +(provide 'magit-base) +;;; magit-base.el ends here diff --git a/elpa/magit-20220116.1908/magit-bisect.el b/elpa/magit-20220518.2359/magit-bisect.el similarity index 91% rename from elpa/magit-20220116.1908/magit-bisect.el rename to elpa/magit-20220518.2359/magit-bisect.el index ff2a53b5..92dc6ab8 100644 --- a/elpa/magit-20220116.1908/magit-bisect.el +++ b/elpa/magit-20220518.2359/magit-bisect.el @@ -1,19 +1,16 @@ -;;; magit-bisect.el --- bisect support for Magit -*- lexical-binding: t -*- +;;; magit-bisect.el --- Bisect support for Magit -*- lexical-binding:t -*- -;; Copyright (C) 2011-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Jonas Bernoulli ;; Maintainer: Jonas Bernoulli ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Magit is free software; you can redistribute it and/or modify it +;; 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. +;; the Free Software Foundation, either version 3 of the License, 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 @@ -21,7 +18,7 @@ ;; 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. +;; along with Magit. If not, see . ;;; Commentary: @@ -224,10 +221,10 @@ bisect run'." (magit-process-sentinel process event) (when (buffer-live-p (process-buffer process)) (with-current-buffer (process-buffer process) - (when-let ((section (get-text-property (point) 'magit-section)) - (output (buffer-substring-no-properties - (oref section content) - (oref section end)))) + (when-let* ((section (magit-section-at)) + (output (buffer-substring-no-properties + (oref section content) + (oref section end)))) (with-temp-file (magit-git-dir "BISECT_CMD_OUTPUT") (insert output))))) (magit-refresh)) @@ -250,7 +247,7 @@ bisect run'." "It appears you have invoked `git bisect' from a shell." "There is nothing wrong with that, we just cannot display" "anything useful here. Consult the shell output instead."))) - (done-re "^\\([a-z0-9]\\{40\\}\\) is the first bad commit$") + (done-re "^\\([a-z0-9]\\{40,\\}\\) is the first bad commit$") (bad-line (or (and (string-match done-re (car lines)) (pop lines)) (--first (string-match done-re it) lines)))) @@ -268,7 +265,7 @@ bisect run'." (when (magit-bisect-in-progress-p) (magit-insert-section (bisect-view) (magit-insert-heading "Bisect Rest:") - (magit-git-wash (apply-partially 'magit-log-wash-log 'bisect-vis) + (magit-git-wash (apply-partially #'magit-log-wash-log 'bisect-vis) "bisect" "visualize" "git" "log" "--format=%h%x00%D%x00%s" "--decorate=full" (and magit-bisect-show-graph "--graph"))))) @@ -295,11 +292,11 @@ bisect run'." 'magit-section-secondary-heading)) (magit-insert-heading) (magit-wash-sequence - (apply-partially 'magit-log-wash-rev 'bisect-log + (apply-partially #'magit-log-wash-rev 'bisect-log (magit-abbrev-length))) (insert ?\n))))) (when (re-search-forward - "# first bad commit: \\[\\([a-z0-9]\\{40\\}\\)\\] [^\n]+\n" nil t) + "# first bad commit: \\[\\([a-z0-9]\\{40,\\}\\)\\] [^\n]+\n" nil t) (magit-bind-match-strings (hash) nil (magit-delete-match) (magit-insert-section (bisect-item) diff --git a/elpa/magit-20220116.1908/magit-blame.el b/elpa/magit-20220518.2359/magit-blame.el similarity index 84% rename from elpa/magit-20220116.1908/magit-blame.el rename to elpa/magit-20220518.2359/magit-blame.el index 81c6219e..d27f84ff 100644 --- a/elpa/magit-20220116.1908/magit-blame.el +++ b/elpa/magit-20220518.2359/magit-blame.el @@ -1,19 +1,16 @@ -;;; magit-blame.el --- blame support for Magit -*- lexical-binding: t -*- +;;; magit-blame.el --- Blame support for Magit -*- lexical-binding:t -*- -;; Copyright (C) 2012-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Jonas Bernoulli ;; Maintainer: Jonas Bernoulli ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Magit is free software; you can redistribute it and/or modify it +;; 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. +;; the Free Software Foundation, either version 3 of the License, 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 @@ -21,7 +18,7 @@ ;; 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. +;; along with Magit. If not, see . ;;; Commentary: @@ -42,11 +39,6 @@ (defcustom magit-blame-styles '((headings (heading-format . "%-20a %C %s\n")) - (margin - (margin-format . (" %s%f" " %C %a" " %H")) - (margin-width . 42) - (margin-face . magit-blame-margin) - (margin-body-face . (magit-blame-dimmed))) (highlight (highlight-face . magit-blame-highlight)) (lines @@ -54,6 +46,10 @@ (show-message . t))) "List of styles used to visualize blame information. +The style used in the current buffer can be cycled from the blame +popup. Blame commands (except `magit-blame-echo') use the first +style as the initial style when beginning to blame in a buffer. + Each entry has the form (IDENT (KEY . VALUE)...). IDENT has to be a symbol uniquely identifying the style. The following KEYs are recognized: @@ -76,7 +72,8 @@ KEYs are recognized: This can also be a list of formats used for the lines at the same positions within the chunk. If the chunk has more lines than formats are specified, then the last is - repeated. + repeated. WARNING: Adding this key affects performance; + see the note at the end of this docstring. `margin-width' Width of the margin, provided `margin-format' is non-nil. `margin-face' @@ -108,9 +105,22 @@ that is displayed in the margin is made at least `margin-width' characters wide, which may be desirable if the used face sets the background color. -The style used in the current buffer can be cycled from the blame -popup. Blame commands (except `magit-blame-echo') use the first -style as the initial style when beginning to blame in a buffer." +Blame information is displayed using overlays. Such extensive +use of overlays is known to slow down even basic operations, such +as moving the cursor. To reduce the number of overlays the margin +style had to be removed from the default value of this option. + +Note that the margin overlays are created even if another style +is currently active. This can only be prevented by not even +defining a style that uses the margin. If you want to use this +style anyway, you can restore this definition, which used to be +part of the default value: + + (margin + (margin-format . (\" %s%f\" \" %C %a\" \" %H\")) + (margin-width . 42) + (margin-face . magit-blame-margin) + (margin-body-face . (magit-blame-dimmed)))" :package-version '(magit . "2.13.0") :group 'magit-blame :type 'string) @@ -153,7 +163,7 @@ and then turned on again when turning off the latter." :package-version '(magit . "2.13.0") :group 'magit-blame :type 'hook - :get 'magit-hook-custom-get + :get #'magit-hook-custom-get :options '(magit-blame-maybe-update-revision-buffer magit-blame-maybe-show-message)) @@ -213,6 +223,20 @@ Also see option `magit-blame-styles'." "Face used for dates when blaming." :group 'magit-faces) +;;; Variables + +(defvar-local magit-blame-buffer-read-only nil) +(defvar-local magit-blame-cache nil) +(defvar-local magit-blame-disabled-modes nil) +(defvar-local magit-blame-process nil) +(defvar-local magit-blame-recursive-p nil) +(defvar-local magit-blame-type nil) +(defvar-local magit-blame-separator nil) +(defvar-local magit-blame-previous-chunk nil) + +(defvar-local magit-blame--make-margin-overlays nil) +(defvar-local magit-blame--style nil) + ;;; Chunks (defclass magit-blame-chunk () @@ -245,7 +269,10 @@ Also see option `magit-blame-styles'." (magit-blame-arguments)) "-L" line rev "--" file) (goto-char (point-min)) - (car (magit-blame--parse-chunk type))))) + (if (eobp) + (unless noerror + (error "Cannot get blame chunk at eob")) + (car (magit-blame--parse-chunk type)))))) (noerror nil) (t (error "Buffer does not visit a tracked file"))))))) @@ -272,41 +299,25 @@ in `magit-blame-read-only-mode-map' instead.") (defvar magit-blame-read-only-mode-map (let ((map (make-sparse-keymap))) - (define-key map (kbd "C-m") 'magit-show-commit) - (define-key map (kbd "p") 'magit-blame-previous-chunk) - (define-key map (kbd "P") 'magit-blame-previous-chunk-same-commit) - (define-key map (kbd "n") 'magit-blame-next-chunk) - (define-key map (kbd "N") 'magit-blame-next-chunk-same-commit) - (define-key map (kbd "b") 'magit-blame-addition) - (define-key map (kbd "r") 'magit-blame-removal) - (define-key map (kbd "f") 'magit-blame-reverse) - (define-key map (kbd "B") 'magit-blame) - (define-key map (kbd "c") 'magit-blame-cycle-style) - (define-key map (kbd "q") 'magit-blame-quit) - (define-key map (kbd "M-w") 'magit-blame-copy-hash) - (define-key map (kbd "SPC") 'magit-diff-show-or-scroll-up) - (define-key map (kbd "S-SPC") 'magit-diff-show-or-scroll-down) - (define-key map (kbd "DEL") 'magit-diff-show-or-scroll-down) + (define-key map (kbd "C-m") #'magit-show-commit) + (define-key map (kbd "p") #'magit-blame-previous-chunk) + (define-key map (kbd "P") #'magit-blame-previous-chunk-same-commit) + (define-key map (kbd "n") #'magit-blame-next-chunk) + (define-key map (kbd "N") #'magit-blame-next-chunk-same-commit) + (define-key map (kbd "b") #'magit-blame-addition) + (define-key map (kbd "r") #'magit-blame-removal) + (define-key map (kbd "f") #'magit-blame-reverse) + (define-key map (kbd "B") #'magit-blame) + (define-key map (kbd "c") #'magit-blame-cycle-style) + (define-key map (kbd "q") #'magit-blame-quit) + (define-key map (kbd "M-w") #'magit-blame-copy-hash) + (define-key map (kbd "SPC") #'magit-diff-show-or-scroll-up) + (define-key map (kbd "S-SPC") #'magit-diff-show-or-scroll-down) + (define-key map (kbd "DEL") #'magit-diff-show-or-scroll-down) map) "Keymap for `magit-blame-read-only-mode'.") ;;; Modes -;;;; Variables - -(defvar-local magit-blame-buffer-read-only nil) -(defvar-local magit-blame-cache nil) -(defvar-local magit-blame-disabled-modes nil) -(defvar-local magit-blame-process nil) -(defvar-local magit-blame-recursive-p nil) -(defvar-local magit-blame-type nil) -(defvar-local magit-blame-separator nil) -(defvar-local magit-blame-previous-chunk nil) - -(defvar-local magit-blame--style nil) - -(defsubst magit-blame--style-get (key) - (cdr (assoc key (cdr magit-blame--style)))) - ;;;; Base Mode (define-minor-mode magit-blame-mode @@ -318,11 +329,11 @@ in `magit-blame-read-only-mode-map' instead.") (user-error (concat "Don't call `magit-blame-mode' directly; " "instead use `magit-blame'"))) - (add-hook 'after-save-hook 'magit-blame--refresh t t) - (add-hook 'post-command-hook 'magit-blame-goto-chunk-hook t t) - (add-hook 'before-revert-hook 'magit-blame--remove-overlays t t) - (add-hook 'after-revert-hook 'magit-blame--refresh t t) - (add-hook 'read-only-mode-hook 'magit-blame-toggle-read-only t t) + (add-hook 'after-save-hook #'magit-blame--refresh t t) + (add-hook 'post-command-hook #'magit-blame-goto-chunk-hook t t) + (add-hook 'before-revert-hook #'magit-blame--remove-overlays t t) + (add-hook 'after-revert-hook #'magit-blame--refresh t t) + (add-hook 'read-only-mode-hook #'magit-blame-toggle-read-only t t) (setq magit-blame-buffer-read-only buffer-read-only) (when (or magit-blame-read-only magit-buffer-file-name) (read-only-mode 1)) @@ -333,17 +344,21 @@ in `magit-blame-read-only-mode-map' instead.") (setq magit-blame-separator (magit-blame--format-separator)) (unless magit-blame--style (setq magit-blame--style (car magit-blame-styles))) + (setq magit-blame--make-margin-overlays + (and (cl-find-if (lambda (style) + (assq 'margin-format (cdr style))) + magit-blame-styles))) (magit-blame--update-margin)) (t (when (process-live-p magit-blame-process) (kill-process magit-blame-process) (while magit-blame-process (sit-for 0.01))) ; avoid racing the sentinel - (remove-hook 'after-save-hook 'magit-blame--refresh t) - (remove-hook 'post-command-hook 'magit-blame-goto-chunk-hook t) - (remove-hook 'before-revert-hook 'magit-blame--remove-overlays t) - (remove-hook 'after-revert-hook 'magit-blame--refresh t) - (remove-hook 'read-only-mode-hook 'magit-blame-toggle-read-only t) + (remove-hook 'after-save-hook #'magit-blame--refresh t) + (remove-hook 'post-command-hook #'magit-blame-goto-chunk-hook t) + (remove-hook 'before-revert-hook #'magit-blame--remove-overlays t) + (remove-hook 'after-revert-hook #'magit-blame--refresh t) + (remove-hook 'read-only-mode-hook #'magit-blame-toggle-read-only t) (unless magit-blame-buffer-read-only (read-only-mode -1)) (magit-blame-read-only-mode -1) @@ -411,17 +426,17 @@ modes is toggled, then this mode also gets toggled automatically. (list (line-number-at-pos (window-start)) (line-number-at-pos (1- (window-end nil t))))) (set-process-sentinel magit-this-process - 'magit-blame-process-quickstart-sentinel))) + #'magit-blame-process-quickstart-sentinel))) (defun magit-blame-run-process (revision file args &optional lines) (let ((process (magit-parse-git-async "blame" "--incremental" args (and lines (list "-L" (apply #'format "%s,%s" lines))) revision "--" file))) - (set-process-filter process 'magit-blame-process-filter) - (set-process-sentinel process 'magit-blame-process-sentinel) + (set-process-filter process #'magit-blame-process-filter) + (set-process-sentinel process #'magit-blame-process-sentinel) (process-put process 'arguments (list revision file args)) - (setq magit-blame-cache (make-hash-table :test 'equal)) + (setq magit-blame-cache (make-hash-table :test #'equal)) (setq magit-blame-process process))) (defun magit-blame-process-quickstart-sentinel (process event) @@ -476,7 +491,7 @@ modes is toggled, then this mode also gets toggled automatically. (defun magit-blame--parse-chunk (type) (let (chunk revinfo) - (unless (looking-at "^\\(.\\{40\\}\\) \\([0-9]+\\) \\([0-9]+\\) \\([0-9]+\\)") + (unless (looking-at "^\\(.\\{40,\\}\\) \\([0-9]+\\) \\([0-9]+\\) \\([0-9]+\\)") (error "Blaming failed due to unexpected output: %s" (buffer-substring-no-properties (point) (line-end-position)))) (with-slots (orig-rev orig-file prev-rev prev-file) @@ -491,7 +506,7 @@ modes is toggled, then this mode also gets toggled automatically. (cond ((looking-at "^filename \\(.+\\)") (setq done t) (setf orig-file (magit-decode-git-path (match-string 1)))) - ((looking-at "^previous \\(.\\{40\\}\\) \\(.+\\)") + ((looking-at "^previous \\(.\\{40,\\}\\) \\(.+\\)") (setf prev-rev (match-string 1)) (setf prev-file (magit-decode-git-path (match-string 2)))) ((looking-at "^\\([^ ]+\\) \\(.+\\)") @@ -520,21 +535,37 @@ modes is toggled, then this mode also gets toggled automatically. ;;; Display +(defsubst magit-blame--style-get (key) + (cdr (assoc key (cdr magit-blame--style)))) + (defun magit-blame--make-overlays (buf chunk revinfo) (with-current-buffer buf (save-excursion (save-restriction (widen) - (goto-char (point-min)) - (forward-line (1- (oref chunk final-line))) - (let ((beg (point)) - (end (save-excursion - (forward-line (oref chunk num-lines)) - (point)))) + (let* ((line (oref chunk final-line)) + (beg (magit-blame--line-beginning-position line)) + (end (magit-blame--line-beginning-position + (+ line (oref chunk num-lines)))) + (before (magit-blame-chunk-at (1- beg)))) + (when (and before + (equal (oref before orig-rev) + (oref chunk orig-rev))) + (setq beg (magit-blame--line-beginning-position + (oset chunk final-line (oref before final-line)))) + (cl-incf (oref chunk num-lines) + (oref before num-lines))) (magit-blame--remove-overlays beg end) - (magit-blame--make-margin-overlays chunk revinfo beg end) + (when magit-blame--make-margin-overlays + (magit-blame--make-margin-overlays chunk revinfo beg end)) (magit-blame--make-heading-overlay chunk revinfo beg end) - (magit-blame--make-highlight-overlay chunk beg)))))) + (magit-blame--make-highlight-overlay chunk beg)))))) + +(defun magit-blame--line-beginning-position (line) + (save-excursion + (goto-char (point-min)) + (forward-line (1- line)) + (point))) (defun magit-blame--make-margin-overlays (chunk revinfo _beg end) (save-excursion @@ -563,7 +594,9 @@ modes is toggled, then this mode also gets toggled automatically. (magit-blame--update-heading-overlay ov))) (defun magit-blame--make-highlight-overlay (chunk beg) - (let ((ov (make-overlay beg (1+ (line-end-position))))) + (let ((ov (make-overlay beg (save-excursion + (goto-char beg) + (1+ (line-end-position)))))) (overlay-put ov 'magit-blame-chunk chunk) (overlay-put ov 'magit-blame-highlight t) (magit-blame--update-highlight-overlay ov))) @@ -638,7 +671,7 @@ modes is toggled, then this mode also gets toggled automatically. (defun magit-blame--format-string-1 (rev revinfo format face) (let ((str - (if (equal rev "0000000000000000000000000000000000000000") + (if (string-match-p "\\`0\\{40,\\}\\'" rev) (propertize (concat (if (string-prefix-p "\s" format) "\s" "") "Not Yet Committed" (if (string-suffix-p "\n" format) "\n" "")) @@ -646,19 +679,19 @@ modes is toggled, then this mode also gets toggled automatically. (magit--format-spec (propertize format 'font-lock-face face) (cl-flet* ((p0 (s f) - (propertize s 'font-lock-face - (if face - (if (listp face) - face - (list f face)) - f))) + (propertize s 'font-lock-face + (if face + (if (listp face) + face + (list f face)) + f))) (p1 (k f) - (p0 (cdr (assoc k revinfo)) f)) + (p0 (cdr (assoc k revinfo)) f)) (p2 (k1 k2 f) - (p0 (magit-blame--format-time-string - (cdr (assoc k1 revinfo)) - (cdr (assoc k2 revinfo))) - f))) + (p0 (magit-blame--format-time-string + (cdr (assoc k1 revinfo)) + (cdr (assoc k2 revinfo))) + f))) `((?H . ,(p0 rev 'magit-blame-hash)) (?s . ,(p1 "summary" 'magit-blame-summary)) (?a . ,(p1 "author" 'magit-blame-name)) @@ -685,7 +718,7 @@ modes is toggled, then this mode also gets toggled automatically. (defun magit-blame--format-time-string (time tz) (let* ((time-format (or (magit-blame--style-get 'time-format) magit-blame-time-format)) - (tz-in-second (and (string-match "%z" time-format) + (tz-in-second (and (string-search "%z" time-format) (car (last (parse-time-string tz)))))) (format-time-string time-format (seconds-to-time (string-to-number time)) @@ -850,8 +883,8 @@ then also kill the buffer." (not (= pos (if previous (point-min) (point-max)))) (setq pos (funcall (if previous - 'previous-single-char-property-change - 'next-single-char-property-change) + #'previous-single-char-property-change + #'next-single-char-property-change) pos 'magit-blame-chunk))) (--when-let (magit-blame--overlay-at pos) (when (equal (oref (magit-blame-chunk-at pos) orig-rev) rev) @@ -864,7 +897,7 @@ then also kill the buffer." (defun magit-blame-previous-chunk-same-commit () "Move to the previous chunk from the same commit." (interactive) - (magit-blame-next-chunk-same-commit 'previous-single-char-property-change)) + (magit-blame-next-chunk-same-commit #'previous-single-char-property-change)) (defun magit-blame-cycle-style () "Change how blame information is visualized. @@ -918,21 +951,21 @@ instead of the hash, like `kill-ring-save' would." :class 'transient-option :argument "-M" :allow-empty t - :reader 'transient-read-number-N+) + :reader #'transient-read-number-N+) (transient-define-argument magit-blame:-C () :description "Detect lines moved or copied between files" :class 'transient-option :argument "-C" :allow-empty t - :reader 'transient-read-number-N+) + :reader #'transient-read-number-N+) ;;; Utilities (defun magit-blame-maybe-update-revision-buffer () - (when-let ((chunk (magit-current-blame-chunk)) - (commit (oref chunk orig-rev)) - (buffer (magit-get-mode-buffer 'magit-revision-mode nil t))) + (when-let* ((chunk (magit-current-blame-chunk)) + (commit (oref chunk orig-rev)) + (buffer (magit-get-mode-buffer 'magit-revision-mode nil t))) (if magit--update-revision-buffer (setq magit--update-revision-buffer (list commit buffer)) (setq magit--update-revision-buffer (list commit buffer)) diff --git a/elpa/magit-20220518.2359/magit-bookmark.el b/elpa/magit-20220518.2359/magit-bookmark.el new file mode 100644 index 00000000..c8780e97 --- /dev/null +++ b/elpa/magit-20220518.2359/magit-bookmark.el @@ -0,0 +1,131 @@ +;;; magit-bookmark.el --- Bookmark support for Magit -*- lexical-binding:t -*- + +;; Copyright (C) 2008-2022 The Magit Project Contributors + +;; Inspired by an earlier implementation by Yuri Khan. + +;; Author: Jonas Bernoulli +;; Maintainer: Jonas Bernoulli + +;; SPDX-License-Identifier: GPL-3.0-or-later + +;; 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 of the License, 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 . + +;;; Commentary: + +;; Support for bookmarks for most Magit buffers. + +;;; Code: + +(require 'magit) + +;;; Diff +;;;; Diff + +(put 'magit-diff-mode 'magit-bookmark-variables + '(magit-buffer-range-hashed + magit-buffer-typearg + magit-buffer-diff-args + magit-buffer-diff-files)) + +(cl-defmethod magit-bookmark-name (&context (major-mode magit-diff-mode)) + (format "magit-diff(%s%s)" + (pcase (magit-diff-type) + ('staged "staged") + ('unstaged "unstaged") + ('committed magit-buffer-range) + ('undefined + (delq nil (list magit-buffer-typearg magit-buffer-range-hashed)))) + (if magit-buffer-diff-files + (concat " -- " (mapconcat #'identity magit-buffer-diff-files " ")) + ""))) + +;;;; Revision + +(put 'magit-revision-mode 'magit-bookmark-variables + '(magit-buffer-revision-hash + magit-buffer-diff-args + magit-buffer-diff-files)) + +(cl-defmethod magit-bookmark-name (&context (major-mode magit-revision-mode)) + (format "magit-revision(%s %s)" + (magit-rev-abbrev magit-buffer-revision) + (if magit-buffer-diff-files + (mapconcat #'identity magit-buffer-diff-files " ") + (magit-rev-format "%s" magit-buffer-revision)))) + +;;;; Stash + +(put 'magit-stash-mode 'magit-bookmark-variables + '(magit-buffer-revision-hash + magit-buffer-diff-args + magit-buffer-diff-files)) + +(cl-defmethod magit-bookmark-name (&context (major-mode magit-stash-mode)) + (format "magit-stash(%s %s)" + (magit-rev-abbrev magit-buffer-revision) + (if magit-buffer-diff-files + (mapconcat #'identity magit-buffer-diff-files " ") + (magit-rev-format "%s" magit-buffer-revision)))) + +;;; Log +;;;; Log + +(put 'magit-log-mode 'magit-bookmark-variables + '(magit-buffer-revisions + magit-buffer-log-args + magit-buffer-log-files)) + +(cl-defmethod magit-bookmark-name (&context (major-mode magit-log-mode)) + (format "magit-log(%s%s)" + (mapconcat #'identity magit-buffer-revisions " ") + (if magit-buffer-log-files + (concat " -- " (mapconcat #'identity magit-buffer-log-files " ")) + ""))) + +;;;; Cherry + +(put 'magit-cherry-mode 'magit-bookmark-variables + '(magit-buffer-refname + magit-buffer-upstream)) + +(cl-defmethod magit-bookmark-name (&context (major-mode magit-cherry-mode)) + (format "magit-cherry(%s > %s)" + magit-buffer-refname + magit-buffer-upstream)) + +;;;; Reflog + +(put 'magit-reflog-mode 'magit-bookmark-variables + '(magit-buffer-refname)) + +(cl-defmethod magit-bookmark-name (&context (major-mode magit-reflog-mode)) + (format "magit-reflog(%s)" magit-buffer-refname)) + +;;; Misc + +(put 'magit-status-mode 'magit-bookmark-variables nil) + +(put 'magit-refs-mode 'magit-bookmark-variables + '(magit-buffer-upstream + magit-buffer-arguments)) + +(put 'magit-stashes-mode 'magit-bookmark-variables nil) + +(cl-defmethod magit-bookmark-name (&context (major-mode magit-stashes-mode)) + (format "magit-states(%s)" magit-buffer-refname)) + +;;; _ +(provide 'magit-bookmark) +;;; magit-bookmark.el ends here diff --git a/elpa/magit-20220116.1908/magit-branch.el b/elpa/magit-20220518.2359/magit-branch.el similarity index 96% rename from elpa/magit-20220116.1908/magit-branch.el rename to elpa/magit-20220518.2359/magit-branch.el index c663eb14..724d4c5d 100644 --- a/elpa/magit-20220116.1908/magit-branch.el +++ b/elpa/magit-20220518.2359/magit-branch.el @@ -1,19 +1,16 @@ -;;; magit-branch.el --- branch support -*- lexical-binding: t -*- +;;; magit-branch.el --- Branch support -*- lexical-binding:t -*- -;; Copyright (C) 2010-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Jonas Bernoulli ;; Maintainer: Jonas Bernoulli ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Magit is free software; you can redistribute it and/or modify it +;; 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. +;; the Free Software Foundation, either version 3 of the License, 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 @@ -21,7 +18,7 @@ ;; 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. +;; along with Magit. If not, see . ;;; Commentary: @@ -554,7 +551,7 @@ defaulting to the branch at point." (interactive (let ((branches (magit-region-values 'branch t)) (force current-prefix-arg)) - (if (> (length branches) 1) + (if (length> branches 1) (magit-confirm t nil "Delete %i branches" nil branches) (setq branches (list (magit-read-branch-prefer-other @@ -605,17 +602,17 @@ defaulting to the branch at point." ;; If that is not the case, then this deletes the tracking branches. (set-process-sentinel magit-this-process - (apply-partially 'magit-delete-remote-branch-sentinel remote refs))) + (apply-partially #'magit-delete-remote-branch-sentinel remote refs))) (t (dolist (ref refs) (message "Delete %s (was %s)" ref (magit-rev-parse "--short" ref)) (magit-call-git "update-ref" "-d" ref)) (magit-refresh))))) - ((> (length branches) 1) + ((length> branches 1) (setq branches (delete (magit-get-current-branch) branches)) - (mapc 'magit-branch-maybe-delete-pr-remote branches) - (mapc 'magit-branch-unset-pushRemote branches) + (mapc #'magit-branch-maybe-delete-pr-remote branches) + (mapc #'magit-branch-unset-pushRemote branches) (magit-run-git "branch" (if force "-D" "-d") branches)) (t ; And now for something completely different. (let* ((branch (car branches)) @@ -673,7 +670,7 @@ defaulting to the branch at point." (format "+refs/heads/%s:refs/remotes/%s/%s" merge remote merge)))))) (when (member refspec refspecs) - (if (and (= (length refspecs) 1) + (if (and (length= refspecs 1) (magit-confirm 'delete-pr-remote (format "Also delete remote %s (%s)" remote "no pull-request branch remains") @@ -847,7 +844,7 @@ and also rename the respective reflog file." (interactive (list (oref transient-current-prefix scope))) (magit-run-git-with-editor "branch" "--edit-description" branch)) -(add-hook 'find-file-hook 'magit-branch-description-check-buffers) +(add-hook 'find-file-hook #'magit-branch-description-check-buffers) (defun magit-branch-description-check-buffers () (and buffer-file-name @@ -860,9 +857,9 @@ and also rename the respective reflog file." :class 'magit--git-branch:upstream) (cl-defmethod transient-init-value ((obj magit--git-branch:upstream)) - (when-let ((branch (oref transient--prefix scope)) - (remote (magit-get "branch" branch "remote")) - (merge (magit-get "branch" branch "merge"))) + (when-let* ((branch (oref transient--prefix scope)) + (remote (magit-get "branch" branch "remote")) + (merge (magit-get "branch" branch "merge"))) (oset obj value (list remote merge)))) (cl-defmethod transient-infix-read ((obj magit--git-branch:upstream)) @@ -873,10 +870,10 @@ and also rename the respective reflog file." (cl-defmethod transient-infix-set ((obj magit--git-branch:upstream) refname) (magit-set-upstream-branch (oref transient--prefix scope) refname) (oset obj value - (let ((branch (oref transient--prefix scope))) - (when-let ((r (magit-get "branch" branch "remote")) - (m (magit-get "branch" branch "merge"))) - (list r m)))) + (and-let* ((branch (oref transient--prefix scope)) + (r (magit-get "branch" branch "remote")) + (m (magit-get "branch" branch "merge"))) + (list r m))) (magit-refresh)) (cl-defmethod transient-format ((obj magit--git-branch:upstream)) @@ -896,7 +893,7 @@ and also rename the respective reflog file." (transient-define-infix magit-branch..rebase () :class 'magit--git-variable:choices - :scope 'magit--read-branch-scope + :scope #'magit--read-branch-scope :variable "branch.%s.rebase" :fallback "pull.rebase" :choices '("true" "false") @@ -904,10 +901,10 @@ and also rename the respective reflog file." (transient-define-infix magit-branch..pushRemote () :class 'magit--git-variable:choices - :scope 'magit--read-branch-scope + :scope #'magit--read-branch-scope :variable "branch.%s.pushRemote" :fallback "remote.pushDefault" - :choices 'magit-list-remotes) + :choices #'magit-list-remotes) (transient-define-infix magit-pull.rebase () :class 'magit--git-variable:choices @@ -918,7 +915,7 @@ and also rename the respective reflog file." (transient-define-infix magit-remote.pushDefault () :class 'magit--git-variable:choices :variable "remote.pushDefault" - :choices 'magit-list-remotes) + :choices #'magit-list-remotes) (transient-define-infix magit-branch.autoSetupMerge () :class 'magit--git-variable:choices diff --git a/elpa/magit-20220116.1908/magit-bundle.el b/elpa/magit-20220518.2359/magit-bundle.el similarity index 90% rename from elpa/magit-20220116.1908/magit-bundle.el rename to elpa/magit-20220518.2359/magit-bundle.el index 8afa7ffc..0310ed84 100644 --- a/elpa/magit-20220116.1908/magit-bundle.el +++ b/elpa/magit-20220518.2359/magit-bundle.el @@ -1,19 +1,16 @@ -;;; magit-bundle.el --- bundle support for Magit -*- lexical-binding: t -*- +;;; magit-bundle.el --- Bundle support for Magit -*- lexical-binding:t -*- -;; Copyright (C) 2011-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Jonas Bernoulli ;; Maintainer: Jonas Bernoulli ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Magit is free software; you can redistribute it and/or modify it +;; 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. +;; the Free Software Foundation, either version 3 of the License, 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 @@ -21,7 +18,7 @@ ;; 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. +;; along with Magit. If not, see . ;;; Code: diff --git a/elpa/magit-20220116.1908/magit-clone.el b/elpa/magit-20220518.2359/magit-clone.el similarity index 86% rename from elpa/magit-20220116.1908/magit-clone.el rename to elpa/magit-20220518.2359/magit-clone.el index f2813cb8..302dcdd4 100644 --- a/elpa/magit-20220116.1908/magit-clone.el +++ b/elpa/magit-20220518.2359/magit-clone.el @@ -1,19 +1,16 @@ -;;; magit-clone.el --- clone a repository -*- lexical-binding: t -*- +;;; magit-clone.el --- Clone a repository -*- lexical-binding:t -*- -;; Copyright (C) 2008-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Jonas Bernoulli ;; Maintainer: Jonas Bernoulli ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Magit is free software; you can redistribute it and/or modify it +;; 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. +;; the Free Software Foundation, either version 3 of the License, 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 @@ -21,7 +18,7 @@ ;; 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. +;; along with Magit. If not, see . ;;; Commentary: @@ -117,6 +114,9 @@ the name of the owner. Also see `magit-clone-name-alist'." ["Setup arguments" ("-o" "Set name of remote" ("-o" "--origin=")) ("-b" "Set HEAD branch" ("-b" "--branch=")) + (magit-clone:--filter + :if (lambda () (magit-git-version>= "2.17.0")) + :level 7) ("-g" "Separate git directory" "--separate-git-dir=" transient-read-directory :level 7) ("-t" "Use template directory" "--template=" @@ -129,13 +129,28 @@ the name of the owner. Also see `magit-clone-name-alist'." ("s" "shallow" magit-clone-shallow) ("d" "shallow since date" magit-clone-shallow-since :level 7) ("e" "shallow excluding" magit-clone-shallow-exclude :level 7) + (">" "sparse checkout" magit-clone-sparse + :if (lambda () (magit-git-version>= "2.25.0")) + :level 6) ("b" "bare" magit-clone-bare) ("m" "mirror" magit-clone-mirror)] (interactive (list (or magit-clone-always-transient current-prefix-arg))) (if transient - (transient-setup #'magit-clone) + (transient-setup 'magit-clone) (call-interactively #'magit-clone-regular))) +(transient-define-argument magit-clone:--filter () + :description "Filter some objects" + :class 'transient-option + :key "-f" + :argument "--filter=" + :reader #'magit-clone-read-filter) + +(defun magit-clone-read-filter (prompt initial-input history) + (magit-completing-read prompt + (list "blob:none" "tree:0") + nil nil initial-input history)) + ;;;###autoload (defun magit-clone-regular (repository directory args) "Create a clone of REPOSITORY in DIRECTORY. @@ -193,7 +208,14 @@ Then show the status buffer for the new repository." (interactive (magit-clone-read-args)) (magit-clone-internal repository directory (cons "--mirror" args))) -(defun magit-clone-internal (repository directory args) +;;;###autoload +(defun magit-clone-sparse (repository directory args) + "Clone REPOSITORY into DIRECTORY and create a sparse checkout." + (interactive (magit-clone-read-args)) + (magit-clone-internal repository directory (cons "--no-checkout" args) + 'sparse)) + +(defun magit-clone-internal (repository directory args &optional sparse) (let* ((checkout (not (memq (car args) '("--bare" "--mirror")))) (remote (or (transient-arg-value "--origin" args) (magit-get "clone.defaultRemote") @@ -208,7 +230,7 @@ Then show the status buffer for the new repository." (setq directory (file-name-as-directory (expand-file-name directory))) (when (file-exists-p directory) (if (file-directory-p directory) - (when (> (length (directory-files directory)) 2) + (when (length> (directory-files directory) 2) (let ((name (magit-clone--url-to-name repository))) (unless (and name (setq directory (file-name-as-directory @@ -234,6 +256,13 @@ Then show the status buffer for the new repository." (setf (magit-get "remote.pushDefault") remote)) (unless magit-clone-set-remote-head (magit-remote-unset-head remote)))) + (when (and sparse checkout) + (when (magit-git-version< "2.25.0") + (user-error + "`git sparse-checkout' not available until Git v2.25")) + (let ((default-directory directory)) + (magit-call-git "sparse-checkout" "init" "--cone") + (magit-call-git "checkout" (magit-get-current-branch)))) (with-current-buffer (process-get process 'command-buf) (magit-status-setup-buffer directory))))))) @@ -285,9 +314,9 @@ Then show the status buffer for the new repository." (format-spec magit-clone-url-format `((?h . ,host) - (?n . ,(if (string-match-p "/" repo) + (?n . ,(if (string-search "/" repo) repo - (if (string-match-p "\\." user) + (if (string-search "." user) (if-let ((user (magit-get user))) (concat user "/" repo) (user-error "Set %S or specify owner explicitly" user)) diff --git a/elpa/magit-20220116.1908/magit-commit.el b/elpa/magit-20220518.2359/magit-commit.el similarity index 87% rename from elpa/magit-20220116.1908/magit-commit.el rename to elpa/magit-20220518.2359/magit-commit.el index c2b5a429..081b8e78 100644 --- a/elpa/magit-20220116.1908/magit-commit.el +++ b/elpa/magit-20220518.2359/magit-commit.el @@ -1,19 +1,16 @@ -;;; magit-commit.el --- create Git commits -*- lexical-binding: t -*- +;;; magit-commit.el --- Create Git commits -*- lexical-binding:t -*- -;; Copyright (C) 2008-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Jonas Bernoulli ;; Maintainer: Jonas Bernoulli ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Magit is free software; you can redistribute it and/or modify it +;; 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. +;; the Free Software Foundation, either version 3 of the License, 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 @@ -21,7 +18,7 @@ ;; 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. +;; along with Magit. If not, see . ;;; Commentary: @@ -34,9 +31,6 @@ (require 'magit) (require 'magit-sequence) -(eval-when-compile (require 'epa)) ; for `epa-protocol' -(eval-when-compile (require 'epg)) - ;;; Options (defcustom magit-commit-ask-to-stage 'verbose @@ -119,13 +113,6 @@ Also see https://github.com/magit/magit/issues/4132." :group 'magit-commands :type 'boolean) -(defvar magit-post-commit-hook-commands - '(magit-commit-extend - magit-commit-fixup - magit-commit-augment - magit-commit-instant-fixup - magit-commit-instant-squash)) - ;;; Popup ;;;###autoload (autoload 'magit-commit "magit-commit" nil t) @@ -168,58 +155,12 @@ Also see https://github.com/magit/magit/issues/4132." (defun magit-commit-arguments nil (transient-args 'magit-commit)) -(transient-define-argument magit:--gpg-sign () - :description "Sign using gpg" - :class 'transient-option - :shortarg "-S" - :argument "--gpg-sign=" - :allow-empty t - :reader 'magit-read-gpg-signing-key) - -(defvar magit-gpg-secret-key-hist nil) - -(defun magit-read-gpg-secret-key - (prompt &optional initial-input history predicate) - (require 'epa) - (let* ((keys (cl-mapcan - (lambda (cert) - (and (or (not predicate) - (funcall predicate cert)) - (let* ((key (car (epg-key-sub-key-list cert))) - (fpr (epg-sub-key-fingerprint key)) - (id (epg-sub-key-id key)) - (author - (when-let ((id-obj - (car (epg-key-user-id-list cert)))) - (let ((id-str (epg-user-id-string id-obj))) - (if (stringp id-str) - id-str - (epg-decode-dn id-obj)))))) - (list - (propertize fpr 'display - (concat (substring fpr 0 (- (length id))) - (propertize id 'face 'highlight) - " " author)))))) - (epg-list-keys (epg-make-context epa-protocol) nil t))) - (choice (completing-read prompt keys nil nil nil - history nil initial-input))) - (set-text-properties 0 (length choice) nil choice) - choice)) - -(defun magit-read-gpg-signing-key (prompt &optional initial-input history) - (magit-read-gpg-secret-key - prompt initial-input history - (lambda (cert) - (cl-some (lambda (key) - (memq 'sign (epg-sub-key-capability key))) - (epg-key-sub-key-list cert))))) - (transient-define-argument magit-commit:--reuse-message () :description "Reuse commit message" :class 'transient-option :shortarg "-C" :argument "--reuse-message=" - :reader 'magit-read-reuse-message + :reader #'magit-read-reuse-message :history-key 'magit-revision-history) (defun magit-read-reuse-message (prompt &optional default history) @@ -267,10 +208,11 @@ to inverse the meaning of the prefix argument. \n(git commit magit-commit-extend-override-date))) (when (setq args (magit-commit-assert args)) (magit-commit-amend-assert) - (let ((process-environment process-environment)) - (unless override-date - (push (magit-rev-format "GIT_COMMITTER_DATE=%cD") process-environment)) - (magit-run-git-with-editor "commit" "--amend" "--no-edit" args)))) + (if override-date + (magit-run-git-with-editor "commit" "--amend" "--no-edit" args) + (with-environment-variables + (("GIT_COMMITTER_DATE" (magit-rev-format "%cD"))) + (magit-run-git-with-editor "commit" "--amend" "--no-edit" args))))) ;;;###autoload (defun magit-commit-reword (&optional args override-date) @@ -288,11 +230,12 @@ and ignore the option. (not magit-commit-reword-override-date) magit-commit-reword-override-date))) (magit-commit-amend-assert) - (let ((process-environment process-environment)) - (unless override-date - (push (magit-rev-format "GIT_COMMITTER_DATE=%cD") process-environment)) - (cl-pushnew "--allow-empty" args :test #'equal) - (magit-run-git-with-editor "commit" "--amend" "--only" args))) + (cl-pushnew "--allow-empty" args :test #'equal) + (if override-date + (magit-run-git-with-editor "commit" "--amend" "--only" args) + (with-environment-variables + (("GIT_COMMITTER_DATE" (magit-rev-format "%cD"))) + (magit-run-git-with-editor "commit" "--amend" "--only" args)))) ;;;###autoload (defun magit-commit-fixup (&optional commit args) @@ -370,7 +313,7 @@ depending on the value of option `magit-commit-squash-confirm'." (magit-call-git "commit" "--no-gpg-sign" (-remove-first - (apply-partially #'string-match-p "\\`--gpg-sign=") + (apply-partially #'string-prefix-p "--gpg-sign=") args))) (magit-run-git-with-editor "commit" args)) t) ; The commit was created; used by below lambda. @@ -417,7 +360,7 @@ depending on the value of option `magit-commit-squash-confirm'." ((and (magit-rebase-in-progress-p) (not (magit-anything-unstaged-p)) (y-or-n-p "Nothing staged. Continue in-progress rebase? ")) - (setq this-command 'magit-rebase-continue) + (setq this-command #'magit-rebase-continue) (magit-run-git-sequencer "rebase" "--continue") nil) ((and (file-exists-p (magit-git-dir "MERGE_MSG")) @@ -467,8 +410,7 @@ is updated: 'magit--reshelve-history) update-author (magit-commit-arguments)))) - (let ((process-environment process-environment)) - (push (concat "GIT_COMMITTER_DATE=" date) process-environment) + (with-environment-variables (("GIT_COMMITTER_DATE" date)) (magit-run-git "commit" "--amend" "--no-edit" (and update-author (concat "--date=" date)) args))) @@ -516,7 +458,7 @@ See `magit-commit-autofixup' for an alternative implementation." (transient-args 'magit-commit-absorb)))) (if (eq phase 'transient) (transient-setup 'magit-commit-absorb) - (unless (executable-find "git-absorb") + (unless (compat-executable-find "git-absorb" t) (user-error "This command requires the git-absorb executable, which %s" "is available from https://github.com/tummychow/git-absorb")) (unless (magit-anything-staged-p) @@ -559,7 +501,7 @@ See `magit-commit-absorb' for an alternative implementation." (transient-args 'magit-commit-autofixup)))) (if (eq phase 'transient) (transient-setup 'magit-commit-autofixup) - (unless (executable-find "git-autofixup") + (unless (compat-executable-find "git-autofixup" t) (user-error "This command requires the git-autofixup script, which %s" "is available from https://github.com/torbiak/git-autofixup")) (unless (magit-anything-modified-p) @@ -579,14 +521,26 @@ See `magit-commit-absorb' for an alternative implementation." :class 'transient-option :shortarg "-c" :argument "--context=" - :reader 'transient-read-number-N0) + :reader #'transient-read-number-N0) (transient-define-argument magit-autofixup:--strict () :description "Strictness" :class 'transient-option :shortarg "-s" :argument "--strict=" - :reader 'transient-read-number-N0) + :reader #'transient-read-number-N0) + +(defvar magit-post-commit-hook-commands + '(magit-commit-extend + magit-commit-fixup + magit-commit-augment + magit-commit-instant-fixup + magit-commit-instant-squash)) + +(defun magit-run-post-commit-hook () + (when (and (not this-command) + (memq last-command magit-post-commit-hook-commands)) + (run-hooks 'magit-post-commit-hook))) ;;; Pending Diff @@ -624,11 +578,11 @@ See `magit-commit-absorb' for an alternative implementation." ;; Mention `magit-diff-while-committing' because that's ;; always what I search for when I try to find this line. -(add-hook 'server-switch-hook 'magit-commit-diff) -(add-hook 'with-editor-filter-visit-hook 'magit-commit-diff) +(add-hook 'server-switch-hook #'magit-commit-diff) +(add-hook 'with-editor-filter-visit-hook #'magit-commit-diff) (add-to-list 'with-editor-server-window-alist - (cons git-commit-filename-regexp 'switch-to-buffer)) + (cons git-commit-filename-regexp #'switch-to-buffer)) ;;; Message Utilities @@ -640,7 +594,7 @@ See `magit-commit-absorb' for an alternative implementation." (append (buffer-list (selected-frame)) (buffer-list))))) -(defvar magit-commit-add-log-insert-function 'magit-commit-add-log-insert +(defvar magit-commit-add-log-insert-function #'magit-commit-add-log-insert "Used by `magit-commit-add-log' to insert a single entry.") (defun magit-commit-add-log () diff --git a/elpa/magit-20220116.1908/magit-core.el b/elpa/magit-20220518.2359/magit-core.el similarity index 88% rename from elpa/magit-20220116.1908/magit-core.el rename to elpa/magit-20220518.2359/magit-core.el index c0873a98..1105f827 100644 --- a/elpa/magit-20220116.1908/magit-core.el +++ b/elpa/magit-20220518.2359/magit-core.el @@ -1,19 +1,16 @@ -;;; magit-core.el --- core functionality -*- lexical-binding: t -*- +;;; magit-core.el --- Core functionality -*- lexical-binding:t -*- -;; Copyright (C) 2010-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Jonas Bernoulli ;; Maintainer: Jonas Bernoulli ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Magit is free software; you can redistribute it and/or modify it +;; 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. +;; the Free Software Foundation, either version 3 of the License, 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 @@ -21,7 +18,7 @@ ;; 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. +;; along with Magit. If not, see . ;;; Commentary: @@ -32,8 +29,7 @@ ;;; Code: -(require 'magit-utils) -(require 'magit-section) +(require 'magit-base) (require 'magit-git) (require 'magit-mode) (require 'magit-margin) @@ -49,6 +45,8 @@ (message "Error while loading `magit-libgit': %S" err) (message "That is not fatal. The `libegit2' module just won't be used.")))) +;;; Options + (defgroup magit nil "Controlling Git from Emacs." :link '(url-link "https://magit.vc") diff --git a/elpa/magit-20220116.1908/magit-diff.el b/elpa/magit-20220518.2359/magit-diff.el similarity index 85% rename from elpa/magit-20220116.1908/magit-diff.el rename to elpa/magit-20220518.2359/magit-diff.el index b38c17ad..44437366 100644 --- a/elpa/magit-20220116.1908/magit-diff.el +++ b/elpa/magit-20220518.2359/magit-diff.el @@ -1,19 +1,16 @@ -;;; magit-diff.el --- inspect Git diffs -*- lexical-binding: t -*- +;;; magit-diff.el --- Inspect Git diffs -*- lexical-binding:t -*- -;; Copyright (C) 2010-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Jonas Bernoulli ;; Maintainer: Jonas Bernoulli ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Magit is free software; you can redistribute it and/or modify it +;; 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. +;; the Free Software Foundation, either version 3 of the License, 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 @@ -21,7 +18,7 @@ ;; 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. +;; along with Magit. If not, see . ;;; Commentary: @@ -41,8 +38,6 @@ ;; For `magit-diff-popup' (declare-function magit-stash-show "magit-stash" (stash &optional args files)) ;; For `magit-diff-visit-file' -(declare-function dired-jump "dired" ; dired-x before 27.1 - (&optional other-window file-name)) (declare-function magit-find-file-noselect "magit-files" (rev file)) (declare-function magit-status-setup-buffer "magit-status" (&optional directory)) ;; For `magit-diff-while-committing' @@ -64,6 +59,29 @@ (declare-function forge--pullreq-ref "forge-pullreq" (pullreq)) ;; For `magit-diff-wash-diff' (declare-function ansi-color-apply-on-region "ansi-color") +;; For `magit-diff-wash-submodule' +(declare-function magit-log-wash-log "magit-log" (style args)) +;; For keymaps and menus +(declare-function magit-apply "magit-apply" (&rest args)) +(declare-function magit-stage "magit-apply" (&optional indent)) +(declare-function magit-unstage "magit-apply" ()) +(declare-function magit-discard "magit-apply" ()) +(declare-function magit-reverse "magit-apply" (&rest args)) +(declare-function magit-file-rename "magit-files" (file newname)) +(declare-function magit-file-untrack "magit-files" (files &optional force)) +(declare-function magit-commit-add-log "magit-commit" ()) +(declare-function magit-diff-trace-definition "magit-log" ()) +(declare-function magit-patch-save "magit-patch" (files &optional arg)) +(declare-function magit-do-async-shell-command "magit-extras" (file)) +(declare-function magit-add-change-log-entry "magit-extras" + (&optional whoami file-name other-window)) +(declare-function magit-add-change-log-entry-other-window "magit-extras" + (&optional whoami file-name)) +(declare-function magit-diff-edit-hunk-commit "magit-extras" (file)) +(declare-function magit-smerge-keep-current "magit-apply" ()) +(declare-function magit-smerge-keep-upper "magit-apply" ()) +(declare-function magit-smerge-keep-base "magit-apply" ()) +(declare-function magit-smerge-keep-lower "magit-apply" ()) (eval-when-compile (cl-pushnew 'orig-rev eieio--known-slot-names) @@ -136,7 +154,7 @@ how we should do it. However the overlay variant actually works better. Also see https://github.com/magit/magit/issues/2758. Instead of, or in addition to, using delimiting horizontal lines, -to emphasize the boundaries, you may which to emphasize the text +to emphasize the boundaries, you may wish to emphasize the text itself, using `magit-diff-highlight-hunk-region-using-face'. In terminal frames it's not possible to draw lines as the overlay @@ -535,24 +553,24 @@ If you prefer the old behaviors, then set this to t." (defface magit-diff-hunk-heading `((((class color) (background light)) ,@(and (>= emacs-major-version 27) '(:extend t)) - :background "grey80" - :foreground "grey30") + :background "grey90" + :foreground "grey20") (((class color) (background dark)) ,@(and (>= emacs-major-version 27) '(:extend t)) :background "grey25" - :foreground "grey70")) + :foreground "grey95")) "Face for diff hunk headings." :group 'magit-faces) (defface magit-diff-hunk-heading-highlight `((((class color) (background light)) ,@(and (>= emacs-major-version 27) '(:extend t)) - :background "grey75" - :foreground "grey30") + :background "grey80" + :foreground "grey20") (((class color) (background dark)) ,@(and (>= emacs-major-version 27) '(:extend t)) :background "grey35" - :foreground "grey70")) + :foreground "grey95")) "Face for current diff hunk headings." :group 'magit-faces) @@ -833,29 +851,6 @@ and `:slant'." (setq magit-buffer-diff-files files) (magit-refresh))) -;;; Section Classes - -(defclass magit-file-section (magit-section) - ((keymap :initform 'magit-file-section-map) - (source :initform nil) - (header :initform nil))) - -(defclass magit-module-section (magit-file-section) - ((keymap :initform 'magit-hunk-section-map))) - -(defclass magit-hunk-section (magit-section) - ((keymap :initform 'magit-hunk-section-map) - (refined :initform nil) - (combined :initform nil) - (from-range :initform nil) - (from-ranges :initform nil) - (to-range :initform nil) - (about :initform nil))) - -(setf (alist-get 'hunk magit--section-type-alist) 'magit-hunk-section) -(setf (alist-get 'module magit--section-type-alist) 'magit-module-section) -(setf (alist-get 'file magit--section-type-alist) 'magit-file-section) - ;;; Commands ;;;; Prefix Commands @@ -917,7 +912,7 @@ and `:slant'." ("=g" "Show signature" "--show-signature" :if-derived magit-diff-mode) (5 "-R" "Reverse sides" "-R" - :if-derived magit-diff-mode) + :if-derived magit-diff-mode) (5 magit-diff:--color-moved) (5 magit-diff:--color-moved-ws)] [["Refresh" @@ -948,13 +943,13 @@ and `:slant'." :class 'transient-files :key "--" :argument "--" - :prompt "Limit to file(s): " - :reader 'magit-read-files + :prompt "Limit to file,s: " + :reader #'magit-read-files :multi-value t) -(defun magit-read-files (prompt initial-input history) +(defun magit-read-files (prompt initial-input history &optional list-fn) (magit-completing-read-multiple* prompt - (magit-list-files) + (funcall (or list-fn #'magit-list-files)) nil nil (or initial-input (magit-file-at-point)) history)) @@ -963,28 +958,28 @@ and `:slant'." :description "Context lines" :class 'transient-option :argument "-U" - :reader 'transient-read-number-N0) + :reader #'transient-read-number-N0) (transient-define-argument magit-diff:-M () :description "Detect renames" :class 'transient-option :argument "-M" :allow-empty t - :reader 'transient-read-number-N+) + :reader #'transient-read-number-N+) (transient-define-argument magit-diff:-C () :description "Detect copies" :class 'transient-option :argument "-C" :allow-empty t - :reader 'transient-read-number-N+) + :reader #'transient-read-number-N+) (transient-define-argument magit-diff:--diff-algorithm () :description "Diff algorithm" :class 'transient-option :key "-A" :argument "--diff-algorithm=" - :reader 'magit-diff-select-algorithm) + :reader #'magit-diff-select-algorithm) (defun magit-diff-select-algorithm (&rest _ignore) (magit-read-char-case nil t @@ -998,7 +993,7 @@ and `:slant'." :class 'transient-option :key "-i" :argument "--ignore-submodules=" - :reader 'magit-diff-select-ignore-submodules) + :reader #'magit-diff-select-ignore-submodules) (defun magit-diff-select-ignore-submodules (&rest _ignored) (magit-read-char-case "Ignore submodules " t @@ -1011,7 +1006,7 @@ and `:slant'." :class 'transient-option :key "-m" :argument "--color-moved=" - :reader 'magit-diff-select-color-moved-mode) + :reader #'magit-diff-select-color-moved-mode) (defun magit-diff-select-color-moved-mode (&rest _ignore) (magit-read-char-case "Color moved " t @@ -1026,7 +1021,7 @@ and `:slant'." :class 'transient-option :key "=w" :argument "--color-moved-ws=" - :reader 'magit-diff-select-color-moved-ws-mode) + :reader #'magit-diff-select-color-moved-ws-mode) (defun magit-diff-select-color-moved-ws-mode (&rest _ignore) (magit-read-char-case "Ignore whitespace " t @@ -1042,22 +1037,36 @@ and `:slant'." (defun magit-diff-dwim (&optional args files) "Show changes for the thing at point." (interactive (magit-diff-arguments)) - (pcase (magit-diff--dwim) - (`unmerged (magit-diff-unmerged args files)) - (`unstaged (magit-diff-unstaged args files)) - (`staged - (let ((file (magit-file-at-point))) - (if (and file (equal (cddr (car (magit-file-status file))) '(?D ?U))) - ;; File was deleted by us and modified by them. Show the latter. - (magit-diff-unmerged args (list file)) - (magit-diff-staged nil args files)))) - (`(commit . ,value) - (magit-diff-range (format "%s^..%s" value value) args files)) - (`(stash . ,value) (magit-stash-show value args)) - ((and range (pred stringp)) - (magit-diff-range range args files)) - (_ - (call-interactively #'magit-diff-range)))) + (let ((default-directory default-directory) + (section (magit-current-section))) + (cond + ((magit-section-match 'module section) + (setq default-directory + (expand-file-name + (file-name-as-directory (oref section value)))) + (magit-diff-range (oref section range))) + (t + (when (magit-section-match 'module-commit section) + (setq args nil) + (setq files nil) + (setq default-directory + (expand-file-name + (file-name-as-directory (magit-section-parent-value section))))) + (pcase (magit-diff--dwim) + ('unmerged (magit-diff-unmerged args files)) + ('unstaged (magit-diff-unstaged args files)) + ('staged + (let ((file (magit-file-at-point))) + (if (and file (equal (cddr (car (magit-file-status file))) '(?D ?U))) + ;; File was deleted by us and modified by them. Show the latter. + (magit-diff-unmerged args (list file)) + (magit-diff-staged nil args files)))) + (`(stash . ,value) (magit-stash-show value args)) + (`(commit . ,value) + (magit-diff-range (format "%s^..%s" value value) args files)) + ((and range (pred stringp)) + (magit-diff-range range args files)) + (_ (call-interactively #'magit-diff-range))))))) (defun magit-diff--dwim () "Return information for performing DWIM diff. @@ -1076,9 +1085,10 @@ The information can be in three forms: If no DWIM context is found, nil is returned." (cond - ((--when-let (magit-region-values '(commit branch) t) + ((when-let* ((commits (magit-region-values '(commit branch) t))) + ;; Cannot use and-let* because of debbugs#31840. (deactivate-mark) - (concat (car (last it)) ".." (car it)))) + (concat (car (last commits)) ".." (car commits)))) (magit-buffer-refname (cons 'commit magit-buffer-refname)) ((derived-mode-p 'magit-stash-mode) @@ -1126,37 +1136,42 @@ If no DWIM context is found, nil is returned." ((string-match "\\.\\." range) (replace-match "..." nil nil range)) (t range))) +(defun magit-diff--region-range (&optional interactive mbase) + (when-let* ((commits (magit-region-values '(commit branch) t)) ;debbugs#31840 + (revA (car (last commits))) + (revB (car commits))) + (when interactive + (deactivate-mark)) + (if mbase + (let ((base (magit-git-string "merge-base" revA revB))) + (cond + ((string= (magit-rev-parse revA) base) + (format "%s..%s" revA revB)) + ((string= (magit-rev-parse revB) base) + (format "%s..%s" revB revA)) + (interactive + (let ((main (magit-completing-read "View changes along" + (list revA revB) + nil t nil nil revB))) + (format "%s...%s" + (if (string= main revB) revA revB) main))) + (t "%s...%s" revA revB))) + (format "%s..%s" revA revB)))) + (defun magit-diff-read-range-or-commit (prompt &optional secondary-default mbase) "Read range or revision with special diff range treatment. If MBASE is non-nil, prompt for which rev to place at the end of a \"revA...revB\" range. Otherwise, always construct \"revA..revB\" range." - (--if-let (magit-region-values '(commit branch) t) - (let ((revA (car (last it))) - (revB (car it))) - (deactivate-mark) - (if mbase - (let ((base (magit-git-string "merge-base" revA revB))) - (cond - ((string= (magit-rev-parse revA) base) - (format "%s..%s" revA revB)) - ((string= (magit-rev-parse revB) base) - (format "%s..%s" revB revA)) - (t - (let ((main (magit-completing-read "View changes along" - (list revA revB) - nil t nil nil revB))) - (format "%s...%s" - (if (string= main revB) revA revB) main))))) - (format "%s..%s" revA revB))) - (magit-read-range prompt - (or (pcase (magit-diff--dwim) - (`(commit . ,value) - (format "%s^..%s" value value)) - ((and range (pred stringp)) - range)) - secondary-default - (magit-get-current-branch))))) + (or (magit-diff--region-range t mbase) + (magit-read-range prompt + (or (pcase (magit-diff--dwim) + (`(commit . ,value) + (format "%s^..%s" value value)) + ((and range (pred stringp)) + range)) + secondary-default + (magit-get-current-branch))))) ;;;###autoload (defun magit-diff-range (rev-or-range &optional args files) @@ -1240,7 +1255,7 @@ be committed." (magit-diff-while-amending args))))) (define-key git-commit-mode-map - (kbd "C-c C-d") 'magit-diff-while-committing) + (kbd "C-c C-d") #'magit-diff-while-committing) (defun magit-diff-while-amending (&optional args) (magit-diff-setup-buffer "HEAD^" "--cached" args nil)) @@ -1300,7 +1315,7 @@ for a revision." (interactive (pcase-let* ((mcommit (magit-section-value-if 'module-commit)) (atpoint (or mcommit - (thing-at-point 'git-revision t) + (magit-thing-at-point 'git-revision t) (magit-branch-or-commit-at-point))) (`(,args ,files) (magit-show-commit--arguments))) (list (or (and (not current-prefix-arg) atpoint) @@ -1310,24 +1325,25 @@ for a revision." (and mcommit (magit-section-parent-value (magit-current-section)))))) (require 'magit) - (let ((file (magit-file-relative-name))) + (let* ((file (magit-file-relative-name)) + (ln (and file (line-number-at-pos)))) (magit-with-toplevel (when module (setq default-directory (expand-file-name (file-name-as-directory module)))) (unless (magit-commit-p rev) (user-error "%s is not a commit" rev)) + (when file + (save-buffer)) (let ((buf (magit-revision-setup-buffer rev args files))) (when file - (save-buffer) - (let ((line (magit-diff-visit--offset file (list "-R" rev) - (line-number-at-pos))) + (let ((line (magit-diff-visit--offset file (list "-R" rev) ln)) (col (current-column))) (with-current-buffer buf (magit-diff--goto-position file line col)))))))) (defun magit-diff--locate-hunk (file line &optional parent) - (when-let ((diff (cl-find-if (lambda (section) + (and-let* ((diff (cl-find-if (lambda (section) (and (cl-typep section 'magit-file-section) (equal (oref section value) file))) (oref (or parent magit-root-section) children)))) @@ -1404,13 +1420,13 @@ toggle the file restriction in the repository's revision buffer instead." (interactive) (cl-flet ((toggle () - (if (or magit-buffer-diff-files - magit-buffer-diff-files-suspended) - (cl-rotatef magit-buffer-diff-files - magit-buffer-diff-files-suspended) - (setq magit-buffer-diff-files - (transient-infix-read 'magit:--))) - (magit-refresh))) + (if (or magit-buffer-diff-files + magit-buffer-diff-files-suspended) + (cl-rotatef magit-buffer-diff-files + magit-buffer-diff-files-suspended) + (setq magit-buffer-diff-files + (transient-infix-read 'magit:--))) + (magit-refresh))) (cond ((derived-mode-p 'magit-log-mode 'magit-cherry-mode @@ -1658,31 +1674,30 @@ the Magit-Status buffer for DIRECTORY." (list buf nil)))) (defun magit-diff-visit--hunk () - (when-let ((scope (magit-diff-scope))) - (let ((section (magit-current-section))) - (cl-case scope - ((file files) - (setq section (car (oref section children)))) - (list - (setq section (car (oref section children))) - (when section - (setq section (car (oref section children)))))) - (and - ;; Unmerged files appear in the list of staged changes - ;; but unlike in the list of unstaged changes no diffs - ;; are shown here. In that case `section' is nil. - section - ;; Currently the `hunk' type is also abused for file - ;; mode changes, which we are not interested in here. - ;; Such sections have no value. - (oref section value) - section)))) + (when-let* ((scope (magit-diff-scope)) ;debbugs#31840 + (section (magit-current-section))) + (cl-case scope + ((file files) + (setq section (car (oref section children)))) + (list + (setq section (car (oref section children))) + (when section + (setq section (car (oref section children)))))) + (and + ;; Unmerged files appear in the list of staged changes + ;; but unlike in the list of unstaged changes no diffs + ;; are shown here. In that case `section' is nil. + section + ;; Currently the `hunk' type is also abused for file + ;; mode changes, which we are not interested in here. + (not (equal (oref section value) '(chmod))) + section))) (defun magit-diff-visit--goto-from-p (section in-worktree) (and magit-diff-visit-previous-blob (not in-worktree) (not (oref section combined)) - (not (< (point) (oref section content))) + (not (< (magit-point) (oref section content))) (= (char-after (line-beginning-position)) ?-))) (defvar magit-diff-visit-jump-to-change t) @@ -1691,24 +1706,25 @@ the Magit-Status buffer for DIRECTORY." (save-excursion (goto-char (line-beginning-position)) (with-slots (content combined from-ranges from-range to-range) section - (when (and magit-diff-visit-jump-to-change (< (point) content)) - (goto-char content) - (re-search-forward "^[-+]")) - (+ (car (if goto-from from-range to-range)) - (let ((prefix (if combined (length from-ranges) 1)) - (target (point)) - (offset 0)) - (goto-char content) - (while (< (point) target) - (unless (string-match-p - (if goto-from "\\+" "-") - (buffer-substring (point) (+ (point) prefix))) - (cl-incf offset)) - (forward-line)) - offset))))) + (when (or from-range to-range) + (when (and magit-diff-visit-jump-to-change (< (point) content)) + (goto-char content) + (re-search-forward "^[-+]")) + (+ (car (if goto-from from-range to-range)) + (let ((prefix (if combined (length from-ranges) 1)) + (target (point)) + (offset 0)) + (goto-char content) + (while (< (point) target) + (unless (string-search + (if goto-from "+" "-") + (buffer-substring (point) (+ (point) prefix))) + (cl-incf offset)) + (forward-line)) + offset)))))) (defun magit-diff-hunk-column (section goto-from) - (if (or (< (point) + (if (or (< (magit-point) (oref section content)) (and (not goto-from) (= (char-after (line-beginning-position)) ?-))) @@ -1772,7 +1788,7 @@ current frame and contains information about that commit or stash, then instead scroll the buffer up. If there is no commit or stash at point, then prompt for a commit." (interactive) - (magit-diff-show-or-scroll 'scroll-up)) + (magit-diff-show-or-scroll #'scroll-up)) (defun magit-diff-show-or-scroll-down () "Update the commit or diff buffer for the thing at point. @@ -1783,14 +1799,15 @@ current frame and contains information about that commit or stash, then instead scroll the buffer down. If there is no commit or stash at point, then prompt for a commit." (interactive) - (magit-diff-show-or-scroll 'scroll-down)) + (magit-diff-show-or-scroll #'scroll-down)) (defun magit-diff-show-or-scroll (fn) (let (rev cmd buf win) (cond - (magit-blame-mode + ((and (bound-and-true-p magit-blame-mode) + (fboundp 'magit-current-blame-chunk)) (setq rev (oref (magit-current-blame-chunk) orig-rev)) - (setq cmd 'magit-show-commit) + (setq cmd #'magit-show-commit) (setq buf (magit-get-mode-buffer 'magit-revision-mode))) ((derived-mode-p 'git-rebase-mode) (with-slots (action-type target) @@ -1798,21 +1815,21 @@ commit or stash at point, then prompt for a commit." (if (not (eq action-type 'commit)) (user-error "No commit on this line") (setq rev target) - (setq cmd 'magit-show-commit) + (setq cmd #'magit-show-commit) (setq buf (magit-get-mode-buffer 'magit-revision-mode))))) (t (magit-section-case (branch (setq rev (magit-ref-maybe-qualify (oref it value))) - (setq cmd 'magit-show-commit) + (setq cmd #'magit-show-commit) (setq buf (magit-get-mode-buffer 'magit-revision-mode))) (commit (setq rev (oref it value)) - (setq cmd 'magit-show-commit) + (setq cmd #'magit-show-commit) (setq buf (magit-get-mode-buffer 'magit-revision-mode))) (stash (setq rev (oref it value)) - (setq cmd 'magit-stash-show) + (setq cmd #'magit-stash-show) (setq buf (magit-get-mode-buffer 'magit-stash-mode)))))) (if rev (if (and buf @@ -1826,10 +1843,10 @@ commit or stash at point, then prompt for a commit." (funcall fn) (error (goto-char (pcase fn - (`scroll-up (point-min)) - (`scroll-down (point-max))))))) + ('scroll-up (point-min)) + ('scroll-down (point-max))))))) (let ((magit-display-buffer-noselect t)) - (if (eq cmd 'magit-show-commit) + (if (eq cmd #'magit-show-commit) (apply #'magit-show-commit rev (magit-show-commit--arguments)) (funcall cmd rev)))) (call-interactively #'magit-show-commit)))) @@ -1858,24 +1875,24 @@ commit or stash at point, then prompt for a commit." (let ((children (--mapcat (oref it children) sections))) (cond ((and (--any-p (oref it hidden) children) (--any-p (oref it children) children)) - (mapc 'magit-section-show-headings sections)) - ((seq-some 'magit-section-hidden-body children) - (mapc 'magit-section-show-children sections)) + (mapc #'magit-section-show-headings sections)) + ((seq-some #'magit-section-hidden-body children) + (mapc #'magit-section-show-children sections)) (t - (mapc 'magit-section-hide sections))))))) + (mapc #'magit-section-hide sections))))))) ;;; Diff Mode (defvar magit-diff-mode-map (let ((map (make-sparse-keymap))) (set-keymap-parent map magit-mode-map) - (define-key map (kbd "C-c C-d") 'magit-diff-while-committing) - (define-key map (kbd "C-c C-b") 'magit-go-backward) - (define-key map (kbd "C-c C-f") 'magit-go-forward) - (define-key map (kbd "SPC") 'scroll-up) - (define-key map (kbd "DEL") 'scroll-down) - (define-key map (kbd "j") 'magit-jump-to-diffstat-or-diff) - (define-key map [remap write-file] 'magit-patch-save) + (define-key map (kbd "C-c C-d") #'magit-diff-while-committing) + (define-key map (kbd "C-c C-b") #'magit-go-backward) + (define-key map (kbd "C-c C-f") #'magit-go-forward) + (define-key map (kbd "SPC") #'scroll-up) + (define-key map (kbd "DEL") #'scroll-down) + (define-key map (kbd "j") #'magit-jump-to-diffstat-or-diff) + (define-key map [remap write-file] #'magit-patch-save) map) "Keymap for `magit-diff-mode'.") @@ -1902,10 +1919,7 @@ Staging and applying changes is documented in info node \\{magit-diff-mode-map}" :group 'magit-diff (hack-dir-local-variables-non-file-buffer) - (setq imenu-prev-index-position-function - 'magit-imenu--diff-prev-index-position-function) - (setq imenu-extract-index-name-function - 'magit-imenu--diff-extract-index-name-function)) + (setq magit--imenu-item-types 'file)) (put 'magit-diff-mode 'magit-diff-default-arguments '("--stat" "--no-ext-diff")) @@ -1955,26 +1969,51 @@ Staging and applying changes is documented in info node (list 'unstaged magit-buffer-typearg))) (and magit-buffer-diff-files (cons "--" magit-buffer-diff-files)))) -(defvar magit-diff-section-base-map +(cl-defmethod magit-menu-common-value ((_section magit-diff-section)) + (magit-diff-scope)) + +(define-obsolete-variable-alias 'magit-diff-section-base-map + 'magit-diff-section-map "Magit-Section 3.4.0") +(defvar magit-diff-section-map (let ((map (make-sparse-keymap))) - (define-key map (kbd "C-j") 'magit-diff-visit-worktree-file) - (define-key map (kbd "C-") 'magit-diff-visit-worktree-file) - (define-key map (kbd "C-x 4 ") 'magit-diff-visit-file-other-window) - (define-key map (kbd "C-x 5 ") 'magit-diff-visit-file-other-frame) - (define-key map [remap magit-visit-thing] 'magit-diff-visit-file) - (define-key map [remap magit-delete-thing] 'magit-discard) - (define-key map [remap magit-revert-no-commit] 'magit-reverse) - (define-key map "a" 'magit-apply) - (define-key map "s" 'magit-stage) - (define-key map "u" 'magit-unstage) - (define-key map "&" 'magit-do-async-shell-command) - (define-key map "C" 'magit-commit-add-log) - (define-key map (kbd "C-x a") 'magit-add-change-log-entry) - (define-key map (kbd "C-x 4 a") 'magit-add-change-log-entry-other-window) - (define-key map (kbd "C-c C-t") 'magit-diff-trace-definition) - (define-key map (kbd "C-c C-e") 'magit-diff-edit-hunk-commit) + (magit-menu-set map [magit-cherry-apply] + #'magit-apply "Apply %x" + '(:enable (not (memq (magit-diff-type) '(unstaged staged))))) + (magit-menu-set map [magit-stage-file] + #'magit-stage "Stage %x" + '(:enable (eq (magit-diff-type) 'unstaged))) + (magit-menu-set map [magit-unstage-file] + #'magit-unstage "Unstage %x" + '(:enable (eq (magit-diff-type) 'staged))) + (magit-menu-set map [magit-delete-thing] + #'magit-discard "Discard %x" + '(:enable (not (memq (magit-diff-type) '(committed undefined))))) + (magit-menu-set map [magit-revert-no-commit] + #'magit-reverse "Reverse %x" + '(:enable (not (memq (magit-diff-type) '(untracked unstaged))))) + (magit-menu-set map [magit-visit-thing] + #'magit-diff-visit-file "Visit file") + (magit-menu-set map [magit-file-untrack] + #'magit-file-untrack "Untrack %x" + '(:enable (memq (magit-diff-scope) '(file files)))) + (magit-menu-set map [magit-file-rename] + #'magit-file-rename "Rename file" + '(:enable (eq (magit-diff-scope) 'file))) + (define-key map (kbd "C-j") #'magit-diff-visit-worktree-file) + (define-key map (kbd "C-") #'magit-diff-visit-worktree-file) + (define-key map (kbd "C-x 4 ") #'magit-diff-visit-file-other-window) + (define-key map (kbd "C-x 5 ") #'magit-diff-visit-file-other-frame) + (define-key map "&" #'magit-do-async-shell-command) + (define-key map "C" #'magit-commit-add-log) + (define-key map (kbd "C-x a") #'magit-add-change-log-entry) + (define-key map (kbd "C-x 4 a") #'magit-add-change-log-entry-other-window) + (define-key map (kbd "C-c C-t") #'magit-diff-trace-definition) + (define-key map (kbd "C-c C-e") #'magit-diff-edit-hunk-commit) map) - "Parent of `magit-{hunk,file}-section-map'.") + "Keymap for diff sections. +The classes `magit-file-section' and `magit-hunk-section' derive +from the abstract `magit-diff-section' class. Accordingly this +keymap is the parent of their keymaps.") (defvar magit-file-section-map (let ((map (make-sparse-keymap))) @@ -1986,10 +2025,10 @@ Staging and applying changes is documented in info node (let ((map (make-sparse-keymap))) (set-keymap-parent map magit-diff-section-base-map) (let ((m (make-sparse-keymap))) - (define-key m (kbd "RET") 'magit-smerge-keep-current) - (define-key m (kbd "u") 'magit-smerge-keep-upper) - (define-key m (kbd "b") 'magit-smerge-keep-base) - (define-key m (kbd "l") 'magit-smerge-keep-lower) + (define-key m (kbd "RET") #'magit-smerge-keep-current) + (define-key m (kbd "u") #'magit-smerge-keep-upper) + (define-key m (kbd "b") #'magit-smerge-keep-base) + (define-key m (kbd "l") #'magit-smerge-keep-lower) (define-key map smerge-command-prefix m)) map) "Keymap for `hunk' sections.") @@ -2048,20 +2087,14 @@ Staging and applying changes is documented in info node (defun magit--insert-diff (&rest args) (declare (indent 0)) (pcase-let ((`(,cmd . ,args) - (-flatten args)) + (flatten-tree args)) (magit-git-global-arguments (remove "--literal-pathspecs" magit-git-global-arguments))) ;; As of Git 2.19.0, we need to generate diffs with ;; --ita-visible-in-index so that `magit-stage' can work with - ;; intent-to-add files (see #4026). Cache the result for each - ;; repo to avoid a `git version' call for every diff insertion. + ;; intent-to-add files (see #4026). (when (and (not (equal cmd "merge-tree")) - (pcase (magit-repository-local-get 'diff-ita-kludge-p 'unset) - (`unset - (let ((val (magit-git-version>= "2.19.0"))) - (magit-repository-local-set 'diff-ita-kludge-p val) - val)) - (val val))) + (magit-git-version>= "2.19.0")) (push "--ita-visible-in-index" args)) (setq args (magit-diff--maybe-add-stat-arguments args)) (when (cl-member-if (lambda (arg) (string-prefix-p "--color-moved" arg)) args) @@ -2081,18 +2114,18 @@ Staging and applying changes is documented in info node (defun magit-diff-use-window-width-as-stat-width () "Use the `window-width' as the value of `--stat-width'." - (when-let ((window (get-buffer-window (current-buffer) 'visible))) + (and-let* ((window (get-buffer-window (current-buffer) 'visible))) (list (format "--stat-width=%d" (window-width window))))) (defun magit-diff-wash-diffs (args &optional limit) (run-hooks 'magit-diff-wash-diffs-hook) (when (member "--show-signature" args) - (magit-diff-wash-signature)) + (magit-diff-wash-signature magit-buffer-revision-hash)) (when (member "--stat" args) (magit-diff-wash-diffstat)) (when (re-search-forward magit-diff-headline-re limit t) (goto-char (line-beginning-position)) - (magit-wash-sequence (apply-partially 'magit-diff-wash-diff args)) + (magit-wash-sequence (apply-partially #'magit-diff-wash-diff args)) (insert ?\n))) (defun magit-jump-to-diffstat-or-diff () @@ -2110,7 +2143,7 @@ section or a child thereof." (magit-section-goto it) (user-error "No diffstat in this buffer"))) -(defun magit-diff-wash-signature () +(defun magit-diff-wash-signature (object) (when (looking-at "^gpg: ") (let (title end) (save-excursion @@ -2126,11 +2159,12 @@ section or a child thereof." 'face '(italic bold))))) (forward-line)) (setq end (point-marker))) - (magit-insert-section (signature magit-buffer-revision title) - (when title - (magit-insert-heading title)) - (goto-char end) - (insert "\n"))))) + (magit-insert-section (signature object title) + (when title + (magit-insert-heading title)) + (goto-char end) + (set-marker end nil) + (insert "\n"))))) (defun magit-diff-wash-diffstat () (let (heading (beg (point))) @@ -2194,13 +2228,13 @@ section or a child thereof." (insert (propertize (format "unmerged %s%s" file (pcase (cddr (car (magit-file-status file))) - (`(?D ?D) " (both deleted)") - (`(?D ?U) " (deleted by us)") - (`(?U ?D) " (deleted by them)") - (`(?A ?A) " (both added)") - (`(?A ?U) " (added by us)") - (`(?U ?A) " (added by them)") - (`(?U ?U) ""))) + ('(?D ?D) " (both deleted)") + ('(?D ?U) " (deleted by us)") + ('(?U ?D) " (deleted by them)") + ('(?A ?A) " (both added)") + ('(?A ?U) " (added by us)") + ('(?U ?A) " (added by them)") + ('(?U ?U) ""))) 'font-lock-face 'magit-diff-file-heading)) (insert ?\n)))) t) @@ -2221,7 +2255,7 @@ section or a child thereof." ("removed in remote" "removed")))) (magit-delete-line) (while (looking-at - "^ \\([^ ]+\\) +[0-9]\\{6\\} \\([a-z0-9]\\{40\\}\\) \\(.+\\)$") + "^ \\([^ ]+\\) +[0-9]\\{6\\} \\([a-z0-9]\\{40,\\}\\) \\(.+\\)$") (magit-bind-match-strings (side _blob name) nil (pcase side ("result" (setq file name)) @@ -2296,7 +2330,7 @@ section or a child thereof." (string-prefix-p "a/" orig) (string-prefix-p "b/" file)) (and (derived-mode-p 'magit-log-mode) - (--first (string-match-p "\\`-L" it) + (--first (string-prefix-p "-L" it) magit-buffer-log-args))) (setq file (substring file 2)) (when orig @@ -2356,7 +2390,7 @@ section or a child thereof." 'font-lock-face 'magit-diff-file-heading) " (" (cond (rewind "rewind") - ((string-match-p "\\.\\.\\." range) "non-ff") + ((string-search "..." range) "non-ff") (t "new commits")) (and (or modified untracked) (concat ", " @@ -2366,9 +2400,9 @@ section or a child thereof." " content")) ")") (let ((default-directory - (file-name-as-directory - (expand-file-name module (magit-toplevel))))) - (magit-git-wash (apply-partially 'magit-log-wash-log 'module) + (file-name-as-directory + (expand-file-name module (magit-toplevel))))) + (magit-git-wash (apply-partially #'magit-log-wash-log 'module) "log" "--oneline" "--left-right" range) (delete-char -1))))) ((and (looking-at "^Submodule \\([^ ]+\\) \\([^ ]+\\) (\\([^)]+\\))$") @@ -2394,12 +2428,18 @@ section or a child thereof." (defun magit-diff-wash-hunk () (when (looking-at "^@\\{2,\\} \\(.+?\\) @\\{2,\\}\\(?: \\(.*\\)\\)?") (let* ((heading (match-string 0)) - (ranges (mapcar (lambda (str) + (ranges (mapcar + (lambda (str) + (let ((range (mapcar #'string-to-number - (split-string (substring str 1) ","))) - (split-string (match-string 1)))) + (split-string (substring str 1) ",")))) + ;; A single line is +1 rather than +1,1. + (if (length= range 1) + (nconc range (list 1)) + range))) + (split-string (match-string 1)))) (about (match-string 2)) - (combined (= (length ranges) 3)) + (combined (length= ranges 3)) (value (cons about ranges))) (magit-delete-line) (magit-insert-section section (hunk value) @@ -2409,7 +2449,7 @@ section or a child thereof." (while (not (or (eobp) (looking-at "^[^-+\s\\]"))) (forward-line)) (oset section end (point)) - (oset section washer 'magit-diff-paint-hunk) + (oset section washer #'magit-diff-paint-hunk) (oset section combined combined) (if combined (oset section from-ranges (butlast ranges)) @@ -2465,7 +2505,7 @@ Staging and applying changes is documented in info node (magit-buffer-diff-files-suspended nil))) (defun magit-revision-refresh-buffer () - (setq magit-buffer-revision-hash (magit-rev-parse magit-buffer-revision)) + (setq magit-buffer-revision-hash (magit-rev-hash magit-buffer-revision)) (magit-set-header-line-format (concat (magit-object-type magit-buffer-revision-hash) " " magit-buffer-revision @@ -2486,7 +2526,7 @@ Staging and applying changes is documented in info node "show" "-p" "--cc" "--format=" "--no-prefix" (and (member "--stat" magit-buffer-diff-args) "--numstat") magit-buffer-diff-args - (concat magit-buffer-revision "^{commit}") + (magit--rev-dereference magit-buffer-revision) "--" magit-buffer-diff-files)) (defun magit-insert-revision-tag () @@ -2516,19 +2556,34 @@ or a ref which is not a branch, then it inserts nothing." (insert (propertize heading 'font-lock-face 'magit-section-secondary-heading))) (magit-insert-heading) + (forward-line) + (magit-insert-section section (message) + (oset section heading-highlight-face + 'magit-diff-revision-summary-highlight) + (let ((beg (point))) + (forward-line) + (magit--add-face-text-property + beg (point) 'magit-diff-revision-summary)) + (magit-insert-heading) + (if (re-search-forward "-----BEGIN PGP SIGNATURE-----" nil t) + (goto-char (match-beginning 0)) + (goto-char (point-max))) + (insert ?\n)) (if (re-search-forward "-----BEGIN PGP SIGNATURE-----" nil t) (progn (let ((beg (match-beginning 0))) - (re-search-forward "-----END PGP SIGNATURE-----") + (re-search-forward "-----END PGP SIGNATURE-----\n") (delete-region beg (point))) - (insert ?\n) - (magit-process-git t "verify-tag" magit-buffer-revision)) + (save-excursion + (magit-process-git t "verify-tag" magit-buffer-revision)) + (magit-diff-wash-signature magit-buffer-revision)) (goto-char (point-max))) (insert ?\n)))) (defvar magit-commit-message-section-map (let ((map (make-sparse-keymap))) - (define-key map [remap magit-visit-thing] 'magit-show-commit) + (magit-menu-set map [magit-visit-thing] #'magit-show-commit "Visit %t" + '(:enable (magit-thing-at-point 'git-revision t))) map) "Keymap for `commit-message' sections.") @@ -2554,6 +2609,10 @@ or a ref which is not a branch, then it inserts nothing." (fill-region (point) (line-end-position)))) (when magit-revision-use-hash-sections (save-excursion + ;; Start after beg to prevent a (commit text) section from + ;; starting at the same point as the (commit-message) + ;; section. + (goto-char (1+ beg)) (while (not (eobp)) (re-search-forward "\\_<" nil 'move) (let ((beg (point))) @@ -2561,18 +2620,18 @@ or a ref which is not a branch, then it inserts nothing." (when (> (point) beg) (let ((text (buffer-substring-no-properties beg (point)))) (when (pcase magit-revision-use-hash-sections - (`quickest ; false negatives and positives + ('quickest ; false negatives and positives (and (>= (length text) 7) (string-match-p "[0-9]" text) (string-match-p "[a-z]" text))) - (`quicker ; false negatives (number-less hashes) + ('quicker ; false negatives (number-less hashes) (and (>= (length text) 7) (string-match-p "[0-9]" text) (magit-commit-p text))) - (`quick ; false negatives (short hashes) + ('quick ; false negatives (short hashes) (and (>= (length text) 7) (magit-commit-p text))) - (`slow + ('slow (magit-commit-p text))) (put-text-property beg (point) 'font-lock-face 'magit-hash) @@ -2640,7 +2699,7 @@ or a ref which is not a branch, then it inserts nothing." (--when-let (magit-rev-format "%D" magit-buffer-revision "--decorate=full") (insert (magit-format-ref-labels it) ?\s)) (insert (propertize - (magit-rev-parse (concat magit-buffer-revision "^{commit}")) + (magit-rev-parse (magit--rev-dereference magit-buffer-revision)) 'font-lock-face 'magit-hash)) (magit-insert-heading) (let ((beg (point))) @@ -2702,9 +2761,9 @@ or a ref which is not a branch, then it inserts nothing." (require 'gravatar) (pcase-let ((`(,author . ,committer) (pcase magit-revision-show-gravatars - (`t '("^Author: " . "^Commit: ")) - (`author '("^Author: " . nil)) - (`committer '(nil . "^Commit: ")) + ('t '("^Author: " . "^Commit: ")) + ('author '("^Author: " . nil)) + ('committer '(nil . "^Commit: ")) (_ magit-revision-show-gravatars)))) (--when-let (and author (magit-rev-format "%aE" rev)) (magit-insert-revision-gravatar beg rev it author)) @@ -2725,7 +2784,7 @@ or a ref which is not a branch, then it inserts nothing." 1)) (gravatar-size (- size 2))) (ignore-errors ; service may be unreachable - (gravatar-retrieve email 'magit-insert-revision-gravatar-cb + (gravatar-retrieve email #'magit-insert-revision-gravatar-cb (list gravatar-size rev (point-marker) align-to column)))))))) @@ -2744,11 +2803,10 @@ or a ref which is not a branch, then it inserts nothing." (car-safe (get-text-property (point) 'display))) 'image))) - ;; `image-property' wasn't added until 26.1. - (setcdr image (plist-put (cdr image) :ascent 'center)) - (setcdr image (plist-put (cdr image) :relief 1)) - (setcdr image (plist-put (cdr image) :scale 1)) - (setcdr image (plist-put (cdr image) :height size)) + (setf (image-property image :ascent) 'center) + (setf (image-property image :relief) 1) + (setf (image-property image :scale) 1) + (setf (image-property image :height) size) (let ((top (list image '(slice 0.0 0.0 1.0 0.5))) (bot (list image '(slice 0.0 0.5 1.0 1.0))) (align `((space :align-to ,align-to)))) @@ -2791,7 +2849,7 @@ or a ref which is not a branch, then it inserts nothing." (cl-defmethod magit-buffer-value (&context (major-mode magit-merge-preview-mode)) magit-buffer-revision) -;;; Diff Sections +;;; Hunk Section (defun magit-hunk-set-window-start (section) "When SECTION is a `hunk', ensure that its beginning is visible. @@ -2801,37 +2859,56 @@ It the SECTION has a different type, then do nothing." (add-hook 'magit-section-movement-hook #'magit-hunk-set-window-start) -(defun magit-hunk-goto-successor (section arg) - (and (magit-hunk-section-p section) - (when-let ((parent (magit-get-section - (magit-section-ident - (oref section parent))))) - (let* ((children (oref parent children)) - (siblings (magit-section-siblings section 'prev)) - (previous (nth (length siblings) children))) - (if (not arg) - (--when-let (or previous (car (last children))) - (magit-section-goto it) - t) - (when previous - (magit-section-goto previous)) - (if (and (stringp arg) - (re-search-forward arg (oref parent end) t)) - (goto-char (match-beginning 0)) - (goto-char (oref (car (last children)) end)) - (forward-line -1) - (while (looking-at "^ ") (forward-line -1)) - (while (looking-at "^[-+]") (forward-line -1)) - (forward-line))))))) - -(add-hook 'magit-section-goto-successor-hook #'magit-hunk-goto-successor) +(cl-defmethod magit-section-get-relative-position ((_section magit-hunk-section)) + (nconc (cl-call-next-method) + (and (region-active-p) + (progn + (goto-char (line-beginning-position)) + (when (looking-at "^[-+]") (forward-line)) + (while (looking-at "^[ @]") (forward-line)) + (let ((beg (magit-point))) + (list (cond + ((looking-at "^[-+]") + (forward-line) + (while (looking-at "^[-+]") (forward-line)) + (while (looking-at "^ ") (forward-line)) + (forward-line -1) + (regexp-quote (buffer-substring-no-properties + beg (line-end-position)))) + (t t)))))))) + +(cl-defmethod magit-section-goto-successor ((section magit-hunk-section) + line char &optional arg) + (or (magit-section-goto-successor--same section line char) + (and-let* ((parent (magit-get-section + (magit-section-ident + (oref section parent))))) + (let* ((children (oref parent children)) + (siblings (magit-section-siblings section 'prev)) + (previous (nth (length siblings) children))) + (if (not arg) + (when-let ((sibling (or previous (car (last children))))) + (magit-section-goto sibling) + t) + (when previous + (magit-section-goto previous)) + (if (and (stringp arg) + (re-search-forward arg (oref parent end) t)) + (goto-char (match-beginning 0)) + (goto-char (oref (car (last children)) end)) + (forward-line -1) + (while (looking-at "^ ") (forward-line -1)) + (while (looking-at "^[-+]") (forward-line -1)) + (forward-line))))) + (magit-section-goto-successor--related section))) + +;;; Diff Sections (defvar magit-unstaged-section-map (let ((map (make-sparse-keymap))) - (define-key map [remap magit-visit-thing] 'magit-diff-unstaged) - (define-key map [remap magit-delete-thing] 'magit-discard) - (define-key map "s" 'magit-stage) - (define-key map "u" 'magit-unstage) + (magit-menu-set map [magit-visit-thing] #'magit-diff-unstaged "Visit diff") + (magit-menu-set map [magit-stage-file] #'magit-stage "Stage all") + (magit-menu-set map [magit-delete-thing] #'magit-discard "Discard all") map) "Keymap for the `unstaged' section.") @@ -2847,11 +2924,10 @@ It the SECTION has a different type, then do nothing." (defvar magit-staged-section-map (let ((map (make-sparse-keymap))) - (define-key map [remap magit-visit-thing] 'magit-diff-staged) - (define-key map [remap magit-delete-thing] 'magit-discard) - (define-key map [remap magit-revert-no-commit] 'magit-reverse) - (define-key map "s" 'magit-stage) - (define-key map "u" 'magit-unstage) + (magit-menu-set map [magit-visit-thing] #'magit-diff-staged "Visit diff") + (magit-menu-set map [magit-unstage-file] #'magit-unstage "Unstage all") + (magit-menu-set map [magit-delete-thing] #'magit-discard "Discard all") + (magit-menu-set map [magit-revert-no-commit] #'magit-reverse "Reverse all") map) "Keymap for the `staged' section.") @@ -2913,13 +2989,13 @@ Do not confuse this with `magit-diff-scope' (which see)." (if (memq stype '(staged unstaged tracked untracked)) stype (pcase stype - ((or `file `module) + ((or 'file 'module) (let* ((parent (oref it parent)) (type (oref parent type))) (if (memq type '(file module)) (magit-diff-type parent) type))) - (`hunk (thread-first it + ('hunk (thread-first it (oref parent) (oref parent) (oref type))))))) @@ -2966,20 +3042,20 @@ actually a `diff' but a `diffstat' section." ssection) (`(hunk nil t ,_) (if (magit-section-internal-region-p section) 'region 'hunk)) - (`(hunk t t nil) 'hunks) + ('(hunk t t nil) 'hunks) (`(hunk ,_ ,_ ,_) 'hunk) - (`(file t t nil) 'files) + ('(file t t nil) 'files) (`(file ,_ ,_ ,_) 'file) - (`(module t t nil) 'files) + ('(module t t nil) 'files) (`(module ,_ ,_ ,_) 'file) - (`(,(or `staged `unstaged `untracked) nil ,_ ,_) 'list))))) + (`(,(or 'staged 'unstaged 'untracked) nil ,_ ,_) 'list))))) (defun magit-diff-use-hunk-region-p () (and (region-active-p) ;; TODO implement this from first principals ;; currently it's trial-and-error - (not (and (or (eq this-command 'mouse-drag-region) - (eq last-command 'mouse-drag-region) + (not (and (or (eq this-command #'mouse-drag-region) + (eq last-command #'mouse-drag-region) ;; When another window was previously ;; selected then the last-command is ;; some byte-code function. @@ -3022,9 +3098,9 @@ are highlighted." (defun magit-diff-highlight-recursive (section &optional selection) (pcase (magit-diff-scope section) - (`list (magit-diff-highlight-list section selection)) - (`file (magit-diff-highlight-file section selection)) - (`hunk (magit-diff-highlight-heading section selection) + ('list (magit-diff-highlight-list section selection)) + ('file (magit-diff-highlight-file section selection)) + ('hunk (magit-diff-highlight-heading section selection) (magit-diff-paint-hunk section selection t)) (_ (magit-section-highlight section nil)))) @@ -3032,14 +3108,15 @@ are highlighted." (let ((beg (oref section start)) (cnt (oref section content)) (end (oref section end))) - (when (or (eq this-command 'mouse-drag-region) + (when (or (eq this-command #'mouse-drag-region) (not selection)) (unless (and (region-active-p) (<= (region-beginning) beg)) (magit-section-make-overlay beg cnt 'magit-section-highlight)) - (unless (oref section hidden) + (if (oref section hidden) + (oset section washer #'ignore) (dolist (child (oref section children)) - (when (or (eq this-command 'mouse-drag-region) + (when (or (eq this-command #'mouse-drag-region) (not (and (region-active-p) (<= (region-beginning) (oref child start))))) @@ -3049,7 +3126,8 @@ are highlighted." (defun magit-diff-highlight-file (section &optional selection) (magit-diff-highlight-heading section selection) - (unless (oref section hidden) + (when (or (not (oref section hidden)) + (cl-typep section 'magit-module-section)) (dolist (child (oref section children)) (magit-diff-highlight-recursive child selection)))) @@ -3060,13 +3138,13 @@ are highlighted." (oref section end)) (pcase (list (oref section type) (and (member section selection) - (not (eq this-command 'mouse-drag-region)))) - (`(file t) 'magit-diff-file-heading-selection) - (`(file nil) 'magit-diff-file-heading-highlight) - (`(module t) 'magit-diff-file-heading-selection) - (`(module nil) 'magit-diff-file-heading-highlight) - (`(hunk t) 'magit-diff-hunk-heading-selection) - (`(hunk nil) 'magit-diff-hunk-heading-highlight)))) + (not (eq this-command #'mouse-drag-region)))) + ('(file t) 'magit-diff-file-heading-selection) + ('(file nil) 'magit-diff-file-heading-highlight) + ('(module t) 'magit-diff-file-heading-selection) + ('(module nil) 'magit-diff-file-heading-highlight) + ('(hunk t) 'magit-diff-hunk-heading-selection) + ('(hunk nil) 'magit-diff-hunk-heading-highlight)))) ;;; Hunk Paint @@ -3112,13 +3190,13 @@ are highlighted." (cond ((looking-at "^\\+\\+?\\([<=|>]\\)\\{7\\}") (setq stage (pcase (list (match-string 1) highlight) - (`("<" nil) 'magit-diff-our) - (`("<" t) 'magit-diff-our-highlight) - (`("|" nil) 'magit-diff-base) - (`("|" t) 'magit-diff-base-highlight) - (`("=" nil) 'magit-diff-their) - (`("=" t) 'magit-diff-their-highlight) - (`(">" nil) nil))) + ('("<" nil) 'magit-diff-our) + ('("<" t) 'magit-diff-our-highlight) + ('("|" nil) 'magit-diff-base) + ('("|" t) 'magit-diff-base-highlight) + ('("=" nil) 'magit-diff-their) + ('("=" t) 'magit-diff-their-highlight) + ('(">" nil) nil))) 'magit-diff-conflict-heading) ((looking-at (if merging "^\\(\\+\\| \\+\\)" "^\\+")) (magit-diff-paint-tab merging tab-width) @@ -3141,20 +3219,20 @@ are highlighted." (defun magit-diff-tab-width (file) (setq file (expand-file-name file)) (cl-flet ((cache (value) - (let ((elt (assoc file magit-diff--tab-width-cache))) - (if elt - (setcdr elt value) - (setq magit-diff--tab-width-cache - (cons (cons file value) - magit-diff--tab-width-cache)))) - value)) + (let ((elt (assoc file magit-diff--tab-width-cache))) + (if elt + (setcdr elt value) + (setq magit-diff--tab-width-cache + (cons (cons file value) + magit-diff--tab-width-cache)))) + value)) (cond ((not magit-diff-adjust-tab-width) tab-width) - ((--when-let (find-buffer-visiting file) - (cache (buffer-local-value 'tab-width it)))) - ((--when-let (assoc file magit-diff--tab-width-cache) - (or (cdr it) + ((and-let* ((buffer (find-buffer-visiting file))) + (cache (buffer-local-value 'tab-width buffer)))) + ((and-let* ((elt (assoc file magit-diff--tab-width-cache))) + (or (cdr elt) tab-width))) ((or (eq magit-diff-adjust-tab-width 'always) (and (numberp magit-diff-adjust-tab-width) @@ -3190,7 +3268,7 @@ are highlighted." (cdr (--first (string-match-p (car it) default-directory) (nreverse (default-value - 'magit-diff-highlight-indentation)))))))) + 'magit-diff-highlight-indentation)))))))) (when (and magit-diff-highlight-trailing (looking-at (concat prefix ".*?\\([ \t]+\\)$"))) (let ((ov (make-overlay (match-beginning 1) (match-end 1) nil t))) @@ -3213,7 +3291,7 @@ are highlighted." (pcase (list magit-diff-refine-hunk (oref section refined) (eq section (magit-current-section))) - ((or `(all nil ,_) `(t nil t)) + ((or `(all nil ,_) '(t nil t)) (oset section refined t) (save-excursion (goto-char (oref section start)) @@ -3224,16 +3302,16 @@ are highlighted." ;; Avoid fsyncing many small temp files (write-region-inhibit-fsync t)) (diff-refine-hunk))))) - ((or `(nil t ,_) `(t t nil)) + ((or `(nil t ,_) '(t t nil)) (oset section refined nil) (remove-overlays (oref section start) (oref section end) 'diff-mode 'fine)))) (cl-labels ((recurse (section) - (if (magit-section-match 'hunk section) - (magit-diff-update-hunk-refinement section) - (dolist (child (oref section children)) - (recurse child))))) + (if (magit-section-match 'hunk section) + (magit-diff-update-hunk-refinement section) + (dolist (child (oref section children)) + (recurse child))))) (recurse magit-root-section)))) @@ -3317,9 +3395,9 @@ last (visual) lines of the region." (point))) (color (face-background 'magit-diff-lines-boundary nil t))) (cl-flet ((ln (b e &rest face) - (magit-diff--make-hunk-overlay - b e 'font-lock-face face 'after-string - (magit-diff--hunk-after-string face)))) + (magit-diff--make-hunk-overlay + b e 'font-lock-face face 'after-string + (magit-diff--hunk-after-string face)))) (if (= beg end-bol) (ln beg beg-eol :overline color :underline color) (ln beg beg-eol :overline color) @@ -3350,8 +3428,8 @@ last (visual) lines of the region." (defun magit-diff-inside-hunk-body-p () "Return non-nil if point is inside the body of a hunk." (and (magit-section-match 'hunk) - (when-let ((content (oref (magit-current-section) content))) - (> (point) content)))) + (and-let* ((content (oref (magit-current-section) content))) + (> (magit-point) content)))) ;;; Diff Extract diff --git a/elpa/magit-20220116.1908/magit-ediff.el b/elpa/magit-20220518.2359/magit-ediff.el similarity index 53% rename from elpa/magit-20220116.1908/magit-ediff.el rename to elpa/magit-20220518.2359/magit-ediff.el index 97b49cc8..ae2f0531 100644 --- a/elpa/magit-20220116.1908/magit-ediff.el +++ b/elpa/magit-20220518.2359/magit-ediff.el @@ -1,19 +1,16 @@ -;;; magit-ediff.el --- Ediff extension for Magit -*- lexical-binding: t -*- +;;; magit-ediff.el --- Ediff extension for Magit -*- lexical-binding:t -*- -;; Copyright (C) 2010-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Jonas Bernoulli ;; Maintainer: Jonas Bernoulli ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Magit is free software; you can redistribute it and/or modify it +;; 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. +;; the Free Software Foundation, either version 3 of the License, 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 @@ -21,7 +18,7 @@ ;; 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. +;; along with Magit. If not, see . ;;; Commentary: @@ -55,10 +52,18 @@ invoked using Magit." :package-version '(magit . "2.2.0") :group 'magit-ediff :type 'hook - :get 'magit-hook-custom-get + :get #'magit-hook-custom-get :options '(magit-ediff-cleanup-auxiliary-buffers magit-ediff-restore-previous-winconf)) +(defcustom magit-ediff-dwim-resolve-function #'magit-ediff-resolve-rest + "The function `magit-ediff-dwim' uses to resolve conflicts." + :package-version '(magit . "3.4.0") + :group 'magit-ediff + :type '(choice (const magit-ediff-resolve-rest) + (const magit-ediff-resolve-all) + (const magit-git-mergetool))) + (defcustom magit-ediff-dwim-show-on-hunks nil "Whether `magit-ediff-dwim' runs show variants on hunks. If non-nil, `magit-ediff-show-staged' or @@ -101,11 +106,10 @@ tree at the time of stashing." :group 'magit-ediff :type 'boolean) -(defcustom magit-ediff-use-indirect-buffers nil - "Whether to use indirect buffers." - :package-version '(magit . "3.1.0") - :group 'magit-ediff - :type 'boolean) +(defvar magit-ediff-use-indirect-buffers nil + "Whether to use indirect buffers. +Ediff already does a lot of buffer and file shuffling and I +recommend you do not further complicate that by enabling this.") ;;; Commands @@ -117,8 +121,10 @@ tree at the time of stashing." :info-manual "(ediff)" ["Ediff" [("E" "Dwim" magit-ediff-dwim) - ("s" "Stage" magit-ediff-stage) - ("m" "Resolve" magit-ediff-resolve)] + ("s" "Stage" magit-ediff-stage)] + [("m" "Resolve rest" magit-ediff-resolve-rest) + ("M" "Resolve all conflicts" magit-ediff-resolve-all) + ("t" "Resolve using mergetool" magit-git-mergetool)] [("u" "Show unstaged" magit-ediff-show-unstaged) ("i" "Show staged" magit-ediff-show-staged) ("w" "Show worktree" magit-ediff-show-working-tree)] @@ -126,21 +132,162 @@ tree at the time of stashing." ("r" "Show range" magit-ediff-compare) ("z" "Show stash" magit-ediff-show-stash)]]) +(defmacro magit-ediff-buffers (a b &optional c setup quit file) + "Run Ediff on two or three buffers. +This is a wrapper around `ediff-buffers-internal'. + +A, B and C have the form (GET-BUFFER CREATE-BUFFER). If +GET-BUFFER returns a non-nil value, then that buffer is used and +it is not killed when exiting Ediff. Otherwise CREATE-BUFFER +must return a buffer and that is killed when exiting Ediff. + +If non-nil, SETUP must be a function. It is called without +arguments after Ediff is done setting up buffers. + +If non-nil, QUIT must be a function. It is added to +`ediff-quit-hook' and is called without arguments. + +If FILE is non-nil, then perform a merge. The merge result +is put in FILE." + (let (get make kill (char ?A)) + (dolist (spec (list a b c)) + (if (not spec) + (push nil make) + (pcase-let ((`(,g ,m) spec)) + (let ((b (intern (format "buf%c" char)))) + (push `(,b ,g) get) + ;; This is an unfortunate complication that I have added for + ;; the benefit of one user. Pretend we used this instead: + ;; (push `(or ,b ,m) make) + (push `(if ,b + (if magit-ediff-use-indirect-buffers + (prog1 (make-indirect-buffer + ,b + (generate-new-buffer-name (buffer-name ,b)) + t) + (setq ,b nil)) + ,b) + ,m) + make) + (push `(unless ,b + ;; For merge jobs Ediff switches buffer names around. + ;; See (if ediff-merge-job ...) in `ediff-setup'. + (let ((var ,(if (and file (= char ?C)) + 'ediff-ancestor-buffer + (intern (format "ediff-buffer-%c" char))))) + (ediff-kill-buffer-carefully var))) + kill)) + (cl-incf char)))) + (setq get (nreverse get)) + (setq make (nreverse make)) + (setq kill (nreverse kill)) + `(magit-with-toplevel + (let ((conf (current-window-configuration)) + (file ,file) + ,@get) + (ediff-buffers-internal + ,@make + (list ,@(and setup (list setup)) + (lambda () + ;; We do not want to kill buffers that existed before + ;; Ediff was invoked, so we cannot use Ediff's default + ;; quit functions. Ediff splits quitting across two + ;; hooks for merge jobs but we only ever use one. + (setq-local ediff-quit-merge-hook nil) + (setq-local ediff-quit-hook + (list ,@(and quit (list quit)) + (lambda () + ,@kill + (let ((magit-ediff-previous-winconf conf)) + (run-hooks 'magit-ediff-quit-hook))))))) + (pcase (list ,(and c t) (and file t)) + ('(nil nil) 'ediff-buffers) + ('(nil t) 'ediff-merge-buffers) + ('(t nil) 'ediff-buffers3) + ('(t t) 'ediff-merge-buffers-with-ancestor)) + file))))) + ;;;###autoload -(defun magit-ediff-resolve (file) - "Resolve outstanding conflicts in FILE using Ediff. -FILE has to be relative to the top directory of the repository. +(defun magit-ediff-resolve-all (file) + "Resolve all conflicts in the FILE at point using Ediff. -In the rare event that you want to manually resolve all -conflicts, including those already resolved by Git, use -`ediff-merge-revisions-with-ancestor'." - (interactive - (let ((current (magit-current-file)) - (unmerged (magit-unmerged-files))) - (unless unmerged - (user-error "There are no unresolved conflicts")) - (list (magit-completing-read "Resolve file" unmerged nil t nil nil - (car (member current unmerged)))))) +If there is no file at point or if it doesn't have any unmerged +changes, then prompt for a file. + +See info node `(magit) Ediffing' for more information about this +and alternative commands." + (interactive (list (magit-read-unmerged-file))) + (magit-with-toplevel + (let* ((revA (or (magit-name-branch "HEAD") + (magit-commit-p "HEAD"))) + (revB (cl-find-if (lambda (head) (file-exists-p (magit-git-dir head))) + '("MERGE_HEAD" "CHERRY_PICK_HEAD" "REVERT_HEAD"))) + (revB (or (magit-name-branch revB) + (magit-commit-p revB))) + (revC (magit-commit-p (magit-git-string "merge-base" revA revB))) + (fileA (magit--rev-file-name file revA revB)) + (fileB (magit--rev-file-name file revB revA)) + (fileC (or (magit--rev-file-name file revC revA) + (magit--rev-file-name file revC revB)))) + ;; Ediff assumes that the FILE where it is going to store the merge + ;; result does not exist yet, so move the existing file out of the + ;; way. If a buffer visits FILE, then we have to kill that upfront. + (when-let ((buffer (find-buffer-visiting file))) + (when (and (buffer-modified-p buffer) + (not (y-or-n-p (format "Save buffer %s %s? " + (buffer-name buffer) + "(cannot continue otherwise)")))) + (user-error "Abort")) + (kill-buffer buffer)) + (let ((orig (concat file ".ORIG"))) + (when (file-exists-p orig) + (rename-file orig (make-temp-name (concat orig "_")))) + (rename-file file orig)) + (let ((setup (lambda () + ;; Use the same conflict marker style as Git uses. + (setq-local ediff-combination-pattern + '("<<<<<<< HEAD" A + ,(format "||||||| %s" revC) Ancestor + "=======" B + ,(format ">>>>>>> %s" revB))))) + (quit (lambda () + ;; For merge jobs Ediff switches buffer names around. + ;; At this point `ediff-buffer-C' no longer refer to + ;; the ancestor buffer but to the merge result buffer. + ;; See (if ediff-merge-job ...) in `ediff-setup'. + (when (buffer-live-p ediff-buffer-C) + (with-current-buffer ediff-buffer-C + (save-buffer) + (save-excursion + (goto-char (point-min)) + (unless (re-search-forward "^<<<<<<< " nil t) + (magit-stage-file file)))))))) + (if fileC + (magit-ediff-buffers + ((magit-get-revision-buffer revA fileA) + (magit-find-file-noselect revA fileA)) + ((magit-get-revision-buffer revB fileB) + (magit-find-file-noselect revB fileB)) + ((magit-get-revision-buffer revC fileC) + (magit-find-file-noselect revC fileC)) + setup quit file) + (magit-ediff-buffers + ((magit-get-revision-buffer revA fileA) + (magit-find-file-noselect revA fileA)) + ((magit-get-revision-buffer revB fileB) + (magit-find-file-noselect revB fileB)) + nil setup quit file)))))) + +;;;###autoload +(defun magit-ediff-resolve-rest (file) + "Resolve outstanding conflicts in the FILE at point using Ediff. + +If there is no file at point or if it doesn't have any unmerged +changes, then prompt for a file. + +See info node `(magit) Ediffing' for more information about this +and alternative commands." + (interactive (list (magit-read-unmerged-file))) (magit-with-toplevel (with-current-buffer (find-file-noselect file) (smerge-ediff) @@ -163,45 +310,6 @@ conflicts, including those already resolved by Git, use (let ((magit-ediff-previous-winconf smerge-ediff-windows)) (run-hooks 'magit-ediff-quit-hook))))))) -(defmacro magit-ediff-buffers (quit &rest spec) - (declare (indent 1)) - (let ((fn (if (= (length spec) 3) 'ediff-buffers3 'ediff-buffers)) - (char ?@) - get make kill) - (pcase-dolist (`(,g ,m) spec) - (let ((b (intern (format "buf%c" (cl-incf char))))) - (push `(,b ,g) get) - (push `(if ,b - (if magit-ediff-use-indirect-buffers - (prog1 - (make-indirect-buffer - ,b (generate-new-buffer-name (buffer-name ,b)) t) - (setq ,b nil)) - ,b) - ,m) - make) - (push `(unless ,b - (ediff-kill-buffer-carefully - ,(intern (format "ediff-buffer-%c" char)))) - kill))) - (setq get (nreverse get)) - (setq make (nreverse make)) - (setq kill (nreverse kill)) - `(magit-with-toplevel - (let ((conf (current-window-configuration)) - ,@get) - (,fn - ,@make - (list (lambda () - (setq-local - ediff-quit-hook - (list ,@(and quit (list quit)) - (lambda () - ,@kill - (let ((magit-ediff-previous-winconf conf)) - (run-hooks 'magit-ediff-quit-hook))))))) - ',fn))))) - ;;;###autoload (defun magit-ediff-stage (file) "Stage and unstage changes to FILE using Ediff. @@ -224,21 +332,22 @@ FILE has to be relative to the top directory of the repository." (bufB* (magit-find-file-index-noselect file t))) (setf (buffer-local-value 'buffer-read-only bufB*) nil) (magit-ediff-buffers - (lambda () - (when (buffer-live-p ediff-buffer-B) - (when lockB - (setf (buffer-local-value 'buffer-read-only bufB) t)) - (when (buffer-modified-p ediff-buffer-B) - (with-current-buffer ediff-buffer-B - (magit-update-index)))) - (when (and (buffer-live-p ediff-buffer-C) - (buffer-modified-p ediff-buffer-C)) - (with-current-buffer ediff-buffer-C - (when (y-or-n-p (format "Save file %s? " buffer-file-name)) - (save-buffer))))) - (bufA bufA*) - (bufB bufB*) - (bufC bufC*))))) + (bufA bufA*) + (bufB bufB*) + (bufC bufC*) + nil + (lambda () + (when (buffer-live-p ediff-buffer-B) + (when lockB + (setf (buffer-local-value 'buffer-read-only bufB) t)) + (when (buffer-modified-p ediff-buffer-B) + (with-current-buffer ediff-buffer-B + (magit-update-index)))) + (when (and (buffer-live-p ediff-buffer-C) + (buffer-modified-p ediff-buffer-C)) + (with-current-buffer ediff-buffer-C + (when (y-or-n-p (format "Save file %s? " buffer-file-name)) + (save-buffer))))))))) ;;;###autoload (defun magit-ediff-compare (revA revB fileA fileB) @@ -258,11 +367,11 @@ range)." nil current-prefix-arg))) (nconc (list revA revB) (magit-ediff-read-files revA revB)))) - (magit-ediff-buffers nil - ((if revA (magit-get-revision-buffer revA fileA) (get-file-buffer fileA)) - (if revA (magit-find-file-noselect revA fileA) (find-file-noselect fileA))) - ((if revB (magit-get-revision-buffer revB fileB) (get-file-buffer fileB)) - (if revB (magit-find-file-noselect revB fileB) (find-file-noselect fileB))))) + (magit-ediff-buffers + ((if revA (magit-get-revision-buffer revA fileA) (get-file-buffer fileA)) + (if revA (magit-find-file-noselect revA fileA) (find-file-noselect fileA))) + ((if revB (magit-get-revision-buffer revB fileB) (get-file-buffer fileB)) + (if revB (magit-find-file-noselect revB fileB) (find-file-noselect fileB))))) (defun magit-ediff-compare--read-revisions (&optional arg mbase) (let ((input (or arg (magit-diff-read-range-or-commit @@ -276,13 +385,23 @@ range)." "Read file in REVB, return it and the corresponding file in REVA. When FILEB is non-nil, use this as REVB's file instead of prompting for it." - (unless fileB - (setq fileB (magit-read-file-choice - (format "File to compare between %s and %s" - revA (or revB "the working tree")) - (magit-changed-files revA revB) - (format "No changed files between %s and %s" - revA (or revB "the working tree"))))) + (unless (and fileB (member fileB (magit-revision-files revB))) + (setq fileB + (or (and fileB + magit-buffer-log-files + (derived-mode-p 'magit-log-mode) + (member "--follow" magit-buffer-log-args) + (cdr (assoc fileB + (magit-renamed-files + revB + (oref (car (oref magit-root-section children)) + value))))) + (magit-read-file-choice + (format "File to compare between %s and %s" + revA (or revB "the working tree")) + (magit-changed-files revA revB) + (format "No changed files between %s and %s" + revA (or revB "the working tree")))))) (list (or (car (member fileB (magit-revision-files revA))) (cdr (assoc fileB (magit-renamed-files revB revA))) (magit-read-file-choice @@ -314,12 +433,12 @@ mind at all, then it asks the user for a command to run." command revA revB) (pcase range ((and (guard (not magit-ediff-dwim-show-on-hunks)) - (or `unstaged `staged)) + (or 'unstaged 'staged)) (setq command (if (magit-anything-unmerged-p) - #'magit-ediff-resolve + magit-ediff-dwim-resolve-function #'magit-ediff-stage))) - (`unstaged (setq command #'magit-ediff-show-unstaged)) - (`staged (setq command #'magit-ediff-show-staged)) + ('unstaged (setq command #'magit-ediff-show-unstaged)) + ('staged (setq command #'magit-ediff-show-staged)) (`(commit . ,value) (setq command #'magit-ediff-show-commit) (setq revB value)) @@ -334,31 +453,34 @@ mind at all, then it asks the user for a command to run." (_ (when (derived-mode-p 'magit-diff-mode) (pcase (magit-diff-type) - (`committed (pcase-let ((`(,a ,b) + ('committed (pcase-let ((`(,a ,b) (magit-ediff-compare--read-revisions magit-buffer-range))) (setq revA a) (setq revB b))) ((guard (not magit-ediff-dwim-show-on-hunks)) (setq command #'magit-ediff-stage)) - (`unstaged (setq command #'magit-ediff-show-unstaged)) - (`staged (setq command #'magit-ediff-show-staged)) - (`undefined (setq command nil)) + ('unstaged (setq command #'magit-ediff-show-unstaged)) + ('staged (setq command #'magit-ediff-show-staged)) + ('undefined (setq command nil)) (_ (setq command nil)))))) (cond ((not command) (call-interactively (magit-read-char-case "Failed to read your mind; do you want to " t - (?c "[c]ommit" 'magit-ediff-show-commit) - (?r "[r]ange" 'magit-ediff-compare) - (?s "[s]tage" 'magit-ediff-stage) - (?v "resol[v]e" 'magit-ediff-resolve)))) - ((eq command 'magit-ediff-compare) - (apply 'magit-ediff-compare revA revB + (?c "[c]ommit" #'magit-ediff-show-commit) + (?r "[r]ange" #'magit-ediff-compare) + (?s "[s]tage" #'magit-ediff-stage) + (?m "[m] resolve remaining conflicts" + #'magit-ediff-resolve-rest) + (?M "[M] resolve all conflicts" + #'magit-ediff-resolve-all)))) + ((eq command #'magit-ediff-compare) + (apply #'magit-ediff-compare revA revB (magit-ediff-read-files revA revB file))) - ((eq command 'magit-ediff-show-commit) + ((eq command #'magit-ediff-show-commit) (magit-ediff-show-commit revB)) - ((eq command 'magit-ediff-show-stash) + ((eq command #'magit-ediff-show-stash) (magit-ediff-show-stash revB)) (file (funcall command file)) @@ -377,11 +499,10 @@ FILE must be relative to the top directory of the repository." (list (magit-read-file-choice "Show staged changes for file" (magit-staged-files) "No staged files"))) - (magit-ediff-buffers nil - ((magit-get-revision-buffer "HEAD" file) - (magit-find-file-noselect "HEAD" file)) - ((get-buffer (concat file ".~{index}~")) - (magit-find-file-index-noselect file t)))) + (magit-ediff-buffers ((magit-get-revision-buffer "HEAD" file) + (magit-find-file-noselect "HEAD" file)) + ((get-buffer (concat file ".~{index}~")) + (magit-find-file-index-noselect file t)))) ;;;###autoload (defun magit-ediff-show-unstaged (file) @@ -395,11 +516,10 @@ FILE must be relative to the top directory of the repository." (list (magit-read-file-choice "Show unstaged changes for file" (magit-unstaged-files) "No unstaged files"))) - (magit-ediff-buffers nil - ((get-buffer (concat file ".~{index}~")) - (magit-find-file-index-noselect file t)) - ((get-file-buffer file) - (find-file-noselect file)))) + (magit-ediff-buffers ((get-buffer (concat file ".~{index}~")) + (magit-find-file-index-noselect file t)) + ((get-file-buffer file) + (find-file-noselect file)))) ;;;###autoload (defun magit-ediff-show-working-tree (file) @@ -409,11 +529,10 @@ FILE must be relative to the top directory of the repository." (list (magit-read-file-choice "Show changes in file" (magit-changed-files "HEAD") "No changed files"))) - (magit-ediff-buffers nil - ((magit-get-revision-buffer "HEAD" file) - (magit-find-file-noselect "HEAD" file)) - ((get-file-buffer file) - (find-file-noselect file)))) + (magit-ediff-buffers ((magit-get-revision-buffer "HEAD" file) + (magit-find-file-noselect "HEAD" file)) + ((get-file-buffer file) + (find-file-noselect file)))) ;;;###autoload (defun magit-ediff-show-commit (commit) @@ -439,13 +558,13 @@ stash that were staged." (fileB fileC)) (if (and magit-ediff-show-stash-with-index (member fileA (magit-changed-files revB revA))) - (magit-ediff-buffers nil - ((magit-get-revision-buffer revA fileA) - (magit-find-file-noselect revA fileA)) - ((magit-get-revision-buffer revB fileB) - (magit-find-file-noselect revB fileB)) - ((magit-get-revision-buffer revC fileC) - (magit-find-file-noselect revC fileC))) + (magit-ediff-buffers + ((magit-get-revision-buffer revA fileA) + (magit-find-file-noselect revA fileA)) + ((magit-get-revision-buffer revB fileB) + (magit-find-file-noselect revB fileB)) + ((magit-get-revision-buffer revC fileC) + (magit-find-file-noselect revC fileC))) (magit-ediff-compare revA revC fileA fileC)))) (defun magit-ediff-cleanup-auxiliary-buffers () diff --git a/elpa/magit-20220116.1908/magit-extras.el b/elpa/magit-20220518.2359/magit-extras.el similarity index 80% rename from elpa/magit-20220116.1908/magit-extras.el rename to elpa/magit-20220518.2359/magit-extras.el index a7966d1a..8308cd84 100644 --- a/elpa/magit-20220116.1908/magit-extras.el +++ b/elpa/magit-20220518.2359/magit-extras.el @@ -1,19 +1,16 @@ -;;; magit-extras.el --- additional functionality for Magit -*- lexical-binding: t -*- +;;; magit-extras.el --- Additional functionality for Magit -*- lexical-binding:t -*- -;; Copyright (C) 2008-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Jonas Bernoulli ;; Maintainer: Jonas Bernoulli ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Magit is free software; you can redistribute it and/or modify it +;; 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. +;; the Free Software Foundation, either version 3 of the License, 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 @@ -21,7 +18,7 @@ ;; 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. +;; along with Magit. If not, see . ;;; Commentary: @@ -31,12 +28,11 @@ (require 'magit) -(declare-function change-log-insert-entries "add-log" (changelogs)) -(declare-function diff-add-log-current-defuns "diff-mode" ()) +;; For `magit-do-async-shell-command'. (declare-function dired-read-shell-command "dired-aux" (prompt arg files)) ;; For `magit-project-status'. -(declare-function project-root "project" (project)) -(declare-function vc-git-command "vc-git" (buffer okstatus file-or-list &rest flags)) +(declare-function vc-git-command "vc-git" + (buffer okstatus file-or-list &rest flags)) (defvar ido-exit) (defvar ido-fallback) @@ -47,25 +43,89 @@ "Additional functionality for Magit." :group 'magit-extensions) -;;; External Tools - -(defcustom magit-gitk-executable - (or (and (eq system-type 'windows-nt) - (let ((exe (magit-git-string - "-c" "alias.X=!x() { which \"$1\" | cygpath -mf -; }; x" - "X" "gitk.exe"))) - (and exe (file-executable-p exe) exe))) - (executable-find "gitk") "gitk") - "The Gitk executable." - :group 'magit-extras - :set-after '(magit-git-executable) - :type 'string) - -;;;###autoload -(defun magit-run-git-gui () - "Run `git gui' for the current git repository." - (interactive) - (magit-with-toplevel (magit-process-git 0 "gui"))) +;;; Git Tools +;;;; Git-Mergetool + +;;;###autoload (autoload 'magit-git-mergetool "magit-extras" nil t) +(transient-define-prefix magit-git-mergetool (file args &optional transient) + "Resolve conflicts in FILE using \"git mergetool --gui\". +With a prefix argument allow changing ARGS using a transient +popup. See info node `(magit) Ediffing' for information about +alternative commands." + :man-page "git-mergetool" + ["Settings" + ("-t" magit-git-mergetool:--tool) + ("=t" magit-merge.guitool) + ("=T" magit-merge.tool) + ("-r" magit-mergetool.hideResolved) + ("-b" magit-mergetool.keepBackup) + ("-k" magit-mergetool.keepTemporaries) + ("-w" magit-mergetool.writeToTemp)] + ["Actions" + (" m" "Invoke mergetool" magit-git-mergetool)] + (interactive + (if (and (not (eq transient-current-prefix 'magit-git-mergetool)) + current-prefix-arg) + (list nil nil t) + (list (magit-read-unmerged-file "Resolve") + (transient-args 'magit-git-mergetool)))) + (if transient + (transient-setup 'magit-git-mergetool) + (magit-run-git-async "mergetool" "--gui" args "--" file))) + +(transient-define-infix magit-git-mergetool:--tool () + :description "Override mergetool" + :class 'transient-option + :shortarg "-t" + :argument "--tool=" + :reader #'magit--read-mergetool) + +(transient-define-infix magit-merge.guitool () + :class 'magit--git-variable + :variable "merge.guitool" + :global t + :reader #'magit--read-mergetool) + +(transient-define-infix magit-merge.tool () + :class 'magit--git-variable + :variable "merge.tool" + :global t + :reader #'magit--read-mergetool) + +(defun magit--read-mergetool (prompt _initial-input history) + (let ((choices nil) + (lines (cdr (magit-git-lines "mergetool" "--tool-help")))) + (while (string-prefix-p "\t\t" (car lines)) + (push (substring (pop lines) 2) choices)) + (setq choices (nreverse choices)) + (magit-completing-read (or prompt "Select mergetool") + choices nil t nil history))) + +(transient-define-infix magit-mergetool.hideResolved () + :class 'magit--git-variable:boolean + :variable "mergetool.hideResolved" + :default "false" + :global t) + +(transient-define-infix magit-mergetool.keepBackup () + :class 'magit--git-variable:boolean + :variable "mergetool.keepBackup" + :default "true" + :global t) + +(transient-define-infix magit-mergetool.keepTemporaries () + :class 'magit--git-variable:boolean + :variable "mergetool.keepTemporaries" + :default "false" + :global t) + +(transient-define-infix magit-mergetool.writeToTemp () + :class 'magit--git-variable:boolean + :variable "mergetool.writeToTemp" + :default "false" + :global t) + +;;;; Git-Gui ;;;###autoload (defun magit-run-git-gui-blame (commit filename &optional linenum) @@ -92,6 +152,26 @@ blame to center around the line point is on." commit filename))) +;;;; Gitk + +(defcustom magit-gitk-executable + (or (and (eq system-type 'windows-nt) + (let ((exe (magit-git-string + "-c" "alias.X=!x() { which \"$1\" | cygpath -mf -; }; x" + "X" "gitk.exe"))) + (and exe (file-executable-p exe) exe))) + (executable-find "gitk") "gitk") + "The Gitk executable." + :group 'magit-extras + :set-after '(magit-git-executable) + :type 'string) + +;;;###autoload +(defun magit-run-git-gui () + "Run `git gui' for the current git repository." + (interactive) + (magit-with-toplevel (magit-process-git 0 "gui"))) + ;;;###autoload (defun magit-run-gitk () "Run `gitk' in the current repository." @@ -135,15 +215,17 @@ like pretty much every other keymap: (kbd \"C-x g\") \\='ido-enter-magit-status)" (interactive) (setq ido-exit 'fallback) - (setq ido-fallback 'magit-status) ; for Emacs >= 26.2 - (with-no-warnings (setq fallback 'magit-status)) ; for Emacs 25 + (setq ido-fallback #'magit-status) ; for Emacs >= 26.2 + (with-no-warnings (setq fallback #'magit-status)) ; for Emacs 25 (exit-minibuffer)) ;;;###autoload (defun magit-project-status () "Run `magit-status' in the current project's root." (interactive) - (magit-status-setup-buffer (project-root (project-current t)))) + (if (fboundp 'project-root) + (magit-status-setup-buffer (project-root (project-current t))) + (user-error "`magit-project-status' requires `project' 0.3.0 or greater"))) (defvar magit-bind-magit-project-status t "Whether to bind \"m\" to `magit-project-status' in `project-prefix-map'. @@ -170,7 +252,7 @@ With a prefix argument, visit in another window. If there is no file at point, then instead visit `default-directory'." (interactive "P") (dired-jump other-window - (when-let ((file (magit-file-at-point))) + (and-let* ((file (magit-file-at-point))) (expand-file-name (if (file-directory-p file) (file-name-as-directory file) file))))) @@ -181,9 +263,9 @@ is no file at point, then instead visit `default-directory'." (interactive "P") (if-let ((topdir (magit-toplevel default-directory))) (let ((args (car (magit-log-arguments))) - (files (dired-get-marked-files nil nil #'magit-file-tracked-p))) - (unless files - (user-error "No marked file is being tracked by Git")) + (files (compat-dired-get-marked-files + nil nil #'magit-file-tracked-p nil + "No marked file is being tracked by Git"))) (when (and follow (not (member "--follow" args)) (not (cdr files))) @@ -204,10 +286,7 @@ for a repository." (interactive (list (or (magit-toplevel) (magit-read-repository t)) current-prefix-arg)) - ;; Note: The ERROR argument of `dired-get-marked-files' isn't - ;; available until Emacs 27. - (let ((files (or (dired-get-marked-files nil arg) - (user-error "No files specified")))) + (let ((files (compat-dired-get-marked-files nil arg nil nil t))) (magit-status-setup-buffer repo) (magit-am-apply-patches files))) @@ -310,31 +389,32 @@ in HEAD as well as staged changes in the diff to check." (require 'diff-mode) ; `diff-add-log-current-defuns'. (require 'vc-git) ; `vc-git-diff'. (require 'add-log) ; `change-log-insert-entries'. - (unless (and (fboundp 'change-log-insert-entries) - (fboundp 'diff-add-log-current-defuns)) - (user-error "`magit-generate-changelog' requires Emacs 27 or better")) - (setq default-directory - (if (and (file-regular-p "gitdir") - (not (magit-git-true "rev-parse" "--is-inside-work-tree")) - (magit-git-true "rev-parse" "--is-inside-git-dir")) - (file-name-directory (magit-file-line "gitdir")) - (magit-toplevel))) - (let ((rev1 (if amending "HEAD^1" "HEAD")) - (rev2 nil)) - ;; Magit may have updated the files without notifying vc, but - ;; `diff-add-log-current-defuns' relies on vc being up-to-date. - (mapc #'vc-file-clearprops (magit-staged-files)) - (change-log-insert-entries - (with-temp-buffer - (vc-git-command (current-buffer) 1 nil - "diff-index" "--exit-code" "--patch" - (and (magit-anything-staged-p) "--cached") - rev1 "--") - ;; `diff-find-source-location' consults these vars. - (defvar diff-vc-revisions) - (setq-local diff-vc-revisions (list rev1 rev2)) - (setq-local diff-vc-backend 'Git) - (diff-add-log-current-defuns))))) + (cond + ((and (fboundp 'change-log-insert-entries) + (fboundp 'diff-add-log-current-defuns)) + (setq default-directory + (if (and (file-regular-p "gitdir") + (not (magit-git-true "rev-parse" "--is-inside-work-tree")) + (magit-git-true "rev-parse" "--is-inside-git-dir")) + (file-name-directory (magit-file-line "gitdir")) + (magit-toplevel))) + (let ((rev1 (if amending "HEAD^1" "HEAD")) + (rev2 nil)) + ;; Magit may have updated the files without notifying vc, but + ;; `diff-add-log-current-defuns' relies on vc being up-to-date. + (mapc #'vc-file-clearprops (magit-staged-files)) + (change-log-insert-entries + (with-temp-buffer + (vc-git-command (current-buffer) 1 nil + "diff-index" "--exit-code" "--patch" + (and (magit-anything-staged-p) "--cached") + rev1 "--") + ;; `diff-find-source-location' consults these vars. + (defvar diff-vc-revisions) + (setq-local diff-vc-revisions (list rev1 rev2)) + (setq-local diff-vc-backend 'Git) + (diff-add-log-current-defuns))))) + (t (user-error "`magit-generate-changelog' requires Emacs 27 or greater")))) ;;;###autoload (defun magit-add-change-log-entry (&optional whoami file-name other-window) @@ -377,7 +457,7 @@ points at it) otherwise." (interactive (list (and current-prefix-arg 'removal))) (let* ((chunk (magit-current-blame-chunk (or type 'addition))) (rev (oref chunk orig-rev))) - (if (equal rev "0000000000000000000000000000000000000000") + (if (string-match-p "\\`0\\{40,\\}\\'" rev) (message "This line has not been committed yet") (let ((rebase (magit-rev-ancestor-p rev "HEAD")) (file (expand-file-name (oref chunk orig-file) @@ -475,11 +555,11 @@ list returned by `magit-rebase-arguments'." "Type %p on a commit to reshelve it and the commits above it,")) (t (cl-flet ((adjust (time offset) - (format-time-string - "%F %T %z" - (+ (floor time) - (* offset 60) - (- (car (decode-time time))))))) + (format-time-string + "%F %T %z" + (+ (floor time) + (* offset 60) + (- (car (decode-time time))))))) (let* ((start (concat rev "^")) (range (concat start ".." current)) (time-rev (adjust (float-time (string-to-number @@ -494,38 +574,38 @@ list returned by `magit-rebase-arguments'." (float-time (date-to-time (read-string "Date for first commit: " - time-now 'magit--reshelve-history))))) - (process-environment process-environment)) - (push "FILTER_BRANCH_SQUELCH_WARNING=1" process-environment) - (magit-with-toplevel - (magit-run-git-async - "filter-branch" "--force" "--env-filter" - (format - "case $GIT_COMMIT in %s\nesac" - (mapconcat - (lambda (rev) - (prog1 (concat - (format "%s) " rev) - (and (not magit-reshelve-since-committer-only) - (format "export GIT_AUTHOR_DATE=\"%s\"; " date)) - (format "export GIT_COMMITTER_DATE=\"%s\";;" date)) - (cl-incf date 60))) - (magit-git-lines "rev-list" "--reverse" range) - " ")) - (and keyid - (list "--commit-filter" - (format "git commit-tree --gpg-sign=%s \"$@\";" - keyid))) - range "--")) - (set-process-sentinel - magit-this-process - (lambda (process event) - (when (memq (process-status process) '(exit signal)) - (if (> (process-exit-status process) 0) + time-now 'magit--reshelve-history)))))) + (with-environment-variables (("FILTER_BRANCH_SQUELCH_WARNING" "1")) + (magit-with-toplevel + (magit-run-git-async + "filter-branch" "--force" "--env-filter" + (format + "case $GIT_COMMIT in %s\nesac" + (mapconcat + (lambda (rev) + (prog1 + (concat + (format "%s) " rev) + (and (not magit-reshelve-since-committer-only) + (format "export GIT_AUTHOR_DATE=\"%s\"; " date)) + (format "export GIT_COMMITTER_DATE=\"%s\";;" date)) + (cl-incf date 60))) + (magit-git-lines "rev-list" "--reverse" range) + " ")) + (and keyid + (list "--commit-filter" + (format "git commit-tree --gpg-sign=%s \"$@\";" + keyid))) + range "--")) + (set-process-sentinel + magit-this-process + (lambda (process event) + (when (memq (process-status process) '(exit signal)) + (if (> (process-exit-status process) 0) + (magit-process-sentinel process event) + (process-put process 'inhibit-refresh t) (magit-process-sentinel process event) - (process-put process 'inhibit-refresh t) - (magit-process-sentinel process event) - (magit-run-git "update-ref" "-d" backup)))))))))))) + (magit-run-git "update-ref" "-d" backup))))))))))))) ;;; Revision Stack @@ -611,10 +691,10 @@ the minibuffer too." (interactive (if (or current-prefix-arg (not magit-revision-stack)) (let ((default-directory - (or (and (not (= (prefix-numeric-value current-prefix-arg) 16)) - (or (magit-toplevel) - (cadr (car magit-revision-stack)))) - (magit-read-repository)))) + (or (and (not (= (prefix-numeric-value current-prefix-arg) 16)) + (or (magit-toplevel) + (cadr (car magit-revision-stack)))) + (magit-read-repository)))) (list (magit-read-branch-or-commit "Insert revision") default-directory)) (push (caar magit-revision-stack) magit-revision-history) @@ -639,13 +719,13 @@ the minibuffer too." (when pnt-format (when idx-format (setq pnt-format - (replace-regexp-in-string "%N" idx pnt-format t t))) + (string-replace "%N" idx pnt-format))) (magit-rev-insert-format pnt-format rev pnt-args) (backward-delete-char 1)) (when eob-format (when idx-format (setq eob-format - (replace-regexp-in-string "%N" idx eob-format t t))) + (string-replace "%N" idx eob-format))) (save-excursion (goto-char (point-max)) (skip-syntax-backward ">s-") @@ -662,7 +742,7 @@ the minibuffer too." (user-error "Revision stack is empty"))) (define-key git-commit-mode-map - (kbd "C-c C-w") 'magit-pop-revision-stack) + (kbd "C-c C-w") #'magit-pop-revision-stack) ;;;###autoload (defun magit-copy-section-value (arg) @@ -704,8 +784,8 @@ argument." ((use-region-p) (call-interactively #'copy-region-as-kill)) (t - (when-let ((section (magit-current-section)) - (value (oref section value))) + (when-let* ((section (magit-current-section)) + (value (oref section value))) (magit-section-case ((branch commit module-commit tag) (let ((default-directory default-directory) ref) diff --git a/elpa/magit-20220116.1908/magit-fetch.el b/elpa/magit-20220518.2359/magit-fetch.el similarity index 92% rename from elpa/magit-20220116.1908/magit-fetch.el rename to elpa/magit-20220518.2359/magit-fetch.el index 3cbd008d..6c97d181 100644 --- a/elpa/magit-20220116.1908/magit-fetch.el +++ b/elpa/magit-20220518.2359/magit-fetch.el @@ -1,19 +1,16 @@ -;;; magit-fetch.el --- download objects and refs -*- lexical-binding: t -*- +;;; magit-fetch.el --- Download objects and refs -*- lexical-binding:t -*- -;; Copyright (C) 2008-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Jonas Bernoulli ;; Maintainer: Jonas Bernoulli ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Magit is free software; you can redistribute it and/or modify it +;; 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. +;; the Free Software Foundation, either version 3 of the License, 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 @@ -21,7 +18,7 @@ ;; 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. +;; along with Magit. If not, see . ;;; Commentary: @@ -73,7 +70,7 @@ With a prefix argument or when the push-remote is either not configured or unusable, then let the user first configure the push-remote." - :description 'magit-fetch--pushremote-description + :description #'magit-fetch--pushremote-description (interactive (list (magit-fetch-arguments))) (let ((remote (magit-get-push-remote))) (when (or current-prefix-arg @@ -181,7 +178,6 @@ with a prefix argument." (t "--jobs=4"))) ["Arguments" ("-v" "verbose" "--verbose") - ("-a" "all remotes" "--all") ("-j" "number of jobs" "--jobs=" :reader transient-read-number-N+)] ["Action" ("m" "fetch modules" magit-fetch-modules)] diff --git a/elpa/magit-20220116.1908/magit-files.el b/elpa/magit-20220518.2359/magit-files.el similarity index 94% rename from elpa/magit-20220116.1908/magit-files.el rename to elpa/magit-20220518.2359/magit-files.el index 2b91c8ef..c1a150fd 100644 --- a/elpa/magit-20220116.1908/magit-files.el +++ b/elpa/magit-20220518.2359/magit-files.el @@ -1,19 +1,16 @@ -;;; magit-files.el --- finding files -*- lexical-binding: t -*- +;;; magit-files.el --- Finding files -*- lexical-binding:t -*- -;; Copyright (C) 2010-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Jonas Bernoulli ;; Maintainer: Jonas Bernoulli ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Magit is free software; you can redistribute it and/or modify it +;; 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. +;; the Free Software Foundation, either version 3 of the License, 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 @@ -21,7 +18,7 @@ ;; 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. +;; along with Magit. If not, see . ;;; Commentary: @@ -154,7 +151,7 @@ then only after asking. A non-nil value for REVERT is ignored if REV is (magit-get-revision-buffer rev file t)) (defun magit-get-revision-buffer (rev file &optional create) - (funcall (if create 'get-buffer-create 'get-buffer) + (funcall (if create #'get-buffer-create #'get-buffer) (format "%s.~%s~" file (subst-char-in-string ?/ ?_ rev)))) (defun magit-revert-rev-file-buffer (_ignore-auto noconfirm) @@ -182,7 +179,8 @@ then only after asking. A non-nil value for REVERT is ignored if REV is (after-change-major-mode-hook (remq 'global-diff-hl-mode-enable-in-buffers after-change-major-mode-hook))) - (normal-mode t)) + (delay-mode-hooks + (normal-mode t))) (setq buffer-read-only t) (set-buffer-modified-p nil) (goto-char (point-min)))) @@ -326,12 +324,12 @@ to `magit-dispatch'." (defvar magit-blob-mode-map (let ((map (make-sparse-keymap))) - (define-key map "p" 'magit-blob-previous) - (define-key map "n" 'magit-blob-next) - (define-key map "b" 'magit-blame-addition) - (define-key map "r" 'magit-blame-removal) - (define-key map "f" 'magit-blame-reverse) - (define-key map "q" 'magit-kill-this-buffer) + (define-key map "p" #'magit-blob-previous) + (define-key map "n" #'magit-blob-next) + (define-key map "b" #'magit-blame-addition) + (define-key map "r" #'magit-blame-removal) + (define-key map "f" #'magit-blame-reverse) + (define-key map "q" #'magit-kill-this-buffer) map) "Keymap for `magit-blob-mode'.") @@ -501,6 +499,15 @@ Git, then fallback to using `delete-file'." (defun magit-read-tracked-file (prompt) (magit-read-file prompt t)) +(defun magit-read-unmerged-file (&optional prompt) + (let ((current (magit-current-file)) + (unmerged (magit-unmerged-files))) + (unless unmerged + (user-error "There are no unresolved conflicts")) + (magit-completing-read (or prompt "Resolve file") + unmerged nil t nil nil + (car (member current unmerged))))) + (defun magit-read-file-choice (prompt files &optional error default) "Read file from FILES. diff --git a/elpa/magit-20220116.1908/magit-git.el b/elpa/magit-20220518.2359/magit-git.el similarity index 85% rename from elpa/magit-20220116.1908/magit-git.el rename to elpa/magit-20220518.2359/magit-git.el index 80e2e30f..d3b88d84 100644 --- a/elpa/magit-20220116.1908/magit-git.el +++ b/elpa/magit-20220518.2359/magit-git.el @@ -1,19 +1,16 @@ -;;; magit-git.el --- Git functionality -*- lexical-binding: t -*- +;;; magit-git.el --- Git functionality -*- lexical-binding:t -*- -;; Copyright (C) 2010-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Jonas Bernoulli ;; Maintainer: Jonas Bernoulli ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Magit is free software; you can redistribute it and/or modify it +;; 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. +;; the Free Software Foundation, either version 3 of the License, 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 @@ -21,7 +18,7 @@ ;; 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. +;; along with Magit. If not, see . ;;; Commentary: @@ -29,8 +26,9 @@ ;;; Code: -(require 'magit-utils) -(require 'magit-section) +(require 'magit-base) + +(require 'format-spec) ;; From `magit-branch'. (defvar magit-branch-prefer-remote-upstream) @@ -61,13 +59,6 @@ (defvar magit-this-error) (defvar magit-process-error-message-regexps) -;; From later in `magit-git'. -(defvar magit-tramp-process-environment nil) - -;; From `magit-blame'. -(declare-function magit-current-blame-chunk "magit-blame" - (&optional type noerror)) - (eval-when-compile (cl-pushnew 'orig-rev eieio--known-slot-names) (cl-pushnew 'number eieio--known-slot-names)) @@ -137,14 +128,14 @@ successfully.") (or (and (eq system-type 'windows-nt) ;; Avoid the wrappers "cmd/git.exe" and "cmd/git.cmd", ;; which are much slower than using "bin/git.exe" directly. - (--when-let (executable-find "git") + (and-let* ((exec (executable-find "git"))) (ignore-errors ;; Git for Windows 2.x provides cygpath so we can ;; ask it for native paths. (let* ((core-exe (car (process-lines - it "-c" + exec "-c" "alias.X=!x() { which \"$1\" | cygpath -mf -; }; x" "X" "git"))) (hack-entry (assoc core-exe magit-git-w32-path-hack)) @@ -153,7 +144,7 @@ successfully.") (path-hack (list (concat "PATH=" (car (process-lines - it "-c" + exec "-c" "alias.P=!cygpath -wp \"$PATH\"" "P")))))) ;; The defcustom STANDARD expression can be @@ -207,26 +198,6 @@ purpose." :group 'magit-process :type '(repeat string)) -(defvar magit-git-debug nil - "Whether to enable additional reporting of git errors. - -Magit basically calls git for one of these two reasons: for -side-effects or to do something with its standard output. - -When git is run for side-effects then its output, including error -messages, go into the process buffer which is shown when using \ -\\\\[magit-process]. - -When git's output is consumed in some way, then it would be too -expensive to also insert it into this buffer, but when this -option is non-nil and git returns with a non-zero exit status, -then at least its standard error is inserted into this buffer. - -This is only intended for debugging purposes. Do not enable this -permanently, that would negatively affect performance. - -Also see `magit-process-extreme-logging'.") - (defcustom magit-prefer-remote-upstream nil "Whether to favor remote branches when reading the upstream branch. @@ -282,6 +253,43 @@ framework ultimately determines how the collection is displayed." ;;; Git +(defvar magit-git-debug nil + "Whether to enable additional reporting of git errors. + +Magit basically calls git for one of these two reasons: for +side-effects or to do something with its standard output. + +When git is run for side-effects then its output, including error +messages, go into the process buffer which is shown when using \ +\\\\[magit-process]. + +When git's output is consumed in some way, then it would be too +expensive to also insert it into this buffer, but when this +option is non-nil and git returns with a non-zero exit status, +then at least its standard error is inserted into this buffer. + +This is only intended for debugging purposes. Do not enable this +permanently, that would negatively affect performance. Also note +that just because git exits with a non-zero exit status and prints +an error message that usually doesn't mean that it is an error as +far as Magit is concerned, which is another reason we usually hide +these error messages. Whether some error message is relevant in +the context of some unexpected behavior has to be judged on a case +by case basis. + +The command `magit-toggle-git-debug' changes the value of this +variable. + +Also see `magit-process-extreme-logging'.") + +(defun magit-toggle-git-debug () + "Toggle whether additional git errors are reported. +See info node `(magit)Debugging Tools' for more information." + (interactive) + (setq magit-git-debug (not magit-git-debug)) + (message "Additional reporting of Git errors %s" + (if magit-git-debug "enabled" "disabled"))) + (defvar magit--refresh-cache nil) (defmacro magit--with-refresh-cache (key &rest body) @@ -356,7 +364,7 @@ to do the following. * Flatten ARGS, removing nil arguments. * Prepend `magit-git-global-arguments' to ARGS. * On w32 systems, encode to `w32-ansi-code-page'." - (setq args (append magit-git-global-arguments (-flatten args))) + (setq args (append magit-git-global-arguments (flatten-tree args))) (if (and (eq system-type 'windows-nt) (boundp 'w32-ansi-code-page)) ;; On w32, the process arguments *must* be encoded in the ;; current code-page (see #3250). @@ -431,7 +439,7 @@ still subject to major changes. Also see `magit-git-string-p'." If there is no output, return nil. If the output begins with a newline, return an empty string. Like `magit-git-string' but ignore `magit-git-debug'." - (setq args (-flatten args)) + (setq args (flatten-tree args)) (magit--with-refresh-cache (cons default-directory args) (magit--with-temp-process-buffer (magit-process-git (list t nil) args) @@ -441,7 +449,7 @@ ignore `magit-git-debug'." (defun magit-git-output (&rest args) "Execute Git with ARGS, returning its output." - (setq args (-flatten args)) + (setq args (flatten-tree args)) (magit--with-refresh-cache (cons default-directory args) (magit--with-temp-process-buffer (magit-process-git (list t nil) args) @@ -523,7 +531,7 @@ add a section in the respective process buffer." "Execute Git with ARGS, returning the first line of its output. If there is no output, return nil. If the output begins with a newline, return an empty string." - (setq args (-flatten args)) + (setq args (flatten-tree args)) (magit--with-refresh-cache (cons default-directory args) (magit--with-temp-process-buffer (apply #'magit-git-insert args) @@ -559,7 +567,7 @@ the buffer to the inserted text, move to its beginning, and then call function WASHER with ARGS as its sole argument." (declare (indent 1)) (let ((beg (point))) - (setq args (-flatten args)) + (setq args (flatten-tree args)) (magit-git-insert args) (if (= (point) beg) (magit-cancel-section) @@ -574,12 +582,12 @@ call function WASHER with ARGS as its sole argument." (magit-cancel-section)) (magit-maybe-make-margin-overlay)))) -(defun magit-git-version (&optional raw) - "Return the installed Git version." - (--when-let (let (magit-git-global-arguments) - (ignore-errors (substring (magit-git-string "version") 12))) - (if raw it (and (string-match "\\`\\([0-9]+\\(\\.[0-9]+\\)\\{1,2\\}\\)" it) - (match-string 1 it))))) +;;; Git Version + +(defconst magit--git-version-regexp + "\\`git version \\([0-9]+\\(\\.[0-9]+\\)\\{1,2\\}\\)") + +(defvar magit--host-git-version-cache nil) (defun magit-git-version>= (n) "Return t if `magit-git-version's value is greater than or equal to N." @@ -589,16 +597,124 @@ call function WASHER with ARGS as its sole argument." "Return t if `magit-git-version's value is smaller than N." (version< (magit-git-version) n)) +(defun magit-git-version () + "Return the Git version used for `default-directory'. +Raise an error if Git cannot be found, if it exits with a +non-zero status, or the output does not have the expected +format." + (magit--with-refresh-cache default-directory + (let ((host (file-remote-p default-directory))) + (or (cdr (assoc host magit--host-git-version-cache)) + (magit--with-temp-process-buffer + ;; Unset global arguments for ancient Git versions. + (let* ((magit-git-global-arguments nil) + (status (magit-process-git t "version")) + (output (buffer-string))) + (cond + ((not (zerop status)) + (display-warning + 'magit + (format "%S\n\nRunning \"%s --version\" failed with output:\n\n%s" + (if host + (format "Magit cannot find Git on host %S.\n +Check the value of `magit-remote-git-executable' using +`magit-debug-git-executable' and consult the info node +`(tramp)Remote programs'." host) + "Magit cannot find Git.\n +Check the values of `magit-git-executable' and `exec-path' +using `magit-debug-git-executable'.") + (magit-git-executable) + output))) + ((save-match-data + (and (string-match magit--git-version-regexp output) + (let ((version (match-string 1 output))) + (push (cons host version) + magit--host-git-version-cache) + version)))) + (t (error "Unexpected \"%s --version\" output: %S" + (magit-git-executable) + output))))))))) + +(defun magit-git-version-assert (&optional minimal who) + "Assert that the used Git version is greater than or equal to MINIMAL. +If optional MINIMAL is nil, compare with `magit--minimal-git' +instead. Optional WHO if non-nil specifies what functionality +needs at least MINIMAL, otherwise it defaults to \"Magit\"." + (when (magit-git-version< (or minimal magit--minimal-git)) + (let* ((host (file-remote-p default-directory)) + (msg (format-spec + (cond (host "\ +%w requires Git %m or greater, but on %h the version is %m. + +If multiple Git versions are installed on the host, then the +problem might be that TRAMP uses the wrong executable. + +Check the value of `magit-remote-git-executable' and consult +the info node `(tramp)Remote programs'.\n") + (t "\ +%w requires Git %m or greater, but you are using %v. + +If you have multiple Git versions installed, then check the +values of `magit-remote-git-executable' and `exec-path'.\n")) + `((?w . ,(or who "Magit")) + (?m . ,(or minimal magit--minimal-git)) + (?v . ,(magit-git-version)) + (?h . ,host))))) + (display-warning 'magit msg :error)))) + +(defun magit--safe-git-version () + "Return the Git version used for `default-directory' or an error message." + (magit--with-temp-process-buffer + (let* ((magit-git-global-arguments nil) + (status (magit-process-git t "version")) + (output (buffer-string))) + (cond ((not (zerop status)) output) + ((save-match-data + (and (string-match magit--git-version-regexp output) + (match-string 1 output)))) + (t output))))) + +(defun magit-debug-git-executable () + "Display a buffer with information about `magit-git-executable'. +Also include information about `magit-remote-git-executable'. +See info node `(magit)Debugging Tools' for more information." + (interactive) + (with-current-buffer (get-buffer-create "*magit-git-debug*") + (pop-to-buffer (current-buffer)) + (erase-buffer) + (insert (format "magit-remote-git-executable: %S\n" + magit-remote-git-executable)) + (insert (concat + (format "magit-git-executable: %S" magit-git-executable) + (and (not (file-name-absolute-p magit-git-executable)) + (format " [%S]" (executable-find magit-git-executable))) + (format " (%s)\n" (magit--safe-git-version)))) + (insert (format "exec-path: %S\n" exec-path)) + (--when-let (cl-set-difference + (-filter #'file-exists-p (remq nil (parse-colon-path + (getenv "PATH")))) + (-filter #'file-exists-p (remq nil exec-path)) + :test #'file-equal-p) + (insert (format " entries in PATH, but not in exec-path: %S\n" it))) + (dolist (execdir exec-path) + (insert (format " %s (%s)\n" execdir (car (file-attributes execdir)))) + (when (file-directory-p execdir) + (dolist (exec (directory-files + execdir t (concat + "\\`git" (regexp-opt exec-suffixes) "\\'"))) + (insert (format " %s (%s)\n" exec + (magit--safe-git-version)))))))) + ;;; Variables (defun magit-config-get-from-cached-list (key) (gethash ;; `git config --list' downcases first and last components of the key. - (--> key - (replace-regexp-in-string "\\`[^.]+" #'downcase it t t) - (replace-regexp-in-string "[^.]+\\'" #'downcase it t t)) + (let* ((key (replace-regexp-in-string "\\`[^.]+" #'downcase key t t)) + (key (replace-regexp-in-string "[^.]+\\'" #'downcase key t t))) + key) (magit--with-refresh-cache (cons (magit-toplevel) 'config) - (let ((configs (make-hash-table :test 'equal))) + (let ((configs (make-hash-table :test #'equal))) (dolist (conf (magit-git-items "config" "--list" "-z")) (let* ((nl-pos (cl-position ?\n conf)) (key (substring conf 0 nl-pos)) @@ -608,7 +724,7 @@ call function WASHER with ARGS as its sole argument." (defun magit-get (&rest keys) "Return the value of the Git variable specified by KEYS." - (car (last (apply 'magit-get-all keys)))) + (car (last (apply #'magit-get-all keys)))) (defun magit-get-all (&rest keys) "Return all values of the Git variable specified by KEYS." @@ -616,7 +732,7 @@ call function WASHER with ARGS as its sole argument." (arg (and (or (null (car keys)) (string-prefix-p "--" (car keys))) (pop keys))) - (key (mapconcat 'identity keys "."))) + (key (mapconcat #'identity keys "."))) (if (and magit--refresh-cache (not arg)) (magit-config-get-from-cached-list key) (magit-git-items "config" arg "-z" "--get-all" key)))) @@ -624,10 +740,13 @@ call function WASHER with ARGS as its sole argument." (defun magit-get-boolean (&rest keys) "Return the boolean value of the Git variable specified by KEYS. Also see `magit-git-config-p'." - (let ((key (mapconcat 'identity keys "."))) + (let ((arg (and (or (null (car keys)) + (string-prefix-p "--" (car keys))) + (pop keys))) + (key (mapconcat #'identity keys "."))) (equal (if magit--refresh-cache (car (last (magit-config-get-from-cached-list key))) - (magit-git-str "config" "--bool" key)) + (magit-git-str "config" arg "--bool" key)) "true"))) (defun magit-set (value &rest keys) @@ -635,7 +754,7 @@ Also see `magit-git-config-p'." (let ((arg (and (or (null (car keys)) (string-prefix-p "--" (car keys))) (pop keys))) - (key (mapconcat 'identity keys "."))) + (key (mapconcat #'identity keys "."))) (if value (magit-git-success "config" arg key value) (magit-git-success "config" arg "--unset" key)) @@ -649,7 +768,7 @@ Also see `magit-git-config-p'." (let ((arg (and (or (null (car keys)) (string-prefix-p "--" (car keys))) (pop keys))) - (var (mapconcat 'identity keys "."))) + (var (mapconcat #'identity keys "."))) (when (magit-get var) (magit-call-git "config" arg "--unset-all" var)) (dolist (v values) @@ -693,10 +812,11 @@ the directory is not located inside a Git repository, then return nil." (magit--with-refresh-cache (list default-directory 'magit-git-dir path) (magit--with-safe-default-directory nil - (when-let ((dir (magit-rev-parse-safe "--git-dir"))) - (setq dir (file-name-as-directory (magit-expand-git-file-name dir))) - (unless (file-remote-p dir) - (setq dir (concat (file-remote-p default-directory) dir))) + (and-let* ((dir (magit-rev-parse-safe "--git-dir")) + (dir (file-name-as-directory (magit-expand-git-file-name dir))) + (dir (if (file-remote-p dir) + dir + (concat (file-remote-p default-directory) dir)))) (if path (expand-file-name (convert-standard-filename path) dir) dir))))) (defvar magit--separated-gitdirs nil) @@ -761,21 +881,22 @@ returning the truename." (setq updir (if (file-name-absolute-p updir) (concat (file-remote-p default-directory) updir) (expand-file-name updir))) - (let ((default-directory updir)) - (and (string-equal (magit-rev-parse-safe "--show-cdup") "") - (--when-let (magit-rev-parse-safe "--show-toplevel") - (string-equal (magit-expand-git-file-name it) - topdir)))))) + (and-let* + ((default-directory updir) + (top (and (string-equal + (magit-rev-parse-safe "--show-cdup") "") + (magit-rev-parse-safe "--show-toplevel")))) + (string-equal (magit-expand-git-file-name top) topdir)))) updir (concat (file-remote-p default-directory) (file-name-as-directory topdir)))) - (when-let ((gitdir (magit-rev-parse-safe "--git-dir"))) - (setq gitdir (file-name-as-directory - (if (file-name-absolute-p gitdir) - ;; We might have followed a symlink. - (concat (file-remote-p default-directory) - (magit-expand-git-file-name gitdir)) - (expand-file-name gitdir)))) + (and-let* ((gitdir (magit-rev-parse-safe "--git-dir")) + (gitdir (file-name-as-directory + (if (file-name-absolute-p gitdir) + ;; We might have followed a symlink. + (concat (file-remote-p default-directory) + (magit-expand-git-file-name gitdir)) + (expand-file-name gitdir))))) (if (magit-bare-repo-p) gitdir (let* ((link (expand-file-name "gitdir" gitdir)) @@ -797,14 +918,14 @@ returning the truename." ;; Step outside the control directory to enter the working tree. (file-name-directory (directory-file-name gitdir))))))))))) +(defun magit--toplevel-safe () + (or (magit-toplevel) + (magit--not-inside-repository-error))) + (defmacro magit-with-toplevel (&rest body) (declare (indent defun) (debug (body))) - (let ((toplevel (cl-gensym "toplevel"))) - `(let ((,toplevel (magit-toplevel))) - (if ,toplevel - (let ((default-directory ,toplevel)) - ,@body) - (magit--not-inside-repository-error))))) + `(let ((default-directory (magit--toplevel-safe))) + ,@body)) (define-error 'magit-outside-git-repo "Not inside Git repository") (define-error 'magit-corrupt-git-config "Corrupt Git configuration") @@ -812,7 +933,7 @@ returning the truename." "Git executable cannot be found (see https://magit.vc/goto/e6a78ed2)") (defun magit--assert-usable-git () - (if (not (executable-find (magit-git-executable))) + (if (not (compat-executable-find (magit-git-executable) t)) (signal 'magit-git-executable-not-found (magit-git-executable)) (let ((magit-git-debug (lambda (err) @@ -906,10 +1027,10 @@ tracked file." (and (derived-mode-p 'dired-mode) default-directory))))) (when (and file (or (not tracked) (magit-file-tracked-p (file-relative-name file)))) - (--when-let (magit-toplevel - (magit--safe-default-directory - (directory-file-name (file-name-directory file)))) - (file-relative-name file it)))) + (and-let* ((dir (magit-toplevel + (magit--safe-default-directory + (directory-file-name (file-name-directory file)))))) + (file-relative-name file dir)))) (defun magit-file-tracked-p (file) (magit-git-success "ls-files" "--error-unmatch" file)) @@ -923,6 +1044,11 @@ tracked file." (defun magit-untracked-files (&optional all files) (magit-list-files "--other" (unless all "--exclude-standard") "--" files)) +(defun magit-modified-files (&optional nomodules files) + (magit-git-items "diff-index" "-z" "--name-only" + (and nomodules "--ignore-submodules") + (magit-headish) "--" files)) + (defun magit-unstaged-files (&optional nomodules files) (magit-git-items "diff-files" "-z" "--name-only" (and nomodules "--ignore-submodules") @@ -961,6 +1087,12 @@ tracked file." (magit-with-toplevel (magit-git-items "ls-tree" "-z" "-r" "--name-only" rev))) +(defun magit-revision-directories (rev) + "List directories that contain a tracked file in revision REV." + (magit-with-toplevel + (mapcar #'file-name-as-directory + (magit-git-items "ls-tree" "-z" "-r" "-d" "--name-only" rev)))) + (defun magit-changed-files (rev-or-range &optional other-rev) "Return list of files the have changed between two revisions. If OTHER-REV is non-nil, REV-OR-RANGE should be a revision, not a @@ -970,10 +1102,19 @@ range. Otherwise, it can be any revision or range accepted by (magit-git-items "diff" "-z" "--name-only" rev-or-range other-rev))) (defun magit-renamed-files (revA revB) - (--map (cons (nth 1 it) (nth 2 it)) - (-partition 3 (magit-git-items - "diff-tree" "-r" "--diff-filter=R" "-z" "-M" - revA revB)))) + (mapcar (pcase-lambda (`(,_status ,fileA ,fileB)) + (cons fileA fileB)) + (seq-partition (magit-git-items "diff" "-z" "--name-status" + "--diff-filter=R" revA revB) + 3))) + +(defun magit--rev-file-name (file rev other-rev) + "For FILE, potentially renamed between REV and OTHER-REV, return name in REV. +Return nil, if FILE appears neither in REV nor OTHER-REV, +or if no rename is detected." + (or (car (member file (magit-revision-files rev))) + (and-let* ((renamed (magit-renamed-files rev other-rev))) + (car (rassoc file renamed))))) (defun magit-file-status (&rest args) (magit--with-temp-process-buffer @@ -1020,10 +1161,10 @@ Sorted from longest to shortest CYGWIN name." (defun magit-expand-git-file-name (filename) (unless (file-name-absolute-p filename) (setq filename (expand-file-name filename))) - (-if-let ((cyg . win) - (cl-assoc filename magit-cygwin-mount-points - :test (lambda (f cyg) (string-prefix-p cyg f)))) - (concat win (substring filename (length cyg))) + (if-let ((cyg:win (cl-assoc filename magit-cygwin-mount-points + :test (lambda (f cyg) (string-prefix-p cyg f))))) + (concat (cdr cyg:win) + (substring filename (length (car cyg:win)))) filename)) (defun magit-convert-filename-for-git (filename) @@ -1033,10 +1174,10 @@ Sorted from longest to shortest CYGWIN name." 2. If it's a remote filename, then remove the remote part. 3. Deal with an `windows-nt' Emacs vs. Cygwin Git incompatibility." (if (file-name-absolute-p filename) - (-if-let ((cyg . win) - (cl-rassoc filename magit-cygwin-mount-points - :test (lambda (f win) (string-prefix-p win f)))) - (concat cyg (substring filename (length win))) + (if-let ((cyg:win (cl-rassoc filename magit-cygwin-mount-points + :test (lambda (f win) (string-prefix-p win f))))) + (concat (car cyg:win) + (substring filename (length (cdr cyg:win)))) (let ((expanded (expand-file-name filename))) (or (file-remote-p expanded 'localname) expanded))) @@ -1074,7 +1215,7 @@ Sorted from longest to shortest CYGWIN name." (defun magit-merge-commit-p (commit) "Return t if COMMIT is a merge commit." - (> (length (magit-commit-parents commit)) 1)) + (length> (magit-commit-parents commit) 1)) (defun magit-anything-staged-p (&optional ignore-submodules &rest files) "Return t if there are any staged changes. @@ -1096,8 +1237,8 @@ are considered." "Return t if there are any staged or unstaged changes. If optional FILES is non-nil, then only changes to those files are considered." - (or (apply 'magit-anything-staged-p ignore-submodules files) - (apply 'magit-anything-unstaged-p ignore-submodules files))) + (or (apply #'magit-anything-staged-p ignore-submodules files) + (apply #'magit-anything-unstaged-p ignore-submodules files))) (defun magit-anything-unmerged-p (&rest files) "Return t if there are any merge conflicts. @@ -1116,7 +1257,7 @@ are considered." (or (cl-find-if (lambda (arg) (string-prefix-p "--ignore-submodules" arg)) magit-buffer-diff-args) - (when-let ((value (magit-get "diff.ignoreSubmodules"))) + (and-let* ((value (magit-get "diff.ignoreSubmodules"))) (if return-argument (concat "--ignore-submodules=" value) (concat "diff.ignoreSubmodules=" value))))) @@ -1157,11 +1298,18 @@ string \"true\", otherwise return nil." (defun magit-commit-p (rev) "Return full hash for REV if it names an existing commit." - (magit-rev-verify (concat rev "^{commit}"))) + (magit-rev-verify (magit--rev-dereference rev))) -(defalias 'magit-rev-verify-commit 'magit-commit-p) +(defalias 'magit-rev-verify-commit #'magit-commit-p) -(defalias 'magit-rev-hash 'magit-commit-p) +(defalias 'magit-rev-hash #'magit-commit-p) + +(defun magit--rev-dereference (rev) + "Return a rev that forces Git to interpret REV as a commit. +If REV is nil or has the form \":/TEXT\", return REV itself." + (cond ((not rev) nil) + ((string-match-p "^:/" rev) rev) + (t (concat rev "^{commit}")))) (defun magit-rev-equal (a b) "Return t if there are no differences between the commits A and B." @@ -1180,7 +1328,7 @@ string \"true\", otherwise return nil." (defun magit-rev-head-p (rev) (or (equal rev "HEAD") (and rev - (not (string-match-p "\\.\\." rev)) + (not (string-search ".." rev)) (equal (magit-rev-parse rev) (magit-rev-parse "HEAD"))))) @@ -1209,7 +1357,7 @@ this function returns nil instead. This is unfortunate because there might be other refs that do match. To fix that, update Git." (if (magit-git-version< "2.13") - (when-let + (and-let* ((ref (magit-git-string "name-rev" "--name-only" "--no-undefined" (and pattern (concat "--refs=" pattern)) rev))) @@ -1231,11 +1379,11 @@ Git." rev))) (defun magit-rev-branch (rev) - (--when-let (magit-rev-name rev "refs/heads/*") - (unless (string-match-p "[~^]" it) it))) + (and-let* ((name (magit-rev-name rev "refs/heads/*"))) + (and (not (string-match-p "[~^]" name)) name))) (defun magit-get-shortname (rev) - (let* ((fn (apply-partially 'magit-rev-name rev)) + (let* ((fn (apply-partially #'magit-rev-name rev)) (name (or (funcall fn "refs/tags/*") (funcall fn "refs/heads/*") (funcall fn "refs/remotes/*")))) @@ -1254,16 +1402,16 @@ Git." (magit-name-remote-branch rev t))))) (defun magit-name-local-branch (rev &optional lax) - (--when-let (magit-rev-name rev "refs/heads/*") - (and (or lax (not (string-match-p "[~^]" it))) it))) + (and-let* ((name (magit-rev-name rev "refs/heads/*"))) + (and (or lax (not (string-match-p "[~^]" name))) name))) (defun magit-name-remote-branch (rev &optional lax) - (--when-let (magit-rev-name rev "refs/remotes/*") - (and (or lax (not (string-match-p "[~^]" it))) - (substring it 8)))) + (and-let* ((name (magit-rev-name rev "refs/remotes/*"))) + (and (or lax (not (string-match-p "[~^]" name))) + (substring name 8)))) (defun magit-name-tag (rev &optional lax) - (when-let ((name (magit-rev-name rev "refs/tags/*"))) + (when-let* ((name (magit-rev-name rev "refs/tags/*"))) ;debbugs#31840 (when (string-suffix-p "^0" name) (setq name (substring name 0 -2))) (and (or lax (not (string-match-p "[~^]" name))) @@ -1334,13 +1482,13 @@ to, or to some other symbolic-ref that points to the same ref." (defun magit--painted-branch-at-point (&optional type) (or (and (not (eq type 'remote)) - (memq (get-text-property (point) 'font-lock-face) + (memq (get-text-property (magit-point) 'font-lock-face) (list 'magit-branch-local 'magit-branch-current)) - (when-let ((branch (thing-at-point 'git-revision t))) + (and-let* ((branch (magit-thing-at-point 'git-revision t))) (cdr (magit-split-branch-name branch)))) (and (not (eq type 'local)) - (memq (get-text-property (point) 'font-lock-face) + (memq (get-text-property (magit-point) 'font-lock-face) (list 'magit-branch-remote 'magit-branch-remote-head)) (thing-at-point 'git-revision t)))) @@ -1363,8 +1511,9 @@ to, or to some other symbolic-ref that points to the same ref." (defun magit-commit-at-point () (or (magit-section-value-if 'commit) - (thing-at-point 'git-revision t) - (when-let ((chunk (magit-current-blame-chunk 'addition t))) + (magit-thing-at-point 'git-revision t) + (and-let* ((chunk (and (fboundp 'magit-current-blame-chunk) + (magit-current-blame-chunk 'addition t)))) (oref chunk orig-rev)) (and (derived-mode-p 'magit-stash-mode 'magit-merge-preview-mode @@ -1383,8 +1532,9 @@ to, or to some other symbolic-ref that points to the same ref." (forge--pullreq-branch (oref it value)))) (magit-ref-p (format "refs/pullreqs/%s" (oref (oref it value) number)))))) - (thing-at-point 'git-revision t) - (when-let ((chunk (magit-current-blame-chunk 'addition t))) + (magit-thing-at-point 'git-revision t) + (and-let* ((chunk (and (fboundp 'magit-current-blame-chunk) + (magit-current-blame-chunk 'addition t)))) (oref chunk orig-rev)) (and magit-buffer-file-name magit-buffer-refname) @@ -1454,7 +1604,7 @@ if any, nil otherwise. If the upstream is not configured, the configured remote is an url, or the named branch does not exist, then return nil. I.e. return an existing local or remote-tracking branch ref." - (when-let ((branch (or branch (magit-get-current-branch)))) + (and-let* ((branch (or branch (magit-get-current-branch)))) (magit-ref-fullname (concat branch "@{upstream}")))) (defun magit-get-upstream-branch (&optional branch) @@ -1465,8 +1615,9 @@ configured remote is an url, or the named branch does not exist, then return nil. I.e. return the name of an existing local or remote-tracking branch. The returned string is colorized according to the branch type." - (magit--with-refresh-cache (list 'magit-get-upstream-branch branch) - (when-let ((branch (or branch (magit-get-current-branch))) + (magit--with-refresh-cache + (list default-directory 'magit-get-upstream-branch branch) + (and-let* ((branch (or branch (magit-get-current-branch))) (upstream (magit-ref-abbrev (concat branch "@{upstream}")))) (magit--propertize-face upstream (if (equal (magit-get "branch" branch "remote") ".") @@ -1493,7 +1644,7 @@ according to the branch type." upstream))))) (defun magit-get-upstream-remote (&optional branch allow-unnamed) - (when-let ((branch (or branch (magit-get-current-branch))) + (and-let* ((branch (or branch (magit-get-current-branch))) (remote (magit-get "branch" branch "remote"))) (and (not (equal remote ".")) (cond ((member remote (magit-list-remotes)) @@ -1503,7 +1654,7 @@ according to the branch type." (magit--propertize-face remote 'bold)))))) (defun magit-get-unnamed-upstream (&optional branch) - (when-let ((branch (or branch (magit-get-current-branch))) + (and-let* ((branch (or branch (magit-get-current-branch))) (remote (magit-get "branch" branch "remote")) (merge (magit-get "branch" branch "merge"))) (and (magit--unnamed-upstream-p remote merge) @@ -1521,22 +1672,23 @@ according to the branch type." (defun magit-get-current-remote (&optional allow-unnamed) (or (magit-get-upstream-remote nil allow-unnamed) - (when-let ((remotes (magit-list-remotes)) - (remote (if (= (length remotes) 1) + (and-let* ((remotes (magit-list-remotes)) + (remote (if (length= remotes 1) (car remotes) (magit-primary-remote)))) (magit--propertize-face remote 'magit-branch-remote)))) (defun magit-get-push-remote (&optional branch) - (when-let ((remote + (and-let* ((remote (or (and (or branch (setq branch (magit-get-current-branch))) (magit-get "branch" branch "pushRemote")) (magit-get "remote.pushDefault")))) (magit--propertize-face remote 'magit-branch-remote))) (defun magit-get-push-branch (&optional branch verify) - (magit--with-refresh-cache (list 'magit-get-push-branch branch verify) - (when-let ((branch (or branch (setq branch (magit-get-current-branch)))) + (magit--with-refresh-cache + (list default-directory 'magit-get-push-branch branch verify) + (and-let* ((branch (or branch (setq branch (magit-get-current-branch)))) (remote (magit-get-push-remote branch)) (target (concat remote "/" branch))) (and (or (not verify) @@ -1557,7 +1709,7 @@ according to the branch type." (defun magit-get-some-remote (&optional branch) (or (magit-get-remote branch) - (when-let ((main (magit-main-branch))) + (and-let* ((main (magit-main-branch))) (magit-get-remote main)) (magit-primary-remote) (car (magit-list-remotes)))) @@ -1606,14 +1758,14 @@ as into its upstream." (if (eq target t) (delete (magit-name-local-branch branch) (magit-list-containing-branches branch)) - (--when-let (or target (magit-get-current-branch)) - (magit-git-success "merge-base" "--is-ancestor" branch it))))) + (and-let* ((target (or target (magit-get-current-branch)))) + (magit-git-success "merge-base" "--is-ancestor" branch target))))) (defun magit-get-tracked (refname) "Return the remote branch tracked by the remote-tracking branch REFNAME. The returned value has the form (REMOTE . REF), where REMOTE is the name of a remote and REF is the ref local to the remote." - (when-let ((ref (magit-ref-fullname refname))) + (and-let* ((ref (magit-ref-fullname refname))) (save-match-data (seq-some (lambda (line) (and (string-match "\ @@ -1622,10 +1774,10 @@ the name of a remote and REF is the ref local to the remote." (src (match-string 2 line)) (dst (match-string 3 line))) (and (string-match (format "\\`%s\\'" - (replace-regexp-in-string - "*" "\\(.+\\)" dst t t)) + (string-replace + "*" "\\(.+\\)" dst)) ref) - (cons rmt (replace-regexp-in-string + (cons rmt (string-replace "*" (match-string 1 ref) src)))))) (magit-git-lines "config" "--local" "--list"))))) @@ -1650,16 +1802,17 @@ If optional WITH-DISTANCE is non-nil then return (TAG COMMITS), if it is `dirty' return (TAG COMMIT DIRTY). COMMITS is the number of commits in `HEAD' but not in TAG and DIRTY is t if there are uncommitted changes, nil otherwise." - (--when-let (magit-git-str "describe" "--long" "--tags" - (and (eq with-distance 'dirty) "--dirty") rev) + (and-let* ((str (magit-git-str "describe" "--long" "--tags" + (and (eq with-distance 'dirty) "--dirty") + rev))) (save-match-data (string-match - "\\(.+\\)-\\(?:0[0-9]*\\|\\([0-9]+\\)\\)-g[0-9a-z]+\\(-dirty\\)?$" it) + "\\(.+\\)-\\(?:0[0-9]*\\|\\([0-9]+\\)\\)-g[0-9a-z]+\\(-dirty\\)?$" str) (if with-distance - `(,(match-string 1 it) - ,(string-to-number (or (match-string 2 it) "0")) - ,@(and (match-string 3 it) (list t))) - (match-string 1 it))))) + `(,(match-string 1 str) + ,(string-to-number (or (match-string 2 str) "0")) + ,@(and (match-string 3 str) (list t))) + (match-string 1 str))))) (defun magit-get-next-tag (&optional rev with-distance) "Return the closest tag from which REV is reachable. @@ -1669,14 +1822,14 @@ If no such tag can be found or if the distance is 0 (in which case it is the current tag, not the next), return nil instead. If optional WITH-DISTANCE is non-nil, then return (TAG COMMITS) where COMMITS is the number of commits in TAG but not in REV." - (--when-let (magit-git-str "describe" "--contains" (or rev "HEAD")) + (and-let* ((str (magit-git-str "describe" "--contains" (or rev "HEAD")))) (save-match-data - (when (string-match "^[^^~]+" it) - (setq it (match-string 0 it)) - (unless (equal it (magit-get-current-tag rev)) + (when (string-match "^[^^~]+" str) + (setq str (match-string 0 str)) + (unless (equal str (magit-get-current-tag rev)) (if with-distance - (list it (car (magit-rev-diff-count it rev))) - it)))))) + (list str (car (magit-rev-diff-count str rev))) + str)))))) (defun magit-list-refs (&optional namespaces format sortby) "Return list of references. @@ -1733,7 +1886,7 @@ SORTBY is a key or list of keys to pass to the `--sort' flag of (magit-list-related-branches "--no-merged" commit args)) (defun magit-list-unmerged-to-upstream-branches () - (--filter (when-let ((upstream (magit-get-upstream-branch it))) + (--filter (and-let* ((upstream (magit-get-upstream-branch it))) (member it (magit-list-unmerged-branches upstream))) (magit-list-local-branch-names))) @@ -1779,7 +1932,7 @@ SORTBY is a key or list of keys to pass to the `--sort' flag of (let ((lines (magit-git-lines "for-each-ref" (concat "--format=" format) (or args (list "refs/heads" "refs/remotes" "refs/tags"))))) - (if (string-match-p "\f" format) + (if (string-search "\f" format) (--map (split-string it "\f") lines) lines))) @@ -1802,17 +1955,17 @@ SORTBY is a key or list of keys to pass to the `--sort' flag of (--map (substring it 6) (magit-list-refnames "refs/notes"))) (defun magit-remote-list-tags (remote) - (--keep (and (not (string-match-p "\\^{}$" it)) + (--keep (and (not (string-suffix-p "^{}" it)) (substring it 51)) (magit-git-lines "ls-remote" "--tags" remote))) (defun magit-remote-list-branches (remote) - (--keep (and (not (string-match-p "\\^{}$" it)) + (--keep (and (not (string-suffix-p "^{}" it)) (substring it 52)) (magit-git-lines "ls-remote" "--heads" remote))) (defun magit-remote-list-refs (remote) - (--keep (and (not (string-match-p "\\^{}$" it)) + (--keep (and (not (string-suffix-p "^{}" it)) (substring it 41)) (magit-git-lines "ls-remote" remote))) @@ -1822,7 +1975,7 @@ SORTBY is a key or list of keys to pass to the `--sort' flag of (magit-git-lines "submodule" "status"))) (defun magit-list-module-paths () - (--mapcat (and (string-match "^160000 [0-9a-z]\\{40\\} 0\t\\(.+\\)$" it) + (--mapcat (and (string-match "^160000 [0-9a-z]\\{40,\\} 0\t\\(.+\\)$" it) (list (match-string 1 it))) (magit-git-items "ls-files" "-z" "--stage"))) @@ -1922,7 +2075,7 @@ exists in the current repository is considered its main branch." (defun magit-rev-diff-count (a b) "Return the commits in A but not B and vice versa. Return a list of two integers: (A>B B>A)." - (mapcar 'string-to-number + (mapcar #'string-to-number (split-string (magit-git-string "rev-list" "--count" "--left-right" (concat a "..." b)) @@ -1966,8 +2119,8 @@ Return a list of two integers: (A>B B>A)." "--not" commit))))) (defun magit-commit-parents (commit) - (--when-let (magit-git-string "rev-list" "-1" "--parents" commit) - (cdr (split-string it)))) + (and-let* ((str (magit-git-string "rev-list" "-1" "--parents" commit))) + (cdr (split-string str)))) (defun magit-patch-id (rev) (magit--with-connection-local-variables @@ -1981,20 +2134,21 @@ Return a list of two integers: (A>B B>A)." (defun magit-rev-format (format &optional rev args) (let ((str (magit-git-string "show" "--no-patch" (concat "--format=" format) args - (if rev (concat rev "^{commit}") "HEAD") "--"))) + (if rev (magit--rev-dereference rev) "HEAD") + "--"))) (unless (string-equal str "") str))) (defun magit-rev-insert-format (format &optional rev args) (magit-git-insert "show" "--no-patch" (concat "--format=" format) args - (if rev (concat rev "^{commit}") "HEAD") "--")) + (if rev (magit--rev-dereference rev) "HEAD") + "--")) (defun magit-format-rev-summary (rev) - (--when-let (magit-rev-format "%h %s" rev) - (string-match " " it) - (magit--put-face 0 (match-beginning 0) 'magit-hash it) - it)) + (when-let* ((str (magit-rev-format "%h %s" rev))) ;debbugs#31840 + (magit--put-face 0 (string-match " " str) 'magit-hash str) + str)) (defvar magit-ref-namespaces '(("\\`HEAD\\'" . magit-head) @@ -2038,7 +2192,7 @@ and this option only controls what face is used.") ((string-match re it) (concat "refs/remotes/" it)) (t (concat "refs/" it))) (split-string - (replace-regexp-in-string "tag: " "refs/tags/" string) + (string-replace "tag: " "refs/tags/" string) regexp t)))) (setq names (split-string string regexp t))) (let (state head upstream tags branches remotes other combined) @@ -2107,13 +2261,13 @@ and this option only controls what face is used.") (setq upstream target) (setq combined (delete target combined)))))) (mapconcat #'identity - (-flatten `(,state - ,head - ,upstream - ,@(nreverse tags) - ,@(nreverse combined) - ,@(nreverse remotes) - ,@other)) + (flatten-tree `(,state + ,head + ,upstream + ,@(nreverse tags) + ,@(nreverse combined) + ,@(nreverse remotes) + ,@other)) " "))))) (defun magit-object-type (object) @@ -2131,6 +2285,8 @@ and this option only controls what face is used.") (point-min) (point-max) buffer-file-name t nil nil t) ,@body))) +(defvar magit-tramp-process-environment nil) + (defmacro magit-with-temp-index (tree arg &rest body) (declare (indent 2) (debug (form form body))) (let ((file (cl-gensym "file"))) @@ -2148,9 +2304,7 @@ and this option only controls what face is used.") (cons (concat "GIT_INDEX_FILE=" ,file) magit-tramp-process-environment))) ,@body) - (let ((process-environment - (cons (concat "GIT_INDEX_FILE=" ,file) - process-environment))) + (with-environment-variables (("GIT_INDEX_FILE" ,file)) ,@body))) (ignore-errors (delete-file (concat (file-remote-p default-directory) ,file))))))) @@ -2212,24 +2366,25 @@ and this option only controls what face is used.") (magit-rev-hash (match-string 3 range))) (magit-rev-hash range))) -(put 'git-revision 'thing-at-point 'magit-thingatpt--git-revision) +(put 'git-revision 'thing-at-point #'magit-thingatpt--git-revision) (defun magit-thingatpt--git-revision () - (--when-let - (let ((c "\s\n\t~^:?*[\\")) - (cl-letf (((get 'git-revision 'beginning-op) - (lambda () - (if (re-search-backward (format "[%s]" c) nil t) - (forward-char) - (goto-char (point-min))))) - ((get 'git-revision 'end-op) - (lambda () - (re-search-forward (format "\\=[^%s]*" c) nil t)))) - (bounds-of-thing-at-point 'git-revision))) - (let ((text (buffer-substring-no-properties (car it) (cdr it)))) - (and (>= (length text) 7) - (string-match-p "[a-z]" text) - (magit-commit-p text) - text)))) + (and-let* ((bounds + (let ((c "\s\n\t~^:?*[\\")) + (cl-letf (((get 'git-revision 'beginning-op) + (lambda () + (if (re-search-backward (format "[%s]" c) nil t) + (forward-char) + (goto-char (point-min))))) + ((get 'git-revision 'end-op) + (lambda () + (re-search-forward (format "\\=[^%s]*" c) nil t)))) + (bounds-of-thing-at-point 'git-revision)))) + (string (buffer-substring-no-properties (car bounds) (cdr bounds)))) + (and (or (and (>= (length string) 7) + (string-match-p "[a-z]" string) + (magit-commit-p string)) + (magit-ref-p string)) + string))) ;;; Completion @@ -2398,7 +2553,7 @@ out. Only existing branches can be selected." (or (let ((r (car (member (magit-remote-branch-at-point) branches))) (l (car (member (magit-local-branch-at-point) branches)))) (if magit-prefer-remote-upstream (or r l) (or l r))) - (when-let ((main (magit-main-branch))) + (and-let* ((main (magit-main-branch))) (let ((r (car (member (concat "origin/" main) branches))) (l (car (member main branches)))) (if magit-prefer-remote-upstream (or r l) (or l r)))) @@ -2453,7 +2608,7 @@ out. Only existing branches can be selected." (defun magit-read-remote (prompt &optional default use-only) (let ((remotes (magit-list-remotes))) - (if (and use-only (= (length remotes) 1)) + (if (and use-only (length= remotes 1)) (car remotes) (magit-completing-read prompt remotes nil t nil nil @@ -2492,7 +2647,7 @@ out. Only existing branches can be selected." (setq modules (-filter predicate modules))) (unless modules (user-error "No modules satisfying %s selected" predicate)))) - (if (> (length modules) 1) + (if (length> modules 1) (magit-confirm t nil (format "%s %%i modules" verb) nil modules) (list (magit-read-module-path (format "%s module" verb) predicate))))) diff --git a/elpa/magit-20220116.1908/magit-gitignore.el b/elpa/magit-20220518.2359/magit-gitignore.el similarity index 92% rename from elpa/magit-20220116.1908/magit-gitignore.el rename to elpa/magit-20220518.2359/magit-gitignore.el index 7ff64695..d53f1497 100644 --- a/elpa/magit-20220116.1908/magit-gitignore.el +++ b/elpa/magit-20220518.2359/magit-gitignore.el @@ -1,19 +1,16 @@ -;;; magit-gitignore.el --- intentionally untracked files -*- lexical-binding: t -*- +;;; magit-gitignore.el --- Intentionally untracked files -*- lexical-binding:t -*- -;; Copyright (C) 2008-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Jonas Bernoulli ;; Maintainer: Jonas Bernoulli ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Magit is free software; you can redistribute it and/or modify it +;; 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. +;; the Free Software Foundation, either version 3 of the License, 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 @@ -21,7 +18,7 @@ ;; 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. +;; along with Magit. If not, see . ;;; Commentary: @@ -121,7 +118,7 @@ Rules that are defined in that file affect all local repositories." (delete-dups (--mapcat (cons (concat "/" it) - (when-let ((ext (file-name-extension it))) + (and-let* ((ext (file-name-extension it))) (list (concat "/" (file-name-directory it) "*." ext) (concat "*." ext)))) (sort (nconc diff --git a/elpa/magit-20220116.1908/magit-log.el b/elpa/magit-20220518.2359/magit-log.el similarity index 87% rename from elpa/magit-20220116.1908/magit-log.el rename to elpa/magit-20220518.2359/magit-log.el index 3c9a12c1..16c4e277 100644 --- a/elpa/magit-20220116.1908/magit-log.el +++ b/elpa/magit-20220518.2359/magit-log.el @@ -1,19 +1,16 @@ -;;; magit-log.el --- inspect Git history -*- lexical-binding: t -*- +;;; magit-log.el --- Inspect Git history -*- lexical-binding:t -*- -;; Copyright (C) 2010-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Jonas Bernoulli ;; Maintainer: Jonas Bernoulli ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Magit is free software; you can redistribute it and/or modify it +;; 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. +;; the Free Software Foundation, either version 3 of the License, 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 @@ -21,7 +18,7 @@ ;; 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. +;; along with Magit. If not, see . ;;; Commentary: @@ -35,12 +32,15 @@ (require 'magit-diff) (declare-function magit-blob-visit "magit-files" (blob-or-file)) +(declare-function magit-cherry-apply "magit-sequence" (commit &optional args)) (declare-function magit-insert-head-branch-header "magit-status" (&optional branch)) (declare-function magit-insert-upstream-branch-header "magit-status" (&optional branch pull keyword)) (declare-function magit-read-file-from-rev "magit-files" (rev prompt &optional default)) +(declare-function magit-rebase--get-state-lines "magit-sequence" + (file)) (declare-function magit-show-commit "magit-diff" (arg1 &optional arg2 arg3 arg4)) (declare-function magit-reflog-format-subject "magit-reflog" (subject)) @@ -114,7 +114,7 @@ AUTHOR-WIDTH has to be an integer. When the name of the author :group 'magit-log :group 'magit-margin :type magit-log-margin--custom-type - :initialize 'magit-custom-initialize-reset + :initialize #'magit-custom-initialize-reset :set (apply-partially #'magit-margin-set-variable 'magit-log-mode)) (defcustom magit-log-margin-show-committer-date nil @@ -142,7 +142,7 @@ This is useful if you use really long branch names." :group 'magit-log :type 'boolean) -(defcustom magit-log-header-line-function 'magit-log-header-line-sentence +(defcustom magit-log-header-line-function #'magit-log-header-line-sentence "Function used to generate text shown in header line of log buffers." :package-version '(magit . "2.12.0") :group 'magit-log @@ -150,7 +150,7 @@ This is useful if you use really long branch names." (function-item magit-log-header-line-sentence) function)) -(defcustom magit-log-trace-definition-function 'magit-which-function +(defcustom magit-log-trace-definition-function #'magit-which-function "Function used to determine the function at point. This is used by the command `magit-log-trace-definition'. You should prefer `magit-which-function' over `which-function' @@ -246,7 +246,7 @@ AUTHOR-WIDTH has to be an integer. When the name of the author :group 'magit-log :group 'magit-margin :type magit-log-margin--custom-type - :initialize 'magit-custom-initialize-reset + :initialize #'magit-custom-initialize-reset :set-after '(magit-log-margin) :set (apply-partially #'magit-margin-set-variable 'magit-log-select-mode)) @@ -286,7 +286,7 @@ AUTHOR-WIDTH has to be an integer. When the name of the author :group 'magit-log :group 'magit-margin :type magit-log-margin--custom-type - :initialize 'magit-custom-initialize-reset + :initialize #'magit-custom-initialize-reset :set-after '(magit-log-margin) :set (apply-partially #'magit-margin-set-variable 'magit-cherry-mode)) @@ -437,23 +437,24 @@ the upstream isn't ahead of the current branch) show." ("-p" "Show diffs" ("-p" "--patch")) ;2 ("-s" "Show diffstats" "--stat")] ;2 [["Log" - ("l" "current" magit-log-current) - ("o" "other" magit-log-other) - ("h" "HEAD" magit-log-head)] + ("l" "current" magit-log-current) + ("h" "HEAD" magit-log-head) + ("u" "related" magit-log-related) + ("o" "other" magit-log-other)] ["" - ("L" "local branches" magit-log-branches) + ("L" "local branches" magit-log-branches) + ("b" "all branches" magit-log-all-branches) + ("a" "all references" magit-log-all) (7 "B" "matching branches" magit-log-matching-branches) - (7 "T" "matching tags" magit-log-matching-tags) - ("b" "all branches" magit-log-all-branches) - ("a" "all references" magit-log-all) - (7 "m" "merged" magit-log-merged)] + (7 "T" "matching tags" magit-log-matching-tags) + (7 "m" "merged" magit-log-merged)] ["Reflog" - ("r" "current" magit-reflog-current) - ("O" "other" magit-reflog-other) - ("H" "HEAD" magit-reflog-head)] + ("r" "current" magit-reflog-current) + ("H" "HEAD" magit-reflog-head) + ("O" "other" magit-reflog-other)] [:if (lambda () - (require 'magit-wip) - (magit--any-wip-mode-enabled-p)) + (and (fboundp 'magit--any-wip-mode-enabled-p) + (magit--any-wip-mode-enabled-p))) :description "Wiplog" ("i" "index" magit-wip-log-index) ("w" "worktree" magit-wip-log-worktree)] @@ -519,9 +520,9 @@ the upstream isn't ahead of the current branch) show." (cond ((not (eq transient-current-command 'magit-log-refresh)) (pcase major-mode - (`magit-reflog-mode + ('magit-reflog-mode (user-error "Cannot change log arguments in reflog buffers")) - (`magit-cherry-mode + ('magit-cherry-mode (user-error "Cannot change log arguments in cherry buffers"))) (transient-setup 'magit-log-refresh)) (t @@ -541,28 +542,28 @@ the upstream isn't ahead of the current branch) show." ;; long argument ("--max-count"). :shortarg "-n" :argument "-n" - :reader 'transient-read-number-N+) + :reader #'transient-read-number-N+) (transient-define-argument magit:--author () :description "Limit to author" :class 'transient-option :key "-A" :argument "--author=" - :reader 'magit-transient-read-person) + :reader #'magit-transient-read-person) (transient-define-argument magit-log:--since () :description "Limit to commits since" :class 'transient-option :key "=s" :argument "--since=" - :reader 'transient-read-date) + :reader #'transient-read-date) (transient-define-argument magit-log:--until () :description "Limit to commits until" :class 'transient-option :key "=u" :argument "--until=" - :reader 'transient-read-date) + :reader #'transient-read-date) (transient-define-argument magit-log:--*-order () :description "Order commits by" @@ -592,7 +593,7 @@ the upstream isn't ahead of the current branch) show." :description "Trace line evolution" :class 'transient-option :argument "-L" - :reader 'magit-read-file-trace) + :reader #'magit-read-file-trace) (defun magit-read-file-trace (&rest _ignored) (let ((file (magit-read-file-from-rev "HEAD" "File")) @@ -604,11 +605,11 @@ the upstream isn't ahead of the current branch) show." (defvar magit-log-read-revs-map (let ((map (make-sparse-keymap))) (set-keymap-parent map crm-local-completion-map) - (define-key map "\s" 'self-insert-command) + (define-key map "\s" #'self-insert-command) map)) (defun magit-log-read-revs (&optional use-current) - (or (and use-current (--when-let (magit-get-current-branch) (list it))) + (or (and use-current (and-let* ((buf (magit-get-current-branch))) (list buf))) (let ((crm-separator "\\(\\.\\.\\.?\\|[, ]\\)") (crm-local-completion-map magit-log-read-revs-map)) (split-string (magit-completing-read-multiple* @@ -634,6 +635,41 @@ one or more revs read from the minibuffer." (magit-log-arguments))) (magit-log-setup-buffer revs args files)) +;;;###autoload +(defun magit-log-head (&optional args files) + "Show log for `HEAD'." + (interactive (magit-log-arguments)) + (magit-log-setup-buffer (list "HEAD") args files)) + +;;;###autoload +(defun magit-log-related (revs &optional args files) + "Show log for the current branch, its upstream and its push target. +When the upstream is a local branch, then also show its own +upstream. When `HEAD' is detached, then show log for that, the +previously checked out branch and its upstream and push-target." + (interactive + (cons (let ((current (magit-get-current-branch)) + head rebase target upstream upup) + (unless current + (setq rebase (magit-rebase--get-state-lines "head-name")) + (cond (rebase + (setq rebase (magit-ref-abbrev rebase)) + (setq current rebase) + (setq head "HEAD")) + (t (setq current (magit-get-previous-branch))))) + (cond (current + (setq current + (magit--propertize-face current'magit-branch-local)) + (setq target (magit-get-push-branch current t)) + (setq upstream (magit-get-upstream-branch current)) + (when upstream + (setq upup (and (magit-local-branch-p upstream) + (magit-get-upstream-branch upstream))))) + (t (setq head "HEAD"))) + (delq nil (list current head target upstream upup))) + (magit-log-arguments))) + (magit-log-setup-buffer revs args files)) + ;;;###autoload (defun magit-log-other (revs &optional args files) "Show log for one or more revs read from the minibuffer. @@ -645,12 +681,6 @@ completion candidates." (magit-log-arguments))) (magit-log-setup-buffer revs args files)) -;;;###autoload -(defun magit-log-head (&optional args files) - "Show log for `HEAD'." - (interactive (magit-log-arguments)) - (magit-log-setup-buffer (list "HEAD") args files)) - ;;;###autoload (defun magit-log-branches (&optional args files) "Show log for all local branches and `HEAD'." @@ -728,7 +758,7 @@ restrict the log to the lines that the region touches." beg end) (setq args (cons (format "-L%s,%s:%s" beg end file) (cl-delete "-L" args :test - 'string-prefix-p))) + #'string-prefix-p))) (setq file nil)) args) (and file (list file)) @@ -749,7 +779,7 @@ restrict the log to the lines that the region touches." (magit-log-setup-buffer (list rev) (cons (format "-L:%s%s:%s" - (replace-regexp-in-string ":" "\\:" (regexp-quote fn) nil t) + (string-replace ":" "\\:" (regexp-quote fn)) (if (derived-mode-p 'lisp-mode 'emacs-lisp-mode) ;; Git doesn't treat "-" the same way as ;; "_", leading to false-positives such as @@ -762,7 +792,7 @@ restrict the log to the lines that the region touches." "") file) (cl-delete "-L" (car (magit-log-arguments)) - :test 'string-prefix-p)) + :test #'string-prefix-p)) nil magit-log-buffer-file-locked)) (defun magit-diff-trace-definition () @@ -788,7 +818,7 @@ https://github.com/mhagger/git-when-merged." (list commit (magit-read-other-branch "Merged into" commit))) (magit-log-arguments))) - (unless (executable-find "git-when-merged") + (unless (compat-executable-find "git-when-merged" t) (user-error "This command requires git-when-merged (%s)" "https://github.com/mhagger/git-when-merged")) (let (exit m) @@ -801,7 +831,7 @@ https://github.com/mhagger/git-when-merged." (if (zerop exit) (magit-log-setup-buffer (list (format "%s^1..%s" m m)) args files nil commit) - (setq m (string-trim-left (substring m (string-match " " m)))) + (setq m (string-trim m)) (if (equal m "Commit is directly on this branch.") (let* ((from (concat commit "~10")) (to (- (car (magit-rev-diff-count branch commit)) 10)) @@ -849,9 +879,9 @@ limit. Otherwise set it to 256." (magit-refresh)) (defun magit-log-get-commit-limit () - (--when-let (--first (string-match "^-n\\([0-9]+\\)?$" it) - magit-buffer-log-args) - (string-to-number (match-string 1 it)))) + (and-let* ((str (--first (string-match "^-n\\([0-9]+\\)?$" it) + magit-buffer-log-args))) + (string-to-number (match-string 1 str)))) ;;;; Mode Commands @@ -903,7 +933,7 @@ of the current repository first; creating it if necessary." (with-current-buffer (cond ((derived-mode-p 'magit-log-mode) (current-buffer)) - ((when-let ((buf (magit-get-mode-buffer 'magit-log-mode))) + ((and-let* ((buf (magit-get-mode-buffer 'magit-log-mode))) (pop-to-buffer-same-window buf))) (t (apply #'magit-log-all-branches (magit-log-arguments)))) @@ -965,14 +995,14 @@ of the current repository first; creating it if necessary." (defvar magit-log-mode-map (let ((map (make-sparse-keymap))) (set-keymap-parent map magit-mode-map) - (define-key map (kbd "C-c C-b") 'magit-go-backward) - (define-key map (kbd "C-c C-f") 'magit-go-forward) - (define-key map (kbd "C-c C-n") 'magit-log-move-to-parent) - (define-key map "j" 'magit-log-move-to-revision) - (define-key map "=" 'magit-log-toggle-commit-limit) - (define-key map "+" 'magit-log-double-commit-limit) - (define-key map "-" 'magit-log-half-commit-limit) - (define-key map "q" 'magit-log-bury-buffer) + (define-key map (kbd "C-c C-b") #'magit-go-backward) + (define-key map (kbd "C-c C-f") #'magit-go-forward) + (define-key map (kbd "C-c C-n") #'magit-log-move-to-parent) + (define-key map "j" #'magit-log-move-to-revision) + (define-key map "=" #'magit-log-toggle-commit-limit) + (define-key map "+" #'magit-log-double-commit-limit) + (define-key map "-" #'magit-log-half-commit-limit) + (define-key map "q" #'magit-log-bury-buffer) map) "Keymap for `magit-log-mode'.") @@ -994,10 +1024,7 @@ Type \\[magit-reset] to reset `HEAD' to the commit at point. \\{magit-log-mode-map}" :group 'magit-log (hack-dir-local-variables-non-file-buffer) - (setq imenu-prev-index-position-function - 'magit-imenu--log-prev-index-position-function) - (setq imenu-extract-index-name-function - 'magit-imenu--log-extract-index-name-function)) + (setq magit--imenu-item-types 'commit)) (put 'magit-log-mode 'magit-log-default-arguments '("--graph" "-n256" "--decorate")) @@ -1021,7 +1048,7 @@ Type \\[magit-reset] to reset `HEAD' to the commit at point. (files magit-buffer-log-files)) (magit-set-header-line-format (funcall magit-log-header-line-function revs args files)) - (unless (= (length files) 1) + (unless (length= files 1) (setq args (remove "--follow" args))) (when (and (car magit-log-remove-graph-args) (--any-p (string-match-p @@ -1030,19 +1057,20 @@ Type \\[magit-reset] to reset `HEAD' to the commit at point. (setq args (remove "--graph" args))) (unless (member "--graph" args) (setq args (remove "--color" args))) - (when-let ((limit (magit-log-get-commit-limit)) - (limit (* 2 limit)) ; increase odds for complete graph - (count (and (= (length revs) 1) - (> limit 1024) ; otherwise it's fast enough - (setq revs (car revs)) - (not (string-match-p "\\.\\." revs)) - (not (member revs '("--all" "--branches"))) - (-none-p (lambda (arg) - (--any-p (string-prefix-p it arg) - magit-log-disable-graph-hack-args)) - args) - (magit-git-string "rev-list" "--count" - "--first-parent" args revs)))) + (when-let* ((limit (magit-log-get-commit-limit)) + (limit (* 2 limit)) ; increase odds for complete graph + (count (and (length= revs 1) + (> limit 1024) ; otherwise it's fast enough + (setq revs (car revs)) + (not (string-search ".." revs)) + (not (member revs '("--all" "--branches"))) + (-none-p (lambda (arg) + (--any-p + (string-prefix-p it arg) + magit-log-disable-graph-hack-args)) + args) + (magit-git-string "rev-list" "--count" + "--first-parent" args revs)))) (setq revs (if (< (string-to-number count) limit) revs (format "%s~%s..%s" revs limit revs)))) @@ -1058,7 +1086,7 @@ Type \\[magit-reset] to reset `HEAD' to the commit at point. (defun magit-log-header-line-arguments (revs args files) "Return string describing some of the used arguments." (mapconcat (lambda (arg) - (if (string-match-p " " arg) + (if (string-search " " arg) (prin1 arg) arg)) `("git" "log" ,@args ,@revs "--" ,@files) @@ -1071,7 +1099,7 @@ Type \\[magit-reset] to reset `HEAD' to the commit at point. (and (member "--reverse" args) " in reverse") (and files (concat " touching " - (mapconcat 'identity files " "))) + (mapconcat #'identity files " "))) (--some (and (string-prefix-p "-L" it) (concat " " it)) args))) @@ -1110,16 +1138,28 @@ Do not add this to a hook variable." args) "--use-mailmap" "--no-prefix" revs "--" files))) +(cl-defmethod magit-menu-common-value ((_section magit-commit-section)) + (or (magit-diff--region-range) + (oref (magit-current-section) value))) + (defvar magit-commit-section-map (let ((map (make-sparse-keymap))) - (define-key map [remap magit-visit-thing] 'magit-show-commit) - (define-key map "a" 'magit-cherry-apply) + ;; The second remapping overrides the first but we still get two menu + ;; items, though only one of them will be available at any given time. + (magit-menu-set map [magit-visit-thing] + #'magit-diff-range "Diff %x" + '(:visible (region-active-p))) + (magit-menu-set map [magit-visit-thing] + #'magit-show-commit "Show commit %x" + '(:visible (not (region-active-p)))) + (magit-menu-set map [magit-cherry-apply] + #'magit-cherry-apply "Apply %x") map) "Keymap for `commit' sections.") (defvar magit-module-commit-section-map (let ((map (make-sparse-keymap))) - (define-key map [remap magit-visit-thing] 'magit-show-commit) + (set-keymap-parent map magit-commit-section-map) map) "Keymap for `module-commit' sections.") @@ -1129,7 +1169,7 @@ Do not add this to a hook variable." ;; ++header is used. (concat "^" "\\(?4:[-_/|\\*o<>. ]*\\)" ; graph - "\\(?1:[0-9a-fA-F]+\\)? " ; sha1 + "\\(?1:[0-9a-fA-F]+\\)? " ; hash "\\(?3:[^ \n]+\\)? " ; refs "\\(?7:[BGUXYREN]\\)? " ; gpg "\\(?5:[^ \n]*\\) " ; author @@ -1141,31 +1181,31 @@ Do not add this to a hook variable." (defconst magit-log-cherry-re (concat "^" "\\(?8:[-+]\\) " ; cherry - "\\(?1:[0-9a-fA-F]+\\) " ; sha1 + "\\(?1:[0-9a-fA-F]+\\) " ; hash "\\(?2:.*\\)$")) ; msg (defconst magit-log-module-re (concat "^" "\\(?:\\(?11:[<>]\\) \\)?" ; side - "\\(?1:[0-9a-fA-F]+\\) " ; sha1 + "\\(?1:[0-9a-fA-F]+\\) " ; hash "\\(?2:.*\\)$")) ; msg (defconst magit-log-bisect-vis-re (concat "^" "\\(?4:[-_/|\\*o<>. ]*\\)" ; graph - "\\(?1:[0-9a-fA-F]+\\)?\0" ; sha1 + "\\(?1:[0-9a-fA-F]+\\)?\0" ; hash "\\(?3:[^\0\n]+\\)?\0" ; refs "\\(?2:.*\\)$")) ; msg (defconst magit-log-bisect-log-re (concat "^# " "\\(?3:[^: \n]+:\\) " ; "refs" - "\\[\\(?1:[^]\n]+\\)\\] " ; sha1 + "\\[\\(?1:[^]\n]+\\)\\] " ; hash "\\(?2:.*\\)$")) ; msg (defconst magit-log-reflog-re (concat "^" - "\\(?1:[^\0\n]+\\)\0" ; sha1 + "\\(?1:[^\0\n]+\\)\0" ; hash "\\(?5:[^\0\n]*\\)\0" ; author "\\(?:\\(?:[^@\n]+@{\\(?6:[^}\n]+\\)}\0" ; date "\\(?10:merge \\|autosave \\|restart \\|[^:\n]+: \\)?" ; refsub @@ -1178,17 +1218,17 @@ Do not add this to a hook variable." (defconst magit-log-stash-re (concat "^" - "\\(?1:[^\0\n]+\\)\0" ; "sha1" + "\\(?1:[^\0\n]+\\)\0" ; "hash" "\\(?5:[^\0\n]*\\)\0" ; author "\\(?6:[^\0\n]+\\)\0" ; date "\\(?2:.*\\)$")) ; msg (defvar magit-log-count nil) -(defvar magit-log-format-message-function 'magit-log-propertize-keywords) +(defvar magit-log-format-message-function #'magit-log-propertize-keywords) (defun magit-log-wash-log (style args) - (setq args (-flatten args)) + (setq args (flatten-tree args)) (when (and (member "--graph" args) (member "--color" args)) (let ((ansi-color-apply-face-function @@ -1201,7 +1241,7 @@ Do not add this to a hook variable." (let ((magit-log-count 0)) (when (looking-at "^\\.\\.\\.") (magit-delete-line)) - (magit-wash-sequence (apply-partially 'magit-log-wash-rev style + (magit-wash-sequence (apply-partially #'magit-log-wash-rev style (magit-abbrev-length))) (if (derived-mode-p 'magit-log-mode 'magit-reflog-mode) (when (eq magit-log-count (magit-log-get-commit-limit)) @@ -1221,13 +1261,13 @@ Do not add this to a hook variable." (when (derived-mode-p 'magit-log-mode 'magit-reflog-mode) (cl-incf magit-log-count)) (looking-at (pcase style - (`log magit-log-heading-re) - (`cherry magit-log-cherry-re) - (`module magit-log-module-re) - (`reflog magit-log-reflog-re) - (`stash magit-log-stash-re) - (`bisect-vis magit-log-bisect-vis-re) - (`bisect-log magit-log-bisect-log-re))) + ('log magit-log-heading-re) + ('cherry magit-log-cherry-re) + ('module magit-log-module-re) + ('reflog magit-log-reflog-re) + ('stash magit-log-stash-re) + ('bisect-vis magit-log-bisect-vis-re) + ('bisect-log magit-log-bisect-log-re))) (magit-bind-match-strings (hash msg refs graph author date gpg cherry _ refsub side) nil (setq msg (substring-no-properties msg)) @@ -1246,9 +1286,9 @@ Do not add this to a hook variable." (cl-return-from magit-log-wash-rev t)) (magit-insert-section section (commit hash) (pcase style - (`stash (oset section type 'stash)) - (`module (oset section type 'module-commit)) - (`bisect-log (setq hash (magit-rev-parse "--short" hash)))) + ('stash (oset section type 'stash)) + ('module (oset section type 'module-commit)) + ('bisect-log (setq hash (magit-rev-parse "--short" hash)))) (setq hash (propertize hash 'font-lock-face (pcase (and gpg (aref gpg 0)) (?G 'magit-signature-good) @@ -1287,7 +1327,8 @@ Do not add this to a hook variable." (insert (format "%-2s " (1- magit-log-count))) (when refsub (insert (magit-reflog-format-subject - (substring refsub 0 (if (string-match-p ":" refsub) -2 -1)))))) + (substring refsub 0 + (if (string-search ":" refsub) -2 -1)))))) (when msg (insert (funcall magit-log-format-message-function hash msg))) (when (and refs magit-log-show-refname-after-summary) @@ -1395,8 +1436,8 @@ If there is no revision buffer in the same frame, then do nothing." (add-hook 'magit-section-movement-hook #'magit-log-maybe-update-revision-buffer) (defun magit--maybe-update-revision-buffer () - (when-let ((commit (magit-section-value-if 'commit)) - (buffer (magit-get-mode-buffer 'magit-revision-mode nil t))) + (when-let* ((commit (magit-section-value-if 'commit)) + (buffer (magit-get-mode-buffer 'magit-revision-mode nil t))) (if magit--update-revision-buffer (setq magit--update-revision-buffer (list commit buffer)) (setq magit--update-revision-buffer (list commit buffer)) @@ -1421,11 +1462,11 @@ If there is no blob buffer in the same frame, then do nothing." (magit--maybe-update-blob-buffer))) (defun magit--maybe-update-blob-buffer () - (when-let ((commit (magit-section-value-if 'commit)) - (buffer (--first (with-current-buffer it - (eq revert-buffer-function - 'magit-revert-rev-file-buffer)) - (mapcar #'window-buffer (window-list))))) + (when-let* ((commit (magit-section-value-if 'commit)) + (buffer (--first (with-current-buffer it + (eq revert-buffer-function + 'magit-revert-rev-file-buffer)) + (mapcar #'window-buffer (window-list))))) (if magit--update-blob-buffer (setq magit--update-blob-buffer (list commit buffer)) (setq magit--update-blob-buffer (list commit buffer)) @@ -1542,13 +1583,13 @@ The shortstat style is experimental and rather slow." (defvar magit-log-select-mode-map (let ((map (make-sparse-keymap))) (set-keymap-parent map magit-log-mode-map) - (define-key map (kbd "C-c C-b") 'undefined) - (define-key map (kbd "C-c C-f") 'undefined) - (define-key map (kbd ".") 'magit-log-select-pick) - (define-key map (kbd "e") 'magit-log-select-pick) - (define-key map (kbd "C-c C-c") 'magit-log-select-pick) - (define-key map (kbd "q") 'magit-log-select-quit) - (define-key map (kbd "C-c C-k") 'magit-log-select-quit) + (define-key map (kbd "C-c C-b") #'undefined) + (define-key map (kbd "C-c C-f") #'undefined) + (define-key map (kbd ".") #'magit-log-select-pick) + (define-key map (kbd "e") #'magit-log-select-pick) + (define-key map (kbd "C-c C-c") #'magit-log-select-pick) + (define-key map (kbd "q") #'magit-log-select-quit) + (define-key map (kbd "C-c C-k") #'magit-log-select-quit) map) "Keymap for `magit-log-select-mode'.") @@ -1650,8 +1691,8 @@ Call `magit-log-select-quit-function' if set." (defvar magit-cherry-mode-map (let ((map (make-sparse-keymap))) (set-keymap-parent map magit-mode-map) - (define-key map "q" 'magit-log-bury-buffer) - (define-key map "L" 'magit-margin-settings) + (define-key map "q" #'magit-log-bury-buffer) + (define-key map "L" #'magit-margin-settings) map) "Keymap for `magit-cherry-mode'.") @@ -1668,8 +1709,7 @@ Type \\[magit-cherry-pick] to apply the commit at point. \\{magit-cherry-mode-map}" :group 'magit-log (hack-dir-local-variables-non-file-buffer) - (setq imenu-create-index-function - 'magit-imenu--cherry-create-index-function)) + (setq magit--imenu-group-types 'cherries)) (defun magit-cherry-setup-buffer (head upstream) (magit-setup-buffer #'magit-cherry-mode nil @@ -1710,7 +1750,7 @@ Type \\[magit-cherry-pick] to apply the commit at point. "Insert commit sections into a `magit-cherry-mode' buffer." (magit-insert-section (cherries) (magit-insert-heading "Cherry commits:") - (magit-git-wash (apply-partially 'magit-log-wash-log 'cherry) + (magit-git-wash (apply-partially #'magit-log-wash-log 'cherry) "cherry" "-v" "--abbrev" magit-buffer-upstream magit-buffer-refname))) @@ -1718,12 +1758,30 @@ Type \\[magit-cherry-pick] to apply the commit at point. ;;; Log Sections ;;;; Standard Log Sections +(defvar magit-log-section-map + (let ((map (make-sparse-keymap))) + (magit-menu-set map [magit-visit-thing] #'magit-diff-dwim "Visit diff") + map) + "Keymap for log sections. +The classes `magit-{unpulled,unpushed,unmerged}-section' derive +from the abstract `magit-log-section' class. Accordingly this +keymap is the parent of their keymaps.") + (defvar magit-unpulled-section-map (let ((map (make-sparse-keymap))) - (define-key map [remap magit-visit-thing] 'magit-diff-dwim) + (set-keymap-parent map magit-log-section-map) map) "Keymap for `unpulled' sections.") +(cl-defmethod magit-section-ident-value ((section magit-unpulled-section)) + "\"..@{push}\" cannot be used as the value because that is +ambiguous if `push.default' does not allow a 1:1 mapping, and +many commands would fail because of that. But here that does +not matter and we need an unique value so we use that string +in the pushremote case." + (let ((value (oref section value))) + (if (equal value "..@{upstream}") value "..@{push}"))) + (magit-define-section-jumper magit-jump-to-unpulled-from-upstream "Unpulled from @{upstream}" unpulled "..@{upstream}") @@ -1756,10 +1814,19 @@ Type \\[magit-cherry-pick] to apply the commit at point. (defvar magit-unpushed-section-map (let ((map (make-sparse-keymap))) - (define-key map [remap magit-visit-thing] 'magit-diff-dwim) + (set-keymap-parent map magit-log-section-map) map) "Keymap for `unpushed' sections.") +(cl-defmethod magit-section-ident-value ((section magit-unpushed-section)) + "\"..@{push}\" cannot be used as the value because that is +ambiguous if `push.default' does not allow a 1:1 mapping, and +many commands would fail because of that. But here that does +not matter and we need an unique value so we use that string +in the pushremote case." + (let ((value (oref section value))) + (if (equal value "@{upstream}..") value "@{push}.."))) + (magit-define-section-jumper magit-jump-to-unpushed-to-upstream "Unpushed to @{upstream}" unpushed "@{upstream}..") @@ -1819,7 +1886,8 @@ Show the last `magit-log-section-commit-count' commits." (magit-log-insert-child-count))))) (defun magit--insert-pushremote-log-p () - (magit--with-refresh-cache 'magit--insert-pushremote-log-p + (magit--with-refresh-cache + (cons default-directory 'magit--insert-pushremote-log-p) (not (and (equal (magit-get-push-branch) (magit-get-upstream-branch)) (or (memq 'magit-insert-unpulled-from-upstream @@ -1831,7 +1899,7 @@ Show the last `magit-log-section-commit-count' commits." (when magit-section-show-child-count (let ((count (length (oref magit-insert-section--current children)))) (when (> count 0) - (when (= count (magit-log-get-commit-limit)) + (when (eq count (magit-log-get-commit-limit)) (setq count (format "%s+" count))) (save-excursion (goto-char (- (oref magit-insert-section--current content) 2)) @@ -1849,7 +1917,7 @@ not shared with any local commit) with \"+\", and all others with (when (magit-git-success "rev-parse" "@{upstream}") (magit-insert-section (unpulled "..@{upstream}") (magit-insert-heading "Unpulled commits:") - (magit-git-wash (apply-partially 'magit-log-wash-log 'cherry) + (magit-git-wash (apply-partially #'magit-log-wash-log 'cherry) "cherry" "-v" (magit-abbrev-arg) (magit-get-current-branch) "@{upstream}")))) @@ -1862,7 +1930,7 @@ all others with \"-\"." (when (magit-git-success "rev-parse" "@{upstream}") (magit-insert-section (unpushed "@{upstream}..") (magit-insert-heading "Unpushed commits:") - (magit-git-wash (apply-partially 'magit-log-wash-log 'cherry) + (magit-git-wash (apply-partially #'magit-log-wash-log 'cherry) "cherry" "-v" (magit-abbrev-arg) "@{upstream}")))) ;;; _ diff --git a/elpa/magit-20220116.1908/magit-margin.el b/elpa/magit-20220518.2359/magit-margin.el similarity index 81% rename from elpa/magit-20220116.1908/magit-margin.el rename to elpa/magit-20220518.2359/magit-margin.el index 4cd8074f..b7e0a67c 100644 --- a/elpa/magit-20220116.1908/magit-margin.el +++ b/elpa/magit-20220518.2359/magit-margin.el @@ -1,19 +1,16 @@ -;;; magit-margin.el --- margins in Magit buffers -*- lexical-binding: t -*- +;;; magit-margin.el --- Margins in Magit buffers -*- lexical-binding:t -*- -;; Copyright (C) 2010-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Jonas Bernoulli ;; Maintainer: Jonas Bernoulli ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Magit is free software; you can redistribute it and/or modify it +;; 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. +;; the Free Software Foundation, either version 3 of the License, 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 @@ -21,7 +18,7 @@ ;; 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. +;; along with Magit. If not, see . ;;; Commentary: @@ -32,10 +29,12 @@ ;;; Code: -(require 'magit-section) +(require 'magit-base) (require 'magit-transient) (require 'magit-mode) +;;; Options + (defgroup magit-margin nil "Information Magit displays in the margin. @@ -77,6 +76,9 @@ does not carry to other options." (setcar magit-buffer-margin (not (magit-buffer-margin-p))) (magit-set-buffer-margin)) +(defvar magit-margin-default-time-format nil + "See https://github.com/magit/magit/pull/4605.") + (defun magit-cycle-margin-style () "Cycle style used for the Magit margin." (interactive) @@ -85,9 +87,10 @@ does not carry to other options." ;; This is only suitable for commit margins (there are not others). (setf (cadr magit-buffer-margin) (pcase (cadr magit-buffer-margin) - (`age 'age-abbreviated) - (`age-abbreviated - (let ((default (cadr (symbol-value (magit-margin-option))))) + ('age 'age-abbreviated) + ('age-abbreviated + (let ((default (or magit-margin-default-time-format + (cadr (symbol-value (magit-margin-option)))))) (if (stringp default) default "%Y-%m-%d %H:%M "))) (_ 'age))) (magit-set-buffer-margin nil t)) @@ -108,14 +111,14 @@ does not carry to other options." (defun magit-margin-option () (pcase major-mode - (`magit-cherry-mode 'magit-cherry-margin) - (`magit-log-mode 'magit-log-margin) - (`magit-log-select-mode 'magit-log-select-margin) - (`magit-reflog-mode 'magit-reflog-margin) - (`magit-refs-mode 'magit-refs-margin) - (`magit-stashes-mode 'magit-stashes-margin) - (`magit-status-mode 'magit-status-margin) - (`forge-notifications-mode 'magit-status-margin))) + ('magit-cherry-mode 'magit-cherry-margin) + ('magit-log-mode 'magit-log-margin) + ('magit-log-select-mode 'magit-log-select-margin) + ('magit-reflog-mode 'magit-reflog-margin) + ('magit-refs-mode 'magit-refs-margin) + ('magit-stashes-mode 'magit-stashes-margin) + ('magit-status-mode 'magit-status-margin) + ('forge-notifications-mode 'magit-status-margin))) (defun magit-set-buffer-margin (&optional reset refresh) (when-let ((option (magit-margin-option))) @@ -133,9 +136,9 @@ does not carry to other options." (magit-set-window-margin window) (if enable (add-hook 'window-configuration-change-hook - 'magit-set-window-margin nil t) + #'magit-set-window-margin nil t) (remove-hook 'window-configuration-change-hook - 'magit-set-window-margin t)))) + #'magit-set-window-margin t)))) (when (and enable (or refresh magit-set-buffer-margin-refresh)) (magit-refresh-buffer)))))) @@ -219,14 +222,14 @@ English.") (defun magit--age (date &optional abbreviate) (cl-labels ((fn (age spec) - (pcase-let ((`(,char ,unit ,units ,weight) (car spec))) - (let ((cnt (round (/ age weight 1.0)))) - (if (or (not (cdr spec)) - (>= (/ age weight) 1)) - (list cnt (cond (abbreviate char) - ((= cnt 1) unit) - (t units))) - (fn age (cdr spec))))))) + (pcase-let ((`(,char ,unit ,units ,weight) (car spec))) + (let ((cnt (round (/ age weight 1.0)))) + (if (or (not (cdr spec)) + (>= (/ age weight) 1)) + (list cnt (cond (abbreviate char) + ((= cnt 1) unit) + (t units))) + (fn age (cdr spec))))))) (fn (abs (- (float-time) (if (stringp date) (string-to-number date) diff --git a/elpa/magit-20220116.1908/magit-merge.el b/elpa/magit-20220518.2359/magit-merge.el similarity index 94% rename from elpa/magit-20220116.1908/magit-merge.el rename to elpa/magit-20220518.2359/magit-merge.el index 470cac96..ead4d21d 100644 --- a/elpa/magit-20220116.1908/magit-merge.el +++ b/elpa/magit-20220518.2359/magit-merge.el @@ -1,19 +1,16 @@ -;;; magit-merge.el --- merge functionality -*- lexical-binding: t -*- +;;; magit-merge.el --- Merge functionality -*- lexical-binding:t -*- -;; Copyright (C) 2010-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Jonas Bernoulli ;; Maintainer: Jonas Bernoulli ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Magit is free software; you can redistribute it and/or modify it +;; 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. +;; the Free Software Foundation, either version 3 of the License, 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 @@ -21,7 +18,7 @@ ;; 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. +;; along with Magit. If not, see . ;;; Commentary: @@ -146,7 +143,7 @@ then also remove the respective remote branch." (or (magit-get-current-branch) (magit-rev-parse "HEAD"))) nil - (when-let ((upstream (magit-get-upstream-branch)) + (and-let* ((upstream (magit-get-upstream-branch)) (upstream (cdr (magit-split-branch-name upstream)))) (and (magit-branch-p upstream) upstream))) (magit-merge-arguments))) @@ -255,7 +252,9 @@ then also remove the respective remote branch." (user-error "Quit"))))) (pcase (cons arg (cddr (car (magit-file-status file)))) ((or `("--ours" ?D ,_) - `("--theirs" ,_ ?D)) + '("--ours" ?U ?A) + `("--theirs" ,_ ?D) + '("--theirs" ?A ?U)) (magit-run-git "rm" "--" file)) (_ (if (equal arg "--merge") ;; This fails if the file was deleted on one @@ -292,7 +291,7 @@ then also remove the respective remote branch." (defvar magit-unmerged-section-map (let ((map (make-sparse-keymap))) - (define-key map [remap magit-visit-thing] 'magit-diff-dwim) + (set-keymap-parent map magit-log-section-map) map) "Keymap for `unmerged' sections.") diff --git a/elpa/magit-20220116.1908/magit-mode.el b/elpa/magit-20220518.2359/magit-mode.el similarity index 78% rename from elpa/magit-20220116.1908/magit-mode.el rename to elpa/magit-20220518.2359/magit-mode.el index f32bf0d7..213c6168 100644 --- a/elpa/magit-20220116.1908/magit-mode.el +++ b/elpa/magit-20220518.2359/magit-mode.el @@ -1,19 +1,16 @@ -;;; magit-mode.el --- create and refresh Magit buffers -*- lexical-binding: t -*- +;;; magit-mode.el --- Create and refresh Magit buffers -*- lexical-binding:t -*- -;; Copyright (C) 2010-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Jonas Bernoulli ;; Maintainer: Jonas Bernoulli ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Magit is free software; you can redistribute it and/or modify it +;; 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. +;; the Free Software Foundation, either version 3 of the License, 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 @@ -21,7 +18,7 @@ ;; 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. +;; along with Magit. If not, see . ;;; Commentary: @@ -31,30 +28,13 @@ ;;; Code: -(require 'magit-section) +(require 'magit-base) (require 'magit-git) (require 'format-spec) (require 'help-mode) (require 'transient) -;; For `magit-display-buffer-fullcolumn-most-v1' from `git-commit' -(defvar git-commit-mode) -;; For `magit-refresh' -(defvar magit-post-commit-hook-commands) -(defvar magit-post-stage-hook-commands) -(defvar magit-post-unstage-hook-commands) -;; For `magit-refresh' and `magit-refresh-all' -(declare-function magit-auto-revert-buffers "magit-autorevert" ()) -;; For `magit-refresh-buffer' -(declare-function magit-process-unset-mode-line-error-status "magit-process" ()) -;; For `magit-refresh-get-relative-position' -(declare-function magit-hunk-section-p "magit-diff" (section) t) -;; For `magit-mode-setup-internal' -(declare-function magit-status-goto-initial-section "magit-status" ()) -;; For `magit-mode' from `bookmark' -(defvar bookmark-make-record-function) - ;;; Options (defcustom magit-mode-hook @@ -96,7 +76,11 @@ inside your function." :type 'hook :options '(magit-maybe-save-repository-buffers)) -(defcustom magit-post-refresh-hook nil +(defcustom magit-post-refresh-hook + '(magit-auto-revert-buffers + magit-run-post-commit-hook + magit-run-post-stage-hook + magit-run-post-unstage-hook) "Hook run after refreshing in `magit-refresh'. This hook, or `magit-pre-refresh-hook', should be used @@ -107,9 +91,13 @@ To run a function with a particular buffer current, use inside your function." :package-version '(magit . "2.4.0") :group 'magit-refresh - :type 'hook) + :type 'hook + :options '(magit-auto-revert-buffers + magit-run-post-commit-hook + magit-run-post-stage-hook + magit-run-post-unstage-hook)) -(defcustom magit-display-buffer-function 'magit-display-buffer-traditional +(defcustom magit-display-buffer-function #'magit-display-buffer-traditional "The function used to display a Magit buffer. All Magit buffers (buffers whose major-modes derive from @@ -130,7 +118,7 @@ which in turn uses the function specified here." :package-version '(magit . "2.3.0") :group 'magit-buffers :type 'hook - :get 'magit-hook-custom-get + :get #'magit-hook-custom-get :options '(magit-save-window-configuration)) (defcustom magit-post-display-buffer-hook '(magit-maybe-set-dedicated) @@ -138,11 +126,11 @@ which in turn uses the function specified here." :package-version '(magit . "2.3.0") :group 'magit-buffers :type 'hook - :get 'magit-hook-custom-get + :get #'magit-hook-custom-get :options '(magit-maybe-set-dedicated)) (defcustom magit-generate-buffer-name-function - 'magit-generate-buffer-name-default-function + #'magit-generate-buffer-name-default-function "The function used to generate the name for a Magit buffer." :package-version '(magit . "2.3.0") :group 'magit-buffers @@ -197,7 +185,7 @@ support additional %-sequences." :group 'magit-buffers :type 'boolean) -(defcustom magit-bury-buffer-function 'magit-mode-quit-window +(defcustom magit-bury-buffer-function #'magit-mode-quit-window "The function used to bury or kill the current Magit buffer." :package-version '(magit . "3.2.0") :group 'magit-buffers @@ -336,6 +324,7 @@ recommended value." (defvar magit-mode-map (let ((map (make-sparse-keymap))) (set-keymap-parent map magit-section-mode-map) + ;; Don't function-quote but make sure all commands are autoloaded. (define-key map [C-return] 'magit-visit-thing) (define-key map (kbd "RET") 'magit-visit-thing) (define-key map (kbd "M-TAB") 'magit-dired-jump) @@ -403,6 +392,7 @@ recommended value." (define-key map "%" 'magit-worktree) (define-key map "$" 'magit-process-buffer) (define-key map "!" 'magit-run) + (define-key map ">" 'magit-sparse-checkout) (define-key map (kbd "C-c C-c") 'magit-dispatch) (define-key map (kbd "C-c C-e") 'magit-edit-thing) (define-key map (kbd "C-c C-o") 'magit-browse-thing) @@ -448,7 +438,8 @@ which visits the thing at point using `browse-url'." (interactive) (user-error "There is no thing at point that could be browsed")) -(defun magit-help () +;;;###autoload +(defun magit-info () "Visit the Magit manual." (interactive) (info "magit")) @@ -460,53 +451,62 @@ which visits the thing at point using `browse-url'." (easy-menu-define magit-mode-menu magit-mode-map "Magit menu" + ;; Similar to `magit-dispatch' but exclude: + ;; - commands that are available from context menus: + ;; apply, reverse, discard, stage, unstage, + ;; cherry-pick, revert, reset, + ;; describe-section + ;; - commands that are available from submenus: + ;; git-command, ediff-dwim + ;; - and: refresh-all, status-jump, status-quick. '("Magit" - ["Refresh" magit-refresh t] - ["Refresh all" magit-refresh-all t] + "---" "Inspect" + [" Bisect..." magit-bisect t] + [" Cherries..." magit-cherry t] + [" Diff..." magit-diff t] + [" Ediff..." magit-ediff t] + [" Log..." magit-log t] + [" References..." magit-show-refs t] + "---" "Manipulate" + [" Commit..." magit-commit t] + [" Stash..." magit-stash t] + [" Tag..." magit-tag t] "---" - ["Stage" magit-stage t] - ["Stage modified" magit-stage-modified t] - ["Unstage" magit-unstage t] - ["Reset index" magit-reset-index t] - ["Commit" magit-commit t] - ["Add log entry" magit-commit-add-log t] - ["Tag" magit-tag-create t] + [" Branch..." magit-branch t] + [" Remote..." magit-remote t] "---" - ["Diff working tree" magit-diff-working-tree t] - ["Diff" magit-diff t] - ("Log" - ["Log" magit-log-other t] - ["Reflog" magit-reflog-other t] - ["Extended..." magit-log t]) + [" Merge..." magit-merge t] + [" Rebase..." magit-rebase t] + "---" "Transfer" + [" Fetch..." magit-fetch t] + [" Pull..." magit-pull t] + [" Push..." magit-push t] + "---" "Setup" + [" Clone..." magit-clone t] + [" Ignore..." magit-gitignore t] + [" Init..." magit-init t] "---" - ["Cherry pick" magit-cherry-pick t] - ["Revert commit" magit-revert t] + ("Advanced" + ["Run..." magit-run t] + "---" + ["Apply patches..." magit-am t] + ["Format patches..." magit-patch t] + "---" + ["Note..." magit-notes t] + "---" + ["Submodule..." magit-submodule t] + ["Subtree..." magit-subtree t] + ["Worktree..." magit-worktree t]) "---" - ["Ignore at toplevel" magit-gitignore-in-topdir t] - ["Ignore in subdirectory" magit-gitignore-in-subdir t] - ["Discard" magit-discard t] - ["Reset head and index" magit-reset-mixed t] - ["Stash" magit-stash-both t] - ["Snapshot" magit-snapshot-both t] + ["Show command dispatcher..." magit-dispatch t] + ["Show manual" magit-help t] + ["Show another buffer" magit-display-repository-buffer t] "---" - ["Branch..." magit-checkout t] - ["Merge" magit-merge t] - ["Ediff resolve" magit-ediff-resolve t] - ["Rebase..." magit-rebase t] - "---" - ["Push" magit-push t] - ["Pull" magit-pull-branch t] - ["Remote update" magit-fetch-all t] - ("Submodule" - ["Submodule update" magit-submodule-update t] - ["Submodule update and init" magit-submodule-setup t] - ["Submodule init" magit-submodule-init t] - ["Submodule sync" magit-submodule-sync t]) - "---" - ("Extensions") - "---" - ["Display Git output" magit-process-buffer t] - ["Quit Magit" magit-mode-bury-buffer t])) + ("Change buffer arguments" + ["Diff arguments" magit-diff-refresh t] + ["Log arguments" magit-log-refresh t]) + ["Refresh buffer" magit-refresh t] + ["Bury buffer" magit-mode-bury-buffer t])) ;;; Mode @@ -525,9 +525,10 @@ Magit is documented in info node `(magit)'." (hack-dir-local-variables-non-file-buffer) (face-remap-add-relative 'header-line 'magit-header-line) (setq mode-line-process (magit-repository-local-get 'mode-line-process)) - (setq-local revert-buffer-function 'magit-refresh-buffer) - (setq-local bookmark-make-record-function 'magit--make-bookmark) - (setq-local isearch-filter-predicate 'magit-section--open-temporarily)) + (setq-local revert-buffer-function #'magit-refresh-buffer) + (setq-local bookmark-make-record-function #'magit--make-bookmark) + (setq-local imenu-create-index-function #'magit--imenu-create-index) + (setq-local isearch-filter-predicate #'magit-section--open-temporarily)) ;;; Local Variables @@ -573,12 +574,15 @@ your mode instead of adding an entry to this variable.") (make-obsolete-variable 'magit-buffer-lock-functions nil "Magit 3.0.0") (cl-defgeneric magit-buffer-value () - (when-let ((fn (cdr (assq major-mode magit-buffer-lock-functions)))) + (and-let* ((fn (cdr (assq major-mode magit-buffer-lock-functions)))) (funcall fn (with-no-warnings magit-refresh-args)))) (defvar-local magit-previous-section nil) (put 'magit-previous-section 'permanent-local t) +(defvar-local magit--imenu-group-types nil) +(defvar-local magit--imenu-item-types nil) + ;;; Setup Buffer (defmacro magit-setup-buffer (mode &optional locked &rest bindings) @@ -600,16 +604,14 @@ your mode instead of adding an entry to this variable.") (section (and buffer (magit-current-section))) (created (not buffer))) (unless buffer - (setq buffer (magit-with-toplevel - (magit-generate-new-buffer mode value)))) + (setq buffer (magit-generate-new-buffer mode value))) (with-current-buffer buffer (setq magit-previous-section section) (funcall mode) - (magit-xref-setup 'magit-setup-buffer-internal bindings) + (magit-xref-setup #'magit-setup-buffer-internal bindings) (pcase-dolist (`(,var ,val) bindings) (set (make-local-variable var) val)) (when created - (magit-status-goto-initial-section) (run-hooks 'magit-create-buffer-hook))) (magit-display-buffer buffer) (with-current-buffer buffer @@ -638,8 +640,7 @@ locked to its value, which is derived from MODE and ARGS." (section (and buffer (magit-current-section))) (created (not buffer))) (unless buffer - (setq buffer (magit-with-toplevel - (magit-generate-new-buffer mode value)))) + (setq buffer (magit-generate-new-buffer mode value))) (with-current-buffer buffer (setq magit-previous-section section) (with-no-warnings @@ -647,7 +648,6 @@ locked to its value, which is derived from MODE and ARGS." (funcall mode) (magit-xref-setup 'magit-mode-setup-internal args) (when created - (magit-status-goto-initial-section) (run-hooks 'magit-create-buffer-hook))) (magit-display-buffer buffer) (with-current-buffer buffer @@ -786,7 +786,7 @@ the mode of the current buffer derives from `magit-log-mode' or `magit-cherry-mode'." (display-buffer buffer - (cond ((and (or git-commit-mode + (cond ((and (or (bound-and-true-p git-commit-mode) (derived-mode-p 'magit-log-mode 'magit-cherry-mode 'magit-reflog-mode)) @@ -847,48 +847,47 @@ If `visible', then only consider buffers on all visible frames. If `selected' or t, then only consider buffers on the selected frame. If a frame, then only consider buffers on that frame." - (if-let ((topdir (magit-toplevel))) - (cl-flet* ((b (buffer) - (with-current-buffer buffer - (and (eq major-mode mode) - (equal magit--default-directory topdir) - (if value - (and magit-buffer-locked-p - (equal (magit-buffer-value) value)) - (not magit-buffer-locked-p)) - buffer))) - (w (window) - (b (window-buffer window))) - (f (frame) - (seq-some #'w (window-list frame 'no-minibuf)))) - (pcase-exhaustive frame - (`nil (seq-some #'b (buffer-list))) - (`all (seq-some #'f (frame-list))) - (`visible (seq-some #'f (visible-frame-list))) - ((or `selected `t) (seq-some #'w (window-list (selected-frame)))) - ((guard (framep frame)) (seq-some #'w (window-list frame))))) - (magit--not-inside-repository-error))) + (let ((topdir (magit--toplevel-safe))) + (cl-flet* ((b (buffer) + (with-current-buffer buffer + (and (eq major-mode mode) + (equal magit--default-directory topdir) + (if value + (and magit-buffer-locked-p + (equal (magit-buffer-value) value)) + (not magit-buffer-locked-p)) + buffer))) + (w (window) + (b (window-buffer window))) + (f (frame) + (seq-some #'w (window-list frame 'no-minibuf)))) + (pcase-exhaustive frame + ('nil (seq-some #'b (buffer-list))) + ('all (seq-some #'f (frame-list))) + ('visible (seq-some #'f (visible-frame-list))) + ((or 'selected 't) (seq-some #'w (window-list (selected-frame)))) + ((guard (framep frame)) (seq-some #'w (window-list frame))))))) (defun magit-mode-get-buffer (mode &optional create frame value) (declare (obsolete magit-get-mode-buffer "Magit 3.0.0")) (when create (error "`magit-mode-get-buffer's CREATE argument is obsolete")) - (if-let ((topdir (magit-toplevel))) - (--first (with-current-buffer it - (and (eq major-mode mode) - (equal magit--default-directory topdir) - (if value - (and magit-buffer-locked-p - (equal (magit-buffer-value) value)) - (not magit-buffer-locked-p)))) - (if frame - (mapcar #'window-buffer - (window-list (unless (eq frame t) frame))) - (buffer-list))) - (magit--not-inside-repository-error))) - -(defun magit-generate-new-buffer (mode &optional value) - (let* ((name (funcall magit-generate-buffer-name-function mode value)) + (let ((topdir (magit--toplevel-safe))) + (--first (with-current-buffer it + (and (eq major-mode mode) + (equal magit--default-directory topdir) + (if value + (and magit-buffer-locked-p + (equal (magit-buffer-value) value)) + (not magit-buffer-locked-p)))) + (if frame + (mapcar #'window-buffer + (window-list (unless (eq frame t) frame))) + (buffer-list))))) + +(defun magit-generate-new-buffer (mode &optional value directory) + (let* ((default-directory (or directory (magit--toplevel-safe))) + (name (funcall magit-generate-buffer-name-function mode value)) (buffer (generate-new-buffer name))) (with-current-buffer buffer (setq magit--default-directory default-directory) @@ -1034,15 +1033,6 @@ Run hooks `magit-pre-refresh-hook' and `magit-post-refresh-hook'." (magit-get-mode-buffer 'magit-status-mode)) (with-current-buffer it (magit-refresh-buffer))) - (magit-auto-revert-buffers) - (cond - ((and (not this-command) - (memq last-command magit-post-commit-hook-commands)) - (magit-run-hook-with-benchmark 'magit-post-commit-hook)) - ((memq this-command magit-post-stage-hook-commands) - (magit-run-hook-with-benchmark 'magit-post-stage-hook)) - ((memq this-command magit-post-unstage-hook-commands) - (magit-run-hook-with-benchmark 'magit-post-unstage-hook))) (magit-run-hook-with-benchmark 'magit-post-refresh-hook) (when magit-refresh-verbose (let* ((c (caar magit--refresh-cache)) @@ -1064,7 +1054,6 @@ Run hooks `magit-pre-refresh-hook' and `magit-post-refresh-hook'." (magit-run-hook-with-benchmark 'magit-pre-refresh-hook) (dolist (buffer (magit-mode-get-buffers)) (with-current-buffer buffer (magit-refresh-buffer))) - (magit-auto-revert-buffers) (magit-run-hook-with-benchmark 'magit-post-refresh-hook)) (defvar-local magit-refresh-start-time nil) @@ -1083,10 +1072,11 @@ Run hooks `magit-pre-refresh-hook' and `magit-post-refresh-hook'." (lambda (window) (with-selected-window window (with-current-buffer buffer - (when-let ((section (magit-current-section))) + (and-let* ((section (magit-section-at))) `(( ,window ,section - ,@(magit-refresh-get-relative-position))))))) + ,@(magit-section-get-relative-position + section))))))) ;; If it qualifies, then the selected window ;; comes first, but we want to handle it last ;; so that its `magit-section-movement-hook' @@ -1098,7 +1088,6 @@ Run hooks `magit-pre-refresh-hook' and `magit-post-refresh-hook'." (setq magit-section-highlight-overlays nil) (setq magit-section-highlighted-sections nil) (setq magit-section-unhighlight-sections nil) - (magit-process-unset-mode-line-error-status) (let ((inhibit-read-only t)) (erase-buffer) (save-excursion @@ -1118,33 +1107,12 @@ Run hooks `magit-pre-refresh-hook' and `magit-post-refresh-hook'." (float-time (time-subtract (current-time) magit-refresh-start-time))))))) -(defun magit-refresh-get-relative-position () - (when-let ((section (magit-current-section))) - (let ((start (oref section start))) - (list (- (line-number-at-pos (point)) - (line-number-at-pos start)) - (- (point) (line-beginning-position)) - (and (magit-hunk-section-p section) - (region-active-p) - (progn (goto-char (line-beginning-position)) - (when (looking-at "^[-+]") (forward-line)) - (while (looking-at "^[ @]") (forward-line)) - (let ((beg (point))) - (cond ((looking-at "^[-+]") - (forward-line) - (while (looking-at "^[-+]") (forward-line)) - (while (looking-at "^ ") (forward-line)) - (forward-line -1) - (regexp-quote (buffer-substring-no-properties - beg (line-end-position)))) - (t t))))))))) - ;;; Save File-Visiting Buffers -(defvar disable-magit-save-buffers nil) +(defvar magit--disable-save-buffers nil) (defun magit-pre-command-hook () - (setq disable-magit-save-buffers nil)) + (setq magit--disable-save-buffers nil)) (add-hook 'pre-command-hook #'magit-pre-command-hook) (defvar magit-after-save-refresh-buffers nil) @@ -1155,7 +1123,7 @@ Run hooks `magit-pre-refresh-hook' and `magit-post-refresh-hook'." (with-current-buffer buffer (magit-refresh-buffer)))) (setq magit-after-save-refresh-buffers nil) - (remove-hook 'post-command-hook 'magit-after-save-refresh-buffers)) + (remove-hook 'post-command-hook #'magit-after-save-refresh-buffers)) (defun magit-after-save-refresh-status () "Refresh the status buffer of the current repository. @@ -1170,11 +1138,11 @@ Note that refreshing a Magit buffer is done by re-creating its contents from scratch, which can be slow in large repositories. If you are not satisfied with Magit's performance, then you should obviously not add this function to that hook." - (when (and (not disable-magit-save-buffers) + (when (and (not magit--disable-save-buffers) (magit-inside-worktree-p t)) (--when-let (ignore-errors (magit-get-mode-buffer 'magit-status-mode)) (add-to-list 'magit-after-save-refresh-buffers it) - (add-hook 'post-command-hook 'magit-after-save-refresh-buffers)))) + (add-hook 'post-command-hook #'magit-after-save-refresh-buffers)))) (defun magit-maybe-save-repository-buffers () "Maybe save file-visiting buffers belonging to the current repository. @@ -1182,8 +1150,8 @@ Do so if `magit-save-repository-buffers' is non-nil. You should not remove this from any hooks, instead set that variable to nil if you so desire." (when (and magit-save-repository-buffers - (not disable-magit-save-buffers)) - (setq disable-magit-save-buffers t) + (not magit--disable-save-buffers)) + (setq magit--disable-save-buffers t) (let ((msg (current-message))) (magit-save-repository-buffers (eq magit-save-repository-buffers 'dontask)) @@ -1371,7 +1339,7 @@ Return a (KEY . VALUE) cons cell. The KEY is matched using `equal'. Unless specified, REPOSITORY is the current buffer's repository." - (when-let ((cache (assoc (or repository + (and-let* ((cache (assoc (or repository (magit-repository-local-repository)) magit-repository-local-cache))) (assoc key (cdr cache)))) @@ -1395,9 +1363,7 @@ Unless specified, REPOSITORY is the current buffer's repository." (when-let ((cache (assoc (or repository (magit-repository-local-repository)) magit-repository-local-cache))) - ;; There is no `assoc-delete-all'. - (setf (cdr cache) - (cl-delete key (cdr cache) :key #'car :test #'equal)))) + (setf cache (compat-assoc-delete-all key cache)))) (defmacro magit--with-repository-local-cache (key &rest body) (declare (indent 1) (debug (form body))) @@ -1420,22 +1386,173 @@ Unless specified, REPOSITORY is the current buffer's repository." (magit-repository-local-get (cons mode 'magit-section-visibility-cache)))) -(defun magit-zap-caches () +(defun magit-zap-caches (&optional all) "Zap caches for the current repository. -Remove the repository's entry from `magit-repository-local-cache' -and set `magit-section-visibility-cache' to nil in all of the -repository's Magit buffers." + +Remove the repository's entry from `magit-repository-local-cache', +remove the host's entry from `magit--host-git-version-cache', set +`magit-section-visibility-cache' to nil for all Magit buffers of +the repository and set `magit--libgit-available-p' to `unknown'. + +With a prefix argument or if optional ALL is non-nil, discard the +mentioned caches completely." (interactive) - (magit-with-toplevel - (setq magit-repository-local-cache - (cl-delete default-directory - magit-repository-local-cache - :key #'car :test #'equal))) - (dolist (buffer (magit-mode-get-buffers)) - (with-current-buffer buffer - (setq magit-section-visibility-cache nil))) + (cond (all + (setq magit-repository-local-cache nil) + (setq magit--host-git-version-cache nil) + (dolist (buffer (buffer-list)) + (with-current-buffer buffer + (when (derived-mode-p 'magit-mode) + (setq magit-section-visibility-cache nil))))) + (t + (magit-with-toplevel + (setq magit-repository-local-cache + (cl-delete default-directory + magit-repository-local-cache + :key #'car :test #'equal)) + (setq magit--host-git-version-cache + (cl-delete (file-remote-p default-directory) + magit--host-git-version-cache + :key #'car :test #'equal))) + (dolist (buffer (magit-mode-get-buffers)) + (with-current-buffer buffer + (setq magit-section-visibility-cache nil))))) (setq magit--libgit-available-p 'unknown)) +;;; Imenu Support + +(defun magit--imenu-create-index () + ;; If `which-function-mode' is active, then the create-index + ;; function is called at the time the major-mode is being enabled. + ;; Modes that derive from `magit-mode' have not populated the buffer + ;; at that time yet, so we have to abort. + (and magit-root-section + (or magit--imenu-group-types + magit--imenu-item-types) + (let ((index + (cl-mapcan + (lambda (section) + (cond + (magit--imenu-group-types + (and (if (eq (car-safe magit--imenu-group-types) 'not) + (not (magit-section-match + (cdr magit--imenu-group-types) + section)) + (magit-section-match magit--imenu-group-types section)) + (and-let* ((children (oref section children))) + `((,(magit--imenu-index-name section) + ,@(mapcar (lambda (s) + (cons (magit--imenu-index-name s) + (oref s start))) + children)))))) + (magit--imenu-item-types + (and (magit-section-match magit--imenu-item-types section) + `((,(magit--imenu-index-name section) + . ,(oref section start))))))) + (oref magit-root-section children)))) + (if (and magit--imenu-group-types (symbolp magit--imenu-group-types)) + (cdar index) + index)))) + +(defun magit--imenu-index-name (section) + (let ((heading (buffer-substring-no-properties + (oref section start) + (1- (or (oref section content) + (oref section end)))))) + (save-match-data + (cond + ((and (magit-section-match [commit logbuf] section) + (string-match "[^ ]+\\([ *|]*\\).+" heading)) + (replace-match " " t t heading 1)) + ((magit-section-match + '([branch local branchbuf] [tag tags branchbuf]) section) + (oref section value)) + ((magit-section-match [branch remote branchbuf] section) + (concat (oref (oref section parent) value) "/" + (oref section value))) + ((string-match " ([0-9]+)\\'" heading) + (substring heading 0 (match-beginning 0))) + (t heading))))) + +;;; Bookmark support + +(declare-function bookmark-get-filename "bookmark" (bookmark-name-or-record)) +(declare-function bookmark-make-record-default "bookmark" + (&optional no-file no-context posn)) +(declare-function bookmark-prop-get "bookmark" (bookmark-name-or-record prop)) +(declare-function bookmark-prop-set "bookmark" (bookmark-name-or-record prop val)) + +(defun magit--make-bookmark () + "Create a bookmark for the current Magit buffer. +Input values are the major-mode's `magit-bookmark-name' method, +and the buffer-local values of the variables referenced in its +`magit-bookmark-variables' property." + (require 'bookmark) + (if (plist-member (symbol-plist major-mode) 'magit-bookmark-variables) + ;; `bookmark-make-record-default's return value does not match + ;; (NAME . ALIST), even though it is used as the default value + ;; of `bookmark-make-record-function', which states that such + ;; functions must do that. See #4356. + (let ((bookmark (cons nil (bookmark-make-record-default 'no-file)))) + (bookmark-prop-set bookmark 'handler #'magit--handle-bookmark) + (bookmark-prop-set bookmark 'mode major-mode) + (bookmark-prop-set bookmark 'filename (magit-toplevel)) + (bookmark-prop-set bookmark 'defaults (list (magit-bookmark-name))) + (dolist (var (get major-mode 'magit-bookmark-variables)) + (bookmark-prop-set bookmark var (symbol-value var))) + (bookmark-prop-set + bookmark 'magit-hidden-sections + (--keep (and (oref it hidden) + (cons (oref it type) + (if (derived-mode-p 'magit-stash-mode) + (string-replace magit-buffer-revision + magit-buffer-revision-hash + (oref it value)) + (oref it value)))) + (oref magit-root-section children))) + bookmark) + (user-error "Bookmarking is not implemented for %s buffers" major-mode))) + +(defun magit--handle-bookmark (bookmark) + "Open a bookmark created by `magit--make-bookmark'. +Call the `magit-*-setup-buffer' function of the the major-mode +with the variables' values as arguments, which were recorded by +`magit--make-bookmark'. Ignore `magit-display-buffer-function'." + (let ((buffer (let ((default-directory (bookmark-get-filename bookmark)) + (mode (bookmark-prop-get bookmark 'mode)) + (magit-display-buffer-function #'identity) + (magit-display-buffer-noselect t)) + (apply (intern (format "%s-setup-buffer" + (substring (symbol-name mode) 0 -5))) + (--map (bookmark-prop-get bookmark it) + (get mode 'magit-bookmark-variables)))))) + (set-buffer buffer) ; That is the interface we have to adhere to. + (when-let ((hidden (bookmark-prop-get bookmark 'magit-hidden-sections))) + (with-current-buffer buffer + (dolist (child (oref magit-root-section children)) + (if (member (cons (oref child type) + (oref child value)) + hidden) + (magit-section-hide child) + (magit-section-show child))))) + ;; Compatibility with `bookmark+' package. See #4356. + (when (bound-and-true-p bmkp-jump-display-function) + (funcall bmkp-jump-display-function (current-buffer))) + nil)) + +(cl-defgeneric magit-bookmark-name () + "Return name for bookmark to current buffer." + (format "%s%s" + (substring (symbol-name major-mode) 0 -5) + (if-let ((vars (get major-mode 'magit-bookmark-variables))) + (cl-mapcan (lambda (var) + (let ((val (symbol-value var))) + (if (and val (atom val)) + (list val) + val))) + vars) + ""))) + ;;; Utilities (defun magit-toggle-verbose-refresh () diff --git a/elpa/magit-20220116.1908/magit-notes.el b/elpa/magit-20220518.2359/magit-notes.el similarity index 82% rename from elpa/magit-20220116.1908/magit-notes.el rename to elpa/magit-20220518.2359/magit-notes.el index 30bbc5f9..8df09bbd 100644 --- a/elpa/magit-20220116.1908/magit-notes.el +++ b/elpa/magit-20220518.2359/magit-notes.el @@ -1,19 +1,16 @@ -;;; magit-notes.el --- notes support -*- lexical-binding: t -*- +;;; magit-notes.el --- Notes support -*- lexical-binding:t -*- -;; Copyright (C) 2010-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Jonas Bernoulli ;; Maintainer: Jonas Bernoulli ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Magit is free software; you can redistribute it and/or modify it +;; 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. +;; the Free Software Foundation, either version 3 of the License, 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 @@ -21,7 +18,7 @@ ;; 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. +;; along with Magit. If not, see . ;;; Commentary: @@ -71,27 +68,29 @@ (transient-define-infix magit-core.notesRef () :class 'magit--git-variable :variable "core.notesRef" - :reader 'magit-notes-read-ref + :reader #'magit-notes-read-ref :prompt "Set local core.notesRef") (transient-define-infix magit-notes.displayRef () :class 'magit--git-variable :variable "notes.displayRef" :multi-value t - :reader 'magit-notes-read-refs + :reader #'magit-notes-read-refs :prompt "Set local notes.displayRef") (transient-define-infix magit-global-core.notesRef () :class 'magit--git-variable :variable "core.notesRef" - :reader 'magit-notes-read-ref + :global t + :reader #'magit-notes-read-ref :prompt "Set global core.notesRef") (transient-define-infix magit-global-notes.displayRef () :class 'magit--git-variable :variable "notes.displayRef" + :global t :multi-value t - :reader 'magit-notes-read-refs + :reader #'magit-notes-read-refs :prompt "Set global notes.displayRef") (transient-define-argument magit-notes:--ref () @@ -99,7 +98,7 @@ :class 'transient-option :key "-r" :argument "--ref=" - :reader 'magit-notes-read-ref) + :reader #'magit-notes-read-ref) (transient-define-argument magit-notes:--strategy () :description "Merge strategy" @@ -165,16 +164,16 @@ Also see `magit-notes-merge'." ;;; Readers (defun magit-notes-read-ref (prompt _initial-input history) - (--when-let (magit-completing-read - prompt (magit-list-notes-refnames) nil nil - (--when-let (magit-get "core.notesRef") - (if (string-prefix-p "refs/notes/" it) - (substring it 11) - it)) - history) - (if (string-prefix-p "refs/" it) - it - (concat "refs/notes/" it)))) + (and-let* ((ref (magit-completing-read + prompt (magit-list-notes-refnames) nil nil + (and-let* ((def (magit-get "core.notesRef"))) + (if (string-prefix-p "refs/notes/" def) + (substring def 11) + def)) + history))) + (if (string-prefix-p "refs/" ref) + ref + (concat "refs/notes/" ref)))) (defun magit-notes-read-refs (prompt &optional _initial-input _history) (mapcar (lambda (ref) @@ -193,9 +192,9 @@ Also see `magit-notes-merge'." (defun magit-notes-read-args (prompt) (list (magit-read-branch-or-commit prompt (magit-stash-at-point)) - (--when-let (--first (string-match "^--ref=\\(.+\\)" it) - (transient-args 'magit-notes)) - (match-string 1 it)))) + (and-let* ((str (--first (string-match "^--ref=\\(.+\\)" it) + (transient-args 'magit-notes)))) + (match-string 1 str)))) ;;; _ (provide 'magit-notes) diff --git a/elpa/magit-20220116.1908/magit-obsolete.el b/elpa/magit-20220518.2359/magit-obsolete.el similarity index 84% rename from elpa/magit-20220116.1908/magit-obsolete.el rename to elpa/magit-20220518.2359/magit-obsolete.el index e6605f34..4d27752b 100644 --- a/elpa/magit-20220116.1908/magit-obsolete.el +++ b/elpa/magit-20220518.2359/magit-obsolete.el @@ -1,19 +1,16 @@ -;;; magit-obsolete.el --- obsolete definitions -*- lexical-binding: t -*- +;;; magit-obsolete.el --- Obsolete definitions -*- lexical-binding:t -*- -;; Copyright (C) 2010-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Jonas Bernoulli ;; Maintainer: Jonas Bernoulli ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Magit is free software; you can redistribute it and/or modify it +;; 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. +;; the Free Software Foundation, either version 3 of the License, 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 @@ -21,7 +18,7 @@ ;; 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. +;; along with Magit. If not, see . ;;; Commentary: @@ -34,10 +31,10 @@ ;;; Obsolete since v3.0.0 (define-obsolete-function-alias 'magit-diff-visit-file-worktree - 'magit-diff-visit-worktree-file "Magit 3.0.0") + #'magit-diff-visit-worktree-file "Magit 3.0.0") (define-obsolete-function-alias 'magit-status-internal - 'magit-status-setup-buffer "Magit 3.0.0") + #'magit-status-setup-buffer "Magit 3.0.0") (define-obsolete-variable-alias 'magit-mode-setup-hook 'magit-setup-buffer-hook "Magit 3.0.0") @@ -46,10 +43,10 @@ 'magit-branch-direct-configure "Magit 3.0.0") (define-obsolete-function-alias 'magit-dispatch-popup - 'magit-dispatch "Magit 3.0.0") + #'magit-dispatch "Magit 3.0.0") (define-obsolete-function-alias 'magit-repolist-column-dirty - 'magit-repolist-column-flag "Magit 3.0.0") + #'magit-repolist-column-flag "Magit 3.0.0") (define-obsolete-variable-alias 'magit-disable-line-numbers 'magit-section-disable-line-numbers "Magit 3.0.0") diff --git a/elpa/magit-20220116.1908/magit-patch.el b/elpa/magit-20220518.2359/magit-patch.el similarity index 92% rename from elpa/magit-20220116.1908/magit-patch.el rename to elpa/magit-20220518.2359/magit-patch.el index e526bead..c114cf2c 100644 --- a/elpa/magit-20220116.1908/magit-patch.el +++ b/elpa/magit-20220518.2359/magit-patch.el @@ -1,19 +1,16 @@ -;;; magit-patch.el --- creating and applying patches -*- lexical-binding: t -*- +;;; magit-patch.el --- Creating and applying patches -*- lexical-binding:t -*- -;; Copyright (C) 2008-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Jonas Bernoulli ;; Maintainer: Jonas Bernoulli ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Magit is free software; you can redistribute it and/or modify it +;; 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. +;; the Free Software Foundation, either version 3 of the License, 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 @@ -21,7 +18,7 @@ ;; 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. +;; along with Magit. If not, see . ;;; Commentary: @@ -106,7 +103,7 @@ which creates patches for all commits that are reachable from (concat (car (last revs)) "^.." (car revs)) (let ((range (magit-read-range-or-commit "Format range or commit"))) - (if (string-match-p "\\.\\." range) + (if (string-search ".." range) range (format "%s~..%s" range range)))) (let ((args (transient-args 'magit-patch-create))) @@ -119,7 +116,7 @@ which creates patches for all commits that are reachable from (save-match-data (find-file (expand-file-name - (concat (when-let ((v (transient-arg-value "--reroll-count=" args))) + (concat (and-let* ((v (transient-arg-value "--reroll-count=" args))) (format "v%s-" v)) "0000-cover-letter.patch") (let ((topdir (magit-toplevel))) @@ -163,7 +160,7 @@ which creates patches for all commits that are reachable from :key "C-m v " :shortarg "-v" :argument "--reroll-count=" - :reader 'transient-read-number-N+) + :reader #'transient-read-number-N+) (transient-define-argument magit-format-patch:--interdiff () :description "Insert interdiff" @@ -214,21 +211,21 @@ which creates patches for all commits that are reachable from :class 'transient-option :key "C-m C-f" :argument "--from=" - :reader 'magit-transient-read-person) + :reader #'magit-transient-read-person) (transient-define-argument magit-format-patch:--to () :description "To" :class 'transient-option :key "C-m C-t" :argument "--to=" - :reader 'magit-transient-read-person) + :reader #'magit-transient-read-person) (transient-define-argument magit-format-patch:--cc () :description "CC" :class 'transient-option :key "C-m C-c" :argument "--cc=" - :reader 'magit-transient-read-person) + :reader #'magit-transient-read-person) (transient-define-argument magit-format-patch:--output-directory () :description "Output directory" @@ -236,7 +233,7 @@ which creates patches for all commits that are reachable from :key "C-m o " :shortarg "-o" :argument "--output-directory=" - :reader 'transient-read-existing-directory) + :reader #'transient-read-existing-directory) ;;;###autoload (autoload 'magit-patch-apply "magit-patch" nil t) (transient-define-prefix magit-patch-apply (file &rest args) @@ -254,7 +251,7 @@ which creates patches for all commits that are reachable from (list (expand-file-name (read-file-name "Apply patch: " default-directory nil nil - (when-let ((file (magit-file-at-point))) + (and-let* ((file (magit-file-at-point))) (file-relative-name file)))) (transient-args 'magit-patch-apply)))) (if (not file) diff --git a/elpa/magit-20220116.1908/magit-pkg.el b/elpa/magit-20220518.2359/magit-pkg.el similarity index 55% rename from elpa/magit-20220116.1908/magit-pkg.el rename to elpa/magit-20220518.2359/magit-pkg.el index e7653c99..a7b52544 100644 --- a/elpa/magit-20220116.1908/magit-pkg.el +++ b/elpa/magit-20220518.2359/magit-pkg.el @@ -1,11 +1,12 @@ -(define-package "magit" "20220116.1908" "A Git porcelain inside Emacs." +(define-package "magit" "20220518.2359" "A Git porcelain inside Emacs." '((emacs "25.1") + (compat "28.1.1.0") (dash "20210826") - (git-commit "20211004") - (magit-section "20211004") - (transient "20210920") - (with-editor "20211001")) - :commit "2a7812705f5cf4b864bb162576415863f4116285" :authors + (git-commit "20220222") + (magit-section "20220325") + (transient "20220325") + (with-editor "20220318")) + :commit "e920cdb326d2c2da5a32809085aa6b9369b51b1a" :authors '(("Marius Vollmer" . "marius.vollmer@gmail.com") ("Jonas Bernoulli" . "jonas@bernoul.li")) :maintainer diff --git a/elpa/magit-20220116.1908/magit-process.el b/elpa/magit-20220518.2359/magit-process.el similarity index 94% rename from elpa/magit-20220116.1908/magit-process.el rename to elpa/magit-20220518.2359/magit-process.el index 165bd162..65b72911 100644 --- a/elpa/magit-20220116.1908/magit-process.el +++ b/elpa/magit-20220518.2359/magit-process.el @@ -1,19 +1,16 @@ -;;; magit-process.el --- process functionality -*- lexical-binding: t -*- +;;; magit-process.el --- Process functionality -*- lexical-binding:t -*- -;; Copyright (C) 2010-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Jonas Bernoulli ;; Maintainer: Jonas Bernoulli ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Magit is free software; you can redistribute it and/or modify it +;; 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. +;; the Free Software Foundation, either version 3 of the License, 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 @@ -21,7 +18,7 @@ ;; 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. +;; along with Magit. If not, see . ;;; Commentary: @@ -33,17 +30,13 @@ ;;; Code: -(require 'magit-utils) -(require 'magit-section) +(require 'magit-base) (require 'magit-git) (require 'magit-mode) (require 'ansi-color) (require 'with-editor) -(declare-function auth-source-search "auth-source" - (&rest spec &key max require create delete &allow-other-keys)) - ;;; Options (defcustom magit-process-connection-type (not (eq system-type 'cygwin)) @@ -286,10 +279,7 @@ Used when `magit-process-display-mode-line-error' is non-nil." "Mode for looking at Git process output." :group 'magit-process (hack-dir-local-variables-non-file-buffer) - (setq imenu-prev-index-position-function - 'magit-imenu--process-prev-index-position-function) - (setq imenu-extract-index-name-function - 'magit-imenu--process-extract-index-name-function)) + (setq magit--imenu-item-types 'process)) (defun magit-process-buffer (&optional nodisplay) "Display the current repository's process buffer. @@ -310,8 +300,8 @@ optional NODISPLAY is non-nil also display it." (and (eq major-mode 'magit-process-mode) (equal default-directory topdir))) (buffer-list)) - (let ((default-directory topdir)) - (magit-generate-new-buffer 'magit-process-mode))))) + (magit-generate-new-buffer 'magit-process-mode + nil topdir)))) (with-current-buffer buffer (if magit-root-section (when magit-process-log-max @@ -495,7 +485,7 @@ and still alive), as well as the respective Magit status buffer. See `magit-start-process' for more information." (message "Running %s %s" (magit-git-executable) - (let ((m (mapconcat #'identity (-flatten args) " "))) + (let ((m (mapconcat #'identity (flatten-tree args) " "))) (remove-list-of-text-properties 0 (length m) '(face) m) m)) (magit-start-git nil args)) @@ -623,7 +613,7 @@ Magit status buffer." (let ((process-connection-type nil) (process-environment (magit-process-environment)) (default-process-coding-system - (magit--process-coding-system))) + (magit--process-coding-system))) (apply #'start-file-process "git" process-buf (magit-git-executable) args)))) (process-put process 'command-buf command-buf) @@ -733,22 +723,22 @@ Magit status buffer." "Special sentinel used by `magit-run-git-sequencer'." (when (memq (process-status process) '(exit signal)) (magit-process-sentinel process event) - (when-let ((process-buf (process-buffer process))) - (when (buffer-live-p process-buf) - (when-let ((status-buf (with-current-buffer process-buf - (magit-get-mode-buffer 'magit-status-mode)))) - (with-current-buffer status-buf - (--when-let - (magit-get-section - `((commit . ,(magit-rev-parse "HEAD")) - (,(pcase (car (cadr (-split-at - (1+ (length magit-git-global-arguments)) - (process-command process)))) - ((or "rebase" "am") 'rebase-sequence) - ((or "cherry-pick" "revert") 'sequence))) - (status))) - (goto-char (oref it start)) - (magit-section-update-highlight)))))))) + (when-let* ((process-buf (process-buffer process)) + (- (buffer-live-p process-buf)) + (status-buf (with-current-buffer process-buf + (magit-get-mode-buffer 'magit-status-mode)))) + (with-current-buffer status-buf + (--when-let + (magit-get-section + `((commit . ,(magit-rev-parse "HEAD")) + (,(pcase (car (cadr (-split-at + (1+ (length magit-git-global-arguments)) + (process-command process)))) + ((or "rebase" "am") 'rebase-sequence) + ((or "cherry-pick" "revert") 'sequence))) + (status))) + (goto-char (oref it start)) + (magit-section-update-highlight)))))) (defun magit-process-filter (proc string) "Default filter used by `magit-start-process'." @@ -842,7 +832,8 @@ be translated on the fly by doing this once [1]: https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token." (require 'auth-source) - (and (string-match "\\`\\(.+\\)@\\([^@]+\\)\\'" key) + (and (fboundp 'auth-source-search) + (string-match "\\`\\(.+\\)@\\([^@]+\\)\\'" key) (let* ((user (match-string 1 key)) (host (match-string 2 key)) (secret @@ -879,7 +870,7 @@ from the user." magit-process-password-prompt-regexps string))) (process-send-string process (magit-process-kill-on-abort process - (concat (or (when-let ((key (match-string 99 string))) + (concat (or (and-let* ((key (match-string 99 string))) (run-hook-with-args-until-success 'magit-process-find-password-functions key)) (read-passwd prompt)) @@ -958,7 +949,7 @@ as argument." (apply fn name buffer program args))) (advice-add 'tramp-sh-handle-start-file-process :around - 'tramp-sh-handle-start-file-process--magit-tramp-process-environment) + #'tramp-sh-handle-start-file-process--magit-tramp-process-environment) (defun tramp-sh-handle-process-file--magit-tramp-process-environment (fn program &optional infile destination display &rest args) @@ -969,7 +960,7 @@ as argument." (apply fn program infile destination display args))) (advice-add 'tramp-sh-handle-process-file :around - 'tramp-sh-handle-process-file--magit-tramp-process-environment) + #'tramp-sh-handle-process-file--magit-tramp-process-environment) (defvar magit-mode-line-process-map (let ((map (make-sparse-keymap))) @@ -1028,15 +1019,15 @@ If STR is supplied, it replaces the `mode-line-process' text." (let ((repokey (magit-repository-local-repository))) ;; The following closure captures the repokey value, and is ;; added to `pre-command-hook'. - (cl-labels ((enable-magit-process-unset-mode-line - () ;;; Remove ourself from the hook variable, so - ;;; that we only run once. - (remove-hook 'pre-command-hook - #'enable-magit-process-unset-mode-line) - ;; Clear the inhibit flag for the repository in - ;; which we set it. - (magit-repository-local-set - 'inhibit-magit-process-unset-mode-line nil repokey))) + (cl-labels ((enable-magit-process-unset-mode-line () + ;; Remove ourself from the hook variable, so + ;; that we only run once. + (remove-hook 'pre-command-hook + #'enable-magit-process-unset-mode-line) + ;; Clear the inhibit flag for the repository in + ;; which we set it. + (magit-repository-local-set + 'inhibit-magit-process-unset-mode-line nil repokey))) ;; Set the inhibit flag until the next command is invoked. (magit-repository-local-set 'inhibit-magit-process-unset-mode-line t repokey) @@ -1052,6 +1043,9 @@ If STR is supplied, it replaces the `mode-line-process' text." 'magit-mode-line-process-error)) (magit-process-unset-mode-line)))) +(add-hook 'magit-refresh-buffer-hook + #'magit-process-unset-mode-line-error-status) + (defun magit-process-unset-mode-line (&optional directory) "Remove the git command from the mode line." (let ((default-directory (or directory default-directory))) diff --git a/elpa/magit-20220116.1908/magit-pull.el b/elpa/magit-20220518.2359/magit-pull.el similarity index 88% rename from elpa/magit-20220116.1908/magit-pull.el rename to elpa/magit-20220518.2359/magit-pull.el index db8783f3..aad99a57 100644 --- a/elpa/magit-20220116.1908/magit-pull.el +++ b/elpa/magit-20220518.2359/magit-pull.el @@ -1,19 +1,16 @@ -;;; magit-pull.el --- update local objects and refs -*- lexical-binding: t -*- +;;; magit-pull.el --- Update local objects and refs -*- lexical-binding:t -*- -;; Copyright (C) 2008-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Jonas Bernoulli ;; Maintainer: Jonas Bernoulli ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Magit is free software; you can redistribute it and/or modify it +;; 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. +;; the Free Software Foundation, either version 3 of the License, 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 @@ -21,7 +18,7 @@ ;; 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. +;; along with Magit. If not, see . ;;; Commentary: @@ -87,13 +84,13 @@ With a prefix argument or when the push-remote is either not configured or unusable, then let the user first configure the push-remote." - :if 'magit-get-current-branch - :description 'magit-pull--pushbranch-description + :if #'magit-get-current-branch + :description #'magit-pull--pushbranch-description (interactive (list (magit-pull-arguments))) (pcase-let ((`(,branch ,remote) (magit--select-push-remote "pull from there"))) (run-hooks 'magit-credential-hook) - (magit-run-git-async "pull" args remote branch))) + (magit-run-git-with-editor "pull" args remote branch))) (defun magit-pull--pushbranch-description () ;; Also used by `magit-rebase-onto-pushremote'. @@ -117,8 +114,8 @@ push-remote." With a prefix argument or when the upstream is either not configured or unusable, then let the user first configure the upstream." - :if 'magit-get-current-branch - :description 'magit-pull--upstream-description + :if #'magit-get-current-branch + :description #'magit-pull--upstream-description (interactive (list (magit-pull-arguments))) (let* ((branch (or (magit-get-current-branch) (user-error "No branch is checked out"))) @@ -136,7 +133,7 @@ the upstream." (magit-run-git-with-editor "pull" args remote merge))) (defun magit-pull--upstream-description () - (when-let ((branch (magit-get-current-branch))) + (and-let* ((branch (magit-get-current-branch))) (or (magit-get-upstream-branch branch) (let ((remote (magit-get "branch" branch "remote")) (merge (magit-get "branch" branch "merge")) diff --git a/elpa/magit-20220116.1908/magit-push.el b/elpa/magit-20220518.2359/magit-push.el similarity index 91% rename from elpa/magit-20220116.1908/magit-push.el rename to elpa/magit-20220518.2359/magit-push.el index 918053ba..c28aca5b 100644 --- a/elpa/magit-20220116.1908/magit-push.el +++ b/elpa/magit-20220518.2359/magit-push.el @@ -1,19 +1,16 @@ -;;; magit-push.el --- update remote objects and refs -*- lexical-binding: t -*- +;;; magit-push.el --- Update remote objects and refs -*- lexical-binding:t -*- -;; Copyright (C) 2008-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Jonas Bernoulli ;; Maintainer: Jonas Bernoulli ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Magit is free software; you can redistribute it and/or modify it +;; 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. +;; the Free Software Foundation, either version 3 of the License, 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 @@ -21,7 +18,7 @@ ;; 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. +;; along with Magit. If not, see . ;;; Commentary: @@ -83,14 +80,14 @@ When the push-remote is not configured, then read the push-remote from the user, set it, and then push to it. With a prefix argument the push-remote can be changed before pushed to it." - :if 'magit-get-current-branch - :description 'magit-push--pushbranch-description + :if #'magit-get-current-branch + :description #'magit-push--pushbranch-description (interactive (list (magit-push-arguments))) (pcase-let ((`(,branch ,remote ,changed) (magit--select-push-remote "push there"))) (when changed (magit-confirm 'set-and-push - (replace-regexp-in-string + (string-replace "%" "%%" (format "Really use \"%s\" as push-remote and push \"%s\" there" remote branch)))) @@ -122,8 +119,8 @@ argument the push-remote can be changed before pushed to it." With a prefix argument or when the upstream is either not configured or unusable, then let the user first configure the upstream." - :if 'magit-get-current-branch - :description 'magit-push--upstream-description + :if #'magit-get-current-branch + :description #'magit-push--upstream-description (interactive (list (magit-push-arguments))) (let* ((branch (or (magit-get-current-branch) (user-error "No branch is checked out"))) @@ -152,7 +149,7 @@ the upstream." ;; is what the user wants to happen. (setq merge (concat "refs/heads/" merge))) (magit-confirm 'set-and-push - (replace-regexp-in-string + (string-replace "%" "%%" (format "Really use \"%s\" as upstream and push \"%s\" there" upstream branch)))) @@ -161,7 +158,7 @@ the upstream." (magit-run-git-async "push" "-v" args remote (concat branch ":" merge)))) (defun magit-push--upstream-description () - (when-let ((branch (magit-get-current-branch))) + (and-let* ((branch (magit-get-current-branch))) (or (magit-get-upstream-branch branch) (let ((remote (magit-get "branch" branch "remote")) (merge (magit-get "branch" branch "merge")) @@ -288,7 +285,7 @@ what this command will do. For example: (transient-insert-suffix \\='magit-push \"p\" \\='(\"i\" magit-push-implicitly))" - :description 'magit-push-implicitly--desc + :description #'magit-push-implicitly--desc (interactive (list (magit-push-arguments))) (run-hooks 'magit-credential-hook) (magit-run-git-async "push" "-v" args)) @@ -296,24 +293,24 @@ what this command will do. For example: (defun magit-push-implicitly--desc () (let ((default (magit-get "push.default"))) (unless (equal default "nothing") - (or (when-let ((remote (or (magit-get-remote) + (or (and-let* ((remote (or (magit-get-remote) (magit-primary-remote))) (refspec (magit-get "remote" remote "push"))) (format "%s using %s" (magit--propertize-face remote 'magit-branch-remote) (magit--propertize-face refspec 'bold))) - (--when-let (and (not (magit-get-push-branch)) - (magit-get-upstream-branch)) + (and-let* ((upstream (and (not (magit-get-push-branch)) + (magit-get-upstream-branch)))) (format "%s aka %s\n" - (magit-branch-set-face it) + (magit-branch-set-face upstream) (magit--propertize-face "@{upstream}" 'bold))) - (--when-let (magit-get-push-branch) + (and-let* ((push-branch (magit-get-push-branch))) (format "%s aka %s\n" - (magit-branch-set-face it) + (magit-branch-set-face push-branch) (magit--propertize-face "pushRemote" 'bold))) - (--when-let (magit-get-@{push}-branch) + (and-let* ((push-branch (magit-get-@{push}-branch))) (format "%s aka %s\n" - (magit-branch-set-face it) + (magit-branch-set-face push-branch) (magit--propertize-face "@{push}" 'bold))) (format "using %s (%s is %s)\n" (magit--propertize-face "git push" 'bold) diff --git a/elpa/magit-20220116.1908/magit-reflog.el b/elpa/magit-20220518.2359/magit-reflog.el similarity index 89% rename from elpa/magit-20220116.1908/magit-reflog.el rename to elpa/magit-20220518.2359/magit-reflog.el index fb79d8ef..639a7017 100644 --- a/elpa/magit-20220116.1908/magit-reflog.el +++ b/elpa/magit-20220518.2359/magit-reflog.el @@ -1,19 +1,16 @@ -;;; magit-reflog.el --- inspect ref history -*- lexical-binding: t -*- +;;; magit-reflog.el --- Inspect ref history -*- lexical-binding:t -*- -;; Copyright (C) 2010-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Jonas Bernoulli ;; Maintainer: Jonas Bernoulli ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Magit is free software; you can redistribute it and/or modify it +;; 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. +;; the Free Software Foundation, either version 3 of the License, 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 @@ -21,7 +18,7 @@ ;; 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. +;; along with Magit. If not, see . ;;; Commentary: @@ -68,7 +65,7 @@ AUTHOR-WIDTH has to be an integer. When the name of the author :group 'magit-log :group 'magit-margin :type magit-log-margin--custom-type - :initialize 'magit-custom-initialize-reset + :initialize #'magit-custom-initialize-reset :set-after '(magit-log-margin) :set (apply-partially #'magit-margin-set-variable 'magit-reflog-mode)) @@ -136,8 +133,8 @@ If `HEAD' is detached, then show the reflog for that instead." (defvar magit-reflog-mode-map (let ((map (make-sparse-keymap))) (set-keymap-parent map magit-log-mode-map) - (define-key map (kbd "C-c C-n") 'undefined) - (define-key map (kbd "L") 'magit-margin-settings) + (define-key map (kbd "C-c C-n") #'undefined) + (define-key map (kbd "L") #'magit-margin-settings) map) "Keymap for `magit-reflog-mode'.") @@ -156,7 +153,8 @@ Type \\[magit-reset] to reset `HEAD' to the commit at point. \\{magit-reflog-mode-map}" :group 'magit-log - (hack-dir-local-variables-non-file-buffer)) + (hack-dir-local-variables-non-file-buffer) + (setq magit--imenu-item-types 'commit)) (defun magit-reflog-setup-buffer (ref) (require 'magit) @@ -167,7 +165,7 @@ Type \\[magit-reset] to reset `HEAD' to the commit at point. (defun magit-reflog-refresh-buffer () (magit-set-header-line-format (concat "Reflog for " magit-buffer-refname)) (magit-insert-section (reflogbuf) - (magit-git-wash (apply-partially 'magit-log-wash-log 'reflog) + (magit-git-wash (apply-partially #'magit-log-wash-log 'reflog) "reflog" "show" "--format=%h%x00%aN%x00%gd%x00%gs" "--date=raw" magit-buffer-log-args magit-buffer-refname "--"))) diff --git a/elpa/magit-20220116.1908/magit-refs.el b/elpa/magit-20220518.2359/magit-refs.el similarity index 92% rename from elpa/magit-20220116.1908/magit-refs.el rename to elpa/magit-20220518.2359/magit-refs.el index 0117e083..07b03d71 100644 --- a/elpa/magit-20220116.1908/magit-refs.el +++ b/elpa/magit-20220518.2359/magit-refs.el @@ -1,19 +1,16 @@ -;;; magit-refs.el --- listing references -*- lexical-binding: t -*- +;;; magit-refs.el --- Listing references -*- lexical-binding:t -*- -;; Copyright (C) 2010-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Jonas Bernoulli ;; Maintainer: Jonas Bernoulli ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Magit is free software; you can redistribute it and/or modify it +;; 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. +;; the Free Software Foundation, either version 3 of the License, 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 @@ -21,7 +18,7 @@ ;; 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. +;; along with Magit. If not, see . ;;; Commentary: @@ -130,7 +127,7 @@ AUTHOR-WIDTH has to be an integer. When the name of the author :group 'magit-margin :safe (lambda (val) (memq val '(all branch nil))) :type magit-log-margin--custom-type - :initialize 'magit-custom-initialize-reset + :initialize #'magit-custom-initialize-reset :set-after '(magit-log-margin) :set (apply-partially #'magit-margin-set-variable 'magit-refs-mode)) @@ -277,8 +274,8 @@ the outcome. (defvar magit-refs-mode-map (let ((map (make-sparse-keymap))) (set-keymap-parent map magit-mode-map) - (define-key map (kbd "C-y") 'magit-refs-set-show-commit-count) - (define-key map (kbd "L") 'magit-margin-settings) + (define-key map (kbd "C-y") #'magit-refs-set-show-commit-count) + (define-key map (kbd "L") #'magit-margin-settings) map) "Keymap for `magit-refs-mode'.") @@ -301,8 +298,7 @@ Type \\[magit-reset] to reset `HEAD' to the commit at point. \\{magit-refs-mode-map}" :group 'magit-refs (hack-dir-local-variables-non-file-buffer) - (setq imenu-create-index-function - #'magit-imenu--refs-create-index-function)) + (setq magit--imenu-group-types '(local remote tags))) (defun magit-refs-setup-buffer (ref args) (magit-setup-buffer #'magit-refs-mode nil @@ -318,7 +314,7 @@ Type \\[magit-reset] to reset `HEAD' to the commit at point. (mapconcat #'identity magit-buffer-arguments " "))) (magit-insert-section (branchbuf) (magit-run-section-hook 'magit-refs-sections-hook)) - (add-hook 'kill-buffer-hook 'magit-preserve-section-visibility-cache)) + (add-hook 'kill-buffer-hook #'magit-preserve-section-visibility-cache)) (cl-defmethod magit-buffer-value (&context (major-mode magit-refs-mode)) (cons magit-buffer-upstream magit-buffer-arguments)) @@ -360,7 +356,7 @@ Type \\[magit-reset] to reset `HEAD' to the commit at point. ((eq major-mode 'magit-refs-mode) (setq args magit-buffer-arguments)) ((and (memq use-buffer-args '(always selected)) - (when-let ((buffer (magit-get-mode-buffer + (when-let* ((buffer (magit-get-mode-buffer ;debbugs#31840 'magit-refs-mode nil (eq use-buffer-args 'selected)))) (setq args (buffer-local-value 'magit-buffer-arguments buffer)) @@ -374,14 +370,14 @@ Type \\[magit-reset] to reset `HEAD' to the commit at point. :class 'transient-option :key "-c" :argument "--contains=" - :reader 'magit-transient-read-revision) + :reader #'magit-transient-read-revision) (transient-define-argument magit-for-each-ref:--sort () :description "Sort" :class 'transient-option :key "-s" :argument "--sort=" - :reader 'magit-read-ref-sort) + :reader #'magit-read-ref-sort) (defun magit-read-ref-sort (prompt initial-input _history) (magit-completing-read prompt @@ -430,10 +426,12 @@ This command behaves just like `magit-show-commit', except if point is on a reference in a `magit-refs-mode' buffer (a buffer listing branches and tags), in which case the behavior may be different, but only if you have customized the option -`magit-visit-ref-behavior' (which see)." +`magit-visit-ref-behavior' (which see). When invoked from a +menu this command always behaves like `magit-show-commit'." (interactive) (if (and (derived-mode-p 'magit-refs-mode) - (magit-section-match '(branch tag))) + (magit-section-match '(branch tag)) + (not (magit-menu-position))) (let ((ref (oref (magit-current-section) value))) (cond (current-prefix-arg (cond ((memq 'focus-on-ref magit-visit-ref-behavior) @@ -477,41 +475,55 @@ Branch %s already exists. (defvar magit-remote-section-map (let ((map (make-sparse-keymap))) - (define-key map [remap magit-delete-thing] 'magit-remote-remove) - (define-key map "R" 'magit-remote-rename) + (magit-menu-set map [magit-delete-thing] #'magit-remote-remove "Remove %m") + (magit-menu-set map [magit-file-rename] #'magit-remote-rename "Rename %s") map) "Keymap for `remote' sections.") (defvar magit-branch-section-map (let ((map (make-sparse-keymap))) - (define-key map [remap magit-visit-thing] 'magit-visit-ref) - (define-key map [remap magit-delete-thing] 'magit-branch-delete) - (define-key map "R" 'magit-branch-rename) + (magit-menu-set map [magit-visit-thing] #'magit-visit-ref "Visit commit") + (magit-menu-set map [magit-delete-thing] #'magit-branch-delete "Delete %m") + (magit-menu-set map [magit-file-rename] #'magit-branch-rename "Rename %s") map) "Keymap for `branch' sections.") (defvar magit-tag-section-map (let ((map (make-sparse-keymap))) - (define-key map [remap magit-visit-thing] 'magit-visit-ref) - (define-key map [remap magit-delete-thing] 'magit-tag-delete) + (magit-menu-set map [magit-visit-thing] #'magit-visit-ref "Visit %s") + (magit-menu-set map [magit-delete-thing] #'magit-tag-delete "Delete %m") map) "Keymap for `tag' sections.") +(defun magit--painted-branch-as-menu-section (section) + (and-let* ((branch (and (magit-section-match 'commit) + (magit--painted-branch-at-point)))) + (let ((dummy (magit-section :type 'branch :value branch))) + (oset dummy keymap magit-branch-section-map) + (dolist (slot '(start content hidden parent children)) + (when (slot-boundp section slot) + (setf (eieio-oref dummy slot) + (eieio-oref section slot)))) + dummy))) + +(add-hook 'magit-menu-alternative-section-hook + #'magit--painted-branch-as-menu-section) + (defun magit-insert-branch-description () "Insert header containing the description of the current branch. Insert a header line with the name and description of the current branch. The description is taken from the Git variable `branch..description'; if that is undefined then no header line is inserted at all." - (when-let ((branch (magit-get-current-branch)) - (desc (magit-get "branch" branch "description")) - (desc (split-string desc "\n"))) + (when-let* ((branch (magit-get-current-branch)) + (desc (magit-get "branch" branch "description")) + (desc (split-string desc "\n"))) (when (equal (car (last desc)) "") (setq desc (butlast desc))) (magit-insert-section (branchdesc branch t) (magit-insert-heading branch ": " (car desc)) (when (cdr desc) - (insert (mapconcat 'identity (cdr desc) "\n")) + (insert (mapconcat #'identity (cdr desc) "\n")) (insert "\n\n"))))) (defun magit-insert-tags () @@ -604,7 +616,7 @@ line is inserted at all." (magit-make-margin-overlay nil t))) (defun magit-refs--format-local-branches () - (let ((lines (-keep 'magit-refs--format-local-branch + (let ((lines (-keep #'magit-refs--format-local-branch (magit-git-lines "for-each-ref" (concat "--format=\ @@ -743,7 +755,7 @@ line is inserted at all." (magit-insert-section-body (let ((start (point)) (magit-insert-section--current nil)) - (magit-git-wash (apply-partially 'magit-log-wash-log 'cherry) + (magit-git-wash (apply-partially #'magit-log-wash-log 'cherry) "cherry" "-v" (magit-abbrev-arg) magit-buffer-upstream ref) (if (= (point) start) (message "No cherries for %s" ref) diff --git a/elpa/magit-20220116.1908/magit-remote.el b/elpa/magit-20220518.2359/magit-remote.el similarity index 94% rename from elpa/magit-20220116.1908/magit-remote.el rename to elpa/magit-20220518.2359/magit-remote.el index 4be41fcf..8c9dc1e0 100644 --- a/elpa/magit-20220116.1908/magit-remote.el +++ b/elpa/magit-20220518.2359/magit-remote.el @@ -1,19 +1,16 @@ -;;; magit-remote.el --- transfer Git commits -*- lexical-binding: t -*- +;;; magit-remote.el --- Transfer Git commits -*- lexical-binding:t -*- -;; Copyright (C) 2008-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Jonas Bernoulli ;; Maintainer: Jonas Bernoulli ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Magit is free software; you can redistribute it and/or modify it +;; 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. +;; the Free Software Foundation, either version 3 of the License, 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 @@ -21,7 +18,7 @@ ;; 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. +;; along with Magit. If not, see . ;;; Commentary: @@ -114,7 +111,7 @@ has to be used to view and change remote related variables." (if (pcase (list magit-remote-add-set-remote.pushDefault (magit-get "remote.pushDefault")) (`(,(pred stringp) ,_) t) - ((or `(ask ,_) `(ask-if-unset nil)) + ((or `(ask ,_) '(ask-if-unset nil)) (y-or-n-p (format "Set `remote.pushDefault' to \"%s\"? " remote)))) (progn (magit-call-git "remote" "add" args remote url) (setf (magit-get "remote.pushDefault") remote) @@ -205,7 +202,7 @@ the now stale refspecs. Other stale branches are not removed." (magit-call-git "remote" "rm" remote)) (?a "or [a]abort" (user-error "Abort"))) - (if (if (= (length stale) 1) + (if (if (length= stale 1) (pcase-let ((`(,refspec . ,refs) (car stale))) (magit-confirm 'prune-stale-refspecs (format "Prune stale refspec %s and branch %%s" refspec) @@ -268,8 +265,8 @@ refspec." (magit-read-remote "Delete remote")))) (let ((refspecs (magit-get-all "remote" remote "fetch")) (standard (format "+refs/heads/*:refs/remotes/%s/*" remote))) - (when (and (= (length refspecs) 1) - (not (string-match-p "\\*" (car refspecs))) + (when (and (length= refspecs 1) + (not (string-search "*" (car refspecs))) (yes-or-no-p (format "Also replace refspec %s with %s? " (car refspecs) standard))) @@ -309,20 +306,20 @@ refspec." (transient-define-infix magit-remote..url () :class 'magit--git-variable:urls - :scope 'magit--read-remote-scope + :scope #'magit--read-remote-scope :variable "remote.%s.url" :multi-value t :history-key 'magit-remote..*url) (transient-define-infix magit-remote..fetch () :class 'magit--git-variable - :scope 'magit--read-remote-scope + :scope #'magit--read-remote-scope :variable "remote.%s.fetch" :multi-value t) (transient-define-infix magit-remote..pushurl () :class 'magit--git-variable:urls - :scope 'magit--read-remote-scope + :scope #'magit--read-remote-scope :variable "remote.%s.pushurl" :multi-value t :history-key 'magit-remote..*url @@ -330,12 +327,12 @@ refspec." (transient-define-infix magit-remote..push () :class 'magit--git-variable - :scope 'magit--read-remote-scope + :scope #'magit--read-remote-scope :variable "remote.%s.push") (transient-define-infix magit-remote..tagopt () :class 'magit--git-variable:choices - :scope 'magit--read-remote-scope + :scope #'magit--read-remote-scope :variable "remote.%s.tagOpt" :choices '("--no-tags" "--tags")) diff --git a/elpa/magit-20220116.1908/magit-repos.el b/elpa/magit-20220518.2359/magit-repos.el similarity index 62% rename from elpa/magit-20220116.1908/magit-repos.el rename to elpa/magit-20220518.2359/magit-repos.el index 123c2edb..9dd924fc 100644 --- a/elpa/magit-20220116.1908/magit-repos.el +++ b/elpa/magit-20220518.2359/magit-repos.el @@ -1,19 +1,16 @@ -;;; magit-repos.el --- listing repositories -*- lexical-binding: t -*- +;;; magit-repos.el --- Listing repositories -*- lexical-binding:t -*- -;; Copyright (C) 2010-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Jonas Bernoulli ;; Maintainer: Jonas Bernoulli ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Magit is free software; you can redistribute it and/or modify it +;; 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. +;; the Free Software Foundation, either version 3 of the License, 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 @@ -21,7 +18,7 @@ ;; 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. +;; along with Magit. If not, see . ;;; Commentary: @@ -64,18 +61,21 @@ This option controls which repositories are being listed by :package-version '(magit . "2.9.0") :group 'magit-repolist :type 'hook - :get 'magit-hook-custom-get + :get #'magit-hook-custom-get :options '(hl-line-mode)) (defcustom magit-repolist-columns '(("Name" 25 magit-repolist-column-ident nil) - ("Version" 25 magit-repolist-column-version nil) + ("Version" 25 magit-repolist-column-version + ((:sort magit-repolist-version<))) ("BU" 3 magit-repolist-column-unpushed-to-upstream - ((:right-align t) - (:help-echo "Local changes not in upstream"))) + (;; (:help-echo "Local changes not in upstream") + (:right-align t) + (:sort <))) ("Path" 99 magit-repolist-column-path nil)) "List of columns displayed by `magit-list-repositories'. @@ -86,9 +86,15 @@ of the column. FORMAT is a function that is called with one argument, the repository identification (usually its basename), and with `default-directory' bound to the toplevel of its working tree. It has to return a string to be inserted or nil. PROPS is -an alist that supports the keys `:right-align' and `:pad-right'. -Some entries also use `:help-echo', but `tabulated-list' does not -actually support that yet. +an alist that supports the keys `:right-align', `:pad-right' and +`:sort'. + +The `:sort' function has a weird interface described in the +docstring of `tabulated-list--get-sort'. Alternatively `<' and +`magit-repolist-version<' can be used as those functions are +automatically replaced with functions that satisfy the interface. +Set `:sort' to nil to inhibit sorting; if unspecifed, then the +column is sortable using the default sorter. You may wish to display a range of numeric columns using just one character per column and without any padding between columns, in @@ -105,6 +111,7 @@ than 9." (list (choice :tag "Property" (const :right-align) (const :pad-right) + (const :sort) (symbol)) (sexp :tag "Value")))))) @@ -137,7 +144,7 @@ non-nil, means to invert the resulting sort." (boolean :tag "Flip order")))) ;;; List Repositories -;;;; Command +;;;; List Commands ;;;###autoload (defun magit-list-repositories () "Display a list of repositories. @@ -147,14 +154,7 @@ repositories are displayed." (interactive) (magit-repolist-setup (default-value 'magit-repolist-columns))) -;;;; Mode - -(defvar magit-repolist-mode-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map tabulated-list-mode-map) - (define-key map (kbd "C-m") 'magit-repolist-status) - map) - "Local keymap for Magit-Repolist mode buffers.") +;;;; Mode Commands (defun magit-repolist-status (&optional _button) "Show the status for the repository at point." @@ -163,15 +163,116 @@ repositories are displayed." (magit-status-setup-buffer (expand-file-name it)) (user-error "There is no repository at point"))) +(defun magit-repolist-mark () + "Mark a repository and move to the next line." + (interactive) + (magit-repolist--ensure-padding) + (tabulated-list-put-tag "*" t)) + +(defun magit-repolist-unmark () + "Unmark a repository and move to the next line." + (interactive) + (tabulated-list-put-tag " " t)) + +(defun magit-repolist-fetch (repos) + "Fetch all marked or listed repositories." + (interactive (list (magit-repolist--get-repos ?*))) + (run-hooks 'magit-credential-hook) + (magit-repolist--mapc (apply-partially #'magit-run-git "remote" "update") + repos "Fetching in %s...")) + +(defun magit-repolist-find-file-other-frame (repos file) + "Find a file in all marked or listed repositories." + (interactive (list (magit-repolist--get-repos ?*) + (read-string "Find file in repositories: "))) + (magit-repolist--mapc (apply-partially #'find-file-other-frame file) repos)) + +(defun magit-repolist--ensure-padding () + "Set `tabulated-list-padding' to 2, unless that is already non-zero." + (when (zerop tabulated-list-padding) + (setq tabulated-list-padding 2) + (tabulated-list-init-header) + (tabulated-list-print t))) + +(defun magit-repolist--get-repos (&optional char) + "Return marked repositories or `all' if none are marked. +If optional CHAR is non-nil, then only return repositories +marked with that character. If no repositories are marked +then ask whether to act on all repositories instead." + (or (magit-repolist--marked-repos char) + (if (magit-confirm 'repolist-all + "Nothing selected. Act on ALL displayed repositories") + 'all + (user-error "Abort")))) + +(defun magit-repolist--marked-repos (&optional char) + "Return marked repositories. +If optional CHAR is non-nil, then only return repositories +marked with that character." + (let (c list) + (save-excursion + (goto-char (point-min)) + (while (not (eobp)) + (setq c (char-after)) + (unless (eq c ?\s) + (if char + (when (eq c char) + (push (tabulated-list-get-id) list)) + (push (cons c (tabulated-list-get-id)) list))) + (forward-line))) + list)) + +(defun magit-repolist--mapc (fn repos &optional msg) + "Apply FN to each directory in REPOS for side effects only. +If REPOS is the symbol `all', then call FN for all displayed +repositories. When FN is called, `default-directory' is bound to +the top-level directory of the current repository. If optional +MSG is non-nil then that is displayed around each call to FN. +If it contains \"%s\" then the directory is substituted for that." + (when (eq repos 'all) + (setq repos nil) + (save-excursion + (goto-char (point-min)) + (while (not (eobp)) + (push (tabulated-list-get-id) repos) + (forward-line))) + (setq repos (nreverse repos))) + (let ((base default-directory) + (len (length repos)) + (i 0)) + (mapc (lambda (repo) + (let ((default-directory + (file-name-as-directory (expand-file-name repo base)))) + (if msg + (let ((msg (concat (format "(%s/%s) " (cl-incf i) len) + (format msg default-directory)))) + (message msg) + (funcall fn) + (message (concat msg "done"))) + (funcall fn)))) + repos))) + +;;;; Mode + +(defvar magit-repolist-mode-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map tabulated-list-mode-map) + (define-key map (kbd "C-m") #'magit-repolist-status) + (define-key map (kbd "m") #'magit-repolist-mark) + (define-key map (kbd "u") #'magit-repolist-unmark) + (define-key map (kbd "f") #'magit-repolist-fetch) + (define-key map (kbd "5") #'magit-repolist-find-file-other-frame) + map) + "Local keymap for Magit-Repolist mode buffers.") + (define-derived-mode magit-repolist-mode tabulated-list-mode "Repos" "Major mode for browsing a list of Git repositories." (setq-local x-stretch-cursor nil) (setq tabulated-list-padding 0) - (add-hook 'tabulated-list-revert-hook 'magit-repolist-refresh nil t) + (add-hook 'tabulated-list-revert-hook #'magit-repolist-refresh nil t) (setq imenu-prev-index-position-function - 'magit-imenu--repolist-prev-index-position-function) - (setq imenu-extract-index-name-function - 'magit-imenu--repolist-extract-index-name-function)) + #'magit-repolist--imenu-prev-index-position) + (setq imenu-extract-index-name-function #'tabulated-list-get-id)) (defun magit-repolist-setup (columns) (unless magit-repository-directories @@ -180,10 +281,11 @@ repositories are displayed." (with-current-buffer (get-buffer-create "*Magit Repositories*") (magit-repolist-mode) (setq-local magit-repolist-columns columns) + (magit-repolist-setup-1) (magit-repolist-refresh) (switch-to-buffer (current-buffer)))) -(defun magit-repolist-refresh () +(defun magit-repolist-setup-1 () (unless tabulated-list-sort-key (setq tabulated-list-sort-key (pcase-let ((`(,column . ,flip) magit-repolist-sort-key)) @@ -191,10 +293,25 @@ repositories are displayed." (caar magit-repolist-columns)) flip)))) (setq tabulated-list-format - (vconcat (mapcar (pcase-lambda (`(,title ,width ,_fn ,props)) - (nconc (list title width t) - (-flatten props))) - magit-repolist-columns))) + (vconcat (-map-indexed + (lambda (idx column) + (pcase-let* ((`(,title ,width ,_fn ,props) column) + (sort-set (assoc :sort props)) + (sort-fn (cadr sort-set))) + (nconc (list title width + (cond ((eq sort-fn '<) + (magit-repolist-make-sorter + sort-fn #'string-to-number idx)) + ((eq sort-fn 'magit-repolist-version<) + (magit-repolist-make-sorter + sort-fn #'identity idx)) + (sort-fn sort-fn) + (sort-set nil) + (t t))) + (flatten-tree props)))) + magit-repolist-columns)))) + +(defun magit-repolist-refresh () (setq tabulated-list-entries (mapcar (pcase-lambda (`(,id . ,path)) (let ((default-directory path)) @@ -216,8 +333,24 @@ repositories are displayed." (tabulated-list-print t) (message "Listing repositories...done")) +(defun magit-repolist--imenu-prev-index-position () + (and (not (bobp)) + (forward-line -1))) + ;;;; Columns +(defun magit-repolist-make-sorter (sort-predicate convert-cell column-idx) + "Return a function suitable as a sorter for tabulated lists. +See `tabulated-list--get-sorter'. Given a more reasonable API +this would not be necessary and one could just use SORT-PREDICATE +directly. CONVERT-CELL can be used to turn the cell value, which +is always a string back into e.g. a number. COLUMN-IDX has to be +the index of the column that uses the returned sorter function." + (lambda (a b) + (funcall sort-predicate + (funcall convert-cell (aref (cadr a) column-idx)) + (funcall convert-cell (aref (cadr b) column-idx))))) + (defun magit-repolist-column-ident (spec) "Insert the identification of the repository. Usually this is just its basename." @@ -227,26 +360,47 @@ Usually this is just its basename." "Insert the absolute path of the repository." (abbreviate-file-name default-directory)) +(defvar magit-repolist-column-version-regexp "\ +\\(?1:-\\(?2:[0-9]*\\)\ +\\(?3:-g[a-z0-9]*\\)\\)?\ +\\(?:-\\(?4:dirty\\)\\)\ +?\\'") + +(defvar magit-repolist-column-version-resume-regexp + "\\`Resume development\\'") + (defun magit-repolist-column-version (_) "Insert a description of the repository's `HEAD' revision." - (when-let ((v (or (magit-git-string "describe" "--tags" "--dirty") + (and-let* ((v (or (magit-git-string "describe" "--tags" "--dirty") ;; If there are no tags, use the date in MELPA format. (magit-git-string "show" "--no-patch" "--format=%cd-g%h" "--date=format:%Y%m%d.%H%M")))) (save-match-data - (when (string-match - "\\(?:-\\([0-9]*\\)-g[a-z0-9]*\\)?\\(?:-\\(dirty\\)\\)?\\'" v) + (when (string-match magit-repolist-column-version-regexp v) (magit--put-face (match-beginning 0) (match-end 0) 'shadow v) - (when (match-end 1) - (magit--put-face (match-beginning 1) (match-end 1) 'bold v)) (when (match-end 2) - (magit--put-face (match-beginning 2) (match-end 2) 'error v))) + (magit--put-face (match-beginning 2) (match-end 2) 'bold v)) + (when (match-end 4) + (magit--put-face (match-beginning 4) (match-end 4) 'error v)) + (when (and (equal (match-string 2 v) "1") + (string-match-p magit-repolist-column-version-resume-regexp + (magit-rev-format "%s"))) + (setq v (replace-match (propertize "+" 'face 'shadow) t t v 1)))) (if (and v (string-match "\\`[0-9]" v)) (concat " " v) (when (and v (string-match "\\`[^0-9]+" v)) (magit--put-face 0 (match-end 0) 'shadow v)) v)))) +(defun magit-repolist-version< (a b) + (save-match-data + (let ((re "[0-9]+\\(\\.[0-9]*\\)*")) + (setq a (and (string-match re a) (match-string 0 a))) + (setq b (and (string-match re b) (match-string 0 b))) + (cond ((and a b) (version< a b)) + (b nil) + (t t))))) + (defun magit-repolist-column-branch (_) "Insert the current branch." (let ((branch (magit-get-current-branch))) @@ -281,23 +435,23 @@ which only lists the first one found." (defun magit-repolist-column-unpulled-from-upstream (spec) "Insert number of upstream commits not in the current branch." - (--when-let (magit-get-upstream-branch) - (magit-repolist-insert-count (cadr (magit-rev-diff-count "HEAD" it)) spec))) + (and-let* ((br (magit-get-upstream-branch))) + (magit-repolist-insert-count (cadr (magit-rev-diff-count "HEAD" br)) spec))) (defun magit-repolist-column-unpulled-from-pushremote (spec) "Insert number of commits in the push branch but not the current branch." - (--when-let (magit-get-push-branch nil t) - (magit-repolist-insert-count (cadr (magit-rev-diff-count "HEAD" it)) spec))) + (and-let* ((br (magit-get-push-branch nil t))) + (magit-repolist-insert-count (cadr (magit-rev-diff-count "HEAD" br)) spec))) (defun magit-repolist-column-unpushed-to-upstream (spec) "Insert number of commits in the current branch but not its upstream." - (--when-let (magit-get-upstream-branch) - (magit-repolist-insert-count (car (magit-rev-diff-count "HEAD" it)) spec))) + (and-let* ((br (magit-get-upstream-branch))) + (magit-repolist-insert-count (car (magit-rev-diff-count "HEAD" br)) spec))) (defun magit-repolist-column-unpushed-to-pushremote (spec) "Insert number of commits in the current branch but not its push branch." - (--when-let (magit-get-push-branch nil t) - (magit-repolist-insert-count (car (magit-rev-diff-count "HEAD" it)) spec))) + (and-let* ((br (magit-get-push-branch nil t))) + (magit-repolist-insert-count (car (magit-rev-diff-count "HEAD" br)) spec))) (defun magit-repolist-column-branches (spec) "Insert number of branches." @@ -359,12 +513,12 @@ instead." directory-files-no-dot-files-regexp t))))) (defun magit-list-repos-uniquify (alist) - (let (result (dict (make-hash-table :test 'equal))) + (let (result (dict (make-hash-table :test #'equal))) (dolist (a (delete-dups alist)) (puthash (car a) (cons (cdr a) (gethash (car a) dict)) dict)) (maphash (lambda (key value) - (if (= (length value) 1) + (if (length= value 1) (push (cons key (car value)) result) (setq result (append result diff --git a/elpa/magit-20220116.1908/magit-reset.el b/elpa/magit-20220518.2359/magit-reset.el similarity index 90% rename from elpa/magit-20220116.1908/magit-reset.el rename to elpa/magit-20220518.2359/magit-reset.el index 6203a69e..e201c3dd 100644 --- a/elpa/magit-20220116.1908/magit-reset.el +++ b/elpa/magit-20220518.2359/magit-reset.el @@ -1,19 +1,16 @@ -;;; magit-reset.el --- reset fuctionality -*- lexical-binding: t -*- +;;; magit-reset.el --- Reset fuctionality -*- lexical-binding:t -*- -;; Copyright (C) 2010-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Jonas Bernoulli ;; Maintainer: Jonas Bernoulli ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Magit is free software; you can redistribute it and/or modify it +;; 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. +;; the Free Software Foundation, either version 3 of the License, 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 @@ -21,7 +18,7 @@ ;; 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. +;; along with Magit. If not, see . ;;; Commentary: @@ -31,6 +28,8 @@ (require 'magit) +;;; Commands + ;;;###autoload (autoload 'magit-reset "magit" nil t) (transient-define-prefix magit-reset () "Reset the `HEAD', index and/or worktree to a previous state." diff --git a/elpa/magit-20220116.1908/magit-sequence.el b/elpa/magit-20220518.2359/magit-sequence.el similarity index 94% rename from elpa/magit-20220116.1908/magit-sequence.el rename to elpa/magit-20220518.2359/magit-sequence.el index ab6c4b17..87cb0723 100644 --- a/elpa/magit-20220116.1908/magit-sequence.el +++ b/elpa/magit-20220518.2359/magit-sequence.el @@ -1,19 +1,16 @@ -;;; magit-sequence.el --- history manipulation in Magit -*- lexical-binding: t -*- +;;; magit-sequence.el --- History manipulation in Magit -*- lexical-binding:t -*- -;; Copyright (C) 2011-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Jonas Bernoulli ;; Maintainer: Jonas Bernoulli ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Magit is free software; you can redistribute it and/or modify it +;; 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. +;; the Free Software Foundation, either version 3 of the License, 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 @@ -21,7 +18,7 @@ ;; 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. +;; along with Magit. If not, see . ;;; Commentary: @@ -95,8 +92,8 @@ "Resume the current cherry-pick or revert sequence." (interactive) (if (magit-sequencer-in-progress-p) - (if (magit-anything-unstaged-p t) - (user-error "Cannot continue due to unstaged changes") + (if (magit-anything-unmerged-p) + (user-error "Cannot continue due to unresolved conflicts") (magit-run-git-sequencer (if (magit-revert-in-progress-p) "revert" "cherry-pick") "--continue")) (user-error "No cherry-pick or revert in progress"))) @@ -165,7 +162,7 @@ This discards all changes made since the sequence started." :class 'transient-option :shortarg "-m" :argument "--mainline=" - :reader 'transient-read-number-N+) + :reader #'transient-read-number-N+) (defun magit-cherry-pick-read-args (prompt) (list (or (nreverse (magit-region-values 'commit)) @@ -176,8 +173,8 @@ This discards all changes made since the sequence started." (declare (indent defun)) (let ((commits (or (nreverse (magit-region-values 'commit)) (list (funcall (if away - 'magit-read-branch-or-commit - 'magit-read-other-branch-or-commit) + #'magit-read-branch-or-commit + #'magit-read-other-branch-or-commit) (format "%s cherry" (capitalize verb)))))) (current (or (magit-get-current-branch) (and allow-detached (magit-rev-parse "HEAD"))))) @@ -186,8 +183,8 @@ This discards all changes made since the sequence started." (let ((reachable (magit-rev-ancestor-p (car commits) current)) (msg "Cannot %s cherries that %s reachable from HEAD")) (pcase (list away reachable) - (`(nil t) (user-error msg verb "are")) - (`(t nil) (user-error msg verb "are not")))) + ('(nil t) (user-error msg verb "are")) + ('(t nil) (user-error msg verb "are not")))) `(,commits ,@(funcall fn commits) ,(transient-args 'magit-cherry-pick)))) @@ -313,12 +310,11 @@ the process manually." (magit-refresh))) (t (magit-git "checkout" src) - (let ((process-environment process-environment)) - (push (format "%s=%s -i -ne '/^pick (%s)/ or print'" - "GIT_SEQUENCE_EDITOR" - magit-perl-executable - (mapconcat #'magit-rev-abbrev commits "|")) - process-environment) + (with-environment-variables + (("GIT_SEQUENCE_EDITOR" + (format "%s -i -ne '/^pick (%s)/ or print'" + magit-perl-executable + (mapconcat #'magit-rev-abbrev commits "|")))) (magit-run-git-sequencer "rebase" "-i" keep)) (when checkout-dst (set-process-sentinel @@ -334,13 +330,13 @@ the process manually." (defun magit--cherry-pick (commits args &optional revert) (let ((command (if revert "revert" "cherry-pick"))) (when (stringp commits) - (setq commits (if (string-match-p "\\.\\." commits) + (setq commits (if (string-search ".." commits) (split-string commits "\\.\\.") (list commits)))) (magit-run-git-sequencer (if revert "revert" "cherry-pick") (pcase-let ((`(,merge ,non-merge) - (-separate 'magit-merge-commit-p commits))) + (-separate #'magit-merge-commit-p commits))) (cond ((not merge) (--remove (string-prefix-p "--mainline=" it) args)) @@ -357,7 +353,11 @@ the process manually." (defun magit-cherry-pick-in-progress-p () ;; .git/sequencer/todo does not exist when there is only one commit left. - (file-exists-p (magit-git-dir "CHERRY_PICK_HEAD"))) + (or (file-exists-p (magit-git-dir "CHERRY_PICK_HEAD")) + ;; And CHERRY_PICK_HEAD does not exist when a conflict happens + ;; while picking a series of commits with --no-commit. + (when-let ((line (magit-file-line (magit-git-dir "sequencer/todo")))) + (string-prefix-p "pick" line)))) ;;; Revert @@ -409,7 +409,11 @@ without prompting." (defun magit-revert-in-progress-p () ;; .git/sequencer/todo does not exist when there is only one commit left. - (file-exists-p (magit-git-dir "REVERT_HEAD"))) + (or (file-exists-p (magit-git-dir "REVERT_HEAD")) + ;; And REVERT_HEAD does not exist when a conflict happens while + ;; reverting a series of commits with --no-commit. + (when-let ((line (magit-file-line (magit-git-dir "sequencer/todo")))) + (string-prefix-p "revert" line)))) ;;; Patch @@ -448,7 +452,7 @@ without prompting." :class 'transient-option :argument "-p" :allow-empty t - :reader 'transient-read-number-N+) + :reader #'transient-read-number-N+) ;;;###autoload (defun magit-am-apply-patches (&optional files args) @@ -522,6 +526,7 @@ This discards all changes made since the sequence started." (7 magit-merge:--strategy) (7 magit-merge:--strategy-option) (7 "=X" magit-diff:--diff-algorithm :argument "-Xdiff-algorithm=") + (7 "-f" "Force rebase" ("-f" "--force-rebase")) ("-d" "Use author date as committer date" "--committer-date-is-author-date") ("-t" "Use current time as author date" "--ignore-date") ("-a" "Autosquash" "--autosquash") @@ -579,8 +584,8 @@ This discards all changes made since the sequence started." With a prefix argument or when the push-remote is either not configured or unusable, then let the user first configure the push-remote." - :if 'magit-get-current-branch - :description 'magit-pull--pushbranch-description + :if #'magit-get-current-branch + :description #'magit-pull--pushbranch-description (interactive (list (magit-rebase-arguments))) (pcase-let ((`(,branch ,remote) (magit--select-push-remote "rebase onto that"))) @@ -593,8 +598,8 @@ push-remote." With a prefix argument or when the upstream is either not configured or unusable, then let the user first configure the upstream." - :if 'magit-get-current-branch - :description 'magit-rebase--upstream-description + :if #'magit-get-current-branch + :description #'magit-rebase--upstream-description (interactive (list (magit-rebase-arguments))) (let* ((branch (or (magit-get-current-branch) (user-error "No branch is checked out"))) @@ -607,7 +612,7 @@ the upstream." (magit-git-rebase upstream args))) (defun magit-rebase--upstream-description () - (when-let ((branch (magit-get-current-branch))) + (and-let* ((branch (magit-get-current-branch))) (or (magit-get-upstream-branch branch) (let ((remote (magit-get "branch" branch "remote")) (merge (magit-get "branch" branch "merge")) @@ -814,8 +819,7 @@ edit. With a prefix argument the old message is reused as-is." (magit-commit-amend-assert (magit-file-line (magit-git-dir "rebase-merge/orig-head")))) (if noedit - (let ((process-environment process-environment)) - (push "GIT_EDITOR=true" process-environment) + (with-environment-variables (("GIT_EDITOR" "true")) (magit-run-git-async (magit--rebase-resume-command) "--continue") (set-process-sentinel magit-this-process #'magit-sequencer-process-sentinel) @@ -856,6 +860,15 @@ edit. With a prefix argument the old message is reused as-is." (defun magit--rebase-resume-command () (if (file-exists-p (magit-git-dir "rebase-recursive")) "rbr" "rebase")) +(defun magit-rebase--get-state-lines (file) + (and (magit-rebase-in-progress-p) + (magit-file-line + (magit-git-dir + (concat (if (file-directory-p (magit-git-dir "rebase-merge")) + "rebase-merge/" + "rebase-apply/") + file))))) + ;;; Sections (defun magit-insert-sequencer-sequence () @@ -963,13 +976,13 @@ status buffer (i.e. the reverse of how they will be applied)." (dolist (line (magit-rebase--todo)) (with-slots (action-type action action-options target) line (pcase action-type - (`commit + ('commit (magit-sequence-insert-commit action target 'magit-sequence-pick)) ((or (or `exec `label) (and `merge (guard (not action-options)))) (insert (propertize action 'font-lock-face 'magit-sequence-onto) "\s" (propertize target 'font-lock-face 'git-rebase-label) "\n")) - (`merge + ('merge (if-let ((hash (and (string-match "-[cC] \\([^ ]+\\)" action-options) (match-string 1 action-options)))) (magit-insert-section (commit hash) @@ -981,8 +994,8 @@ status buffer (i.e. the reverse of how they will be applied)." (magit-sequence-insert-sequence (magit-file-line (magit-git-dir "rebase-merge/stopped-sha")) onto - (--when-let (magit-file-lines (magit-git-dir "rebase-merge/done")) - (cadr (split-string (car (last it))))))) + (and-let* ((lines (magit-file-lines (magit-git-dir "rebase-merge/done")))) + (cadr (split-string (car (last lines))))))) (defun magit-rebase-insert-apply-sequence (onto) (let ((rewritten @@ -1042,7 +1055,7 @@ status buffer (i.e. the reverse of how they will be applied)." (magit-sequence-insert-commit "gone" stop 'magit-sequence-drop))) (setq stop nil)))) (dolist (rev done) - (apply 'magit-sequence-insert-commit + (apply #'magit-sequence-insert-commit (cond ((equal rev stop) ;; ...but its reincarnation lives on. ;; Or it didn't die in the first place. diff --git a/elpa/magit-20220518.2359/magit-sparse-checkout.el b/elpa/magit-20220518.2359/magit-sparse-checkout.el new file mode 100644 index 00000000..e9f761d7 --- /dev/null +++ b/elpa/magit-20220518.2359/magit-sparse-checkout.el @@ -0,0 +1,170 @@ +;;; magit-sparse-checkout.el --- Sparse checkout support for Magit -*- lexical-binding:t -*- + +;; Copyright (C) 2008-2022 The Magit Project Contributors + +;; Author: Kyle Meyer +;; Maintainer: Jonas Bernoulli + +;; SPDX-License-Identifier: GPL-3.0-or-later + +;; 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 of the License, 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 . + +;;; Commentary: + +;; This library provides an interface to the `git sparse-checkout' +;; command. It's been possible to define sparse checkouts since Git +;; v1.7.0 by adding patterns to $GIT_DIR/info/sparse-checkout and +;; calling `git read-tree -mu HEAD' to update the index and working +;; tree. However, Git v2.25 introduced the `git sparse-checkout' +;; command along with "cone mode", which restricts the possible +;; patterns to directories to provide better performance. +;; +;; The goal of this library is to support the `git sparse-checkout' +;; command operating in cone mode. + +;;; Code: + +(require 'magit) + +;;; Utilities + +(defun magit-sparse-checkout-enabled-p () + "Return non-nil if working tree is a sparse checkout." + (magit-get-boolean "core.sparsecheckout")) + +(defun magit-sparse-checkout--assert-version () + ;; Older versions of Git have the ability to define sparse checkout + ;; patterns in .git/info/sparse-checkout, but the sparse-checkout + ;; command isn't available until 2.25.0. + (when (magit-git-version< "2.25.0") + (user-error "`git sparse-checkout' not available until Git v2.25"))) + +(defun magit-sparse-checkout--auto-enable () + (if (magit-sparse-checkout-enabled-p) + (unless (magit-get-boolean "core.sparsecheckoutcone") + (user-error + "Magit's sparse checkout functionality requires cone mode")) + ;; Note: Don't use `magit-sparse-checkout-enable' because it's + ;; asynchronous. + (magit-run-git "sparse-checkout" "init" "--cone"))) + +(defun magit-sparse-checkout-directories () + "Return directories that are recursively included in the sparse checkout. +See the `git sparse-checkout' manpage for details about +\"recursive\" versus \"parent\" directories in cone mode." + (and (magit-get-boolean "core.sparsecheckoutcone") + (mapcar #'file-name-as-directory + (magit-git-lines "sparse-checkout" "list")))) + +;;; Commands + +;;;###autoload (autoload 'magit-sparse-checkout "magit-sparse-checkout" nil t) +(transient-define-prefix magit-sparse-checkout () + "Create and manage sparse checkouts." + :man-page "git-sparse-checkout" + ["Arguments for enabling" + :if-not magit-sparse-checkout-enabled-p + ("-i" "Use sparse index" "--sparse-index")] + ["Actions" + [:if-not magit-sparse-checkout-enabled-p + ("e" "Enable sparse checkout" magit-sparse-checkout-enable)] + [:if magit-sparse-checkout-enabled-p + ("d" "Disable sparse checkout" magit-sparse-checkout-disable) + ("r" "Reapply rules" magit-sparse-checkout-reapply)] + [("s" "Set directories" magit-sparse-checkout-set) + ("a" "Add directories" magit-sparse-checkout-add)]]) + +;;;###autoload +(defun magit-sparse-checkout-enable (&optional args) + "Convert the working tree to a sparse checkout." + (interactive (list (transient-args 'magit-sparse-checkout))) + (magit-sparse-checkout--assert-version) + (magit-run-git-async "sparse-checkout" "init" "--cone" args)) + +;;;###autoload +(defun magit-sparse-checkout-set (directories) + "Restrict working tree to DIRECTORIES. +To extend rather than override the currently configured +directories, call `magit-sparse-checkout-add' instead." + (interactive + (list (magit-completing-read-multiple* + "Include these directories: " + ;; Note: Given that the appeal of sparse checkouts is + ;; dealing with very large trees, listing all subdirectories + ;; may need to be reconsidered. + (magit-revision-directories "HEAD")))) + (magit-sparse-checkout--assert-version) + (magit-sparse-checkout--auto-enable) + (magit-run-git-async "sparse-checkout" "set" directories)) + +;;;###autoload +(defun magit-sparse-checkout-add (directories) + "Add DIRECTORIES to the working tree. +To override rather than extend the currently configured +directories, call `magit-sparse-checkout-set' instead." + (interactive + (list (magit-completing-read-multiple* + "Add these directories: " + ;; Same performance note as in `magit-sparse-checkout-set', + ;; but even more so given the additional processing. + (seq-remove + (let ((re (concat + "\\`" + (regexp-opt (magit-sparse-checkout-directories))))) + (lambda (d) (string-match-p re d))) + (magit-revision-directories "HEAD"))))) + (magit-sparse-checkout--assert-version) + (magit-sparse-checkout--auto-enable) + (magit-run-git-async "sparse-checkout" "add" directories)) + +;;;###autoload +(defun magit-sparse-checkout-reapply () + "Reapply the sparse checkout rules to the working tree. +Some operations such as merging or rebasing may need to check out +files that aren't included in the sparse checkout. Call this +command to reset to the sparse checkout state." + (interactive) + (magit-sparse-checkout--assert-version) + (magit-run-git-async "sparse-checkout" "reapply")) + +;;;###autoload +(defun magit-sparse-checkout-disable () + "Convert sparse checkout to full checkout. +Note that disabling the sparse checkout does not clear the +configured directories. Call `magit-sparse-checkout-enable' to +restore the previous sparse checkout." + (interactive) + (magit-sparse-checkout--assert-version) + (magit-run-git-async "sparse-checkout" "disable")) + +;;; Miscellaneous + +(defun magit-sparse-checkout-insert-header () + "Insert header line with sparse checkout information. +This header is not inserted by default. To enable it, add it to +`magit-status-headers-hook'." + (when (magit-sparse-checkout-enabled-p) + (insert (propertize (format "%-10s" "Sparse! ") + 'font-lock-face 'magit-section-heading)) + (insert + (let ((dirs (magit-sparse-checkout-directories))) + (pcase (length dirs) + (0 "top-level directory") + (1 (car dirs)) + (n (format "%d directories" n))))) + (insert ?\n))) + +;;; _ +(provide 'magit-sparse-checkout) +;;; magit-sparse-checkout.el ends here diff --git a/elpa/magit-20220116.1908/magit-stash.el b/elpa/magit-20220518.2359/magit-stash.el similarity index 88% rename from elpa/magit-20220116.1908/magit-stash.el rename to elpa/magit-20220518.2359/magit-stash.el index 2b80fc87..8aee060a 100644 --- a/elpa/magit-20220116.1908/magit-stash.el +++ b/elpa/magit-20220518.2359/magit-stash.el @@ -1,19 +1,16 @@ -;;; magit-stash.el --- stash support for Magit -*- lexical-binding: t -*- +;;; magit-stash.el --- Stash support for Magit -*- lexical-binding:t -*- -;; Copyright (C) 2008-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Jonas Bernoulli ;; Maintainer: Jonas Bernoulli ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Magit is free software; you can redistribute it and/or modify it +;; 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. +;; the Free Software Foundation, either version 3 of the License, 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 @@ -21,7 +18,7 @@ ;; 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. +;; along with Magit. If not, see . ;;; Commentary: @@ -31,6 +28,7 @@ (require 'magit) (require 'magit-reflog) +(require 'magit-sequence) ;;; Options @@ -78,7 +76,7 @@ AUTHOR-WIDTH has to be an integer. When the name of the author :group 'magit-stash :group 'magit-margin :type magit-log-margin--custom-type - :initialize 'magit-custom-initialize-reset + :initialize #'magit-custom-initialize-reset :set-after '(magit-log-margin) :set (apply-partially #'magit-margin-set-variable 'magit-stashes-mode)) @@ -95,7 +93,8 @@ AUTHOR-WIDTH has to be an integer. When the name of the author ("z" "both" magit-stash-both) ("i" "index" magit-stash-index) ("w" "worktree" magit-stash-worktree) - ("x" "keeping index" magit-stash-keep-index)] + ("x" "keeping index" magit-stash-keep-index) + ("P" "push" magit-stash-push :level 5)] ["Snapshot" ("Z" "both" magit-snapshot-both) ("I" "index" magit-snapshot-index) @@ -210,6 +209,30 @@ while two prefix arguments are equivalent to `--all'." (magit-stash-save (concat "WIP on " (magit-stash-summary)) index worktree untracked refresh t)) +;;;###autoload (autoload 'magit-stash-push "magit-stash" nil t) +(transient-define-prefix magit-stash-push (&optional transient args) + "Create stash using \"git stash push\". + +This differs from Magit's other stashing commands, which don't +use \"git stash\" and are generally more flexible but don't allow +specifying a list of files to be stashed." + :man-page "git-stash" + ["Arguments" + (magit:-- :reader ,(-rpartial #'magit-read-files + #'magit-modified-files)) + ("-u" "Also save untracked files" ("-u" "--include-untracked")) + ("-a" "Also save untracked and ignored files" ("-a" "--all")) + ("-k" "Keep index" ("-k" "--keep-index")) + ("-K" "Don't keep index" "--no-keep-index")] + ["Actions" + ("P" "push" magit-stash-push)] + (interactive (if (eq transient-current-command 'magit-stash-push) + (list nil (transient-args 'magit-stash-push)) + (list t))) + (if transient + (transient-setup 'magit-stash-push) + (magit-run-git "stash" "push" args))) + ;;;###autoload (defun magit-stash-apply (stash) "Apply a stash to the working tree. @@ -294,7 +317,7 @@ current branch or `HEAD' as the start-point." (magit-stash-create message index worktree untracked)) (if (eq keep 'worktree) (with-temp-buffer - (magit-git-insert "diff" "--cached") + (magit-git-insert "diff" "--cached" "--no-ext-diff") (magit-run-git-with-input "apply" "--reverse" "--cached" "--ignore-space-change" "-") (magit-run-git-with-input @@ -351,16 +374,17 @@ current branch or `HEAD' as the start-point." (defvar magit-stashes-section-map (let ((map (make-sparse-keymap))) - (define-key map [remap magit-delete-thing] 'magit-stash-clear) + (magit-menu-set map [magit-visit-thing] #'magit-stash-list "List %t") + (magit-menu-set map [magit-delete-thing] #'magit-stash-clear "Clear %t") map) "Keymap for `stashes' section.") (defvar magit-stash-section-map (let ((map (make-sparse-keymap))) - (define-key map [remap magit-visit-thing] 'magit-stash-show) - (define-key map [remap magit-delete-thing] 'magit-stash-drop) - (define-key map "a" 'magit-stash-apply) - (define-key map "A" 'magit-stash-pop) + (magit-menu-set map [magit-visit-thing] #'magit-stash-show "Visit %v") + (magit-menu-set map [magit-delete-thing] #'magit-stash-drop "Delete %M") + (magit-menu-set map [magit-cherry-apply] #'magit-stash-apply "Apply %M") + (magit-menu-set map [magit-cherry-pick] #'magit-stash-pop "Pop %M") map) "Keymap for `stash' sections.") @@ -374,14 +398,7 @@ If optional REF is non-nil, show reflog for that instead. If optional HEADING is non-nil, use that as section heading instead of \"Stashes:\"." (let ((verified (magit-rev-verify ref)) - (autostash - (and (magit-rebase-in-progress-p) - (thread-first - (if (file-directory-p (magit-git-dir "rebase-merge")) - "rebase-merge/autostash" - "rebase-apply/autostash") - magit-git-dir - magit-file-line)))) + (autostash (magit-rebase--get-state-lines "autostash"))) (when (or autostash verified) (magit-insert-section (stashes ref) (magit-insert-heading heading) @@ -399,7 +416,7 @@ instead of \"Stashes:\"." (backward-char) (magit-log-format-margin autostash author date))))) (if verified - (magit-git-wash (apply-partially 'magit-log-wash-log 'stash) + (magit-git-wash (apply-partially #'magit-log-wash-log 'stash) "reflog" "--format=%gd%x00%aN%x00%at%x00%gs" ref) (insert ?\n) (save-excursion @@ -428,7 +445,7 @@ instead of \"Stashes:\"." (magit-insert-heading (if (equal magit-buffer-refname "refs/stash") "Stashes:" (format "Stashes [%s]:" magit-buffer-refname))) - (magit-git-wash (apply-partially 'magit-log-wash-log 'stash) + (magit-git-wash (apply-partially #'magit-log-wash-log 'stash) "reflog" "--format=%gd%x00%aN%x00%at%x00%gs" magit-buffer-refname))) (cl-defmethod magit-buffer-value (&context (major-mode magit-stashes-mode)) @@ -443,8 +460,8 @@ If there is no stash buffer in the same frame, then do nothing." (magit--maybe-update-stash-buffer))) (defun magit--maybe-update-stash-buffer () - (when-let ((stash (magit-section-value-if 'stash)) - (buffer (magit-get-mode-buffer 'magit-stash-mode nil t))) + (when-let* ((stash (magit-section-value-if 'stash)) + (buffer (magit-get-mode-buffer 'magit-stash-mode nil t))) (if magit--update-stash-buffer (setq magit--update-stash-buffer (list stash buffer)) (setq magit--update-stash-buffer (list stash buffer)) @@ -477,7 +494,8 @@ If there is no stash buffer in the same frame, then do nothing." (define-derived-mode magit-stash-mode magit-diff-mode "Magit Stash" "Mode for looking at individual stashes." :group 'magit-diff - (hack-dir-local-variables-non-file-buffer)) + (hack-dir-local-variables-non-file-buffer) + (setq magit--imenu-group-types '(commit))) (defun magit-stash-setup-buffer (stash args files) (magit-setup-buffer #'magit-stash-mode nil diff --git a/elpa/magit-20220116.1908/magit-status.el b/elpa/magit-20220518.2359/magit-status.el similarity index 90% rename from elpa/magit-20220116.1908/magit-status.el rename to elpa/magit-20220518.2359/magit-status.el index eed0dcd2..53a4f17d 100644 --- a/elpa/magit-20220116.1908/magit-status.el +++ b/elpa/magit-20220518.2359/magit-status.el @@ -1,19 +1,16 @@ -;;; magit-status.el --- the grand overview -*- lexical-binding: t -*- +;;; magit-status.el --- The grand overview -*- lexical-binding:t -*- -;; Copyright (C) 2010-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Jonas Bernoulli ;; Maintainer: Jonas Bernoulli ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Magit is free software; you can redistribute it and/or modify it +;; 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. +;; the Free Software Foundation, either version 3 of the License, 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 @@ -21,7 +18,7 @@ ;; 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. +;; along with Magit. If not, see . ;;; Commentary: @@ -171,7 +168,7 @@ AUTHOR-WIDTH has to be an integer. When the name of the author :group 'magit-status :group 'magit-margin :type magit-log-margin--custom-type - :initialize 'magit-custom-initialize-reset + :initialize #'magit-custom-initialize-reset :set-after '(magit-log-margin) :set (apply-partially #'magit-margin-set-variable 'magit-status-mode)) @@ -292,7 +289,7 @@ prefix arguments: (put 'magit-status 'interactive-only 'magit-status-setup-buffer) ;;;###autoload -(defalias 'magit 'magit-status +(defalias 'magit #'magit-status "An alias for `magit-status' for better discoverability. Instead of invoking this alias for `magit-status' using @@ -333,37 +330,13 @@ init file: (global-set-key (kbd \"C-x g\") 'magit-status-quick)." (magit-display-buffer buffer) (call-interactively #'magit-status))) -(defvar magit--remotes-using-recent-git nil) - -(defun magit--tramp-asserts (directory) - (when-let ((remote (file-remote-p directory))) - (unless (member remote magit--remotes-using-recent-git) - (if-let ((version (let ((default-directory directory)) - (magit-git-version)))) - (if (magit--version>= version magit--minimal-git) - (push remote magit--remotes-using-recent-git) - (display-warning 'magit (format "\ -Magit requires Git >= %s, but on %s the version is %s. - -If multiple Git versions are installed on the host, then the -problem might be that TRAMP uses the wrong executable. - -Check the value of `magit-remote-git-executable' and consult -the info node `(tramp)Remote programs'. -" magit--minimal-git remote version) :error)) - (display-warning 'magit (format "\ -Magit cannot find Git on %s. - -Check the value of `magit-remote-git-executable' and consult -the info node `(tramp)Remote programs'." remote) :error))))) - ;;; Mode (defvar magit-status-mode-map (let ((map (make-sparse-keymap))) (set-keymap-parent map magit-mode-map) - (define-key map "j" 'magit-status-jump) - (define-key map [remap dired-jump] 'magit-dired-jump) + (define-key map "j" #'magit-status-jump) + (define-key map [remap dired-jump] #'magit-dired-jump) map) "Keymap for `magit-status-mode'.") @@ -430,8 +403,10 @@ Type \\[magit-commit] to create a commit. \\{magit-status-mode-map}" :group 'magit-status (hack-dir-local-variables-non-file-buffer) - (setq imenu-create-index-function - 'magit-imenu--status-create-index-function)) + (when magit-status-initial-section + (add-hook 'magit-refresh-buffer-hook + #'magit-status-goto-initial-section nil t)) + (setq magit--imenu-group-types '(not branch commit))) (put 'magit-status-mode 'magit-diff-default-arguments '("--no-ext-diff")) @@ -442,7 +417,8 @@ Type \\[magit-commit] to create a commit. (defun magit-status-setup-buffer (&optional directory) (unless directory (setq directory default-directory)) - (magit--tramp-asserts directory) + (when (file-remote-p directory) + (magit-git-version-assert)) (let* ((default-directory directory) (d (magit-diff--get-value 'magit-status-mode magit-status-use-buffer-arguments)) @@ -476,19 +452,7 @@ Type \\[magit-commit] to create a commit. (magit-run-section-hook 'magit-status-sections-hook))) (defun magit-status-goto-initial-section () - "In a `magit-status-mode' buffer, jump `magit-status-initial-section'. -Actually doing so is deferred until `magit-refresh-buffer-hook' -runs `magit-status-goto-initial-section-1'. That function then -removes itself from the hook, so that this only happens when the -status buffer is first created." - (when (and magit-status-initial-section - (derived-mode-p 'magit-status-mode)) - (add-hook 'magit-refresh-buffer-hook - 'magit-status-goto-initial-section-1 nil t))) - -(defun magit-status-goto-initial-section-1 () - "In a `magit-status-mode' buffer, jump `magit-status-initial-section'. -This function removes itself from `magit-refresh-buffer-hook'." + "Jump to the section specified by `magit-status-initial-section'." (when-let ((section (--some (if (integerp it) (nth (1- it) @@ -503,7 +467,7 @@ This function removes itself from `magit-refresh-buffer-hook'." (magit-section-hide section) (magit-section-show section)))) (remove-hook 'magit-refresh-buffer-hook - 'magit-status-goto-initial-section-1 t)) + #'magit-status-goto-initial-section t)) (defun magit-status-maybe-update-revision-buffer (&optional _) "When moving in the status buffer, update the revision buffer. @@ -536,7 +500,8 @@ The sections are inserted by running the functions on the hook (defvar magit-error-section-map (let ((map (make-sparse-keymap))) - (define-key map [remap magit-visit-thing] 'magit-process-buffer) + (magit-menu-set map [magit-visit-thing] + #'magit-process-buffer "Visit process output") map) "Keymap for `error' sections.") @@ -652,17 +617,17 @@ arguments are for internal use only." (defun magit-insert-push-branch-header () "Insert a header line about the branch the current branch is pushed to." - (when-let ((branch (magit-get-current-branch)) - (target (magit-get-push-branch branch))) + (when-let* ((branch (magit-get-current-branch)) + (target (magit-get-push-branch branch))) (magit-insert-section (branch target) (insert (format "%-10s" "Push: ")) (insert (if (magit-rev-verify target) - (concat target " " - (and magit-status-show-hashes-in-headers + (concat (and magit-status-show-hashes-in-headers (concat (propertize (magit-rev-format "%h" target) 'font-lock-face 'magit-hash) " ")) + target " " (funcall magit-log-format-message-function target (funcall magit-log-format-message-function nil (or (magit-rev-format "%s" target) @@ -689,14 +654,13 @@ arguments are for internal use only." (when (or this-tag next-tag) (magit-insert-section (tag (or this-tag next-tag)) (insert (format "%-10s" (if both-tags "Tags: " "Tag: "))) - (cl-flet ((insert-count - (tag count face) - (insert (concat (propertize tag 'font-lock-face 'magit-tag) - (and (> count 0) - (format " (%s)" - (propertize - (format "%s" count) - 'font-lock-face face))))))) + (cl-flet ((insert-count (tag count face) + (insert (concat (propertize tag 'font-lock-face 'magit-tag) + (and (> count 0) + (format " (%s)" + (propertize + (format "%s" count) + 'font-lock-face face))))))) (when this-tag (insert-count this-tag this-cnt 'magit-branch-local)) (when both-tags (insert ", ")) (when next-tag (insert-count next-tag next-cnt 'magit-tag))) @@ -726,10 +690,10 @@ arguments are for internal use only." If no remote is configured for the current branch, then fall back showing the \"origin\" remote, or if that does not exist the first remote in alphabetic order." - (when-let ((name (magit-get-some-remote)) - ;; Under certain configurations it's possible for url - ;; to be nil, when name is not, see #2858. - (url (magit-get "remote" name "url"))) + (when-let* ((name (magit-get-some-remote)) + ;; Under certain configurations it's possible for + ;; url to be nil, when name is not, see #2858. + (url (magit-get "remote" name "url"))) (magit-insert-section (remote name) (insert (format "%-10s" "Remote: ")) (insert (propertize name 'font-lock-face 'magit-branch-remote) ?\s) @@ -739,8 +703,8 @@ remote in alphabetic order." (defvar magit-untracked-section-map (let ((map (make-sparse-keymap))) - (define-key map [remap magit-delete-thing] 'magit-discard) - (define-key map "s" 'magit-stage) + (magit-menu-set map [magit-stage-file] #'magit-stage "Stage files") + (magit-menu-set map [magit-delete-thing] #'magit-discard "Discard files") map) "Keymap for the `untracked' section.") diff --git a/elpa/magit-20220116.1908/magit-submodule.el b/elpa/magit-20220518.2359/magit-submodule.el similarity index 90% rename from elpa/magit-20220116.1908/magit-submodule.el rename to elpa/magit-20220518.2359/magit-submodule.el index a6d98231..0625e20d 100644 --- a/elpa/magit-20220116.1908/magit-submodule.el +++ b/elpa/magit-20220518.2359/magit-submodule.el @@ -1,19 +1,16 @@ -;;; magit-submodule.el --- submodule support for Magit -*- lexical-binding: t -*- +;;; magit-submodule.el --- Submodule support for Magit -*- lexical-binding:t -*- -;; Copyright (C) 2011-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Jonas Bernoulli ;; Maintainer: Jonas Bernoulli ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Magit is free software; you can redistribute it and/or modify it +;; 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. +;; the Free Software Foundation, either version 3 of the License, 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 @@ -21,7 +18,7 @@ ;; 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. +;; along with Magit. If not, see . ;;; Code: @@ -66,14 +63,27 @@ is inserted. If it is nil, then all sections listed in (defcustom magit-submodule-list-columns '(("Path" 25 magit-modulelist-column-path nil) - ("Version" 25 magit-repolist-column-version nil) + ("Version" 25 magit-repolist-column-version + ((:sort magit-repolist-version<))) ("Branch" 20 magit-repolist-column-branch nil) - ("BU" 3 magit-repolist-column-unpushed-to-upstream ((:right-align t))) - ("BP" 3 magit-repolist-column-unpushed-to-pushremote ((:right-align t))) - ("B" 3 magit-repolist-column-branches ((:right-align t))) - ("S" 3 magit-repolist-column-stashes ((:right-align t)))) + ("BU" 3 magit-repolist-column-unpushed-to-upstream + ((:right-align t) + (:sort <))) + ("BP" 3 magit-repolist-column-unpushed-to-pushremote + ((:right-align t) + (:sort <))) + ("B" 3 magit-repolist-column-branches + ((:right-align t) + (:sort <))) + ("S" 3 magit-repolist-column-stashes + ((:right-align t) + (:sort <)))) "List of columns displayed by `magit-list-submodules'. Each element has the form (HEADER WIDTH FORMAT PROPS). @@ -83,7 +93,15 @@ of the column. FORMAT is a function that is called with one argument, the repository identification (usually its basename), and with `default-directory' bound to the toplevel of its working tree. It has to return a string to be inserted or nil. PROPS is -an alist that supports the keys `:right-align' and `:pad-right'. +an alist that supports the keys `:right-align', `:pad-right' and +`:sort'. + +The `:sort' function has a weird interface described in the +docstring of `tabulated-list--get-sort'. Alternatively `<' and +`magit-repolist-version<' can be used as those functions are +automatically replaced with functions that satisfy the interface. +Set `:sort' to nil to inhibit sorting; if unspecifed, then the +column is sortable using the default sorter. You may wish to display a range of numeric columns using just one character per column and without any padding between columns, in @@ -100,6 +118,7 @@ than 9." (list (choice :tag "Property" (const :right-align) (const :pad-right) + (const :sort) (symbol)) (sexp :tag "Value")))))) @@ -163,7 +182,7 @@ and also setting this variable to t will lead to tears." ()) (cl-defmethod transient-format-description ((obj magit--git-submodule-suffix)) - (let ((value (delq nil (mapcar 'transient-infix-value transient--suffixes)))) + (let ((value (delq nil (mapcar #'transient-infix-value transient--suffixes)))) (replace-regexp-in-string "\\[--[^]]+\\]" (lambda (match) @@ -460,12 +479,12 @@ or, failing that, the abbreviated HEAD commit hash." (magit-with-toplevel (let* ((modules (magit-list-module-paths)) (path-format (format "%%-%is " - (min (apply 'max (mapcar 'length modules)) + (min (apply #'max (mapcar #'length modules)) (/ (window-width) 2)))) (branch-format (format "%%-%is " (min 25 (/ (window-width) 3))))) (dolist (module modules) (let ((default-directory - (expand-file-name (file-name-as-directory module)))) + (expand-file-name (file-name-as-directory module)))) (magit-insert-section (magit-module-section module t) (insert (propertize (format path-format module) 'font-lock-face 'magit-diff-file-heading)) @@ -488,19 +507,25 @@ or, failing that, the abbreviated HEAD commit hash." (defvar magit-modules-section-map (let ((map (make-sparse-keymap))) - (define-key map [remap magit-visit-thing] 'magit-list-submodules) + (magit-menu-set map [remap magit-visit-thing] + #'magit-list-submodules "List %t") map) "Keymap for `modules' sections.") (defvar magit-module-section-map (let ((map (make-sparse-keymap))) - (set-keymap-parent map magit-file-section-map) - (define-key map (kbd "C-j") 'magit-submodule-visit) - (define-key map [C-return] 'magit-submodule-visit) - (define-key map [remap magit-visit-thing] 'magit-submodule-visit) - (define-key map [remap magit-delete-thing] 'magit-submodule-unpopulate) - (define-key map "K" 'magit-file-untrack) - (define-key map "R" 'magit-file-rename) + (define-key map (kbd "C-j") #'magit-submodule-visit) + (define-key map [C-return] #'magit-submodule-visit) + (magit-menu-set map [magit-visit-thing] + #'magit-submodule-visit "Visit %s") + (magit-menu-set map [magit-stage-file] + #'magit-stage "Stage %T" + '(:visible (eq (magit-diff-type) 'unstaged))) + (magit-menu-set map [magit-unstage-file] + #'magit-unstage "Unstage %T" + '(:visible (eq (magit-diff-type) 'staged))) + (define-key-after map [separator-magit-submodule] menu-bar-separator) + (magit-menu-set map [magit-submodule] #'magit-submodule "Module commands...") map) "Keymap for `module' sections.") @@ -578,15 +603,16 @@ These sections can be expanded to show the respective commits." (dolist (module modules) (when (magit-module-worktree-p module) (let ((default-directory - (expand-file-name (file-name-as-directory module)))) + (expand-file-name (file-name-as-directory module)))) (when (magit-file-accessible-directory-p default-directory) (magit-insert-section sec (magit-module-section module t) (magit-insert-heading (propertize module 'font-lock-face 'magit-diff-file-heading) ":") + (oset sec range range) (magit-git-wash - (apply-partially 'magit-log-wash-log 'module) + (apply-partially #'magit-log-wash-log 'module) "-c" "push.default=current" "log" "--oneline" range) (when (> (point) (oref sec content)) @@ -615,40 +641,29 @@ These sections can be expanded to show the respective commits." :group 'magit-repolist-mode (setq-local x-stretch-cursor nil) (setq tabulated-list-padding 0) - (add-hook 'tabulated-list-revert-hook 'magit-submodule-list-refresh nil t) + (add-hook 'tabulated-list-revert-hook #'magit-submodule-list-refresh nil t) (setq imenu-prev-index-position-function - #'magit-imenu--submodule-prev-index-position-function) - (setq imenu-extract-index-name-function - #'magit-imenu--submodule-extract-index-name-function)) + #'magit-repolist--imenu-prev-index-position) + (setq imenu-extract-index-name-function #'tabulated-list-get-id)) (defvar-local magit-submodule-list-predicate nil) (defun magit-submodule-list-setup (columns &optional predicate) (magit-display-buffer (or (magit-get-mode-buffer 'magit-submodule-list-mode) - (magit-with-toplevel - (magit-generate-new-buffer 'magit-submodule-list-mode)))) + (magit-generate-new-buffer 'magit-submodule-list-mode))) (magit-submodule-list-mode) (setq-local magit-repolist-columns columns) + (setq-local magit-repolist-sort-key magit-submodule-list-sort-key) (setq-local magit-submodule-list-predicate predicate) + (magit-repolist-setup-1) (magit-submodule-list-refresh)) (defun magit-submodule-list-refresh () - (unless tabulated-list-sort-key - (setq tabulated-list-sort-key - (pcase-let ((`(,column . ,flip) magit-submodule-list-sort-key)) - (cons (or (car (assoc column magit-submodule-list-columns)) - (caar magit-submodule-list-columns)) - flip)))) - (setq tabulated-list-format - (vconcat (mapcar (pcase-lambda (`(,title ,width ,_fn ,props)) - (nconc (list title width t) - (-flatten props))) - magit-repolist-columns))) (setq tabulated-list-entries (-keep (lambda (module) (let ((default-directory - (expand-file-name (file-name-as-directory module)))) + (expand-file-name (file-name-as-directory module)))) (and (file-exists-p ".git") (or (not magit-submodule-list-predicate) (funcall magit-submodule-list-predicate module)) diff --git a/elpa/magit-20220116.1908/magit-subtree.el b/elpa/magit-20220518.2359/magit-subtree.el similarity index 91% rename from elpa/magit-20220116.1908/magit-subtree.el rename to elpa/magit-20220518.2359/magit-subtree.el index 3d0514ed..fec2affb 100644 --- a/elpa/magit-20220116.1908/magit-subtree.el +++ b/elpa/magit-20220518.2359/magit-subtree.el @@ -1,19 +1,16 @@ -;;; magit-subtree.el --- subtree support for Magit -*- lexical-binding: t -*- +;;; magit-subtree.el --- Subtree support for Magit -*- lexical-binding:t -*- -;; Copyright (C) 2011-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Jonas Bernoulli ;; Maintainer: Jonas Bernoulli ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Magit is free software; you can redistribute it and/or modify it +;; 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. +;; the Free Software Foundation, either version 3 of the License, 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 @@ -21,7 +18,7 @@ ;; 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. +;; along with Magit. If not, see . ;;; Code: @@ -71,7 +68,7 @@ :class 'transient-option :shortarg "-P" :argument "--prefix=" - :reader 'magit-subtree-read-prefix) + :reader #'magit-subtree-read-prefix) (defun magit-subtree-read-prefix (prompt &optional default _history) (let* ((insert-default-directory nil) @@ -107,7 +104,7 @@ :class 'transient-option :key "-o" :argument "--onto=" - :reader 'magit-transient-read-revision) + :reader #'magit-transient-read-revision) (defun magit-subtree-prefix (transient prompt) (--if-let (--first (string-prefix-p "--prefix=" it) diff --git a/elpa/magit-20220116.1908/magit-tag.el b/elpa/magit-20220518.2359/magit-tag.el similarity index 79% rename from elpa/magit-20220116.1908/magit-tag.el rename to elpa/magit-20220518.2359/magit-tag.el index c10a46c8..f127f13a 100644 --- a/elpa/magit-20220116.1908/magit-tag.el +++ b/elpa/magit-20220518.2359/magit-tag.el @@ -1,19 +1,16 @@ -;;; magit-tag.el --- tag functionality -*- lexical-binding: t -*- +;;; magit-tag.el --- Tag functionality -*- lexical-binding:t -*- -;; Copyright (C) 2010-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Jonas Bernoulli ;; Maintainer: Jonas Bernoulli ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Magit is free software; you can redistribute it and/or modify it +;; 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. +;; the Free Software Foundation, either version 3 of the License, 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 @@ -21,7 +18,7 @@ ;; 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. +;; along with Magit. If not, see . ;;; Commentary: @@ -34,6 +31,8 @@ ;; For `magit-tag-delete'. (defvar helm-comp-read-use-marked) +;;; Commands + ;;;###autoload (autoload 'magit-tag "magit" nil t) (transient-define-prefix magit-tag () "Create or delete a tag." @@ -58,7 +57,7 @@ :class 'transient-option :shortarg "-u" :argument "--local-user=" - :reader 'magit-read-gpg-signing-key + :reader #'magit-read-gpg-signing-key :history-key 'magit:--gpg-sign) ;;;###autoload @@ -140,15 +139,21 @@ If this matches versions that are not dot separated numbers, then `magit-tag-version-regexp-alist' has to contain entries for the separators allowed here.") +(defvar magit-release-commit-regexp "\\`Release version \\(.+\\)\\'" + "Regexp used by `magit-tag-release' to parse release commit messages. +The first submatch must match the version string.") + ;;;###autoload (defun magit-tag-release (tag msg &optional args) - "Create a release tag. + "Create a release tag for `HEAD'. Assume that release tags match `magit-release-tag-regexp'. -First prompt for the name of the new tag using the highest -existing tag as initial input and leaving it to the user to -increment the desired part of the version string. +If `HEAD's message matches `magit-release-commit-regexp', then +base the tag on the version string specified by that. Otherwise +prompt for the name of the new tag using the highest existing +tag as initial input and leaving it to the user to increment the +desired part of the version string. If `--annotate' is enabled, then prompt for the message of the new tag. Base the proposed tag message on the message of the @@ -161,7 +166,28 @@ like \"/path/to/foo-bar\"." (save-match-data (pcase-let* ((`(,pver ,ptag ,pmsg) (car (magit--list-releases))) - (tag (read-string "Create release tag: " ptag)) + (msg (magit-rev-format "%s")) + (ver (and (string-match magit-release-commit-regexp msg) + (match-string 1 msg))) + (_ (and (not ver) + (require (quote sisyphus) nil t) + (string-match magit-release-commit-regexp + (magit-rev-format "%s" ptag)) + (user-error "Use `sisyphus-create-release' first"))) + (tag (cond + ((not ptag) + (read-string "Create first release tag: " + (if (string-match-p "\\`[0-9]" ver) + (concat "v" ver) + ver))) + (ver + (concat (and (string-match magit-release-tag-regexp ptag) + (match-string 1 ptag)) + ver)) + (t + (read-string + (format "Create release tag (previous was %s): " ptag) + ptag)))) (ver (and (string-match magit-release-tag-regexp tag) (match-string 2 tag))) (args (magit-tag-arguments))) diff --git a/elpa/magit-20220116.1908/magit-transient.el b/elpa/magit-20220518.2359/magit-transient.el similarity index 70% rename from elpa/magit-20220116.1908/magit-transient.el rename to elpa/magit-20220518.2359/magit-transient.el index 8d6d582f..d7bca899 100644 --- a/elpa/magit-20220116.1908/magit-transient.el +++ b/elpa/magit-20220518.2359/magit-transient.el @@ -1,19 +1,16 @@ -;;; magit-transient.el --- support for transients -*- lexical-binding: t -*- +;;; magit-transient.el --- Support for transients -*- lexical-binding:t -*- -;; Copyright (C) 2008-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Jonas Bernoulli ;; Maintainer: Jonas Bernoulli ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Magit is free software; you can redistribute it and/or modify it +;; 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. +;; the Free Software Foundation, either version 3 of the License, 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 @@ -21,7 +18,7 @@ ;; 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. +;; along with Magit. If not, see . ;;; Commentary: @@ -39,13 +36,17 @@ ;;; Classes (defclass magit--git-variable (transient-variable) - ((scope :initarg :scope))) + ((scope :initarg :scope) + (global :initarg :global :initform nil))) (defclass magit--git-variable:choices (magit--git-variable) ((choices :initarg :choices) (fallback :initarg :fallback :initform nil) (default :initarg :default :initform nil))) +(defclass magit--git-variable:boolean (magit--git-variable:choices) + ((choices :initarg :choices :initform '("true" "false")))) + (defclass magit--git-variable:urls (magit--git-variable) ((seturl-arg :initarg :seturl-arg :initform nil))) @@ -61,22 +62,32 @@ (cl-defmethod transient-init-value ((obj magit--git-variable)) (let ((variable (format (oref obj variable) - (oref obj scope)))) + (oref obj scope))) + (arg (if (oref obj global) "--global" "--local"))) (oset obj variable variable) (oset obj value (cond ((oref obj multi-value) - (magit-get-all variable)) + (magit-get-all arg variable)) (t - (magit-git-string "config" "--local" variable)))))) + (magit-get arg variable)))))) + +(cl-defmethod transient-init-value ((obj magit--git-variable:boolean)) + (let ((variable (format (oref obj variable) + (oref obj scope))) + (arg (if (oref obj global) "--global" "--local"))) + (oset obj variable variable) + (oset obj value (if (magit-get-boolean arg variable) "true" "false")))) ;;;; Read (cl-defmethod transient-infix-read :around ((obj magit--git-variable:urls)) - (mapcar (lambda (url) - (if (string-prefix-p "~" url) - (expand-file-name url) - url)) - (cl-call-next-method obj))) + (transient--with-emergency-exit + (transient--with-suspended-override + (mapcar (lambda (url) + (if (string-prefix-p "~" url) + (expand-file-name url) + url)) + (cl-call-next-method obj))))) (cl-defmethod transient-infix-read ((obj magit--git-variable:choices)) (let ((choices (oref obj choices))) @@ -108,11 +119,12 @@ ;;;; Set (cl-defmethod transient-infix-set ((obj magit--git-variable) value) - (let ((variable (oref obj variable))) + (let ((variable (oref obj variable)) + (arg (if (oref obj global) "--global" "--local"))) (oset obj value value) (if (oref obj multi-value) - (magit-set-all value variable) - (magit-set value variable)) + (magit-set-all value arg variable) + (magit-set value arg variable)) (magit-refresh) (unless (or value transient--prefix) (message "Unset %s" variable)))) @@ -151,25 +163,31 @@ (cl-defmethod transient-format-value ((obj magit--git-variable:choices)) (let* ((variable (oref obj variable)) (choices (oref obj choices)) - (local (magit-git-string "config" "--local" variable)) + (globalp (oref obj global)) + (value nil) (global (magit-git-string "config" "--global" variable)) - (default (oref obj default)) + (defaultp (oref obj default)) + (default (if (functionp defaultp) (funcall defaultp obj) defaultp)) (fallback (oref obj fallback)) (fallback (and fallback - (when-let ((val (magit-get fallback))) + (and-let* ((val (magit-get fallback))) (concat fallback ":" val))))) + (if (not globalp) + (setq value (magit-git-string "config" "--local" variable)) + (setq value global) + (setq global nil)) (when (functionp choices) (setq choices (funcall choices))) (concat (propertize "[" 'face 'transient-inactive-value) (mapconcat (lambda (choice) - (propertize choice 'face (if (equal choice local) + (propertize choice 'face (if (equal choice value) (if (member choice choices) 'transient-value 'font-lock-warning-face) 'transient-inactive-value))) - (if (and local (not (member local choices))) - (cons local choices) + (if (and value (not (member value choices))) + (cons value choices) choices) (propertize "|" 'face 'transient-inactive-value)) (and (or global fallback default) @@ -177,7 +195,7 @@ (propertize "|" 'face 'transient-inactive-value) (cond (global (propertize (concat "global:" global) - 'face (cond (local + 'face (cond (value 'transient-inactive-value) ((member global choices) 'transient-value) @@ -185,14 +203,16 @@ 'font-lock-warning-face)))) (fallback (propertize fallback - 'face (if local + 'face (if value 'transient-inactive-value 'transient-value))) (default - (propertize (concat "default:" default) - 'face (if local - 'transient-inactive-value - 'transient-value)))))) + (propertize (if (functionp defaultp) + (concat "dwim:" default) + (concat "default:" default)) + 'face (if value + 'transient-inactive-value + 'transient-value)))))) (propertize "]" 'face 'transient-inactive-value)))) ;;; _ diff --git a/elpa/magit-20220116.1908/magit-wip.el b/elpa/magit-20220518.2359/magit-wip.el similarity index 92% rename from elpa/magit-20220116.1908/magit-wip.el rename to elpa/magit-20220518.2359/magit-wip.el index 7f42b573..ec6b0cc7 100644 --- a/elpa/magit-20220116.1908/magit-wip.el +++ b/elpa/magit-20220518.2359/magit-wip.el @@ -1,19 +1,16 @@ -;;; magit-wip.el --- commit snapshots to work-in-progress refs -*- lexical-binding: t -*- +;;; magit-wip.el --- Commit snapshots to work-in-progress refs -*- lexical-binding:t -*- -;; Copyright (C) 2010-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Jonas Bernoulli ;; Maintainer: Jonas Bernoulli ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Magit is free software; you can redistribute it and/or modify it +;; 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. +;; the Free Software Foundation, either version 3 of the License, 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 @@ -21,7 +18,7 @@ ;; 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. +;; along with Magit. If not, see . ;;; Commentary: @@ -140,10 +137,10 @@ variant `magit-wip-after-save-mode'." :lighter magit-wip-after-save-local-mode-lighter (if magit-wip-after-save-local-mode (if (and buffer-file-name (magit-inside-worktree-p t)) - (add-hook 'after-save-hook 'magit-wip-commit-buffer-file t t) + (add-hook 'after-save-hook #'magit-wip-commit-buffer-file t t) (setq magit-wip-after-save-local-mode nil) (user-error "Need a worktree and a file")) - (remove-hook 'after-save-hook 'magit-wip-commit-buffer-file t))) + (remove-hook 'after-save-hook #'magit-wip-commit-buffer-file t))) (defun magit-wip-after-save-local-mode-turn-on () (and buffer-file-name @@ -224,8 +221,8 @@ command which is about to be called are committed." :lighter magit-wip-initial-backup-mode-lighter :global t (if magit-wip-initial-backup-mode - (add-hook 'before-save-hook 'magit-wip-commit-initial-backup) - (remove-hook 'before-save-hook 'magit-wip-commit-initial-backup))) + (add-hook 'before-save-hook #'magit-wip-commit-initial-backup) + (remove-hook 'before-save-hook #'magit-wip-commit-initial-backup))) (defun magit--any-wip-mode-enabled-p () "Return non-nil if any global wip mode is enabled." @@ -301,14 +298,7 @@ commit message." ;; deleted in the temporary index. (magit-call-git "update-index" "--add" "--remove" - (and (pcase (magit-repository-local-get - 'update-index-has-ignore-sw-p 'unset) - (`unset - (let ((val (magit-git-version>= "2.25.0"))) - (magit-repository-local-set - 'update-index-has-ignore-sw-p val) - val)) - (val val)) + (and (magit-git-version>= "2.25.0") "--ignore-skip-worktree-entries") "--" files) (magit-with-toplevel @@ -376,7 +366,7 @@ commit message." (defun magit--wip-ref (namespace &optional ref) (concat magit-wip-namespace namespace (or (and ref (string-prefix-p "refs/" ref) ref) - (when-let ((branch (and (not (equal ref "HEAD")) + (and-let* ((branch (and (not (equal ref "HEAD")) (or ref (magit-get-current-branch))))) (concat "refs/heads/" branch)) "HEAD"))) @@ -384,7 +374,7 @@ commit message." (defun magit-wip-maybe-add-commit-hook () (when (and magit-wip-merge-branch (magit-wip-any-enabled-p)) - (add-hook 'git-commit-post-finish-hook 'magit-wip-commit nil t))) + (add-hook 'git-commit-post-finish-hook #'magit-wip-commit nil t))) (defun magit-wip-any-enabled-p () (or magit-wip-mode @@ -443,7 +433,7 @@ many \"branches\" of each wip ref are shown." args files)) (defun magit-wip-log-get-tips (wipref count) - (when-let ((reflog (magit-git-lines "reflog" wipref))) + (and-let* ((reflog (magit-git-lines "reflog" wipref))) (let (tips) (while (and reflog (> count 1)) ;; "start autosaving ..." is the current message, but it used diff --git a/elpa/magit-20220116.1908/magit-worktree.el b/elpa/magit-20220518.2359/magit-worktree.el similarity index 89% rename from elpa/magit-20220116.1908/magit-worktree.el rename to elpa/magit-20220518.2359/magit-worktree.el index 3e176e35..4a94c5bf 100644 --- a/elpa/magit-20220116.1908/magit-worktree.el +++ b/elpa/magit-20220518.2359/magit-worktree.el @@ -1,19 +1,16 @@ -;;; magit-worktree.el --- worktree support -*- lexical-binding: t -*- +;;; magit-worktree.el --- Worktree support -*- lexical-binding:t -*- -;; Copyright (C) 2010-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Jonas Bernoulli ;; Maintainer: Jonas Bernoulli ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Magit is free software; you can redistribute it and/or modify it +;; 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. +;; the Free Software Foundation, either version 3 of the License, 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 @@ -21,7 +18,7 @@ ;; 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. +;; along with Magit. If not, see . ;;; Commentary: @@ -33,7 +30,7 @@ ;;; Options -(defcustom magit-worktree-read-directory-name-function 'read-directory-name +(defcustom magit-worktree-read-directory-name-function #'read-directory-name "Function used to read a directory for worktree commands. This is called with one argument, the prompt, and can be used to e.g. use a base directory other than `default-directory'. @@ -150,8 +147,10 @@ then show it in Dired instead." (defvar magit-worktree-section-map (let ((map (make-sparse-keymap))) - (define-key map [remap magit-visit-thing] 'magit-worktree-status) - (define-key map [remap magit-delete-thing] 'magit-worktree-delete) + (magit-menu-set map [magit-visit-thing] #'magit-worktree-status "Visit %s") + (magit-menu-set map [magit-delete-thing] #'magit-worktree-delete "Delete %m") + (define-key-after map [separator-magit-worktree] menu-bar-separator) + (magit-menu-set map [magit-worktree ] #'magit-worktree "Worktree commands...") map) "Keymap for `worktree' sections.") @@ -159,7 +158,7 @@ then show it in Dired instead." "Insert sections for all worktrees. If there is only one worktree, then insert nothing." (let ((worktrees (magit-list-worktrees))) - (when (> (length worktrees) 1) + (when (length> worktrees 1) (magit-insert-section (worktrees) (magit-insert-heading "Worktrees:") (let* ((cols diff --git a/elpa/magit-20220116.1908/magit.el b/elpa/magit-20220518.2359/magit.el similarity index 77% rename from elpa/magit-20220116.1908/magit.el rename to elpa/magit-20220518.2359/magit.el index 83cba084..75d319c2 100644 --- a/elpa/magit-20220116.1908/magit.el +++ b/elpa/magit-20220518.2359/magit.el @@ -1,42 +1,49 @@ -;;; magit.el --- A Git porcelain inside Emacs -*- lexical-binding: t; coding: utf-8 -*- +;;; magit.el --- A Git porcelain inside Emacs -*- lexical-binding:t; coding:utf-8 -*- -;; Copyright (C) 2008-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Marius Vollmer -;; Jonas Bernoulli +;; Jonas Bernoulli ;; Maintainer: Jonas Bernoulli -;; Kyle Meyer -;; Noam Postavsky +;; Kyle Meyer ;; Former-Maintainers: -;; Nicolas Dudebout -;; Peter J. Weisberg -;; Phil Jackson -;; Rémi Vanicat -;; Yann Hodique +;; Nicolas Dudebout +;; Noam Postavsky +;; Peter J. Weisberg +;; Phil Jackson +;; Rémi Vanicat +;; Yann Hodique -;; Keywords: git tools vc ;; Homepage: https://github.com/magit/magit -;; Package-Requires: ((emacs "25.1") (dash "2.19.1") (git-commit "3.3.0") (magit-section "3.3.0") (transient "0.3.6") (with-editor "3.0.5")) -;; Package-Version: 3.3.0 +;; Keywords: git tools vc + +;; Package-Version: 3.3.0-git +;; Package-Requires: ( +;; (emacs "25.1") +;; (compat "28.1.1.0") +;; (dash "2.19.1") +;; (git-commit "3.3.0") +;; (magit-section "3.3.0") +;; (transient "0.3.6") +;; (with-editor "3.0.5")) + ;; SPDX-License-Identifier: GPL-3.0-or-later -;; 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 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 of the License, +;; 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. +;; 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. +;; along with Magit. If not, see . -;; Magit requires at least GNU Emacs 25.1 and Git 2.2.0. +;; You should have received a copy of the AUTHORS.md file, which +;; lists all contributors. If not, see https://magit.vc/authors. ;;; Commentary: @@ -65,8 +72,21 @@ (require 'package nil t) ; used in `magit-version' (require 'with-editor) -(defconst magit--minimal-git "2.2.0") -(defconst magit--minimal-emacs "25.1") +;; For `magit:--gpg-sign' +(declare-function epg-list-keys "epg" (context &optional name mode)) +(declare-function epg-decode-dn "epg" (alist)) + +;;; Options + +(defcustom magit-openpgp-default-signing-key nil + "Fingerprint of your default Openpgp key used for signing. +If the specified primary key has signing capacity then it is used +as the value of the `--gpg-sign' argument without prompting, even +when other such keys exist. To be able to select another key you +must then use a prefix argument." + :package-version '(magit . "3.4.0") + :group 'magit-commands + :type 'string) ;;; Faces @@ -92,7 +112,7 @@ own faces for the `header-line', or for parts of the (defface magit-hash '((((class color) (background light)) :foreground "grey60") (((class color) (background dark)) :foreground "grey40")) - "Face for the sha1 part of the log output." + "Face for the commit object name in the log output." :group 'magit-faces) (defface magit-tag @@ -279,7 +299,7 @@ Also see info node `(magit)Commands for Buffers Visiting Files'." ;;;###autoload (progn - (defun magit-maybe-define-global-key-bindings () + (defun magit-maybe-define-global-key-bindings (&optional force) (when magit-define-global-key-bindings (let ((map (current-global-map))) (dolist (elt '(("C-x g" . magit-status) @@ -287,12 +307,13 @@ Also see info node `(magit)Commands for Buffers Visiting Files'." ("C-c M-g" . magit-file-dispatch))) (let ((key (kbd (car elt))) (def (cdr elt))) - (unless (or (lookup-key map key) - (where-is-internal def (make-sparse-keymap) t)) + (when (or force + (not (or (lookup-key map key) + (where-is-internal def (make-sparse-keymap) t)))) (define-key map key def))))))) (if after-init-time (magit-maybe-define-global-key-bindings) - (add-hook 'after-init-hook 'magit-maybe-define-global-key-bindings t))) + (add-hook 'after-init-hook #'magit-maybe-define-global-key-bindings t))) ;;; Dispatch Popup @@ -317,7 +338,7 @@ Also see info node `(magit)Commands for Buffers Visiting Files'." ("F" "Pull" magit-pull) ;; g ↓ ;; G → magit-refresh-all - ("h" "Help" magit-help) + ("h" "Help" magit-info) ("H" "Section info" magit-describe-section :if-derived magit-mode)] [("i" "Ignore" magit-gitignore) ("I" "Init" magit-init) @@ -368,10 +389,12 @@ Also see info node `(magit)Commands for Buffers Visiting Files'." ("U" "Unstage all" magit-unstage-all)]] ["Essential commands" :if-derived magit-mode - ("g" " refresh current buffer" magit-refresh) - ("" " toggle section at point" magit-section-toggle) - ("" "visit thing at point" magit-visit-thing) - ("C-x m" " show all key bindings" describe-mode)]) + [("g" " refresh current buffer" magit-refresh) + ("q" " bury current buffer" magit-mode-bury-buffer) + ("" " toggle section at point" magit-section-toggle) + ("" "visit thing at point" magit-visit-thing)] + [("C-x m" "show all key bindings" describe-mode) + ("C-x i" "show Info manual" magit-info)]]) ;;; Git Popup @@ -398,7 +421,8 @@ This affects `magit-git-command', `magit-git-command-topdir', ("k" "gitk" magit-run-gitk) ("a" "gitk --all" magit-run-gitk-all) ("b" "gitk --branches" magit-run-gitk-branches) - ("g" "git gui" magit-run-git-gui)]]) + ("g" "git gui" magit-run-git-gui) + ("m" "git mergetool --gui" magit-git-mergetool)]]) ;;;###autoload (defun magit-git-command (command) @@ -444,26 +468,77 @@ is run in the top-level directory of the current working tree." (magit--shell-command command (magit-toplevel))) (defun magit--shell-command (command &optional directory) - (let ((default-directory (or directory default-directory)) - (process-environment process-environment)) - (push "GIT_PAGER=cat" process-environment) - (magit--with-connection-local-variables - (magit-start-process shell-file-name nil - shell-command-switch command))) + (let ((default-directory (or directory default-directory))) + (with-environment-variables (("GIT_PAGER" "cat")) + (magit--with-connection-local-variables + (magit-start-process shell-file-name nil + shell-command-switch command)))) (magit-process-buffer)) (defun magit-read-shell-command (&optional toplevel initial-input) (let ((default-directory - (if (or toplevel current-prefix-arg) - (or (magit-toplevel) - (magit--not-inside-repository-error)) - default-directory))) + (if (or toplevel current-prefix-arg) + (or (magit-toplevel) + (magit--not-inside-repository-error)) + default-directory))) (read-shell-command (if magit-shell-command-verbose-prompt (format "Async shell command in %s: " (abbreviate-file-name default-directory)) "Async shell command: ") initial-input 'magit-git-command-history))) +;;; Shared Infix Arguments + +(transient-define-argument magit:--gpg-sign () + :description "Sign using gpg" + :class 'transient-option + :shortarg "-S" + :argument "--gpg-sign=" + :allow-empty t + :reader #'magit-read-gpg-signing-key) + +(defvar magit-gpg-secret-key-hist nil) + +(defun magit-read-gpg-secret-key + (prompt &optional initial-input history predicate default) + (require 'epa) + (let* ((keys (cl-mapcan + (lambda (cert) + (and (or (not predicate) + (funcall predicate cert)) + (let* ((key (car (epg-key-sub-key-list cert))) + (fpr (epg-sub-key-fingerprint key)) + (id (epg-sub-key-id key)) + (author + (and-let* ((id-obj + (car (epg-key-user-id-list cert)))) + (let ((id-str (epg-user-id-string id-obj))) + (if (stringp id-str) + id-str + (epg-decode-dn id-obj)))))) + (list + (propertize fpr 'display + (concat (substring fpr 0 (- (length id))) + (propertize id 'face 'highlight) + " " author)))))) + (epg-list-keys (epg-make-context epa-protocol) nil t))) + (choice (or (and (not current-prefix-arg) + (or (and (length= keys 1) (car keys)) + (and default (car (member default keys))))) + (completing-read prompt keys nil nil nil + history nil initial-input)))) + (set-text-properties 0 (length choice) nil choice) + choice)) + +(defun magit-read-gpg-signing-key (prompt &optional initial-input history) + (magit-read-gpg-secret-key + prompt initial-input history + (lambda (cert) + (cl-some (lambda (key) + (memq 'sign (epg-sub-key-capability key))) + (epg-key-sub-key-list cert))) + magit-openpgp-default-signing-key)) + ;;; Font-Lock Keywords (defconst magit-font-lock-keywords @@ -486,7 +561,7 @@ is run in the top-level directory of the current working tree." ;;; Version -(defvar magit-version 'undefined +(defvar magit-version #'undefined "The version of Magit that you're using. Use the function by the same name instead of this variable.") @@ -579,12 +654,7 @@ and Emacs to it." (locate-library "magit.el" t)) (lm-header "Package-Version")))))) "") - (or (let ((magit-git-debug - (lambda (err) - (display-warning '(magit git) - err :error)))) - (magit-git-version t)) - "(unknown)") + (magit--safe-git-version) emacs-version system-type) print-dest)) @@ -597,75 +667,26 @@ and Emacs to it." (message "Cannot determine Magit's version %S" debug))) magit-version)) -;;; Debugging Tools - -(defun magit-debug-git-executable () - "Display a buffer with information about `magit-git-executable'. -Also include information about `magit-remote-git-executable'. -See info node `(magit)Debugging Tools' for more information." - (interactive) - (with-current-buffer (get-buffer-create "*magit-git-debug*") - (pop-to-buffer (current-buffer)) - (erase-buffer) - (insert (format "magit-remote-git-executable: %S\n" - magit-remote-git-executable)) - (insert (concat - (format "magit-git-executable: %S" magit-git-executable) - (and (not (file-name-absolute-p magit-git-executable)) - (format " [%S]" (executable-find magit-git-executable))) - (format " (%s)\n" - (let* ((errmsg nil) - (magit-git-debug (lambda (err) (setq errmsg err)))) - (or (magit-git-version t) errmsg))))) - (insert (format "exec-path: %S\n" exec-path)) - (--when-let (cl-set-difference - (-filter #'file-exists-p (remq nil (parse-colon-path - (getenv "PATH")))) - (-filter #'file-exists-p (remq nil exec-path)) - :test #'file-equal-p) - (insert (format " entries in PATH, but not in exec-path: %S\n" it))) - (dolist (execdir exec-path) - (insert (format " %s (%s)\n" execdir (car (file-attributes execdir)))) - (when (file-directory-p execdir) - (dolist (exec (directory-files - execdir t (concat - "\\`git" (regexp-opt exec-suffixes) "\\'"))) - (insert (format " %s (%s)\n" exec - (let* ((magit-git-executable exec) - (errmsg nil) - (magit-git-debug (lambda (err) (setq errmsg err)))) - (or (magit-git-version t) errmsg))))))))) - ;;; Startup Asserts (defun magit-startup-asserts () (when-let ((val (getenv "GIT_DIR"))) (setenv "GIT_DIR") - (message "Magit unset $GIT_DIR (was %S). See \ -https://github.com/magit/magit/wiki/Don't-set-$GIT_DIR-and-alike" val)) + (message + "Magit unset $GIT_DIR (was %S). See %s" val + ;; Note: Pass URL as argument rather than embedding in the format + ;; string to prevent the single quote from being rendered + ;; according to `text-quoting-style'. + "https://github.com/magit/magit/wiki/Don't-set-$GIT_DIR-and-alike")) (when-let ((val (getenv "GIT_WORK_TREE"))) (setenv "GIT_WORK_TREE") - (message "Magit unset $GIT_WORK_TREE (was %S). See \ -https://github.com/magit/magit/wiki/Don't-set-$GIT_DIR-and-alike" val)) - (let ((version (magit-git-version))) - (when (and version - (version< version magit--minimal-git) - (not (equal (getenv "CI") "true"))) - (display-warning 'magit (format "\ -Magit requires Git >= %s, you are using %s. - -If this comes as a surprise to you, because you do actually have -a newer version installed, then that probably means that the -older version happens to appear earlier on the `$PATH'. If you -always start Emacs from a shell, then that can be fixed in the -shell's init file. If you start Emacs by clicking on an icon, -or using some sort of application launcher, then you probably -have to adjust the environment as seen by graphical interface. -For X11 something like ~/.xinitrc should work. - -If you use Tramp to work inside remote Git repositories, then you -have to make sure a suitable Git is used on the remote machines -too.\n" magit--minimal-git version) :error))) + (message + "Magit unset $GIT_WORK_TREE (was %S). See %s" val + ;; See comment above. + "https://github.com/magit/magit/wiki/Don't-set-$GIT_DIR-and-alike")) + ;; Git isn't required while building Magit. + (unless (bound-and-true-p byte-compile-current-file) + (magit-git-version-assert)) (when (version< emacs-version magit--minimal-emacs) (display-warning 'magit (format "\ Magit requires Emacs >= %s, you are using %s. @@ -712,18 +733,19 @@ For X11 something like ~/.xinitrc should work.\n" (require 'magit-subtree) (require 'magit-ediff) (require 'magit-gitignore) + (require 'magit-sparse-checkout) (require 'magit-extras) (require 'git-rebase) - (require 'magit-imenu) (require 'magit-bookmark))) (with-eval-after-load 'bookmark (require 'magit-bookmark)) -(if after-init-time - (progn (magit-startup-asserts) - (magit-version)) - (add-hook 'after-init-hook #'magit-startup-asserts t) - (add-hook 'after-init-hook #'magit-version t)) +(unless (bound-and-true-p byte-compile-current-file) + (if after-init-time + (progn (magit-startup-asserts) + (magit-version)) + (add-hook 'after-init-hook #'magit-startup-asserts t) + (add-hook 'after-init-hook #'magit-version t))) ;;; magit.el ends here diff --git a/elpa/magit-20220116.1908/magit.info b/elpa/magit-20220518.2359/magit.info similarity index 95% rename from elpa/magit-20220116.1908/magit.info rename to elpa/magit-20220518.2359/magit.info index 1dac8896..6f3bc6a7 100644 --- a/elpa/magit-20220116.1908/magit.info +++ b/elpa/magit-20220518.2359/magit.info @@ -31,7 +31,7 @@ to perform almost all of their daily version control tasks directly from within Emacs. While many fine Git clients exist, only Magit and Git itself deserve to be called porcelains. -This manual is for Magit version v3.3.0-79-g2e73b66c2+1. +This manual is for Magit version 3.3.0-git. Copyright (C) 2015-2022 Jonas Bernoulli @@ -78,6 +78,7 @@ Interface Concepts * Transient Commands:: * Transient Arguments and Buffer Variables:: * Completion, Confirmation and the Selection: Completion Confirmation and the Selection. +* Mouse Support:: * Running Git:: Modes and Buffers @@ -234,6 +235,7 @@ Miscellaneous * Submodules:: * Subtree:: * Worktree:: +* Sparse checkouts:: * Bundle:: * Common Commands:: * Wip Modes:: @@ -301,7 +303,6 @@ FAQ - How to ...? * How to install the gitman info manual?:: * How to show diffs for gpg-encrypted files?:: * How does branching and pushing work?:: -* Can Magit be used as ediff-version-control-package?:: * Should I disable VC?:: @@ -662,6 +663,9 @@ buffers. The global binding is ‘C-x M-g’. commands that act on just the visited file, see *note Commands for Buffers Visiting Files::. + Magit also provides a context menu and other mouse commands, see +*note Mouse Support::. + It is not necessary that you do so now, but if you stick with Magit, then it is highly recommended that you read the next section too. @@ -678,6 +682,7 @@ File: magit.info, Node: Interface Concepts, Next: Inspecting, Prev: Getting S * Transient Commands:: * Transient Arguments and Buffer Variables:: * Completion, Confirmation and the Selection: Completion Confirmation and the Selection. +* Mouse Support:: * Running Git::  @@ -1712,7 +1717,7 @@ I am afraid it gets more complicated still: ‘magit-direct-use-buffer-arguments’.  -File: magit.info, Node: Completion Confirmation and the Selection, Next: Running Git, Prev: Transient Arguments and Buffer Variables, Up: Interface Concepts +File: magit.info, Node: Completion Confirmation and the Selection, Next: Mouse Support, Prev: Transient Arguments and Buffer Variables, Up: Interface Concepts 4.5 Completion, Confirmation and the Selection ============================================== @@ -2150,9 +2155,24 @@ File: magit.info, Node: Additional Completion Options, Prev: Support for Compl full name (e.g., "refs/heads/master").  -File: magit.info, Node: Running Git, Prev: Completion Confirmation and the Selection, Up: Interface Concepts +File: magit.info, Node: Mouse Support, Next: Running Git, Prev: Completion Confirmation and the Selection, Up: Interface Concepts + +4.6 Mouse Support +================= + +Double clicking on a section heading toggles the visibility of its body, +if any. Likewise clicking in the left fringe toggles the visibility of +the appropriate section. + + A context menu is provided but has to be enabled explicitly. In +Emacs 28 and greater, enable the global mode ‘context-menu-mode’. If +you use an older Emacs release, set +‘magit-section-show-context-menu-for-emacs<28’. + + +File: magit.info, Node: Running Git, Prev: Mouse Support, Up: Interface Concepts -4.6 Running Git +4.7 Running Git =============== * Menu: @@ -2166,7 +2186,7 @@ File: magit.info, Node: Running Git, Prev: Completion Confirmation and the Sel  File: magit.info, Node: Viewing Git Output, Next: Git Process Status, Up: Running Git -4.6.1 Viewing Git Output +4.7.1 Viewing Git Output ------------------------ Magit runs Git either for side-effects (e.g. when pushing) or to get @@ -2207,6 +2227,18 @@ sections are available. There is one additional command. This is only intended for debugging purposes. Do not enable this permanently, that would negatively affect performance. + This is only intended for debugging purposes. Do not enable this + permanently, that would negatively affect performance. Also note + that just because git exits with a non-zero exit status and prints + an error message that usually doesn’t mean that it is an error as + far as Magit is concerned, which is another reason we usually hide + these error messages. Whether some error message is relevant in + the context of some unexpected behavior has to be judged on a case + by case basis. + + The command ‘magit-toggle-git-debug’ changes the value of this + variable. + -- Variable: magit-process-extreme-logging This option controls whether ‘magit-process-file’ logs to the ‘*Messages*’ buffer. @@ -2219,7 +2251,7 @@ sections are available. There is one additional command.  File: magit.info, Node: Git Process Status, Next: Running Git Manually, Prev: Viewing Git Output, Up: Running Git -4.6.2 Git Process Status +4.7.2 Git Process Status ------------------------ When a Git process is running for side-effects, Magit displays an @@ -2243,7 +2275,7 @@ buffer.  File: magit.info, Node: Running Git Manually, Next: Git Executable, Prev: Git Process Status, Up: Running Git -4.6.3 Running Git Manually +4.7.3 Running Git Manually -------------------------- While Magit provides many Emacs commands to interact with Git, it does @@ -2301,10 +2333,16 @@ to a shell. ‘! g’ (‘magit-run-git-gui’) This command runs ‘git gui’ in the current repository. +‘! m’ (‘magit-git-mergetool’) + This command runs ‘git mergetool --gui’ in the current repository. + + With a prefix argument this acts as a transient prefix command, + allowing the user to select the mergetool and change some settings. +  File: magit.info, Node: Git Executable, Next: Global Git Arguments, Prev: Running Git Manually, Up: Running Git -4.6.4 Git Executable +4.7.4 Git Executable -------------------- When Magit calls Git, then it may do so using the absolute path to the @@ -2367,7 +2405,7 @@ where Emacs is searching for ‘git’.  File: magit.info, Node: Global Git Arguments, Prev: Git Executable, Up: Running Git -4.6.5 Global Git Arguments +4.7.5 Global Git Arguments -------------------------- -- User Option: magit-git-global-arguments @@ -2860,15 +2898,22 @@ File: magit.info, Node: Repository List, Next: Logging, Prev: Status Buffer, argument, the repository identification (usually its basename), and with ‘default-directory’ bound to the toplevel of its working tree. It has to return a string to be inserted or nil. PROPS is an alist - that supports the keys ‘:right-align’ and ‘:pad-right’. + that supports the keys ‘:right-align’, ‘:pad-right’ and ‘:sort’. + + The ‘:sort’ function has a weird interface described in the + docstring of ‘tabulated-list--get-sort’. Alternatively ‘<’ and + ‘magit-repolist-version<’ can be used as those functions are + automatically replaced with functions that satisfy the interface. + Set ‘:sort’ to ‘nil’ to inhibit sorting; if unspecifed, then the + column is sortable using the default sorter. You may wish to display a range of numeric columns using just one character per column and without any padding between columns, in - which case you should use an appropriate HEADER, set WIDTH to 1, - and set ‘:pad-right’ to 0. ‘+’ is substituted for numbers higher - than 9. + which case you should use an appropriat HEADER, set WIDTH to 1, and + set ‘:pad-right’ to 9. ‘+’ is substituted for numbers higher than + 9. - The following functions can be added to the above option: +The following functions can be added to the above option: -- Function: magit-repolist-column-ident This function inserts the identification of the repository. @@ -2922,6 +2967,27 @@ File: magit.info, Node: Repository List, Next: Logging, Prev: Status Buffer, This function inserts the number of commits in the current branch but not its push branch. +The following commands are available in repolist buffers: + +‘’ (‘magit-repolist-status’) + This command shows the status for the repository at point. + +‘m’ (‘magit-repolist-mark’) + This command marks the repository at point. + +‘u’ (‘magit-repolist-unmark’) + This command unmarks the repository at point. + +‘f’ (‘magit-repolist-fetch’) + This command fetches all marked repositories. If no repositories + are marked, then it offers to fetch all displayed repositories. + +‘5’ (‘magit-repolist-find-file-other-frame’) + This command reads a relative file-name (without completion) and + opens the respective file in each marked repository in a new frame. + If no repositories are marked, then it offers to do this for all + displayed repositories. +  File: magit.info, Node: Logging, Next: Diffing, Prev: Repository List, Up: Inspecting @@ -2961,15 +3027,21 @@ Reflog::. prefix argument, show log for one or more revs read from the minibuffer. +‘l h’ (‘magit-log-head’) + Show log for ‘HEAD’. + +‘l u’ (‘magit-log-related’) + Show log for the current branch, its upstream and its push target. + When the upstream is a local branch, then also show its own + upstream. When ‘HEAD’ is detached, then show log for that, the + previously checked out branch and its upstream and push-target. + ‘l o’ (‘magit-log-other’) Show log for one or more revs read from the minibuffer. The user can input any revision or revisions separated by a space, or even ranges, but only branches, tags, and a representation of the commit at point are available as completion candidates. -‘l h’ (‘magit-log-head’) - Show log for ‘HEAD’. - ‘l L’ (‘magit-log-branches’) Show log for all local branches and ‘HEAD’. @@ -3662,7 +3734,7 @@ File: magit.info, Node: Diff Options, Next: Revision Buffer, Prev: Commands A ff. Instead of, or in addition to, using delimiting horizontal lines, - to emphasize the boundaries, you may which to emphasize the text + to emphasize the boundaries, you may wish to emphasize the text itself, using ‘magit-diff-highlight-hunk-region-using-face’. In terminal frames it’s not possible to draw lines as the overlay @@ -3791,17 +3863,59 @@ information on how to use Ediff itself, see *note (ediff)Top::. revisions, choose a revision to view changes along, starting at the common ancestor of both revisions (i.e., use a "..." range). -‘E m’ (‘magit-ediff-resolve’) - Resolve outstanding conflicts in a file using Ediff, defaulting to - the file at point. +‘E m’ (‘magit-ediff-resolve-rest’) + This command allows you to resolve outstanding conflicts in the + file at point using Ediff. If there is no file at point or if it + doesn’t have any unmerged changes, then this command prompts for a + file. + + Provided that the value of ‘merge.conflictstyle’ is ‘diff3’, you + can view the file’s merge-base revision using ‘/’ in the Ediff + control buffer. + + The A, B and Ancestor buffers are constructed from the conflict + markers in the worktree file. Because you and/or Git may have + already resolved some conflicts, that means that these buffers may + not contain the actual versions from the respective blobs. + +‘E m’ (‘magit-ediff-resolve-all’) + This command allows you to resolve all conflicts in the file at + point using Ediff. If there is no file at point or if it doesn’t + have any unmerged changes, then this command prompts for a file. Provided that the value of ‘merge.conflictstyle’ is ‘diff3’, you can view the file’s merge-base revision using ‘/’ in the Ediff control buffer. - In the rare event that you want to manually resolve all conflicts, - including those already resolved by Git, use - ‘ediff-merge-revisions-with-ancestor’. + First the file in the worktree is moved aside, appending the suffix + ‘.ORIG’, so that you could later go back to that version. Then it + is reconstructed from the two sides of the conflict and the + merge-base, if available. + + It would be nice if the worktree file were just used as-is, but + Ediff does not support that. This means that all conflicts, that + Git has already resolved, are restored. On the other hand Ediff + also tries to resolve conflicts, and in many cases Ediff and Git + should produce similar results. + + However if you have already resolved some conflicts manually, then + those changes are discarded (though you can recover them from the + backup file). In such cases ‘magit-ediff-resolve-rest’ might be + more suitable. + + The advantage that this command has over ‘magit-ediff-resolve-rest’ + is that the A, B and Ancestor buffers correspond to blobs from the + respective commits, allowing you to inspect a side in context and + to use Magit commands in these buffers to do so. Blame and log + commands are particularly useful here. + +‘E t’ (‘magit-git-mergetool’) + This command does not actually use Ediff. While it serves the same + purpose as ‘magit-ediff-resolve-rest’, it uses ‘git mergetool + --gui’ to resolve conflicts. + + With a prefix argument this acts as a transient prefix command, + allowing the user to select the mergetool and change some settings. ‘E s’ (‘magit-ediff-stage’) Stage and unstage changes to a file using Ediff, defaulting to the @@ -3822,6 +3936,12 @@ information on how to use Ediff itself, see *note (ediff)Top::. ‘E z’ (‘magit-ediff-show-stash’) Show changes to a file introduced by a stash using Ediff. + -- User Option: magit-ediff-dwim-resolve-function + This option controls which function ‘magit-ediff-dwim’ uses to + resolve conflicts. One of ‘magit-ediff-resolve-rest’, + ‘magit-ediff-resolve-all’ or ‘magit-git-mergetool’; which are all + discussed above. + -- User Option: magit-ediff-dwim-show-on-hunks This option controls what command ‘magit-ediff-dwim’ calls when point is on uncommitted hunks. When nil, always run @@ -4506,6 +4626,12 @@ is used and on the value of ‘magit-clone-always-transient’. default the depth of the cloned history is a single commit, but with a prefix argument the depth is read from the user. +‘C >’ (‘magit-clone-sparse’) + This command creates a clone of an existing repository and + initializes a sparse checkout, avoiding a checkout of the full + working tree. To add more directories, use the + ‘magit-sparse-checkout’ transient (see *note Sparse checkouts::). + ‘C b’ (‘magit-clone-bare’) This command creates a bare clone of an existing repository. The repository and the target directory are read from the user. @@ -5107,7 +5233,7 @@ The following functions are suitable for this hook: -- Function: with-editor-usage-message Show usage information in the echo area. - -- User Option: git-commit-setup-hook + -- User Option: git-commit-post-finish-hook Hook run after the user finished writing a commit message. This hook is only run after pressing ‘C-c C-c’ in a buffer used to @@ -6112,7 +6238,12 @@ shown in different colors to indicate the status of the commits. The following colors are used: - • Yellow commits have not been applied yet. + • Commits that use the same foreground color as the ‘default’ face + have not been applied yet. + + • Yellow commits have some special relationship to the commit rebase + stopped at. This is used for the words "join", "goal", "same" and + "work" (see below). • Gray commits have already been applied. @@ -6701,7 +6832,7 @@ These variables can be set from the transient prefix command have multiple values. -- Variable: remote.NAME.pushurl - This variable specifies the url used for fetching from the remote + This variable specifies the url used for pushing to the remote named NAME. If it is not specified, then ‘remote.NAME.url’ is used instead. It can have multiple values. @@ -6999,6 +7130,7 @@ File: magit.info, Node: Miscellaneous, Next: Customizing, Prev: Transferring, * Submodules:: * Subtree:: * Worktree:: +* Sparse checkouts:: * Bundle:: * Common Commands:: * Wip Modes:: @@ -7158,7 +7290,20 @@ Sections::. argument, the repository identification (usually its basename), and with ‘default-directory’ bound to the toplevel of its working tree. It has to return a string to be inserted or nil. PROPS is an alist - that supports the keys ‘:right-align’ and ‘:pad-right’. + that supports the keys ‘:right-align’, ‘:pad-right’ and ‘:sort’. + + The ‘:sort’ function has a weird interface described in the + docstring of ‘tabulated-list--get-sort’. Alternatively ‘<’ and + ‘magit-repolist-version<’ can be used as those functions are + automatically replaced with functions that satisfy the interface. + Set ‘:sort’ to ‘nil’ to inhibit sorting; if unspecifed, then the + column is sortable using the default sorter. + + You may wish to display a range of numeric columns using just one + character per column and without any padding between columns, in + which case you should use an appropriat HEADER, set WIDTH to 1, and + set ‘:pad-right’ to 9. ‘+’ is substituted for numbers higher than + 9.  File: magit.info, Node: Submodule Transient, Prev: Listing Submodules, Up: Submodules @@ -7273,7 +7418,7 @@ Also see *note (gitman)git-subtree::. This command extracts the history of the subtree PREFIX.  -File: magit.info, Node: Worktree, Next: Bundle, Prev: Subtree, Up: Miscellaneous +File: magit.info, Node: Worktree, Next: Sparse checkouts, Prev: Subtree, Up: Miscellaneous 8.5 Worktree ============ @@ -7305,9 +7450,70 @@ Also see *note (gitman)git-worktree::. displayed in the current buffer, then show it in Dired instead.  -File: magit.info, Node: Bundle, Next: Common Commands, Prev: Worktree, Up: Miscellaneous +File: magit.info, Node: Sparse checkouts, Next: Bundle, Prev: Worktree, Up: Miscellaneous + +8.6 Sparse checkouts +==================== -8.6 Bundle +Sparse checkouts provide a way to restrict the working tree to a subset +of directories. See *note (gitman)git-sparse-checkout::. + + *Warning*: Git introduced the ‘git sparse-checkout’ command in +version 2.25 and still advertises it as experimental and subject to +change. Magit’s interface should be considered the same. In +particular, if Git introduces a backward incompatible change, Magit’s +sparse checkout functionality may be updated in a way that requires a +more recent Git version. + +‘>’ (‘magit-sparse-checkout’) + This transient prefix command binds the following suffix commands + and displays them in a temporary buffer until a suffix is invoked. + +‘> e’ (‘magit-sparse-checkout-enable’) + This command initializes a sparse checkout that includes only the + files in the top-level directory. + + Note that ‘magit-sparse-checkout-set’ and + ‘magit-sparse-checkout-add’ automatically initialize a sparse + checkout if necessary. However, you may want to call + ‘magit-sparse-checkout-enable’ explicitly to re-initialize a sparse + checkout after calling ‘magit-sparse-checkout-disable’, to pass + additional arguments to ‘git sparse-checkout init’, or to execute + the initialization asynchronously. + +‘> s’ (‘magit-sparse-checkout-set’) + This command takes a list of directories and configures the sparse + checkout to include only files in those subdirectories. Any + previously included directories are excluded unless they are in the + provided list of directories. + +‘> a’ (‘magit-sparse-checkout-add’) + This command is like ‘magit-sparse-checkout-set’, but instead adds + the specified list of directories to the set of directories that is + already included in the sparse checkout. + +‘> r’ (‘magit-sparse-checkout-reapply’) + This command applies the currently configured sparse checkout + patterns to the working tree. This is useful to call if excluded + files have been checked out after operations such as merging or + rebasing. + +‘> d’ (‘magit-sparse-checkout-disable’) + This command restores the full checkout. To return to the previous + sparse checkout, call ‘magit-sparse-checkout-enable’. + + A sparse checkout can also be initiated when cloning a repository by +using the ‘magit-clone-sparse’ command in the ‘magit-clone’ transient +(see *note Cloning Repository::). + + If you want the status buffer to indicate when a sparse checkout is +enabled, add the function ‘magit-sparse-checkout-insert-header’ to +‘magit-status-headers-hook’. + + +File: magit.info, Node: Bundle, Next: Common Commands, Prev: Sparse checkouts, Up: Miscellaneous + +8.7 Bundle ========== Also see *note (gitman)git-bundle::. @@ -7320,7 +7526,7 @@ Also see *note (gitman)git-bundle::.  File: magit.info, Node: Common Commands, Next: Wip Modes, Prev: Bundle, Up: Miscellaneous -8.7 Common Commands +8.8 Common Commands =================== -- Command: magit-switch-to-repository-buffer @@ -7376,7 +7582,7 @@ above.  File: magit.info, Node: Wip Modes, Next: Commands for Buffers Visiting Files, Prev: Common Commands, Up: Miscellaneous -8.8 Wip Modes +8.9 Wip Modes ============= Git keeps *committed* changes around long enough for users to recover @@ -7482,7 +7688,7 @@ files are being committed.  File: magit.info, Node: Wip Graph, Next: Legacy Wip Modes, Up: Wip Modes -8.8.1 Wip Graph +8.9.1 Wip Graph --------------- -- User Option: magit-wip-merge-branch @@ -7541,7 +7747,7 @@ should be committed to the respective wip ref.  File: magit.info, Node: Legacy Wip Modes, Prev: Wip Graph, Up: Wip Modes -8.8.2 Legacy Wip Modes +8.9.2 Legacy Wip Modes ---------------------- It is recommended that you use the mode ‘magit-wip-mode’ (which see) and @@ -7604,8 +7810,8 @@ making changes that could cause the loss of earlier changes.  File: magit.info, Node: Commands for Buffers Visiting Files, Next: Minor Mode for Buffers Visiting Blobs, Prev: Wip Modes, Up: Miscellaneous -8.9 Commands for Buffers Visiting Files -======================================= +8.10 Commands for Buffers Visiting Files +======================================== Magit defines a few global key bindings unless the user sets ‘magit-define-global-key-bindings’ to ‘nil’. This includes binding ‘C-c @@ -7732,7 +7938,7 @@ Disabling Suffixes::.  File: magit.info, Node: Minor Mode for Buffers Visiting Blobs, Prev: Commands for Buffers Visiting Files, Up: Miscellaneous -8.10 Minor Mode for Buffers Visiting Blobs +8.11 Minor Mode for Buffers Visiting Blobs ========================================== The ‘magit-blob-mode’ enables certain Magit features in blob-visiting @@ -8922,7 +9128,7 @@ frequently *and recently* asked questions, i.e. questions that haven’t made it into the manual yet, see . - Please also use the *note Debugging Tools::. + Please also see *note Debugging Tools::. * Menu: @@ -8942,7 +9148,6 @@ A.1 FAQ - How to ...? * How to install the gitman info manual?:: * How to show diffs for gpg-encrypted files?:: * How does branching and pushing work?:: -* Can Magit be used as ediff-version-control-package?:: * Should I disable VC?::  @@ -9019,7 +9224,7 @@ affects the diffs displayed inside Magit. echo "*.gpg filter=gpg diff=gpg" > .gitattributes  -File: magit.info, Node: How does branching and pushing work?, Next: Can Magit be used as ediff-version-control-package?, Prev: How to show diffs for gpg-encrypted files?, Up: FAQ - How to ...? +File: magit.info, Node: How does branching and pushing work?, Next: Should I disable VC?, Prev: How to show diffs for gpg-encrypted files?, Up: FAQ - How to ...? A.1.5 How does branching and pushing work? ------------------------------------------ @@ -9028,43 +9233,9 @@ Please see *note Branching:: and  -File: magit.info, Node: Can Magit be used as ediff-version-control-package?, Next: Should I disable VC?, Prev: How does branching and pushing work?, Up: FAQ - How to ...? - -A.1.6 Can Magit be used as ‘ediff-version-control-package’? ------------------------------------------------------------ - -No, it cannot. For that to work the functions ‘ediff-magit-internal’ -and ‘ediff-magit-merge-internal’ would have to be implemented, and they -are not. These two functions are only used by the three commands -‘ediff-revision’, ‘ediff-merge-revisions-with-ancestor’, and -‘ediff-merge-revisions’. - - These commands only delegate the task of populating buffers with -certain revisions to the "internal" functions. The equally important -task of determining which revisions are to be compared/merged is not -delegated. Instead this is done without any support whatsoever from the -version control package/system - meaning that the user has to enter the -revisions explicitly. Instead of implementing ‘ediff-magit-internal’ we -provide ‘magit-ediff-compare’, which handles both tasks like it is 2005. +File: magit.info, Node: Should I disable VC?, Prev: How does branching and pushing work?, Up: FAQ - How to ...? - The other commands ‘ediff-merge-revisions’ and -‘ediff-merge-revisions-with-ancestor’ are normally not what you want -when using a modern version control system like Git. Instead of letting -the user resolve only those conflicts which Git could not resolve on its -own, they throw away all work done by Git and then expect the user to -manually merge all conflicts, including those that had already been -resolved. That made sense back in the days when version control systems -couldn’t merge (or so I have been told), but not anymore. Once in a -blue moon you might actually want to see all conflicts, in which case -you *can* use these commands, which then use ‘ediff-vc-merge-internal’. -So we don’t actually have to implement ‘ediff-magit-merge-internal’. -Instead we provide the more useful command ‘magit-ediff-resolve’ which -only shows yet-to-be resolved conflicts. - - -File: magit.info, Node: Should I disable VC?, Prev: Can Magit be used as ediff-version-control-package?, Up: FAQ - How to ...? - -A.1.7 Should I disable VC? +A.1.6 Should I disable VC? -------------------------- If you don’t use VC (the built-in version control interface) then you @@ -9382,6 +9553,29 @@ issue. Please include all relevant output when reporting an issue. If you run Magit from its Git repository, then you should be able to use ‘make emacs-Q’ instead of the output of this command. +‘M-x magit-toggle-verbose-refresh’ + This command toggles whether additional git errors are reported. + + Magit basically calls git for one of these two reasons: for + side-effects or to do something with its standard output. + + When git is run for side-effects then its output, including error + messages, go into the process buffer which is shown when using ‘$’. + + When git’s output is consumed in some way, then it would be too + expensive to also insert it into this buffer, but when this option + is non-nil and git returns with a non-zero exit status, then at + least its standard error is inserted into this buffer. + + This is only intended for debugging purposes. Do not enable this + permanently, that would negatively affect performance. Also note + that just because git exits with a non-zero exit status and prints + an error message that usually doesn’t mean that it is an error as + far as Magit is concerned, which is another reason we usually hide + these error messages. Whether some error message is relevant in + the context of some unexpected behavior has to be judged on a case + by case basis. + ‘M-x magit-toggle-verbose-refresh’ This command toggles whether Magit refreshes buffers verbosely. Enabling this helps figuring out which sections are bottlenecks. @@ -9402,7 +9596,7 @@ issue. Please include all relevant output when reporting an issue. Also see *note (with-editor)Debugging::. - Please also see the *note FAQ::. +Please also see *note FAQ::.  File: magit.info, Node: Keystroke Index, Next: Function and Command Index, Prev: Debugging Tools, Up: Top @@ -9425,6 +9619,8 @@ Appendix C Keystroke Index (line 59) * ! k: Running Git Manually. (line 50) +* ! m: Running Git Manually. + (line 62) * ! p: Running Git Manually. (line 25) * ! s: Running Git Manually. @@ -9441,9 +9637,16 @@ Appendix C Keystroke Index * 2: Section Visibility. (line 26) * 3: Section Visibility. (line 26) * 4: Section Visibility. (line 26) +* 5: Repository List. (line 109) * :: Running Git Manually. (line 25) * =: Log Buffer. (line 59) +* >: Sparse checkouts. (line 17) +* > a: Sparse checkouts. (line 39) +* > d: Sparse checkouts. (line 50) +* > e: Sparse checkouts. (line 21) +* > r: Sparse checkouts. (line 44) +* > s: Sparse checkouts. (line 33) * ^: Section Movement. (line 28) * a: Applying. (line 34) * A: Cherry Picking. (line 9) @@ -9483,17 +9686,18 @@ Appendix C Keystroke Index * c <1>: Initiating a Commit. (line 9) * c <2>: Editing Rebase Sequences. (line 59) +* C >: Cloning Repository. (line 38) * c a: Initiating a Commit. (line 18) * c A: Initiating a Commit. (line 59) -* C b: Cloning Repository. (line 38) +* C b: Cloning Repository. (line 44) * C C: Cloning Repository. (line 28) * c c: Initiating a Commit. (line 14) -* C d: Cloning Repository. (line 49) -* C e: Cloning Repository. (line 55) +* C d: Cloning Repository. (line 55) +* C e: Cloning Repository. (line 61) * c e: Initiating a Commit. (line 21) * c f: Initiating a Commit. (line 39) * c F: Initiating a Commit. (line 46) -* C m: Cloning Repository. (line 42) +* C m: Cloning Repository. (line 48) * C s: Cloning Repository. (line 32) * c s: Initiating a Commit. (line 49) * c S: Initiating a Commit. (line 56) @@ -9608,17 +9812,20 @@ Appendix C Keystroke Index * E: Ediffing. (line 21) * e <1>: Editing Rebase Sequences. (line 46) -* E c: Ediffing. (line 58) -* E i: Ediffing. (line 52) +* E c: Ediffing. (line 100) +* E i: Ediffing. (line 94) * E m: Ediffing. (line 33) +* E m <1>: Ediffing. (line 48) * E r: Ediffing. (line 25) -* E s: Ediffing. (line 45) -* E u: Ediffing. (line 49) -* E w: Ediffing. (line 55) -* E z: Ediffing. (line 61) -* f: Editing Rebase Sequences. +* E s: Ediffing. (line 87) +* E t: Ediffing. (line 79) +* E u: Ediffing. (line 91) +* E w: Ediffing. (line 97) +* E z: Ediffing. (line 103) +* f: Repository List. (line 105) +* f <1>: Editing Rebase Sequences. (line 52) -* f <1>: Fetching. (line 10) +* f <2>: Fetching. (line 10) * F: Pulling. (line 10) * f a: Fetching. (line 45) * f C: Branch Commands. (line 31) @@ -9653,23 +9860,25 @@ Appendix C Keystroke Index * L <2>: Log Margin. (line 52) * l <1>: Editing Rebase Sequences. (line 94) -* l a: Logging. (line 55) -* l b: Logging. (line 52) +* l a: Logging. (line 61) +* l b: Logging. (line 58) * L d: Log Margin. (line 66) * L g: Refreshing Logs. (line 17) -* l h: Logging. (line 46) +* l h: Logging. (line 40) * l H: Reflog. (line 18) * l l: Logging. (line 35) -* l L: Logging. (line 49) +* l L: Logging. (line 55) * L L: Log Margin. (line 60) * L l: Log Margin. (line 63) -* l o: Logging. (line 40) +* l o: Logging. (line 49) * l O: Reflog. (line 15) * l r: Reflog. (line 12) * L s: Refreshing Logs. (line 21) * L t: Refreshing Logs. (line 34) +* l u: Logging. (line 43) * L w: Refreshing Logs. (line 27) -* m: Merging. (line 10) +* m: Repository List. (line 99) +* m <1>: Merging. (line 10) * M: Remote Commands. (line 14) * m a: Merging. (line 42) * m a <1>: Merging. (line 87) @@ -9771,11 +9980,12 @@ Appendix C Keystroke Index * r s <1>: Rebasing. (line 103) * r u: Rebasing. (line 35) * r w: Rebasing. (line 87) -* RET: References Buffer. (line 159) -* RET <1>: Visiting Files and Blobs from a Diff. +* RET: Repository List. (line 96) +* RET <1>: References Buffer. (line 159) +* RET <2>: Visiting Files and Blobs from a Diff. (line 9) -* RET <2>: Blaming. (line 71) -* RET <3>: Editing Rebase Sequences. +* RET <3>: Blaming. (line 71) +* RET <4>: Editing Rebase Sequences. (line 15) * s: Staging and Unstaging. (line 29) @@ -9805,7 +10015,8 @@ Appendix C Keystroke Index * t t: Tagging. (line 14) * T T: Notes. (line 14) * TAB: Section Visibility. (line 10) -* u: Staging and Unstaging. +* u: Repository List. (line 102) +* u <1>: Staging and Unstaging. (line 42) * U: Staging and Unstaging. (line 50) @@ -10030,12 +10241,13 @@ Appendix D Function and Command Index * magit-cherry-spinoff: Cherry Picking. (line 72) * magit-cherry-spinout: Cherry Picking. (line 62) * magit-clone: Cloning Repository. (line 20) -* magit-clone-bare: Cloning Repository. (line 38) -* magit-clone-mirror: Cloning Repository. (line 42) +* magit-clone-bare: Cloning Repository. (line 44) +* magit-clone-mirror: Cloning Repository. (line 48) * magit-clone-regular: Cloning Repository. (line 28) * magit-clone-shallow: Cloning Repository. (line 32) -* magit-clone-shallow-exclude: Cloning Repository. (line 55) -* magit-clone-shallow-since: Cloning Repository. (line 49) +* magit-clone-shallow-exclude: Cloning Repository. (line 61) +* magit-clone-shallow-since: Cloning Repository. (line 55) +* magit-clone-sparse: Cloning Repository. (line 38) * magit-commit: Initiating a Commit. (line 9) * magit-commit <1>: Commands for Buffers Visiting Files. (line 36) @@ -10055,7 +10267,7 @@ Appendix D Function and Command Index * magit-current-section: Section Selection. (line 6) * magit-cycle-margin-style: Log Margin. (line 63) * magit-debug-git-executable: Git Executable. (line 55) -* magit-debug-git-executable <1>: Debugging Tools. (line 34) +* magit-debug-git-executable <1>: Debugging Tools. (line 57) * magit-define-section-jumper: Creating Sections. (line 74) * magit-describe-section: Section Types and Values. (line 14) @@ -10126,13 +10338,14 @@ Appendix D Function and Command Index * magit-ediff: Ediffing. (line 21) * magit-ediff-compare: Ediffing. (line 25) * magit-ediff-dwim: Ediffing. (line 10) -* magit-ediff-resolve: Ediffing. (line 33) -* magit-ediff-show-commit: Ediffing. (line 58) -* magit-ediff-show-staged: Ediffing. (line 52) -* magit-ediff-show-stash: Ediffing. (line 61) -* magit-ediff-show-unstaged: Ediffing. (line 49) -* magit-ediff-show-working-tree: Ediffing. (line 55) -* magit-ediff-stage: Ediffing. (line 45) +* magit-ediff-resolve-all: Ediffing. (line 48) +* magit-ediff-resolve-rest: Ediffing. (line 33) +* magit-ediff-show-commit: Ediffing. (line 100) +* magit-ediff-show-staged: Ediffing. (line 94) +* magit-ediff-show-stash: Ediffing. (line 103) +* magit-ediff-show-unstaged: Ediffing. (line 91) +* magit-ediff-show-working-tree: Ediffing. (line 97) +* magit-ediff-stage: Ediffing. (line 87) * magit-edit-line-commit: Commands for Buffers Visiting Files. (line 95) * magit-emacs-Q-command: Debugging Tools. (line 16) @@ -10182,6 +10395,9 @@ Appendix D Function and Command Index (line 41) * magit-git-lines: Getting a Value from Git. (line 37) +* magit-git-mergetool: Running Git Manually. + (line 62) +* magit-git-mergetool <1>: Ediffing. (line 79) * magit-git-str: Getting a Value from Git. (line 75) * magit-git-string: Getting a Value from Git. @@ -10270,25 +10486,26 @@ Appendix D Function and Command Index * magit-log: Logging. (line 30) * magit-log <1>: Commands for Buffers Visiting Files. (line 60) -* magit-log-all: Logging. (line 55) -* magit-log-all-branches: Logging. (line 52) -* magit-log-branches: Logging. (line 49) +* magit-log-all: Logging. (line 61) +* magit-log-all-branches: Logging. (line 58) +* magit-log-branches: Logging. (line 55) * magit-log-buffer-file: Commands for Buffers Visiting Files. (line 70) * magit-log-bury-buffer: Log Buffer. (line 14) * magit-log-current: Logging. (line 35) * magit-log-double-commit-limit: Log Buffer. (line 64) * magit-log-half-commit-limit: Log Buffer. (line 67) -* magit-log-head: Logging. (line 46) +* magit-log-head: Logging. (line 40) * magit-log-maybe-show-more-commits: Section Movement. (line 58) * magit-log-maybe-update-blob-buffer: Section Movement. (line 72) * magit-log-maybe-update-revision-buffer: Section Movement. (line 65) * magit-log-move-to-parent: Log Buffer. (line 26) * magit-log-move-to-revision: Log Buffer. (line 31) -* magit-log-other: Logging. (line 40) +* magit-log-other: Logging. (line 49) * magit-log-refresh: Refreshing Logs. (line 12) * magit-log-refresh <1>: Refreshing Logs. (line 17) * magit-log-refresh <2>: Log Buffer. (line 7) +* magit-log-related: Logging. (line 43) * magit-log-save-default-arguments: Refreshing Logs. (line 27) * magit-log-select-pick: Select from Log. (line 21) * magit-log-select-quit: Select from Log. (line 26) @@ -10379,22 +10596,27 @@ Appendix D Function and Command Index * magit-remote-remove: Remote Commands. (line 60) * magit-remote-rename: Remote Commands. (line 52) * magit-remote-set-url: Remote Commands. (line 56) -* magit-repolist-column-branch: Repository List. (line 45) -* magit-repolist-column-branches: Repository List. (line 52) -* magit-repolist-column-flag: Repository List. (line 58) -* magit-repolist-column-ident: Repository List. (line 34) -* magit-repolist-column-path: Repository List. (line 38) -* magit-repolist-column-stashes: Repository List. (line 55) +* magit-repolist-column-branch: Repository List. (line 52) +* magit-repolist-column-branches: Repository List. (line 59) +* magit-repolist-column-flag: Repository List. (line 65) +* magit-repolist-column-ident: Repository List. (line 41) +* magit-repolist-column-path: Repository List. (line 45) +* magit-repolist-column-stashes: Repository List. (line 62) * magit-repolist-column-unpulled-from-pushremote: Repository List. - (line 74) + (line 81) * magit-repolist-column-unpulled-from-upstream: Repository List. - (line 70) + (line 77) * magit-repolist-column-unpushed-to-pushremote: Repository List. - (line 82) + (line 89) * magit-repolist-column-unpushed-to-upstream: Repository List. - (line 78) -* magit-repolist-column-upstream: Repository List. (line 48) -* magit-repolist-column-version: Repository List. (line 41) + (line 85) +* magit-repolist-column-upstream: Repository List. (line 55) +* magit-repolist-column-version: Repository List. (line 48) +* magit-repolist-fetch: Repository List. (line 105) +* magit-repolist-find-file-other-frame: Repository List. (line 109) +* magit-repolist-mark: Repository List. (line 99) +* magit-repolist-status: Repository List. (line 96) +* magit-repolist-unmark: Repository List. (line 102) * magit-reset-hard: Resetting. (line 24) * magit-reset-index: Staging and Unstaging. (line 78) @@ -10478,6 +10700,12 @@ Appendix D Function and Command Index * magit-snapshot-both: Stashing. (line 36) * magit-snapshot-index: Stashing. (line 42) * magit-snapshot-worktree: Stashing. (line 46) +* magit-sparse-checkout: Sparse checkouts. (line 17) +* magit-sparse-checkout-add: Sparse checkouts. (line 39) +* magit-sparse-checkout-disable: Sparse checkouts. (line 50) +* magit-sparse-checkout-enable: Sparse checkouts. (line 21) +* magit-sparse-checkout-reapply: Sparse checkouts. (line 44) +* magit-sparse-checkout-set: Sparse checkouts. (line 33) * magit-stage: Staging and Unstaging. (line 29) * magit-stage-file: Staging from File-Visiting Buffers. @@ -10544,6 +10772,7 @@ Appendix D Function and Command Index * magit-toggle-margin <1>: Log Margin. (line 60) * magit-toggle-margin-details: Log Margin. (line 66) * magit-toggle-verbose-refresh: Debugging Tools. (line 29) +* magit-toggle-verbose-refresh <1>: Debugging Tools. (line 52) * magit-unstage: Staging and Unstaging. (line 42) * magit-unstage-all: Staging and Unstaging. @@ -10572,7 +10801,7 @@ Appendix D Function and Command Index (line 22) * with-editor-cancel <1>: Editing Rebase Sequences. (line 11) -* with-editor-debug: Debugging Tools. (line 41) +* with-editor-debug: Debugging Tools. (line 64) * with-editor-finish: Editing Commit Messages. (line 18) * with-editor-finish <1>: Editing Rebase Sequences. @@ -10624,10 +10853,10 @@ Appendix E Variable Index (line 9) * git-commit-major-mode: Commit Mode and Hooks. (line 12) +* git-commit-post-finish-hook: Commit Mode and Hooks. + (line 55) * git-commit-setup-hook: Commit Mode and Hooks. (line 21) -* git-commit-setup-hook <1>: Commit Mode and Hooks. - (line 55) * git-commit-style-convention-checks: Commit Message Conventions. (line 42) * git-commit-summary-max-length: Commit Message Conventions. @@ -10661,11 +10890,11 @@ Appendix E Variable Index * magit-bury-buffer-function: Quitting Windows. (line 13) * magit-cherry-margin: Cherries. (line 21) * magit-clone-always-transient: Cloning Repository. (line 12) -* magit-clone-default-directory: Cloning Repository. (line 78) -* magit-clone-name-alist: Cloning Repository. (line 88) -* magit-clone-set-remote-head: Cloning Repository. (line 60) -* magit-clone-set-remote.pushDefault: Cloning Repository. (line 69) -* magit-clone-url-format: Cloning Repository. (line 108) +* magit-clone-default-directory: Cloning Repository. (line 84) +* magit-clone-name-alist: Cloning Repository. (line 94) +* magit-clone-set-remote-head: Cloning Repository. (line 66) +* magit-clone-set-remote.pushDefault: Cloning Repository. (line 75) +* magit-clone-url-format: Cloning Repository. (line 114) * magit-commit-ask-to-stage: Initiating a Commit. (line 65) * magit-commit-diff-inhibit-same-window: Initiating a Commit. (line 97) * magit-commit-extend-override-date: Initiating a Commit. (line 72) @@ -10696,9 +10925,10 @@ Appendix E Variable Index * magit-display-buffer-noselect: Switching Buffers. (line 17) * magit-dwim-selection: Completion and Confirmation. (line 42) -* magit-ediff-dwim-show-on-hunks: Ediffing. (line 63) -* magit-ediff-quit-hook: Ediffing. (line 76) -* magit-ediff-show-stash-with-index: Ediffing. (line 70) +* magit-ediff-dwim-resolve-function: Ediffing. (line 105) +* magit-ediff-dwim-show-on-hunks: Ediffing. (line 111) +* magit-ediff-quit-hook: Ediffing. (line 124) +* magit-ediff-show-stash-with-index: Ediffing. (line 118) * magit-generate-buffer-name-function: Naming Buffers. (line 6) * magit-git-debug: Viewing Git Output. (line 26) * magit-git-debug <1>: Getting a Value from Git. @@ -10733,7 +10963,7 @@ Appendix E Variable Index (line 109) * magit-prefix-use-buffer-arguments: Transient Arguments and Buffer Variables. (line 64) -* magit-process-extreme-logging: Viewing Git Output. (line 44) +* magit-process-extreme-logging: Viewing Git Output. (line 56) * magit-process-raise-error: Calling Git for Effect. (line 125) * magit-pull-or-fetch: Fetching. (line 51) @@ -10819,173 +11049,174 @@ Appendix E Variable Index  Tag Table: Node: Top754 -Node: Introduction6610 -Node: Installation11326 -Node: Installing from Melpa11656 -Node: Installing from the Git Repository12729 -Node: Post-Installation Tasks15461 -Node: Getting Started16746 -Node: Interface Concepts21986 -Node: Modes and Buffers22347 -Node: Switching Buffers24058 -Node: Naming Buffers28797 -Node: Quitting Windows32100 -Node: Automatic Refreshing of Magit Buffers33838 -Node: Automatic Saving of File-Visiting Buffers36719 -Node: Automatic Reverting of File-Visiting Buffers37903 -Node: Risk of Reverting Automatically42888 -Node: Sections45270 -Node: Section Movement46196 -Node: Section Visibility51070 -Node: Section Hooks57085 -Node: Section Types and Values59491 -Node: Section Options60906 -Node: Transient Commands61377 -Node: Transient Arguments and Buffer Variables62609 -Node: Completion Confirmation and the Selection69620 -Node: Action Confirmation70064 -Node: Completion and Confirmation77916 -Node: The Selection81101 -Node: The hunk-internal region83999 -Node: Support for Completion Frameworks85088 -Node: Additional Completion Options89991 -Node: Running Git90589 -Node: Viewing Git Output90862 -Node: Git Process Status92956 -Node: Running Git Manually93921 -Node: Git Executable96353 -Node: Global Git Arguments99361 -Node: Inspecting100166 -Node: Status Buffer101323 -Node: Status Sections106333 -Node: Status Header Sections111860 -Node: Status Module Sections114479 -Node: Status Options116976 -Node: Repository List118439 -Node: Logging121765 -Node: Refreshing Logs124291 -Node: Log Buffer125712 -Node: Log Margin129912 -Node: Select from Log133065 -Node: Reflog135275 -Node: Cherries136912 -Node: Diffing138750 -Node: Refreshing Diffs141784 -Node: Commands Available in Diffs145293 -Node: Diff Options147807 -Node: Revision Buffer153271 -Node: Ediffing156591 -Node: References Buffer160186 -Node: References Sections170780 -Node: Bisecting171637 -Node: Visiting Files and Blobs173948 -Node: General-Purpose Visit Commands174418 -Node: Visiting Files and Blobs from a Diff175371 -Node: Blaming178815 -Node: Manipulating184950 -Node: Creating Repository185292 -Node: Cloning Repository185829 -Node: Staging and Unstaging191189 -Node: Staging from File-Visiting Buffers195170 -Node: Applying196276 -Node: Committing198349 -Node: Initiating a Commit198932 -Node: Editing Commit Messages204121 -Node: Using the Revision Stack206894 -Node: Commit Pseudo Headers209939 -Node: Commit Mode and Hooks211234 -Node: Commit Message Conventions214162 -Node: Branching216285 -Node: The Two Remotes216511 -Node: Branch Commands219164 -Node: Branch Git Variables231709 -Node: Auxiliary Branch Commands237082 -Node: Merging238198 -Node: Resolving Conflicts242156 -Node: Rebasing247527 -Node: Editing Rebase Sequences252316 -Node: Information About In-Progress Rebase256532 -Ref: Information About In-Progress Rebase-Footnote-1265414 -Node: Cherry Picking266010 -Node: Reverting270344 -Node: Resetting271763 -Node: Stashing273589 -Node: Transferring278200 -Node: Remotes278422 -Node: Remote Commands278574 -Node: Remote Git Variables282613 -Node: Fetching283887 -Node: Pulling286333 -Node: Pushing287359 -Node: Plain Patches291650 -Node: Maildir Patches293121 -Node: Miscellaneous294600 -Node: Tagging294925 -Node: Notes296818 -Node: Submodules299153 -Node: Listing Submodules299371 -Node: Submodule Transient300775 -Node: Subtree303252 -Node: Worktree305183 -Node: Bundle306249 -Node: Common Commands306616 -Node: Wip Modes309244 -Node: Wip Graph314135 -Node: Legacy Wip Modes316448 -Node: Commands for Buffers Visiting Files319335 -Node: Minor Mode for Buffers Visiting Blobs324891 -Node: Customizing325689 -Node: Per-Repository Configuration327285 -Node: Essential Settings329539 -Node: Safety329884 -Node: Performance331645 -Ref: Log Performance334674 -Ref: Diff Performance335984 -Ref: Refs Buffer Performance337325 -Ref: Committing Performance337900 -Node: Microsoft Windows Performance338813 -Node: MacOS Performance340004 -Ref: MacOS Performance-Footnote-1340709 -Node: Default Bindings340791 -Node: Plumbing343032 -Node: Calling Git343861 -Node: Getting a Value from Git345386 -Node: Calling Git for Effect349114 -Node: Section Plumbing355008 -Node: Creating Sections355236 -Node: Section Selection359132 -Node: Matching Sections360928 -Node: Refreshing Buffers366849 -Node: Conventions369993 -Node: Theming Faces370185 -Node: FAQ378290 -Node: FAQ - How to ...?378732 -Node: How to pronounce Magit?379145 -Node: How to show git's output?379947 -Node: How to install the gitman info manual?380733 -Node: How to show diffs for gpg-encrypted files?381703 -Node: How does branching and pushing work?382299 -Node: Can Magit be used as ediff-version-control-package?382662 -Node: Should I disable VC?384680 -Node: FAQ - Issues and Errors385298 -Node: Magit is slow386299 -Node: I changed several thousand files at once and now Magit is unusable386513 -Node: I am having problems committing387242 -Node: I am using MS Windows and cannot push with Magit387723 -Node: I am using OS X and SOMETHING works in shell but not in Magit388340 -Node: Expanding a file to show the diff causes it to disappear389171 -Node: Point is wrong in the COMMIT_EDITMSG buffer389752 -Node: The mode-line information isn't always up-to-date390798 -Node: A branch and tag sharing the same name breaks SOMETHING391861 -Node: My Git hooks work on the command-line but not inside Magit392747 -Node: git-commit-mode isn't used when committing from the command-line393593 -Node: Point ends up inside invisible text when jumping to a file-visiting buffer395864 -Node: I am unable to stage when using Tramp from MS Windows396724 -Node: I am no longer able to save popup defaults397631 -Node: Debugging Tools398591 -Node: Keystroke Index400595 -Node: Function and Command Index433692 -Node: Variable Index484418 +Node: Introduction6580 +Node: Installation11296 +Node: Installing from Melpa11626 +Node: Installing from the Git Repository12699 +Node: Post-Installation Tasks15431 +Node: Getting Started16716 +Node: Interface Concepts22048 +Node: Modes and Buffers22427 +Node: Switching Buffers24138 +Node: Naming Buffers28877 +Node: Quitting Windows32180 +Node: Automatic Refreshing of Magit Buffers33918 +Node: Automatic Saving of File-Visiting Buffers36799 +Node: Automatic Reverting of File-Visiting Buffers37983 +Node: Risk of Reverting Automatically42968 +Node: Sections45350 +Node: Section Movement46276 +Node: Section Visibility51150 +Node: Section Hooks57165 +Node: Section Types and Values59571 +Node: Section Options60986 +Node: Transient Commands61457 +Node: Transient Arguments and Buffer Variables62689 +Node: Completion Confirmation and the Selection69700 +Node: Action Confirmation70146 +Node: Completion and Confirmation77998 +Node: The Selection81183 +Node: The hunk-internal region84081 +Node: Support for Completion Frameworks85170 +Node: Additional Completion Options90073 +Node: Mouse Support90671 +Node: Running Git91247 +Node: Viewing Git Output91492 +Node: Git Process Status94196 +Node: Running Git Manually95161 +Node: Git Executable97851 +Node: Global Git Arguments100859 +Node: Inspecting101664 +Node: Status Buffer102821 +Node: Status Sections107831 +Node: Status Header Sections113358 +Node: Status Module Sections115977 +Node: Status Options118474 +Node: Repository List119937 +Node: Logging124504 +Node: Refreshing Logs127346 +Node: Log Buffer128767 +Node: Log Margin132967 +Node: Select from Log136120 +Node: Reflog138330 +Node: Cherries139967 +Node: Diffing141805 +Node: Refreshing Diffs144839 +Node: Commands Available in Diffs148348 +Node: Diff Options150862 +Node: Revision Buffer156325 +Node: Ediffing159645 +Node: References Buffer165695 +Node: References Sections176289 +Node: Bisecting177146 +Node: Visiting Files and Blobs179457 +Node: General-Purpose Visit Commands179927 +Node: Visiting Files and Blobs from a Diff180880 +Node: Blaming184324 +Node: Manipulating190459 +Node: Creating Repository190801 +Node: Cloning Repository191338 +Node: Staging and Unstaging196996 +Node: Staging from File-Visiting Buffers200977 +Node: Applying202083 +Node: Committing204156 +Node: Initiating a Commit204739 +Node: Editing Commit Messages209928 +Node: Using the Revision Stack212701 +Node: Commit Pseudo Headers215746 +Node: Commit Mode and Hooks217041 +Node: Commit Message Conventions219975 +Node: Branching222098 +Node: The Two Remotes222324 +Node: Branch Commands224977 +Node: Branch Git Variables237522 +Node: Auxiliary Branch Commands242895 +Node: Merging244011 +Node: Resolving Conflicts247969 +Node: Rebasing253340 +Node: Editing Rebase Sequences258129 +Node: Information About In-Progress Rebase262345 +Ref: Information About In-Progress Rebase-Footnote-1271458 +Node: Cherry Picking272054 +Node: Reverting276388 +Node: Resetting277807 +Node: Stashing279633 +Node: Transferring284244 +Node: Remotes284466 +Node: Remote Commands284618 +Node: Remote Git Variables288657 +Node: Fetching289928 +Node: Pulling292374 +Node: Pushing293400 +Node: Plain Patches297691 +Node: Maildir Patches299162 +Node: Miscellaneous300641 +Node: Tagging300987 +Node: Notes302880 +Node: Submodules305215 +Node: Listing Submodules305433 +Node: Submodule Transient307569 +Node: Subtree310046 +Node: Worktree311977 +Node: Sparse checkouts313053 +Node: Bundle315829 +Node: Common Commands316204 +Node: Wip Modes318832 +Node: Wip Graph323723 +Node: Legacy Wip Modes326036 +Node: Commands for Buffers Visiting Files328923 +Node: Minor Mode for Buffers Visiting Blobs334481 +Node: Customizing335279 +Node: Per-Repository Configuration336875 +Node: Essential Settings339129 +Node: Safety339474 +Node: Performance341235 +Ref: Log Performance344264 +Ref: Diff Performance345574 +Ref: Refs Buffer Performance346915 +Ref: Committing Performance347490 +Node: Microsoft Windows Performance348403 +Node: MacOS Performance349594 +Ref: MacOS Performance-Footnote-1350299 +Node: Default Bindings350381 +Node: Plumbing352622 +Node: Calling Git353451 +Node: Getting a Value from Git354976 +Node: Calling Git for Effect358704 +Node: Section Plumbing364598 +Node: Creating Sections364826 +Node: Section Selection368722 +Node: Matching Sections370518 +Node: Refreshing Buffers376439 +Node: Conventions379583 +Node: Theming Faces379775 +Node: FAQ387880 +Node: FAQ - How to ...?388318 +Node: How to pronounce Magit?388675 +Node: How to show git's output?389477 +Node: How to install the gitman info manual?390263 +Node: How to show diffs for gpg-encrypted files?391233 +Node: How does branching and pushing work?391829 +Node: Should I disable VC?392161 +Node: FAQ - Issues and Errors392764 +Node: Magit is slow393765 +Node: I changed several thousand files at once and now Magit is unusable393979 +Node: I am having problems committing394708 +Node: I am using MS Windows and cannot push with Magit395189 +Node: I am using OS X and SOMETHING works in shell but not in Magit395806 +Node: Expanding a file to show the diff causes it to disappear396637 +Node: Point is wrong in the COMMIT_EDITMSG buffer397218 +Node: The mode-line information isn't always up-to-date398264 +Node: A branch and tag sharing the same name breaks SOMETHING399327 +Node: My Git hooks work on the command-line but not inside Magit400213 +Node: git-commit-mode isn't used when committing from the command-line401059 +Node: Point ends up inside invisible text when jumping to a file-visiting buffer403330 +Node: I am unable to stage when using Tramp from MS Windows404190 +Node: I am no longer able to save popup defaults405097 +Node: Debugging Tools406057 +Node: Keystroke Index409237 +Node: Function and Command Index443565 +Node: Variable Index495595  End Tag Table diff --git a/elpa/magit-section-20220101.841/dir b/elpa/magit-section-20220513.1429/dir similarity index 100% rename from elpa/magit-section-20220101.841/dir rename to elpa/magit-section-20220513.1429/dir diff --git a/elpa/magit-section-20220101.841/magit-section-autoloads.el b/elpa/magit-section-20220513.1429/magit-section-autoloads.el similarity index 79% rename from elpa/magit-section-20220101.841/magit-section-autoloads.el rename to elpa/magit-section-20220513.1429/magit-section-autoloads.el index 0899fbfa..e31297d5 100644 --- a/elpa/magit-section-20220101.841/magit-section-autoloads.el +++ b/elpa/magit-section-20220513.1429/magit-section-autoloads.el @@ -1,4 +1,4 @@ -;;; magit-section-autoloads.el --- automatically extracted autoloads +;;; magit-section-autoloads.el --- automatically extracted autoloads -*- lexical-binding: t -*- ;; ;;; Code: @@ -9,7 +9,7 @@ ;;;### (autoloads nil "magit-section" "magit-section.el" (0 0 0 0)) ;;; Generated autoloads from magit-section.el -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "magit-section" '("isearch-clean-overlays@magit-mode" "magit-"))) +(register-definition-prefixes "magit-section" '("isearch-clean-overlays@magit-mode" "magit-")) ;;;*** diff --git a/elpa/magit-section-20220101.841/magit-section-pkg.el b/elpa/magit-section-20220513.1429/magit-section-pkg.el similarity index 60% rename from elpa/magit-section-20220101.841/magit-section-pkg.el rename to elpa/magit-section-20220513.1429/magit-section-pkg.el index 4610002a..ad58038b 100644 --- a/elpa/magit-section-20220101.841/magit-section-pkg.el +++ b/elpa/magit-section-20220513.1429/magit-section-pkg.el @@ -1,7 +1,8 @@ -(define-package "magit-section" "20220101.841" "Sections for read-only buffers" +(define-package "magit-section" "20220513.1429" "Sections for read-only buffers." '((emacs "25.1") + (compat "28.1.1.0") (dash "20210826")) - :commit "2a7812705f5cf4b864bb162576415863f4116285" :authors + :commit "e920cdb326d2c2da5a32809085aa6b9369b51b1a" :authors '(("Jonas Bernoulli" . "jonas@bernoul.li")) :maintainer '("Jonas Bernoulli" . "jonas@bernoul.li") diff --git a/elpa/magit-section-20220101.841/magit-section.el b/elpa/magit-section-20220513.1429/magit-section.el similarity index 71% rename from elpa/magit-section-20220101.841/magit-section.el rename to elpa/magit-section-20220513.1429/magit-section.el index 3daf4dc1..186fac3e 100644 --- a/elpa/magit-section-20220101.841/magit-section.el +++ b/elpa/magit-section-20220513.1429/magit-section.el @@ -1,31 +1,33 @@ -;;; magit-section.el --- Sections for read-only buffers -*- lexical-binding: t -*- +;;; magit-section.el --- Sections for read-only buffers -*- lexical-binding:t -*- -;; Copyright (C) 2010-2022 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. +;; Copyright (C) 2008-2022 The Magit Project Contributors ;; Author: Jonas Bernoulli ;; Maintainer: Jonas Bernoulli -;; Keywords: tools ;; Homepage: https://github.com/magit/magit -;; Package-Requires: ((emacs "25.1") (dash "2.19.1")) -;; Package-Version: 3.3.0 +;; Keywords: tools + +;; Package-Version: 3.3.0-git +;; Package-Requires: ((emacs "25.1") (compat "28.1.1.0") (dash "2.19.1")) + ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Magit-Section 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 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 of the License, +;; or (at your option) any later version. ;; -;; Magit-Section is distributed in the hope that it will be useful, +;; 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. +;; along with Magit. If not, see . + +;; You should have received a copy of the AUTHORS.md file, which +;; lists all contributors. If not, see https://magit.vc/authors. ;;; Commentary: @@ -37,13 +39,20 @@ ;;; Code: (require 'cl-lib) +(require 'compat) +(require 'compat-26) +(require 'compat-27) (require 'dash) (require 'eieio) +(require 'format-spec) (require 'seq) (require 'subr-x) (eval-when-compile (require 'benchmark)) +;; For `magit-section-get-relative-position' +(declare-function magit-hunk-section-p "magit-diff" (section) t) + ;;; Hooks (defvar magit-section-movement-hook nil @@ -72,11 +81,6 @@ value should be `show', `hide' or nil. If no function returns non-nil, determine the visibility as usual, i.e. use the hardcoded section specific default (see `magit-insert-section').") -(defvar magit-section-goto-successor-hook nil - "Hook used to go to the same section as was current before a refresh. -This is only used if the standard mechanism for doing so did not -succeed.") - ;;; Options (defgroup magit-section nil @@ -246,6 +250,25 @@ but that ship has sailed, thus this option." :group 'magit-section :type 'boolean) +(defcustom magit-section-show-context-menu-for-emacs<28 nil + "Whether `mouse-3' shows a context menu for Emacs < 28. + +This has to be set before loading `magit-section' or it has +no effect. This also has no effect for Emacs >= 28, where +`context-menu-mode' should be enabled instead." + :package-version '(magit-section . "3.4.0") + :group 'magit-section + :type 'boolean) + +;;; Variables + +(defvar-local magit-section-pre-command-region-p nil) +(defvar-local magit-section-pre-command-section nil) +(defvar-local magit-section-highlight-force-update nil) +(defvar-local magit-section-highlight-overlays nil) +(defvar-local magit-section-highlighted-sections nil) +(defvar-local magit-section-unhighlight-sections nil) + ;;; Faces (defgroup magit-section-faces nil @@ -291,6 +314,10 @@ but that ship has sailed, thus this option." "Face for selected section headings." :group 'magit-section-faces) +(defface magit-section-child-count '((t nil)) + "Face used for child counts at the end of some section headings." + :group 'magit-section-faces) + ;;; Classes (defvar magit--current-section-hook nil @@ -299,7 +326,7 @@ but that ship has sailed, thus this option." (defvar magit--section-type-alist nil) (defclass magit-section () - ((keymap :initform nil :allocation :class) + ((keymap :initform nil) (type :initform nil :initarg :type) (value :initform nil :initarg :value) (start :initform nil :initarg :start) @@ -317,28 +344,54 @@ but that ship has sailed, thus this option." (defvar symbol-overlay-inhibit-map) +(defvar magit-section-heading-map + (let ((map (make-sparse-keymap))) + (define-key map [double-down-mouse-1] #'ignore) + (define-key map [double-mouse-1] #'magit-mouse-toggle-section) + (define-key map [double-mouse-2] #'magit-mouse-toggle-section) + map) + "Keymap used in the heading line of all expandable sections. +This keymap is used in addition to the section-specifi keymap, +if any.") + (defvar magit-section-mode-map (let ((map (make-keymap))) (suppress-keymap map t) - (define-key map (kbd "TAB") 'magit-section-toggle) - (define-key map [C-tab] 'magit-section-cycle) - (define-key map [M-tab] 'magit-section-cycle) + (when (and magit-section-show-context-menu-for-emacs<28 + (< emacs-major-version 28)) + (define-key map [mouse-3] nil) + (define-key + map [down-mouse-3] + `( menu-item "" ,(make-sparse-keymap) + :filter ,(lambda (_) + (let ((menu (make-sparse-keymap))) + (if (fboundp 'context-menu-local) + (context-menu-local menu last-input-event) + (magit--context-menu-local menu last-input-event)) + (magit-section-context-menu menu last-input-event) + menu))))) + (define-key map [left-fringe mouse-1] #'magit-mouse-toggle-section) + (define-key map [left-fringe mouse-2] #'magit-mouse-toggle-section) + (define-key map (kbd "TAB") #'magit-section-toggle) + (define-key map [C-tab] #'magit-section-cycle) + (define-key map [M-tab] #'magit-section-cycle) ;; [backtab] is the most portable binding for Shift+Tab. - (define-key map [backtab] 'magit-section-cycle-global) - (define-key map (kbd "^") 'magit-section-up) - (define-key map (kbd "p") 'magit-section-backward) - (define-key map (kbd "n") 'magit-section-forward) - (define-key map (kbd "M-p") 'magit-section-backward-sibling) - (define-key map (kbd "M-n") 'magit-section-forward-sibling) - (define-key map (kbd "1") 'magit-section-show-level-1) - (define-key map (kbd "2") 'magit-section-show-level-2) - (define-key map (kbd "3") 'magit-section-show-level-3) - (define-key map (kbd "4") 'magit-section-show-level-4) - (define-key map (kbd "M-1") 'magit-section-show-level-1-all) - (define-key map (kbd "M-2") 'magit-section-show-level-2-all) - (define-key map (kbd "M-3") 'magit-section-show-level-3-all) - (define-key map (kbd "M-4") 'magit-section-show-level-4-all) - map)) + (define-key map [backtab] #'magit-section-cycle-global) + (define-key map (kbd "^") #'magit-section-up) + (define-key map (kbd "p") #'magit-section-backward) + (define-key map (kbd "n") #'magit-section-forward) + (define-key map (kbd "M-p") #'magit-section-backward-sibling) + (define-key map (kbd "M-n") #'magit-section-forward-sibling) + (define-key map (kbd "1") #'magit-section-show-level-1) + (define-key map (kbd "2") #'magit-section-show-level-2) + (define-key map (kbd "3") #'magit-section-show-level-3) + (define-key map (kbd "4") #'magit-section-show-level-4) + (define-key map (kbd "M-1") #'magit-section-show-level-1-all) + (define-key map (kbd "M-2") #'magit-section-show-level-2-all) + (define-key map (kbd "M-3") #'magit-section-show-level-3-all) + (define-key map (kbd "M-4") #'magit-section-show-level-4-all) + map) + "Parent keymap for all keymaps of modes derived from `magit-section-mode'.") (define-derived-mode magit-section-mode special-mode "Magit-Sections" "Parent major mode from which major modes with Magit-like sections inherit. @@ -360,12 +413,14 @@ Magit-Section is documented in info node `(magit-section)'." (make-local-variable 'text-property-default-nonsticky) (push (cons 'keymap t) text-property-default-nonsticky) (add-hook 'pre-command-hook #'magit-section-pre-command-hook nil t) - (add-hook 'post-command-hook #'magit-section-update-highlight t t) + (add-hook 'post-command-hook #'magit-section-post-command-hook t t) (add-hook 'deactivate-mark-hook #'magit-section-deactivate-mark t t) (setq-local redisplay-highlight-region-function - 'magit-section--highlight-region) + #'magit-section--highlight-region) (setq-local redisplay-unhighlight-region-function - 'magit-section--unhighlight-region) + #'magit-section--unhighlight-region) + (when (fboundp 'magit-section-context-menu) + (add-hook 'context-menu-functions #'magit-section-context-menu 10 t)) (when magit-section-disable-line-numbers (when (bound-and-true-p global-linum-mode) (linum-mode -1)) @@ -387,42 +442,77 @@ of this variable is set by `magit-insert-section' and you should never modify it.") (put 'magit-root-section 'permanent-local t) +(defvar-local magit--context-menu-section nil "For internal use only.") + +(defvar magit--context-menu-buffer nil "For internal use only.") + +(defun magit-point () + "Return point or the position where the context menu was invoked. +When using the context menu, return the position the user clicked +on, provided the current buffer is the buffer in which the click +occurred. Otherwise return the same value as `point'." + (if magit--context-menu-section + (magit-menu-position) + (point))) + +(defun magit-thing-at-point (thing &optional no-properties) + "Return the THING at point or where the context menu was invoked. +When using the context menu, return the thing the user clicked +on, provided the current buffer is the buffer in which the click +occurred. Otherwise return the same value as `thing-at-point'. +For the meaning of THING and NO-PROPERTIES see that function." + (if-let ((pos (magit-menu-position))) + (save-excursion + (goto-char pos) + (thing-at-point thing no-properties)) + (thing-at-point thing no-properties))) + (defun magit-current-section () - "Return the section at point." - (or (get-text-property (point) 'magit-section) magit-root-section)) + "Return the section at point or where the context menu was invoked. +When using the context menu, return the section that the user +clicked on, provided the current buffer is the buffer in which +the click occurred. Otherwise return the section at point." + (or magit--context-menu-section + (magit-section-at) + magit-root-section)) + +(defun magit-section-at (&optional position) + "Return the section at POSITION, defaulting to point." + (get-text-property (or position (point)) 'magit-section)) (defun magit-section-ident (section) "Return an unique identifier for SECTION. The return value has the form ((TYPE . VALUE)...)." - (with-slots (type value parent) section - (cons (cons type - (cond ((eieio-object-p value) - (magit-section-ident-value value)) - ((not (memq type '(unpulled unpushed))) value) - ((string-match-p "@{upstream}" value) value) - ;; Unfortunately Git chokes on "@{push}" when - ;; the value of `push.default' does not allow a - ;; 1:1 mapping. Arbitrary commands may consult - ;; the section value so we cannot use "@{push}". - ;; But `unpushed' and `unpulled' sections should - ;; keep their identity when switching branches - ;; so we have to use another value here. - ((string-match-p "\\`\\.\\." value) "..@{push}") - (t "@{push}.."))) - (and parent - (magit-section-ident parent))))) - -(cl-defgeneric magit-section-ident-value (value) - "Return a constant representation of VALUE. -VALUE is the value of a `magit-section' object. If that is an -object itself, then that is not suitable to be used to identify -the section because two objects may represent the same thing but -not be equal. If possible a method should be added for such -objects, which returns a value that is equal. Otherwise the -catch-all method is used, which just returns the argument -itself.") - -(cl-defmethod magit-section-ident-value (arg) arg) + (cons (cons (oref section type) + (magit-section-ident-value section)) + (and-let* ((parent (oref section parent))) + (magit-section-ident parent)))) + +(cl-defgeneric magit-section-ident-value (object) + "Return OBJECT's value, making it constant and unique if necessary. + +This is used to correlate different incarnations of the same +section, see `magit-section-ident' and `magit-get-section'. + +Sections whose values that are not constant and/or unique should +implement a method that return a value that can be used for this +purpose.") + +(cl-defmethod magit-section-ident-value ((section magit-section)) + "Return the value unless it is an object. + +Different object incarnations representing the same value then to +not be equal, so call this generic function on the object itself +to determine a constant value." + (let ((value (oref section value))) + (if (eieio-object-p value) + (magit-section-ident-value value) + value))) + +(cl-defmethod magit-section-ident-value ((object eieio-default-superclass)) + "Simply return the object itself. That likely isn't +good enough, so you need to implement your own method." + object) (defun magit-get-section (ident &optional root) "Return the section identified by IDENT. @@ -434,15 +524,14 @@ instead of in the one whose root `magit-root-section' is." (when (eq (car (pop ident)) (oref section type)) (while (and ident - (pcase-let* ((`(,type . ,value) (car ident)) - (value (magit-section-ident-value value))) + (pcase-let ((`(,type . ,value) (car ident))) (setq section - (cl-find-if (lambda (section) - (and (eq (oref section type) type) - (equal (magit-section-ident-value - (oref section value)) - value))) - (oref section children))))) + (cl-find-if + (lambda (section) + (and (eq (oref section type) type) + (equal (magit-section-ident-value section) + value))) + (oref section children))))) (pop ident)) section))) @@ -450,13 +539,209 @@ instead of in the one whose root `magit-root-section' is." "Return the lineage of SECTION. The return value has the form (TYPE...)." (cons (oref section type) - (when-let ((parent (oref section parent))) + (and-let* ((parent (oref section parent))) (magit-section-lineage parent)))) (defvar magit-insert-section--current nil "For internal use only.") (defvar magit-insert-section--parent nil "For internal use only.") (defvar magit-insert-section--oldroot nil "For internal use only.") +;;; Menu + +(defvar magit-menu-common-value nil "See function `magit-menu-common-value'.") +(defvar magit-menu--desc-values nil "For internal use only.") + +(defun magit-section-context-menu (menu click) + "Populate MENU with Magit-Section commands at CLICK." + (when-let ((section (save-excursion + (unless (region-active-p) + (mouse-set-point click)) + (magit-section-at)))) + (unless (region-active-p) + (setq magit--context-menu-buffer (current-buffer)) + (if-let ((alt (save-excursion + (mouse-set-point click) + (run-hook-with-args-until-success + 'magit-menu-alternative-section-hook section)))) + (setq magit--context-menu-section (setq section alt)) + (setq magit--context-menu-section section) + (magit-section-update-highlight t))) + (when (magit-section-content-p section) + (define-key-after menu [magit-section-toggle] + `(menu-item + ,(if (oref section hidden) "Expand section" "Collapse section") + magit-section-toggle)) + (unless (oref section hidden) + (when-let ((children (oref section children))) + (when (seq-some #'magit-section-content-p children) + (when (seq-some (lambda (c) (oref c hidden)) children) + (define-key-after menu [magit-section-show-children] + `(menu-item "Expand children" + magit-section-show-children))) + (when (seq-some (lambda (c) (not (oref c hidden))) children) + (define-key-after menu [magit-section-hide-children] + `(menu-item "Collapse children" + magit-section-hide-children)))))) + (define-key-after menu [separator-magit-1] menu-bar-separator)) + (define-key-after menu [magit-describe-section] + `(menu-item "Describe section" magit-describe-section)) + (when-let ((map (oref section keymap))) + (define-key-after menu [separator-magit-2] menu-bar-separator) + (when (symbolp map) + (setq map (symbol-value map))) + (setq magit-menu-common-value (magit-menu-common-value section)) + (setq magit-menu--desc-values (magit-menu--desc-values section)) + (map-keymap (lambda (key binding) + (when (consp binding) + (define-key-after menu (vector key) + (copy-sequence binding)))) + (if (fboundp 'menu-bar-keymap) + (menu-bar-keymap map) + (magit--menu-bar-keymap map))))) + menu) + +(defun magit-menu-set (keymap key def desc &optional props after) + "In KEYMAP, define KEY and a menu entry for DEF. + +Add the menu item (menu-item DESC DEF . PROPS) at the end of +KEYMAP, or if optional AFTER is non-nil, then after that. + +Because it is so common, and would otherwise result in overlong +lines or else unsightly line wrapping, a definition [remap CMD] +can be written as just [CMD]. As a result KEY might have to be +a string when otherwise a vector would have worked. + +If DESC is a string that contains a support %-spec, substitute +the expression (magit-menu-format-desc DESC) for that. See +`magit-menu-format-desc'." + (declare (indent defun)) + (when (vectorp key) + ;; Expand the short-hand. + (unless (eq (aref key 0) 'remap) + (setq key (vconcat [remap] key))) + ;; The default binding is RET, but in my configuration it + ;; is . In that case the displayed binding would + ;; be instead of , for unknown reasons. The + ;; same does not happen for similar events, such as . + (when (and (equal key [remap magit-visit-thing]) + (boundp 'magit-mode-map) + (ignore-errors (eq (lookup-key magit-mode-map [return]) + 'magit-visit-thing))) + (setq key [return])) + ;; `define-key-after' cannot deal with [remap CMD], + ;; so we have to add the key binding separately. + (define-key keymap key def) + (unless (symbolp def) + (error "When KEY is a remapping, then DEF must be a symbol: %s" def)) + (setq key (vector def))) + (when (and (stringp desc) (string-match-p "%[tTvsmMx]" desc)) + (setq desc (list 'magit-menu-format-desc desc))) + (define-key-after keymap key + `( menu-item ,desc ,def ,@props + ;; Without this, the keys for point would be shown instead + ;; of the relevant ones from where the click occurred. + ,@(and (not (region-active-p)) + (list :keys + (lambda () + (or (ignore-errors + (save-excursion + (goto-char (magit-menu-position)) + (key-description (where-is-internal def nil t)))) + ""))))) + after)) + +(defun magit-menu-position () + "Return the position where the context-menu was invoked. +If the current command wasn't invoked using the context-menu, +then return nil." + (and magit--context-menu-section + (ignore-errors + (posn-point (event-start (aref (this-command-keys-vector) 0)))))) + +(defun magit-menu-highlight-point-section () + (setq magit-section-highlight-force-update t) + (if (eq (current-buffer) magit--context-menu-buffer) + (setq magit--context-menu-section nil) + (if-let ((window (get-buffer-window magit--context-menu-buffer))) + (with-selected-window window + (setq magit--context-menu-section nil) + (magit-section-update-highlight)) + (with-current-buffer magit--context-menu-buffer + (setq magit--context-menu-section nil)))) + (setq magit--context-menu-buffer nil)) + +(defvar magit--plural-append-es '(branch)) + +(cl-defgeneric magit-menu-common-value (_section) + "Return some value to be used by multiple menu items. +This function is called by `magit-section-context-menu', which +stores the value in `magit-menu-common-value'. Individual menu +items can use it, e.g., in the expression used to set their +description." + nil) + +(defun magit-menu--desc-values (section) + (let ((type (oref section type)) + (value (oref section value)) + (multiple (magit-region-sections nil t))) + (list type + value + (format "%s %s" type value) + (and multiple (length multiple)) + (if (memq type magit--plural-append-es) "es" "s")))) + +(defun magit-menu-format-desc (format) + "Format a string based on FORMAT and menu section or selection. +The following %-specs are allowed: +%t means \"TYPE\". +%T means \"TYPE\", or \"TYPEs\" if multiple sections are selected. +%v means \"VALUE\". +%s means \"TYPE VALUE\". +%m means \"TYPE VALUE\", or \"COUNT TYPEs\" if multiple sections + are selected. +%M means \"VALUE\", or \"COUNT TYPEs\" if multiple sections are + selected. +%x means the value of `magit-menu-common-value'." + (pcase-let* ((`(,type ,value ,single ,count ,suffix) magit-menu--desc-values) + (multiple (and count (format "%s %s%s" count type suffix)))) + (format-spec format + `((?t . ,type) + (?T . ,(format "%s%s" type (if count suffix ""))) + (?v . ,value) + (?s . ,single) + (?m . ,(or multiple single)) + (?M . ,(or multiple value)) + (?x . ,(format "%s" magit-menu-common-value)))))) + +(defun magit--menu-bar-keymap (keymap) + "Backport of `menu-bar-keymap' for Emacs < 28. +Slight trimmed down." + (let ((menu-bar nil)) + (map-keymap (lambda (key binding) + (push (cons key binding) menu-bar)) + keymap) + (cons 'keymap (nreverse menu-bar)))) + +(defun magit--context-menu-local (menu _click) + "Backport of `context-menu-local' for Emacs < 28." + (run-hooks 'activate-menubar-hook 'menu-bar-update-hook) + (define-key-after menu [separator-local] menu-bar-separator) + (let ((keymap (local-key-binding [menu-bar]))) + (when keymap + (map-keymap (lambda (key binding) + (when (consp binding) + (define-key-after menu (vector key) + (copy-sequence binding)))) + (magit--menu-bar-keymap keymap)))) + menu) + +(advice-add 'context-menu-region :around + (lambda (fn menu click) + "Disable in `magit-section-mode' buffers." + (if (derived-mode-p 'magit-section-mode) + menu + (funcall fn menu click)))) + ;;; Commands ;;;; Movement @@ -605,7 +890,7 @@ With a prefix argument also expand it." heading) (oset section content (point-marker)) (funcall washer) (oset section end (point-marker))))) - (magit-section-update-highlight t))) + (setq magit-section-highlight-force-update t))) (defun magit-section-hide (section) "Hide the body of the current section." @@ -615,6 +900,8 @@ With a prefix argument also expand it." heading) (oset section hidden t) (when-let ((beg (oref section content))) (let ((end (oref section end))) + (when (< beg (point) end) + (goto-char (oref section start))) (remove-overlays beg end 'invisible t) (let ((o (make-overlay beg end))) (overlay-put o 'evaporate t) @@ -625,17 +912,15 @@ With a prefix argument also expand it." heading) (defun magit-section-toggle (section) "Toggle visibility of the body of the current section." (interactive (list (magit-current-section))) - (if (eq section magit-root-section) - (user-error "Cannot hide root section") - (goto-char (oref section start)) - (if (oref section hidden) - (magit-section-show section) - (magit-section-hide section)))) + (cond ((eq section magit-root-section) + (user-error "Cannot hide root section")) + ((oref section hidden) + (magit-section-show section)) + (t (magit-section-hide section)))) (defun magit-section-toggle-children (section) "Toggle visibility of bodies of children of the current section." (interactive (list (magit-current-section))) - (goto-char (oref section start)) (let* ((children (oref section children)) (show (--any-p (oref it hidden) children))) (dolist (c children) @@ -662,7 +947,7 @@ children." (defun magit-section-hide-children (section) "Recursively hide the bodies of children of the current section." (interactive (list (magit-current-section))) - (mapc 'magit-section-hide (oref section children))) + (mapc #'magit-section-hide (oref section children))) (defun magit-section-show-headings (section) "Recursively show headings of children of the current section. @@ -682,7 +967,6 @@ hidden." (defun magit-section-cycle (section) "Cycle visibility of current section and its children." (interactive (list (magit-current-section))) - (goto-char (oref section start)) (if (oref section hidden) (progn (magit-section-show section) (magit-section-hide-children section)) @@ -690,7 +974,7 @@ hidden." (cond ((and (--any-p (oref it hidden) children) (--any-p (oref it children) children)) (magit-section-show-headings section)) - ((seq-some 'magit-section-hidden-body children) + ((seq-some #'magit-section-hidden-body children) (magit-section-show-children section)) (t (magit-section-hide section)))))) @@ -702,24 +986,29 @@ hidden." (cond ((and (--any-p (oref it hidden) children) (--any-p (oref it children) children)) (magit-section-show-headings magit-root-section)) - ((seq-some 'magit-section-hidden-body children) + ((seq-some #'magit-section-hidden-body children) (magit-section-show-children magit-root-section)) (t - (mapc 'magit-section-hide children))))) + (mapc #'magit-section-hide children))))) (defun magit-section-hidden-body (section &optional pred) (--if-let (oref section children) - (funcall (or pred '-any-p) 'magit-section-hidden-body it) + (funcall (or pred #'-any-p) #'magit-section-hidden-body it) (and (oref section content) (oref section hidden)))) +(defun magit-section-content-p (section) + "Return non-nil if SECTION has content or an unused washer function." + (with-slots (content end washer) section + (and content (or (not (= content end)) washer)))) + (defun magit-section-invisible-p (section) "Return t if the SECTION's body is invisible. When the body of an ancestor of SECTION is collapsed then SECTION's body (and heading) obviously cannot be visible." (or (oref section hidden) - (--when-let (oref section parent) - (magit-section-invisible-p it)))) + (and-let* ((parent (oref section parent))) + (magit-section-invisible-p parent)))) (defun magit-section-show-level (level) "Show surrounding sections up to LEVEL. @@ -780,6 +1069,22 @@ Sections at higher levels are hidden." (interactive) (magit-section-show-level -4)) +(defun magit-mouse-toggle-section (event) + "Toggle visibility of the clicked section. +Clicks outside either the section heading or the left fringe are +silently ignored." + (interactive "e") + (let* ((pos (event-start event)) + (section (magit-section-at (posn-point pos)))) + (if (eq (posn-area pos) 'left-fringe) + (when section + (while (not (magit-section-content-p section)) + (setq section (oref section parent))) + (unless (eq section magit-root-section) + (goto-char (oref section start)) + (magit-section-toggle section))) + (magit-section-toggle section)))) + ;;;; Auxiliary (defun magit-describe-section-briefly (section &optional ident) @@ -800,12 +1105,12 @@ section lineage. This command is intended for debugging purposes." (if ident (magit-section-ident section) (apply #'vector (magit-section-lineage section))) - (when-let ((m (oref section start))) + (and-let* ((m (oref section start))) (marker-position m)) (if-let ((m (oref section content))) (format "[%s-]" (marker-position m)) "") - (when-let ((m (oref section end))) + (and-let* ((m (oref section end))) (marker-position m))))) (if (called-interactively-p 'any) (message "%s" str) @@ -905,7 +1210,7 @@ of course you want to be that precise." (defun magit-section-match-2 (condition section) (if (eq (car condition) '*) (or (magit-section-match-2 (cdr condition) section) - (when-let ((parent (oref section parent))) + (and-let* ((parent (oref section parent))) (magit-section-match-2 condition parent))) (and (let ((c (car condition))) (if (class-p c) @@ -914,7 +1219,7 @@ of course you want to be that precise." (cl-typep section class) (eq (oref section type) c)))) (or (not (setq condition (cdr condition))) - (when-let ((parent (oref section parent))) + (and-let* ((parent (oref section parent))) (magit-section-match-2 condition parent)))))) (defun magit-section-value-if (condition &optional section) @@ -926,7 +1231,7 @@ then return nil. If the section does not match, then return nil. See `magit-section-match' for the forms CONDITION can take." - (when-let ((section (or section (magit-current-section)))) + (and-let* ((section (or section (magit-current-section)))) (and (magit-section-match condition section) (oref section value)))) @@ -1099,24 +1404,27 @@ anything this time around. (magit-insert-child-count ,s) (set-marker-insertion-type (oref ,s start) t) (let* ((end (oset ,s end (point-marker))) - (class-map (oref-default ,s keymap)) + (class-map (oref ,s keymap)) (magit-map (intern (format "magit-%s-section-map" (oref ,s type)))) (forge-map (intern (format "forge-%s-section-map" (oref ,s type)))) - (map (or (and class-map (symbol-value class-map)) - (and (boundp magit-map) (symbol-value magit-map)) - (and (boundp forge-map) (symbol-value forge-map))))) + (map (and class-map (symbol-value class-map)))) + (unless map + (setq map (or (and (boundp magit-map) (symbol-value magit-map)) + (and (boundp forge-map) (symbol-value forge-map)))) + (oset ,s keymap map)) (save-excursion (goto-char (oref ,s start)) (while (< (point) end) (let ((next (or (next-single-property-change (point) 'magit-section) end))) - (unless (get-text-property (point) 'magit-section) + (unless (magit-section-at) (put-text-property (point) next 'magit-section ,s) (when map (put-text-property (point) next 'keymap map))) + (magit-section-maybe-add-heading-map ,s) (goto-char next))))) (if (eq ,s magit-root-section) (let ((magit-section-cache-visibility nil)) @@ -1193,6 +1501,7 @@ is explicitly expanded." (oset ,s washer (lambda () (funcall ,f) + (magit-section-maybe-remove-heading-map ,s) (magit-section-maybe-remove-visibility-indicator ,s))) (funcall ,f))))) @@ -1218,7 +1527,29 @@ is explicitly expanded." (oset 1st-header content (oref (car header-sections) start)) (oset 1st-header end (oref (car (last header-sections)) end)) (dolist (sub-header header-sections) - (oset sub-header parent 1st-header))))))) + (oset sub-header parent 1st-header)) + (magit-section-maybe-add-heading-map 1st-header)))))) + +(defun magit-section-maybe-add-heading-map (section) + (when (magit-section-content-p section) + (let ((start (oref section start)) + (map (oref section keymap))) + (when (symbolp map) + (setq map (symbol-value map))) + (put-text-property + start + (save-excursion + (goto-char start) + (line-end-position)) + 'keymap (if map + (make-composed-keymap + (list map magit-section-heading-map)) + magit-section-heading-map))))) + +(defun magit-section-maybe-remove-heading-map (section) + (with-slots (start content end keymap) section + (when (= content end) + (put-text-property start end 'keymap keymap)))) (defun magit-insert-child-count (section) "Modify SECTION's heading to contain number of child sections. @@ -1238,30 +1569,46 @@ evaluated its BODY. Admittedly that's a bit of a hack." (eq (char-before (1- content)) ?:)) (save-excursion (goto-char (- content 2)) - (insert (format " (%s)" count)) + (insert (concat (magit--propertize-face " " 'magit-section-heading) + (magit--propertize-face (format "(%s)" count) + 'magit-section-child-count))) (delete-char 1))))) ;;; Highlight -(defvar-local magit-section-pre-command-region-p nil) -(defvar-local magit-section-pre-command-section nil) -(defvar-local magit-section-highlight-overlays nil) -(defvar-local magit-section-highlighted-sections nil) -(defvar-local magit-section-unhighlight-sections nil) - (defun magit-section-pre-command-hook () + (when (and (not (bound-and-true-p transient--prefix)) + (or magit--context-menu-buffer + magit--context-menu-section) + (not (eq (ignore-errors + (event-basic-type (aref (this-command-keys) 0))) + 'mouse-3))) + ;; This is the earliest opportunity to clean up after an aborted + ;; context-menu because that neither causes the command that created + ;; the menu to abort nor some abortion hook to be run. It is not + ;; possible to update highlighting before the first command invoked + ;; after the menu is aborted. Here we can only make sure it is + ;; updated afterwards. + (magit-menu-highlight-point-section)) (setq magit-section-pre-command-region-p (region-active-p)) (setq magit-section-pre-command-section (magit-current-section))) +(defun magit-section-post-command-hook () + (unless (bound-and-true-p transient--prefix) + (when (or magit--context-menu-buffer + magit--context-menu-section) + (magit-menu-highlight-point-section)) + (unless (memq this-command '(magit-refresh magit-refresh-all)) + (magit-section-update-highlight)))) + (defun magit-section-deactivate-mark () - (magit-section-update-highlight t)) + (setq magit-section-highlight-force-update t)) (defun magit-section-update-highlight (&optional force) (let ((section (magit-current-section))) (when (or force - (cond ; `xor' wasn't added until 27.1. - ((not magit-section-pre-command-region-p) (region-active-p)) - ((not (region-active-p)) magit-section-pre-command-region-p)) + magit-section-highlight-force-update + (xor magit-section-pre-command-region-p (region-active-p)) (not (eq magit-section-pre-command-section section))) (let ((inhibit-read-only t) (deactivate-mark nil) @@ -1278,6 +1625,7 @@ evaluated its BODY. Admittedly that's a bit of a hack." (run-hook-with-args-until-success 'magit-section-unhighlight-hook s selection)) (restore-buffer-modified-p nil))) + (setq magit-section-highlight-force-update nil) (magit-section-maybe-paint-visibility-ellipses))) (defun magit-section-highlight (section selection) @@ -1339,39 +1687,55 @@ invisible." (push ov magit-section-highlight-overlays) ov)) -(defun magit-section-goto-successor (section line char arg) +(cl-defgeneric magit-section-get-relative-position (section)) + +(cl-defmethod magit-section-get-relative-position ((section magit-section)) + (let ((start (oref section start)) + (point (magit-point))) + (list (- (line-number-at-pos point) + (line-number-at-pos start)) + (- point (line-beginning-position))))) + +(cl-defgeneric magit-section-goto-successor ()) + +(cl-defmethod magit-section-goto-successor ((section magit-section) + line char &optional _arg) + (or (magit-section-goto-successor--same section line char) + (magit-section-goto-successor--related section))) + +(defun magit-section-goto-successor--same (section line char) (let ((ident (magit-section-ident section))) - (--if-let (magit-get-section ident) - (let ((start (oref it start))) - (goto-char start) - (unless (eq it magit-root-section) - (ignore-errors - (forward-line line) - (forward-char char)) - (unless (eq (magit-current-section) it) - (goto-char start)))) - (or (run-hook-with-args-until-success - 'magit-section-goto-successor-hook section arg) - (goto-char (--if-let (magit-section-goto-successor-1 section) - (if (eq (oref it type) 'button) - (point-min) - (oref it start)) - (point-min))))))) - -(defun magit-section-goto-successor-1 (section) - (or (--when-let (pcase (oref section type) - (`staged 'unstaged) - (`unstaged 'staged) - (`unpushed 'unpulled) - (`unpulled 'unpushed)) - (magit-get-section `((,it) (status)))) - (--when-let (car (magit-section-siblings section 'next)) - (magit-get-section (magit-section-ident it))) - (--when-let (car (magit-section-siblings section 'prev)) - (magit-get-section (magit-section-ident it))) - (--when-let (oref section parent) - (or (magit-get-section (magit-section-ident it)) - (magit-section-goto-successor-1 it))))) + (and-let* ((found (magit-get-section ident))) + (let ((start (oref found start))) + (goto-char start) + (unless (eq found magit-root-section) + (ignore-errors + (forward-line line) + (forward-char char)) + (unless (eq (magit-current-section) found) + (goto-char start)))) + t))) + +(defun magit-section-goto-successor--related (section) + (and-let* ((found (magit-section-goto-successor--related-1 section))) + (goto-char (if (eq (oref found type) 'button) + (point-min) + (oref found start))))) + +(defun magit-section-goto-successor--related-1 (section) + (or (and-let* ((alt (pcase (oref section type) + ('staged 'unstaged) + ('unstaged 'staged) + ('unpushed 'unpulled) + ('unpulled 'unpushed)))) + (magit-get-section `((,alt) (status)))) + (and-let* ((next (car (magit-section-siblings section 'next)))) + (magit-get-section (magit-section-ident next))) + (and-let* ((prev (car (magit-section-siblings section 'prev)))) + (magit-get-section (magit-section-ident prev))) + (and-let* ((parent (oref section parent))) + (or (magit-get-section (magit-section-ident parent)) + (magit-section-goto-successor--related-1 parent))))) ;;; Region @@ -1411,13 +1775,10 @@ invisible." (cl-defun magit-section-cache-visibility (&optional (section magit-insert-section--current)) - ;; Emacs 25's `alist-get' lacks TESTFN. - (let* ((id (magit-section-ident section)) - (elt (assoc id magit-section-visibility-cache)) - (val (if (oref section hidden) 'hide 'show))) - (if elt - (setcdr elt val) - (push (cons id val) magit-section-visibility-cache)))) + (setf (compat-alist-get (magit-section-ident section) + magit-section-visibility-cache + nil nil #'equal) + (if (oref section hidden) 'hide 'show))) (cl-defun magit-section-maybe-cache-visibility (&optional (section magit-insert-section--current)) @@ -1427,45 +1788,38 @@ invisible." (magit-section-cache-visibility section))) (defun magit-section-maybe-update-visibility-indicator (section) - (when magit-section-visibility-indicator - (let ((beg (oref section start)) - (cnt (oref section content)) - (end (oref section end))) - (when (and cnt (or (not (= cnt end)) (oref section washer))) - (let ((eoh (save-excursion - (goto-char beg) - (line-end-position)))) - (cond - ((symbolp (car-safe magit-section-visibility-indicator)) - ;; It would make more sense to put the overlay only on the - ;; location we actually don't put it on, but then inserting - ;; before that location (while taking care not to mess with - ;; the overlay) would cause the fringe bitmap to disappear - ;; (but not other effects of the overlay). - (let ((ov (magit--overlay-at (1+ beg) 'magit-vis-indicator 'fringe))) - (unless ov - (setq ov (make-overlay (1+ beg) eoh)) - (overlay-put ov 'evaporate t) - (overlay-put ov 'magit-vis-indicator 'fringe)) - (overlay-put - ov 'before-string - (propertize "fringe" 'display - (list 'left-fringe - (if (oref section hidden) - (car magit-section-visibility-indicator) - (cdr magit-section-visibility-indicator)) - 'fringe))))) - ((stringp (car-safe magit-section-visibility-indicator)) - (let ((ov (magit--overlay-at (1- eoh) 'magit-vis-indicator 'eoh))) - (cond ((oref section hidden) - (unless ov - (setq ov (make-overlay (1- eoh) eoh)) - (overlay-put ov 'evaporate t) - (overlay-put ov 'magit-vis-indicator 'eoh)) - (overlay-put ov 'after-string - (car magit-section-visibility-indicator))) - (ov - (delete-overlay ov))))))))))) + (when (and magit-section-visibility-indicator + (magit-section-content-p section)) + (let* ((beg (oref section start)) + (eoh (save-excursion + (goto-char beg) + (line-end-position)))) + (cond + ((symbolp (car-safe magit-section-visibility-indicator)) + (let ((ov (magit--overlay-at beg 'magit-vis-indicator 'fringe))) + (unless ov + (setq ov (make-overlay beg eoh nil t)) + (overlay-put ov 'evaporate t) + (overlay-put ov 'magit-vis-indicator 'fringe)) + (overlay-put + ov 'before-string + (propertize "fringe" 'display + (list 'left-fringe + (if (oref section hidden) + (car magit-section-visibility-indicator) + (cdr magit-section-visibility-indicator)) + 'fringe))))) + ((stringp (car-safe magit-section-visibility-indicator)) + (let ((ov (magit--overlay-at (1- eoh) 'magit-vis-indicator 'eoh))) + (cond ((oref section hidden) + (unless ov + (setq ov (make-overlay (1- eoh) eoh)) + (overlay-put ov 'evaporate t) + (overlay-put ov 'magit-vis-indicator 'eoh)) + (overlay-put ov 'after-string + (car magit-section-visibility-indicator))) + (ov + (delete-overlay ov))))))))) (defvar-local magit--ellipses-sections nil) @@ -1544,7 +1898,7 @@ invisible." (funcall fn))) (advice-add 'isearch-clean-overlays :around - 'isearch-clean-overlays@magit-mode) + #'isearch-clean-overlays@magit-mode) ;;; Utilities @@ -1554,11 +1908,11 @@ invisible." (memq section (if sselection selection (setq selection (magit-region-sections)))) - (--when-let (oref section parent) - (magit-section-selected-p it selection))))) + (and-let* ((parent (oref section parent))) + (magit-section-selected-p parent selection))))) (defun magit-section-parent-value (section) - (when-let ((parent (oref section parent))) + (and-let* ((parent (oref section parent))) (oref parent value))) (defun magit-section-siblings (section &optional direction) @@ -1568,12 +1922,12 @@ If optional DIRECTION is `prev', then return siblings that come before SECTION. If it is `next', then return siblings that come after SECTION. For all other values, return all siblings excluding SECTION itself." - (when-let ((parent (oref section parent))) - (let ((siblings (oref parent children))) - (pcase direction - (`prev (cdr (member section (reverse siblings)))) - (`next (cdr (member section siblings))) - (_ (remq section siblings)))))) + (and-let* ((parent (oref section parent)) + (siblings (oref parent children))) + (pcase direction + ('prev (cdr (member section (reverse siblings)))) + ('next (cdr (member section siblings))) + (_ (remq section siblings))))) (defun magit-region-values (&optional condition multiple) "Return a list of the values of the selected sections. @@ -1611,8 +1965,8 @@ forms CONDITION can take." (when (region-active-p) (let* ((rbeg (region-beginning)) (rend (region-end)) - (sbeg (get-text-property rbeg 'magit-section)) - (send (get-text-property rend 'magit-section))) + (sbeg (magit-section-at rbeg)) + (send (magit-section-at rend))) (when (and send (not (eq send magit-root-section)) (not (and multiple (eq send sbeg)))) @@ -1649,34 +2003,13 @@ current section." If optional SECTION is nil, use the current section." (and (region-active-p) (or section (setq section (magit-current-section))) - (let ((beg (get-text-property (region-beginning) 'magit-section))) - (and (eq beg (get-text-property (region-end) 'magit-section)) + (let ((beg (magit-section-at (region-beginning)))) + (and (eq beg (magit-section-at (region-end))) (eq beg section))) (not (or (magit-section-position-in-heading-p section (region-beginning)) (magit-section-position-in-heading-p section (region-end)))) t)) -(defun magit-section--backward-protected () - "Move to the beginning of the current or the previous visible section. -Same as `magit-section-backward' but for non-interactive use. -Suppress `magit-section-movement-hook', and return a boolean to -indicate whether a section was found, instead of raising an error -if not." - (condition-case nil - (let ((magit-section-movement-hook nil)) - (magit-section-backward) - t) - (user-error nil))) - -(defun magit-section--backward-find (predicate) - "Move to the first previous section satisfying PREDICATE. -PREDICATE does not take any parameter and should not move -point." - (let (found) - (while (and (setq found (magit-section--backward-protected)) - (not (funcall predicate)))) - found)) - (defun magit-wash-sequence (function) "Repeatedly call FUNCTION until it returns nil or eob is reached. FUNCTION has to move point forward or return nil." @@ -1785,6 +2118,38 @@ Configuration'." val))))) (overlays-at pos t))) +(defun magit-face-property-all (face string) + "Return non-nil if FACE is present in all of STRING." + (catch 'missing + (let ((pos 0)) + (while (setq pos (next-single-property-change pos 'font-lock-face string)) + (let ((val (get-text-property pos 'font-lock-face string))) + (unless (if (consp val) + (memq face val) + (eq face val)) + (throw 'missing nil)))) + (not pos)))) + +(defun magit--add-face-text-property (beg end face &optional append object) + "Like `add-face-text-property' but for `font-lock-face'." + (while (< beg end) + (let* ((pos (next-single-property-change beg 'font-lock-face object end)) + (val (get-text-property beg 'font-lock-face object)) + (val (if (listp val) val (list val)))) + (put-text-property beg pos 'font-lock-face + (if append + (append val (list face)) + (cons face val)) + object) + (setq beg pos)))) + +(defun magit--propertize-face (string face) + (propertize string 'face face 'font-lock-face face)) + +(defun magit--put-face (beg end face string) + (put-text-property beg end 'face face string) + (put-text-property beg end 'font-lock-face face string)) + ;;; Bitmaps (when (fboundp 'define-fringe-bitmap) diff --git a/elpa/magit-section-20220101.841/magit-section.info b/elpa/magit-section-20220513.1429/magit-section.info similarity index 85% rename from elpa/magit-section-20220101.841/magit-section.info rename to elpa/magit-section-20220513.1429/magit-section.info index e75d7ee5..7e6ad9e3 100644 --- a/elpa/magit-section-20220101.841/magit-section.info +++ b/elpa/magit-section-20220513.1429/magit-section.info @@ -33,7 +33,7 @@ packages that have nothing to do with Magit or Git. and user options see *note (magit)Sections::. This manual documents how you can use sections in your own packages. -This manual is for Magit-Section version v3.3.0-73-g03f495f35+1. +This manual is for Magit-Section version 3.3.0-git. Copyright (C) 2015-2022 Jonas Bernoulli @@ -169,7 +169,14 @@ File: magit-section.info, Node: Core Functions, Next: Matching Functions, Pre **************** -- Function: magit-current-section - Return the section at point. + Return the section at point or where the context menu was invoked. + When using the context menu, return the section that the user + clicked on, provided the current buffer is the buffer in which the + click occurred. Otherwise return the section at point. + +Function magit-section-at &optional position + Return the section at POSITION, defaulting to point. Default to + point even when the context menu is used. -- Function: magit-section-ident section Return an unique identifier for SECTION. The return value has the @@ -195,6 +202,32 @@ File: magit-section.info, Node: Core Functions, Next: Matching Functions, Pre Return the lineage of SECTION. The return value has the form ‘(TYPE...)’. + -- Function: magit-section-content-p section + Return non-nil if SECTION has content or an unused washer function. + + The next two functions are replacements for the Emacs functions that +have the same name except for the ‘magit-’ prefix. Like +‘magit-current-section’ they do not act on point, the cursors position, +but on the position where the user clicked to invoke the context menu. + + If your package provides a context menu and some of its commands act +on the "thing at point", even if just as a default, then use the +prefixed functions to teach them to instead use the click location when +appropriate. + +Function magit-point + Return point or the position where the context menu was invoked. + When using the context menu, return the position the user clicked + on, provided the current buffer is the buffer in which the click + occurred. Otherwise return the same value as ‘point’. + +Function magit-thing-at-point thing &optional no-properties + Return the THING at point or where the context menu was invoked. + When using the context menu, return the thing the user clicked on, + provided the current buffer is the buffer in which the click + occurred. Otherwise return the same value as ‘thing-at-point’. + For the meaning of THING and NO-PROPERTIES see that function. +  File: magit-section.info, Node: Matching Functions, Prev: Core Functions, Up: Top @@ -261,10 +294,10 @@ File: magit-section.info, Node: Matching Functions, Prev: Core Functions, Up:  Tag Table: Node: Top788 -Node: Introduction2086 -Node: Creating Sections2856 -Node: Core Functions7365 -Node: Matching Functions8686 +Node: Introduction2073 +Node: Creating Sections2843 +Node: Core Functions7352 +Node: Matching Functions10404  End Tag Table -- 2.47.3