update packages
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
;;; magit-apply.el --- Apply Git diffs -*- lexical-binding:t -*-
|
||||
|
||||
;; Copyright (C) 2008-2023 The Magit Project Contributors
|
||||
;; Copyright (C) 2008-2025 The Magit Project Contributors
|
||||
|
||||
;; Author: Jonas Bernoulli <jonas@bernoul.li>
|
||||
;; Maintainer: Jonas Bernoulli <jonas@bernoul.li>
|
||||
;; Author: Jonas Bernoulli <emacs.magit@jonas.bernoulli.dev>
|
||||
;; Maintainer: Jonas Bernoulli <emacs.magit@jonas.bernoulli.dev>
|
||||
|
||||
;; SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
@@ -49,11 +49,6 @@
|
||||
(path &optional prefer-short))
|
||||
(defvar borg-user-emacs-directory)
|
||||
|
||||
(cl-eval-when (compile load)
|
||||
(when (< emacs-major-version 26)
|
||||
(defalias 'smerge-keep-upper 'smerge-keep-mine)
|
||||
(defalias 'smerge-keep-lower 'smerge-keep-other)))
|
||||
|
||||
;;; Options
|
||||
|
||||
(defcustom magit-delete-by-moving-to-trash t
|
||||
@@ -192,10 +187,8 @@ adjusted as \"@@ -10,6 +10,7 @@\" and \"@@ -18,6 +19,7 @@\"."
|
||||
(magit-apply-patch
|
||||
file args
|
||||
(concat (oref file header)
|
||||
(mapconcat #'identity
|
||||
(magit-apply--adjust-hunk-new-starts
|
||||
(mapcar #'magit-apply--section-content hunks))
|
||||
"")))))
|
||||
(string-join (magit-apply--adjust-hunk-new-starts
|
||||
(mapcar #'magit-apply--section-content hunks)))))))
|
||||
|
||||
(defun magit-apply-hunk (hunk &rest args)
|
||||
(let ((file (oref hunk parent)))
|
||||
@@ -224,7 +217,7 @@ adjusted as \"@@ -10,6 +10,7 @@\" and \"@@ -18,6 +19,7 @@\"."
|
||||
(defun magit-apply-patch (section:s args patch)
|
||||
(let* ((files (if (atom section:s)
|
||||
(list (oref section:s value))
|
||||
(--map (oref it value) section:s)))
|
||||
(mapcar (##oref % value) section:s)))
|
||||
(command (symbol-name this-command))
|
||||
(command (if (and command (string-match "^magit-\\([^-]+\\)" command))
|
||||
(match-string 1 command)
|
||||
@@ -258,11 +251,12 @@ adjusted as \"@@ -10,6 +10,7 @@\" and \"@@ -18,6 +19,7 @@\"."
|
||||
(defun magit-apply--get-diffs (sections)
|
||||
(magit-section-case
|
||||
([file diffstat]
|
||||
(--map (or (magit-get-section
|
||||
(append `((file . ,(oref it value)))
|
||||
(magit-section-ident magit-root-section)))
|
||||
(error "Cannot get required diff headers"))
|
||||
sections))
|
||||
(mapcar (lambda (section)
|
||||
(or (magit-get-section
|
||||
(append `((file . ,(oref section value)))
|
||||
(magit-section-ident magit-root-section)))
|
||||
(error "Cannot get required diff headers")))
|
||||
sections))
|
||||
(t sections)))
|
||||
|
||||
(defun magit-apply--ignore-whitespace-p (selection type scope)
|
||||
@@ -344,7 +338,7 @@ With prefix argument FORCE, offer ignored files for completion."
|
||||
;; For backward compatibility, and because of
|
||||
;; the function's name, don't require a list.
|
||||
(magit-stage-1 (and force "--force")
|
||||
(if (listp files) files (list files)))))
|
||||
(ensure-list files))))
|
||||
|
||||
;;;###autoload
|
||||
(defun magit-stage-modified (&optional all)
|
||||
@@ -413,10 +407,10 @@ ignored) files."
|
||||
(magit-wip-commit-after-apply files " after stage")))
|
||||
|
||||
(defvar magit-post-stage-hook-commands
|
||||
'(magit-stage
|
||||
magit-stage-buffer-file
|
||||
magit-stage-file
|
||||
magit-stage-modified))
|
||||
(list #'magit-stage
|
||||
#'magit-stage-buffer-file
|
||||
#'magit-stage-file
|
||||
#'magit-stage-modified))
|
||||
|
||||
(defun magit-run-post-stage-hook ()
|
||||
(when (memq this-command magit-post-stage-hook-commands)
|
||||
@@ -472,7 +466,7 @@ ignored) files."
|
||||
(magit-with-toplevel
|
||||
;; For backward compatibility, and because of
|
||||
;; the function's name, don't require a list.
|
||||
(magit-unstage-1 (if (listp files) files (list files)))))
|
||||
(magit-unstage-1 (ensure-list files))))
|
||||
|
||||
(defun magit-unstage-1 (files)
|
||||
(magit-wip-commit-before-change files " before unstage")
|
||||
@@ -483,7 +477,7 @@ ignored) files."
|
||||
|
||||
(defun magit-unstage-intent (files)
|
||||
(if-let ((staged (magit-staged-files))
|
||||
(intent (--filter (member it staged) files)))
|
||||
(intent (seq-filter (##member % staged) files)))
|
||||
(magit-unstage-1 intent)
|
||||
(user-error "Already unstaged")))
|
||||
|
||||
@@ -501,10 +495,10 @@ ignored) files."
|
||||
(magit-wip-commit-after-apply nil " after unstage"))
|
||||
|
||||
(defvar magit-post-unstage-hook-commands
|
||||
'(magit-unstage
|
||||
magit-unstage-buffer-file
|
||||
magit-unstage-file
|
||||
magit-unstage-all))
|
||||
(list #'magit-unstage
|
||||
#'magit-unstage-buffer-file
|
||||
#'magit-unstage-file
|
||||
#'magit-unstage-all))
|
||||
|
||||
(defun magit-run-post-unstage-hook ()
|
||||
(when (memq this-command magit-post-unstage-hook-commands)
|
||||
@@ -555,9 +549,10 @@ of a side, then keep that side without prompting."
|
||||
(funcall apply section "--reverse" "--index"))))
|
||||
|
||||
(defun magit-discard-hunks (sections)
|
||||
(magit-confirm 'discard (format "Discard %s hunks from %s"
|
||||
(length sections)
|
||||
(magit-section-parent-value (car sections))))
|
||||
(magit-confirm 'discard
|
||||
(list "Discard %d hunks from %s"
|
||||
(length sections)
|
||||
(magit-section-parent-value (car sections))))
|
||||
(magit-discard-apply-n sections #'magit-apply-hunks))
|
||||
|
||||
(defun magit-discard-apply-n (sections apply)
|
||||
@@ -689,7 +684,7 @@ of a side, then keep that side without prompting."
|
||||
(magit-call-git "reset" "--" orig)))))
|
||||
|
||||
(defun magit-discard-files--discard (sections new-files)
|
||||
(let ((files (--map (oref it value) sections)))
|
||||
(let ((files (mapcar (##oref % value) sections)))
|
||||
(magit-confirm-files 'discard (append files new-files)
|
||||
(format "Discard %s changes in" (magit-diff-type)))
|
||||
(if (eq (magit-diff-type (car sections)) 'unstaged)
|
||||
@@ -700,15 +695,15 @@ of a side, then keep that side without prompting."
|
||||
(let ((binaries (magit-binary-files "--cached")))
|
||||
(when binaries
|
||||
(setq sections
|
||||
(--remove (member (oref it value) binaries)
|
||||
sections)))
|
||||
(seq-remove (##member (oref % value) binaries)
|
||||
sections)))
|
||||
(cond ((length= sections 1)
|
||||
(magit-discard-apply (car sections) 'magit-apply-diff))
|
||||
(sections
|
||||
(magit-discard-apply-n sections #'magit-apply-diffs)))
|
||||
(when binaries
|
||||
(let ((modified (magit-unstaged-files t)))
|
||||
(setq binaries (--separate (member it modified) binaries)))
|
||||
(setq binaries (magit--separate (##member % modified) binaries)))
|
||||
(when (cadr binaries)
|
||||
(magit-call-git "reset" "--" (cadr binaries)))
|
||||
(when (car binaries)
|
||||
@@ -745,9 +740,9 @@ so causes the change to be applied to the index as well."
|
||||
|
||||
(defun magit-reverse-hunks (sections args)
|
||||
(magit-confirm 'reverse
|
||||
(format "Reverse %s hunks from %s"
|
||||
(length sections)
|
||||
(magit-section-parent-value (car sections))))
|
||||
(list "Reverse %d hunks from %s"
|
||||
(length sections)
|
||||
(magit-section-parent-value (car sections))))
|
||||
(magit-reverse-apply sections #'magit-apply-hunks args))
|
||||
|
||||
(defun magit-reverse-file (section args)
|
||||
@@ -762,9 +757,9 @@ so causes the change to be applied to the index as well."
|
||||
magit-buffer-range)
|
||||
(t
|
||||
"--cached")))))
|
||||
(--separate (member (oref it value) bs)
|
||||
sections))))
|
||||
(magit-confirm-files 'reverse (--map (oref it value) sections))
|
||||
(magit--separate (##member (oref % value) bs)
|
||||
sections))))
|
||||
(magit-confirm-files 'reverse (mapcar (##oref % value) sections))
|
||||
(cond ((length= sections 1)
|
||||
(magit-reverse-apply (car sections) #'magit-apply-diff args))
|
||||
(sections
|
||||
@@ -789,7 +784,7 @@ a separate commit. A typical workflow would be:
|
||||
1. Visit the `HEAD' commit and navigate to the change that should
|
||||
not have been included in that commit.
|
||||
2. Type \"u\" (`magit-unstage') to reverse it in the index.
|
||||
This assumes that `magit-unstage-committed-changes' is non-nil.
|
||||
This assumes that `magit-unstage-committed' is non-nil.
|
||||
3. Type \"c e\" to extend `HEAD' with the staged changes,
|
||||
including those that were already staged before.
|
||||
4. Optionally stage the remaining changes using \"s\" or \"S\"
|
||||
|
||||
Reference in New Issue
Block a user