update packages and add valign

This commit is contained in:
2026-04-05 20:00:27 +02:00
parent b062fb98e3
commit 03fb00e374
640 changed files with 109768 additions and 39311 deletions

View File

@@ -1,6 +1,6 @@
;;; magit-wip.el --- Commit snapshots to work-in-progress refs -*- lexical-binding:t -*-
;; Copyright (C) 2008-2025 The Magit Project Contributors
;; Copyright (C) 2008-2026 The Magit Project Contributors
;; Author: Jonas Bernoulli <emacs.magit@jonas.bernoulli.dev>
;; Maintainer: Jonas Bernoulli <emacs.magit@jonas.bernoulli.dev>
@@ -70,6 +70,12 @@ Customize `magit-overriding-githook-directory' to enable use of
Git hooks."
:package-version '(magit . "2.90.0")
:group 'magit-wip
:set (lambda (symbol value)
(set-default-toplevel-value symbol value)
(when (bound-and-true-p magit-wip-mode)
(if (eq value 'immediately)
(add-hook 'git-commit-post-finish-hook #'magit-wip-commit)
(remove-hook 'git-commit-post-finish-hook #'magit-wip-commit))))
:type '(choice
(const :tag "Yes (safely, just in time)" t)
(const :tag "Yes (immediately, with race condition)" immediately)
@@ -104,29 +110,28 @@ buffer."
:package-version '(magit . "2.90.0")
:lighter magit-wip-mode-lighter
:global t
:set-after '(magit-wip-merge-branch)
(cond
(magit-wip-mode
(add-hook 'after-save-hook #'magit-wip-commit-buffer-file)
(add-hook 'magit-after-apply-functions #'magit-wip-commit)
(add-hook 'magit-before-change-functions #'magit-wip-commit)
(add-hook 'before-save-hook #'magit-wip-commit-initial-backup)
(add-hook 'magit-common-git-post-commit-functions #'magit-wip-post-commit)
(add-hook 'git-commit-post-finish-hook #'magit-wip-commit-post-editmsg))
(t
(remove-hook 'after-save-hook #'magit-wip-commit-buffer-file)
(remove-hook 'magit-after-apply-functions #'magit-wip-commit)
(remove-hook 'magit-before-change-functions #'magit-wip-commit)
(remove-hook 'before-save-hook #'magit-wip-commit-initial-backup)
(remove-hook 'magit-common-git-post-commit-functions #'magit-wip-post-commit)
(remove-hook 'git-commit-post-finish-hook #'magit-wip-commit-post-editmsg))))
(magit-wip-mode
(add-hook 'after-save-hook #'magit-wip-commit-buffer-file)
(add-hook 'magit-after-apply-functions #'magit-wip-commit)
(add-hook 'magit-before-change-functions #'magit-wip-commit)
(add-hook 'before-save-hook #'magit-wip-commit-initial-backup)
(add-hook 'magit-common-git-post-commit-functions #'magit-wip-post-commit)
(when (eq magit-wip-merge-branch 'immediately)
(add-hook 'git-commit-post-finish-hook #'magit-wip-commit)))
(t
(remove-hook 'after-save-hook #'magit-wip-commit-buffer-file)
(remove-hook 'magit-after-apply-functions #'magit-wip-commit)
(remove-hook 'magit-before-change-functions #'magit-wip-commit)
(remove-hook 'before-save-hook #'magit-wip-commit-initial-backup)
(remove-hook 'magit-common-git-post-commit-functions #'magit-wip-post-commit)
(remove-hook 'git-commit-post-finish-hook #'magit-wip-commit))))
(defun magit-wip-commit-buffer-file (&optional msg)
"Commit visited file to a worktree work-in-progress ref."
(interactive (list "save %s snapshot"))
(when (and (not magit--wip-inhibit-autosave)
buffer-file-name
(magit-inside-worktree-p t)
(magit-file-tracked-p buffer-file-name))
(when (magit-wip--commitable-p)
(magit-wip-commit-worktree
(magit-wip-get-ref)
(list buffer-file-name)
@@ -147,10 +152,7 @@ buffer."
(put 'magit-wip-buffer-backed-up 'permanent-local t)
(defun magit-wip-commit-initial-backup ()
(when (and (not magit-wip-buffer-backed-up)
buffer-file-name
(magit-inside-worktree-p t)
(magit-file-tracked-p buffer-file-name))
(when (magit-wip--commitable-p)
(let ((magit-save-repository-buffers nil))
(magit-wip-commit-buffer-file "autosave %s before save"))
(setq magit-wip-buffer-backed-up t)))
@@ -159,10 +161,6 @@ buffer."
(when (eq magit-wip-merge-branch 'githook)
(magit-wip-commit)))
(defun magit-wip-commit-post-editmsg ()
(when (eq magit-wip-merge-branch 'immediately)
(magit-wip-commit)))
;;; Core
(defun magit-wip-commit (&optional files msg)
@@ -189,24 +187,29 @@ commit message."
(defun magit-wip-commit-worktree (ref files msg)
(when (or (not files)
;; `update-index' will either ignore (before Git v2.32.0)
;; or fail when passed directories (relevant for the
;; untracked files code paths).
;; "git update-index" either ignores (before Git v2.32.0) or
;; fails, when passed directories. This is relevant for the
;; untracked files code paths.
(setq files (seq-remove #'file-directory-p files)))
(let* ((wipref (magit--wip-wtree-ref ref))
(parent (magit-wip-get-parent ref wipref))
(tree (magit-with-temp-index parent (list "--reset" "-i")
(if files
;; Note: `update-index' is used instead of `add'
;; because `add' will fail if a file is already
;; deleted in the temporary index.
(magit-wip--git "update-index" "--add" "--remove"
"--ignore-skip-worktree-entries"
"--" files)
(magit-with-toplevel
(magit-wip--git "add" "-u" ".")))
(magit-git-string "write-tree"))))
(magit-wip-update-wipref ref wipref tree parent files msg "worktree"))))
(tree (condition-case nil
(magit-with-temp-index parent (list "--reset" "-i")
(if files
;; Use "git update-index" instead of "git add"
;; because the latter fails if a file is already
;; deleted in the temporary index.
(magit-wip--git "update-index" "--add" "--remove"
"--ignore-skip-worktree-entries"
"--" files)
(magit-with-toplevel
(magit-wip--git "add" "-u" ".")))
(magit-git-string "write-tree"))
(error
(message "Index locked; no worktree wip commit created")))))
(when tree
(magit-wip-update-wipref ref wipref tree parent
files msg "worktree")))))
(defun magit-wip--git (&rest args)
(if magit-wip-debug
@@ -220,29 +223,29 @@ commit message."
(defun magit-wip-update-wipref (ref wipref tree parent files msg start-msg)
(cond
((and (not (equal parent wipref))
(or (not magit-wip-merge-branch)
(not (magit-rev-verify wipref))))
(setq start-msg (concat "start autosaving " start-msg))
(magit-wip--update-ref wipref start-msg
(magit-git-string "commit-tree" "--no-gpg-sign"
"-p" parent "-m" start-msg
(concat parent "^{tree}")))
(setq parent wipref))
((and magit-wip-merge-branch
(or (not (magit-rev-ancestor-p ref wipref))
(not (magit-rev-ancestor-p
(concat (magit-git-string "log" "--format=%H"
"-1" "--merges" wipref)
"^2")
ref))))
(setq start-msg (format "merge %s into %s" ref start-msg))
(magit-wip--update-ref wipref start-msg
(magit-git-string "commit-tree" "--no-gpg-sign"
"-p" wipref "-p" ref
"-m" start-msg
(concat ref "^{tree}")))
(setq parent wipref)))
((and (not (equal parent wipref))
(or (not magit-wip-merge-branch)
(not (magit-rev-verify wipref))))
(setq start-msg (concat "start autosaving " start-msg))
(magit-wip--update-ref wipref start-msg
(magit-git-string "commit-tree" "--no-gpg-sign"
"-p" parent "-m" start-msg
(concat parent "^{tree}")))
(setq parent wipref))
((and magit-wip-merge-branch
(or (not (magit-rev-ancestor-p ref wipref))
(not (magit-rev-ancestor-p
(concat (magit-git-string "log" "--format=%H"
"-1" "--merges" wipref)
"^2")
ref))))
(setq start-msg (format "merge %s into %s" ref start-msg))
(magit-wip--update-ref wipref start-msg
(magit-git-string "commit-tree" "--no-gpg-sign"
"-p" wipref "-p" ref
"-m" start-msg
(concat ref "^{tree}")))
(setq parent wipref)))
(when (magit-git-failure "diff-tree" "--quiet" parent tree "--" files)
(unless (and msg (not (= (aref msg 0) ?\s)))
(let ((len (length files)))
@@ -289,6 +292,13 @@ commit message."
(concat "refs/heads/" branch))
"HEAD")))
(defun magit-wip--commitable-p ()
(and (not magit--wip-inhibit-autosave)
buffer-file-name
(magit-inside-worktree-p t)
(magit-file-tracked-p buffer-file-name)
(magit-wip-get-ref)))
;;; Log
(defun magit-wip-log-index (args files)
@@ -307,9 +317,9 @@ With a negative prefix argument only show the worktree wip ref.
The absolute numeric value of the prefix argument controls how
many \"branches\" of each wip ref are shown."
(interactive
(nconc (list (or (magit-get-current-branch) "HEAD"))
(magit-log-arguments)
(list (prefix-numeric-value current-prefix-arg))))
(nconc (list (or (magit-get-current-branch) "HEAD"))
(magit-log-arguments)
(list (prefix-numeric-value current-prefix-arg))))
(magit-wip-log branch args files count))
(defun magit-wip-log (branch args files count)
@@ -318,16 +328,16 @@ With a negative prefix argument only show the worktree wip ref.
The absolute numeric value of the prefix argument controls how
many \"branches\" of each wip ref are shown."
(interactive
(nconc (list (magit-completing-read
"Log branch and its wip refs"
(nconc (magit-list-local-branch-names)
(list "HEAD"))
nil t nil 'magit-revision-history
(or (magit-branch-at-point)
(magit-get-current-branch)
"HEAD")))
(magit-log-arguments)
(list (prefix-numeric-value current-prefix-arg))))
(nconc (list (magit-completing-read
"Log branch and its wip refs"
(nconc (magit-list-local-branch-names)
(list "HEAD"))
nil t nil 'magit-revision-history
(or (magit-branch-at-point)
(magit-get-current-branch)
"HEAD")))
(magit-log-arguments)
(list (prefix-numeric-value current-prefix-arg))))
(magit-log-setup-buffer (nconc (list branch)
(magit-wip-log-get-tips
(magit--wip-wtree-ref branch)
@@ -383,6 +393,7 @@ many \"branches\" of each wip ref are shown."
;; ("and>" . "cond-let--and>")
;; ("and-let" . "cond-let--and-let")
;; ("if-let" . "cond-let--if-let")
;; ("when$" . "cond-let--when$")
;; ("when-let" . "cond-let--when-let")
;; ("while-let" . "cond-let--while-let")
;; ("match-string" . "match-string")