fix magit update

This commit is contained in:
2022-01-27 17:13:55 +01:00
parent 03507476ec
commit b6f0853efe
28 changed files with 13645 additions and 11087 deletions

View File

@@ -65,11 +65,11 @@
["Arguments"
("-n" "Don't checkout commits" "--no-checkout")
("-p" "Follow only first parent of a merge" "--first-parent"
:if (lambda () (version<= "2.29" (magit-git-version))))
:if (lambda () (magit-git-version>= "2.29")))
(6 magit-bisect:--term-old
:if (lambda () (version<= "2.7" (magit-git-version))))
:if (lambda () (magit-git-version>= "2.7")))
(6 magit-bisect:--term-new
:if (lambda () (version<= "2.7" (magit-git-version))))]
:if (lambda () (magit-git-version>= "2.7")))]
["Actions"
("B" "Start" magit-bisect-start)
("s" "Start script" magit-bisect-run)]]
@@ -78,7 +78,7 @@
("B" "Bad" magit-bisect-bad)
("g" "Good" magit-bisect-good)
(6 "m" "Mark" magit-bisect-mark
:if (lambda () (version<= "2.7" (magit-git-version))))
:if (lambda () (magit-git-version>= "2.7")))
("k" "Skip" magit-bisect-skip)
("r" "Reset" magit-bisect-reset)
("s" "Run script" magit-bisect-run)])
@@ -204,7 +204,9 @@ bisect run'."
(magit-process-git-arguments
(list "bisect" "start" bad good args)))
(magit-refresh)))
(magit-git-bisect "run" (list shell-file-name shell-command-switch cmdline)))
(magit--with-connection-local-variables
(magit-git-bisect "run" (list shell-file-name
shell-command-switch cmdline))))
(defun magit-git-bisect (subcommand &optional args no-assert)
(unless (or no-assert (magit-bisect-in-progress-p))

View File

@@ -217,7 +217,7 @@ has to be used to view and change branch related variables."
["Arguments"
(7 "-r" "Recurse submodules when checking out an existing branch"
"--recurse-submodules"
:if (lambda () (version<= "2.13" (magit-git-version))))]
:if (lambda () (magit-git-version>= "2.13")))]
["Variables"
:if (lambda ()
(and magit-branch-direct-configure

View File

@@ -117,6 +117,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,6 +132,9 @@ 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)))
@@ -136,6 +142,18 @@ the name of the owner. Also see `magit-clone-name-alist'."
(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 +211,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")
@@ -234,6 +259,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)))))))

View File

@@ -952,9 +952,9 @@ and `:slant'."
: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))
@@ -2058,7 +2058,7 @@ Staging and applying changes is documented in info node
(when (and (not (equal cmd "merge-tree"))
(pcase (magit-repository-local-get 'diff-ita-kludge-p 'unset)
(`unset
(let ((val (version<= "2.19.0" (magit-git-version))))
(let ((val (magit-git-version>= "2.19.0")))
(magit-repository-local-set 'diff-ita-kludge-p val)
val))
(val val)))

View File

@@ -297,6 +297,7 @@ with two prefix arguments remove ignored files only.
;;; ChangeLog
;;;###autoload
(defun magit-generate-changelog (&optional amending)
"Insert ChangeLog entries into the current buffer.

View File

@@ -190,11 +190,11 @@ with a prefix argument."
(list nil (transient-args 'magit-fetch-modules))))
(if transient
(transient-setup 'magit-fetch-modules)
(let ((git-version (magit-git-version)))
(when (version< git-version "2.8.0")
(when-let ((value (transient-arg-value "--jobs=" args)))
(message "Dropping --jobs; not supported by Git v%s" git-version)
(setq args (remove (format "--jobs=%s" value) args)))))
(when (magit-git-version< "2.8.0")
(when-let ((value (transient-arg-value "--jobs=" args)))
(message "Dropping --jobs; not supported by Git v%s"
(magit-git-version))
(setq args (remove (format "--jobs=%s" value) args))))
(magit-with-toplevel
(magit-run-git-async "fetch" "--recurse-submodules" args))))

View File

@@ -575,11 +575,20 @@ call function WASHER with ARGS as its sole argument."
(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)))))
(defun magit-git-version>= (n)
"Return t if `magit-git-version's value is greater than or equal to N."
(magit--version>= (magit-git-version) n))
(defun magit-git-version< (n)
"Return t if `magit-git-version's value is smaller than N."
(version< (magit-git-version) n))
;;; Variables
(defun magit-config-get-from-cached-list (key)
@@ -914,6 +923,12 @@ 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)
(delete-consecutive-dups
(sort (nconc (magit-staged-files nomodules files)
(magit-unstaged-files nomodules files))
#'string<)))
(defun magit-unstaged-files (&optional nomodules files)
(magit-git-items "diff-files" "-z" "--name-only"
(and nomodules "--ignore-submodules")
@@ -952,6 +967,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
@@ -1199,7 +1220,7 @@ ref that should have been excluded, then that is discarded and
this function returns nil instead. This is unfortunate because
there might be other refs that do match. To fix that, update
Git."
(if (version< (magit-git-version) "2.13")
(if (magit-git-version< "2.13")
(when-let
((ref (magit-git-string "name-rev" "--name-only" "--no-undefined"
(and pattern (concat "--refs=" pattern))
@@ -1691,7 +1712,9 @@ SORTBY is a key or list of keys to pass to the `--sort' flag of
((and val (pred listp)) val)))
(or namespaces magit-list-refs-namespaces))))
(if (member format '("%(refname)" "%(refname:short)"))
(--remove (string-match-p "\\(\\`\\|/\\)HEAD\\'" it) refs)
(let ((case-fold-search nil))
(--remove (string-match-p "\\(\\`\\|/\\)HEAD\\'" it)
refs))
refs)))
(defun magit-list-branches ()
@@ -1959,12 +1982,13 @@ Return a list of two integers: (A>B B>A)."
(cdr (split-string it))))
(defun magit-patch-id (rev)
(magit--with-temp-process-buffer
(magit-process-file
shell-file-name nil '(t nil) nil shell-command-switch
(let ((exec (shell-quote-argument (magit-git-executable))))
(format "%s diff-tree -u %s | %s patch-id" exec rev exec)))
(car (split-string (buffer-string)))))
(magit--with-connection-local-variables
(magit--with-temp-process-buffer
(magit-process-file
shell-file-name nil '(t nil) nil shell-command-switch
(let ((exec (shell-quote-argument (magit-git-executable))))
(format "%s diff-tree -u %s | %s patch-id" exec rev exec)))
(car (split-string (buffer-string))))))
(defun magit-rev-format (format &optional rev args)
(let ((str (magit-git-string "show" "--no-patch"
@@ -2160,7 +2184,7 @@ and this option only controls what face is used.")
(defun magit-update-ref (ref message rev &optional stashish)
(let ((magit--refresh-cache nil))
(or (if (not (version< (magit-git-version) "2.6.0"))
(or (if (magit-git-version>= "2.6.0")
(zerop (magit-call-git "update-ref" "--create-reflog"
"-m" message ref rev
(or (magit-rev-verify ref) "")))

View File

@@ -153,7 +153,8 @@ Rules that are defined in that file affect all local repositories."
(magit-with-toplevel
(cl-set-difference
(magit-list-files)
(magit-skip-worktree-files))))))
(magit-skip-worktree-files)
:test #'equal)))))
(magit-with-toplevel
(magit-run-git "update-index" "--skip-worktree" "--" file)))
@@ -177,7 +178,8 @@ Rules that are defined in that file affect all local repositories."
(magit-with-toplevel
(cl-set-difference
(magit-list-files)
(magit-assume-unchanged-files))))))
(magit-assume-unchanged-files)
:test #'equal)))))
(magit-with-toplevel
(magit-run-git "update-index" "--assume-unchanged" "--" file)))

View File

@@ -41,6 +41,8 @@
(&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))
@@ -437,20 +439,21 @@ 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))
@@ -634,6 +637,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 +683,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'."

View File

@@ -403,6 +403,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)

View File

@@ -1,11 +1,11 @@
(define-package "magit" "20220102.1825" "A Git porcelain inside Emacs."
(define-package "magit" "20220126.1645" "A Git porcelain inside Emacs."
'((emacs "25.1")
(dash "20210826")
(git-commit "20211004")
(magit-section "20211004")
(transient "20210920")
(with-editor "20211001"))
:commit "2e73b66c2980abb9211d9881a8710c8ac5a33184" :authors
:commit "6ba3b50373fffa89ae99fc0ad5135e3d574f6df4" :authors
'(("Marius Vollmer" . "marius.vollmer@gmail.com")
("Jonas Bernoulli" . "jonas@bernoul.li"))
:maintainer

View File

@@ -426,7 +426,7 @@ without prompting."
("-k" "Inhibit removal of email cruft" ("-k" "--keep"))
("-b" "Limit removal of email cruft" "--keep-non-patch")
("-d" "Use author date as committer date" "--committer-date-is-author-date")
("-D" "Use committer date as author date" "--ignore-date")
("-t" "Use current time as author date" "--ignore-date")
("-s" "Add Signed-off-by lines" ("-s" "--signoff"))
(5 magit:--gpg-sign)]
["Apply"
@@ -514,18 +514,22 @@ This discards all changes made since the sequence started."
["Arguments"
:if-not magit-rebase-in-progress-p
("-k" "Keep empty commits" "--keep-empty")
("-p" "Preserve merges" ("-p" "--preserve-merges"))
("-p" "Preserve merges" ("-p" "--preserve-merges")
:if (lambda () (magit-git-version< "2.33.0")))
("-r" "Rebase merges" ("-r" "--rebase-merges=")
magit-rebase-merges-select-mode
:if (lambda () (magit-git-version>= "2.18.0")))
(7 magit-merge:--strategy)
(7 magit-merge:--strategy-option)
(7 "=X" magit-diff:--diff-algorithm :argument "-Xdiff-algorithm=")
("-d" "Lie about committer date" "--committer-date-is-author-date")
("-d" "Use author date as committer date" "--committer-date-is-author-date")
("-t" "Use current time as author date" "--ignore-date")
("-a" "Autosquash" "--autosquash")
("-A" "Autostash" "--autostash")
("-i" "Interactive" ("-i" "--interactive"))
("-h" "Disable hooks" "--no-verify")
(7 magit-rebase:--exec)
(5 magit:--gpg-sign)
(5 "-r" "Rebase merges" "--rebase-merges=" magit-rebase-merges-select-mode)]
(5 magit:--gpg-sign)]
[:if-not magit-rebase-in-progress-p
:description (lambda ()
(format (propertize "Rebase %s onto" 'face 'transient-heading)
@@ -852,6 +856,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 ()

View File

@@ -0,0 +1,173 @@
;;; magit-sparse-checkout.el --- sparse checkout support for Magit -*- lexical-binding: t -*-
;; Copyright (C) 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: Kyle Meyer <kyle@kyleam.com>
;; Maintainer: Jonas Bernoulli <jonas@bernoul.li>
;; 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:
;; 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

View File

@@ -31,6 +31,7 @@
(require 'magit)
(require 'magit-reflog)
(require 'magit-sequence)
;;; Options
@@ -95,7 +96,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 +212,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.
@@ -374,14 +400,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)

View File

@@ -340,7 +340,7 @@ init file: (global-set-key (kbd \"C-x g\") 'magit-status-quick)."
(unless (member remote magit--remotes-using-recent-git)
(if-let ((version (let ((default-directory directory))
(magit-git-version))))
(if (version<= magit--minimal-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.

View File

@@ -225,7 +225,7 @@ it is nil, then PATH also becomes the name."
(magit-process-sentinel process event)
(process-put process 'inhibit-refresh t)
(magit-process-sentinel process event)
(unless (version< (magit-git-version) "2.12.0")
(when (magit-git-version>= "2.12.0")
(magit-call-git "submodule" "absorbgitdirs" path))
(magit-refresh)))))))
@@ -360,7 +360,7 @@ to recover from making a mistake here, but don't count on it."
(list (magit-read-module-path "Remove module")))
(magit-submodule-arguments "--force")
current-prefix-arg))
(when (version< (magit-git-version) "2.12.0")
(when (magit-git-version< "2.12.0")
(error "This command requires Git v2.12.0"))
(when magit-submodule-remove-trash-gitdirs
(setq trash-gitdirs t))
@@ -383,14 +383,14 @@ to recover from making a mistake here, but don't count on it."
(expand-file-name module))))
(magit-git "stash" "push"
"-m" "backup before removal of this module")))
(setq modules (cl-set-difference modules modified)))
(setq modules (cl-set-difference modules modified :test #'equal)))
(if (cdr modified)
(message "Omitting %s modules with uncommitted changes: %s"
(length modified)
(mapconcat #'identity modified ", "))
(message "Omitting module %s, it has uncommitted changes"
(car modified)))
(setq modules (cl-set-difference modules modified))))
(setq modules (cl-set-difference modules modified :test #'equal))))
(when modules
(let ((alist
(and trash-gitdirs

View File

@@ -1010,6 +1010,16 @@ one trailing newline is added."
(and (eq trim ?\n) "\n"))
str)))
(defun magit--version> (v1 v2)
"Return t if version V1 is higher (younger) than V2.
This function should be named `version>' and be part of Emacs."
(version-list-< (version-to-list v2) (version-to-list v1)))
(defun magit--version>= (v1 v2)
"Return t if version V1 is higher (younger) than or equal to V2.
This function should be named `version>=' and be part of Emacs."
(version-list-<= (version-to-list v2) (version-to-list v1)))
;;; Kludges for Emacs Bugs
(defun magit-file-accessible-directory-p (filename)
@@ -1019,7 +1029,7 @@ and https://github.com/magit/magit/issues/2295."
(and (file-directory-p filename)
(file-accessible-directory-p filename)))
(when (version<= "25.1" emacs-version)
(when (magit--version>= emacs-version "25.1")
(with-eval-after-load 'vc-git
(defun vc-git-conflicted-files (directory)
"Return the list of files with conflicts in DIRECTORY."
@@ -1158,6 +1168,9 @@ or (last of all) the value of EXP."
(advice-add 'Info-follow-nearest-node :around
'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)
@@ -1177,10 +1190,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)
@@ -1198,6 +1207,32 @@ See <https://github.com/raxod502/straight.el/issues/520>."
(setq filename target))))
(file-chase-links filename))
;;; Kludges for older Emacs versions
(if (fboundp 'with-connection-local-variables)
(defalias 'magit--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.
`with-connection-local-variables' isn't available until Emacs 27.
This kludge provides the minimal functionality required by
Magit."
`(if (file-remote-p default-directory)
(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
(defun magit-message (format-string &rest args)

View File

@@ -304,8 +304,7 @@ commit message."
(and (pcase (magit-repository-local-get
'update-index-has-ignore-sw-p 'unset)
(`unset
(let ((val (version<= "2.25.0"
(magit-git-version))))
(let ((val (magit-git-version>= "2.25.0")))
(magit-repository-local-set
'update-index-has-ignore-sw-p val)
val))

View File

@@ -447,8 +447,9 @@ is run in the top-level directory of the current working tree."
(let ((default-directory (or directory default-directory))
(process-environment process-environment))
(push "GIT_PAGER=cat" process-environment)
(magit-start-process shell-file-name nil
shell-command-switch command))
(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)
@@ -566,7 +567,8 @@ and Emacs to it."
(when print-dest
(princ (format "Magit %s%s, Git %s, Emacs %s, %s"
(or magit-version "(unknown)")
(or (and (ignore-errors (version< "2008" magit-version))
(or (and (ignore-errors
(magit--version>= magit-version "2008"))
(ignore-errors
(require 'lisp-mnt)
(and (fboundp 'lm-header)
@@ -710,6 +712,7 @@ 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)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff