update packages and add valign
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
;;; magit-commit.el --- Create Git commits -*- 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>
|
||||
@@ -144,6 +144,7 @@ This hook is still experimental.")
|
||||
"Create a new commit or replace an existing commit."
|
||||
:info-manual "(magit)Initiating a Commit"
|
||||
:man-page "git-commit"
|
||||
:value '("--verbose")
|
||||
["Arguments"
|
||||
("-a" "Stage all modified and deleted files" ("-a" "--all"))
|
||||
("-e" "Allow empty commit" "--allow-empty")
|
||||
@@ -457,49 +458,49 @@ Like `magit-commit-squash' but also run a `--autofixup' rebase."
|
||||
|
||||
(defun magit-commit-assert (args &optional nopatch strict)
|
||||
(cond
|
||||
(nopatch (or args (list "--")))
|
||||
((or (magit-anything-staged-p)
|
||||
(and (magit-anything-unstaged-p)
|
||||
;; ^ Everything of nothing is still nothing.
|
||||
(member "--all" args))
|
||||
(and (not strict)
|
||||
;; ^ For amend variants that don't make sense otherwise.
|
||||
(or (member "--amend" args)
|
||||
(member "--allow-empty" args)
|
||||
(member "--reset-author" args)
|
||||
(member "--signoff" args)
|
||||
(transient-arg-value "--author=" args)
|
||||
(transient-arg-value "--date=" args))))
|
||||
(or args (list "--")))
|
||||
((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)
|
||||
(magit-run-git-sequencer "rebase" "--continue")
|
||||
nil)
|
||||
((file-exists-p (expand-file-name "MERGE_MSG" (magit-gitdir)))
|
||||
(cond ((magit-anything-unmerged-p)
|
||||
(user-error "Unresolved conflicts"))
|
||||
((and (magit-anything-unstaged-p)
|
||||
(not (y-or-n-p
|
||||
"Proceed with merge despite unstaged changes? ")))
|
||||
(user-error "Abort"))
|
||||
((or args (list "--")))))
|
||||
((not (magit-anything-unstaged-p))
|
||||
(user-error "Nothing staged (or unstaged)"))
|
||||
(magit-commit-ask-to-stage
|
||||
(when (eq magit-commit-ask-to-stage 'verbose)
|
||||
(apply #'magit-diff-unstaged (magit-diff-arguments)))
|
||||
(prog1 (when (or (eq magit-commit-ask-to-stage 'stage)
|
||||
(y-or-n-p
|
||||
"Nothing staged. Commit all uncommitted changes? "))
|
||||
(setq this-command 'magit-commit--all)
|
||||
(cons "--all" (or args (list "--"))))
|
||||
(when (and (eq magit-commit-ask-to-stage 'verbose)
|
||||
(derived-mode-p 'magit-diff-mode))
|
||||
(magit-mode-bury-buffer))))
|
||||
(t
|
||||
(user-error "Nothing staged"))))
|
||||
(nopatch (or args (list "--")))
|
||||
((or (magit-anything-staged-p)
|
||||
(and (magit-anything-unstaged-p)
|
||||
;; ^ Everything of nothing is still nothing.
|
||||
(member "--all" args))
|
||||
(and (not strict)
|
||||
;; ^ For amend variants that don't make sense otherwise.
|
||||
(or (member "--amend" args)
|
||||
(member "--allow-empty" args)
|
||||
(member "--reset-author" args)
|
||||
(member "--signoff" args)
|
||||
(transient-arg-value "--author=" args)
|
||||
(transient-arg-value "--date=" args))))
|
||||
(or args (list "--")))
|
||||
((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)
|
||||
(magit-run-git-sequencer "rebase" "--continue")
|
||||
nil)
|
||||
((file-exists-p (expand-file-name "MERGE_MSG" (magit-gitdir)))
|
||||
(cond ((magit-anything-unmerged-p)
|
||||
(user-error "Unresolved conflicts"))
|
||||
((and (magit-anything-unstaged-p)
|
||||
(not (y-or-n-p
|
||||
"Proceed with merge despite unstaged changes? ")))
|
||||
(user-error "Abort"))
|
||||
((or args (list "--")))))
|
||||
((not (magit-anything-unstaged-p))
|
||||
(user-error "Nothing staged (or unstaged)"))
|
||||
(magit-commit-ask-to-stage
|
||||
(when (eq magit-commit-ask-to-stage 'verbose)
|
||||
(apply #'magit-diff-unstaged (magit-diff-arguments)))
|
||||
(prog1 (when (or (eq magit-commit-ask-to-stage 'stage)
|
||||
(y-or-n-p
|
||||
"Nothing staged. Commit all uncommitted changes? "))
|
||||
(setq this-command 'magit-commit--all)
|
||||
(cons "--all" (or args (list "--"))))
|
||||
(when (and (eq magit-commit-ask-to-stage 'verbose)
|
||||
(derived-mode-p 'magit-diff-mode))
|
||||
(magit-mode-bury-buffer))))
|
||||
(t
|
||||
(user-error "Nothing staged"))))
|
||||
|
||||
;;;; Reshelve
|
||||
|
||||
@@ -520,18 +521,18 @@ is updated:
|
||||
- The command was invoked with a prefix argument.
|
||||
- Non-interactively if UPDATE-AUTHOR is nil."
|
||||
(interactive
|
||||
(let ((update-author (and (magit-rev-author-p "HEAD")
|
||||
(not current-prefix-arg))))
|
||||
(push (magit-rev-format (if update-author "%ad" "%cd") "HEAD"
|
||||
(concat "--date=format:%F %T %z"))
|
||||
magit--reshelve-history)
|
||||
(list (read-string (if update-author
|
||||
"Change author and committer dates to: "
|
||||
"Change committer date to: ")
|
||||
(cons (format-time-string "%F %T %z") 17)
|
||||
'magit--reshelve-history)
|
||||
update-author
|
||||
(magit-commit-arguments))))
|
||||
(let ((update-author (and (magit-rev-author-p "HEAD")
|
||||
(not current-prefix-arg))))
|
||||
(push (magit-rev-format (if update-author "%ad" "%cd") "HEAD"
|
||||
(concat "--date=format:%F %T %z"))
|
||||
magit--reshelve-history)
|
||||
(list (read-string (if update-author
|
||||
"Change author and committer dates to: "
|
||||
"Change committer date to: ")
|
||||
(cons (format-time-string "%F %T %z") 17)
|
||||
'magit--reshelve-history)
|
||||
update-author
|
||||
(magit-commit-arguments))))
|
||||
(with-environment-variables (("GIT_COMMITTER_DATE" date))
|
||||
(magit-run-git "commit" "--amend" "--no-edit"
|
||||
(and update-author (concat "--date=" date))
|
||||
@@ -548,20 +549,19 @@ is updated:
|
||||
(user-error "There are no modified modules that could be absorbed"))
|
||||
(when commit
|
||||
(setq commit (magit-rebase-interactive-assert commit t)))
|
||||
(if (and commit (eq phase 'run))
|
||||
(progn
|
||||
(dolist (module modules)
|
||||
(when-let ((msg (magit-git-string
|
||||
"log" "-1" "--format=%s"
|
||||
(concat commit "..") "--" module)))
|
||||
(magit-git "commit" "-m" (concat "fixup! " msg)
|
||||
"--only" "--" module)))
|
||||
(magit-refresh)
|
||||
t)
|
||||
(magit-log-select
|
||||
(lambda (commit)
|
||||
(magit-commit-absorb-modules 'run commit))
|
||||
nil nil nil nil commit))))
|
||||
(cond ((and commit (eq phase 'run))
|
||||
(dolist (module modules)
|
||||
(when-let ((msg (magit-git-string
|
||||
"log" "-1" "--format=%s"
|
||||
(concat commit "..") "--" module)))
|
||||
(magit-git "commit" "-m" (concat "fixup! " msg)
|
||||
"--only" "--" module)))
|
||||
(magit-refresh)
|
||||
t)
|
||||
((magit-log-select
|
||||
(lambda (commit)
|
||||
(magit-commit-absorb-modules 'run commit))
|
||||
nil nil nil nil commit)))))
|
||||
|
||||
;;;###autoload(autoload 'magit-commit-absorb "magit-commit" nil t)
|
||||
(transient-define-prefix magit-commit-absorb (phase commit args)
|
||||
@@ -669,18 +669,25 @@ an alternative implementation."
|
||||
'magit-commit--rebase
|
||||
last-command))
|
||||
(when (and git-commit-mode magit-commit-show-diff)
|
||||
(when-let ((diff-buffer (magit-get-mode-buffer 'magit-diff-mode)))
|
||||
;; This window just started displaying the commit message
|
||||
;; buffer. Without this that buffer would immediately be
|
||||
;; replaced with the diff buffer. See #2632.
|
||||
(when-let ((diff-buffer
|
||||
;; This signals an error if not inside a Git repository,
|
||||
;; but the user may be visiting COMMIT_EDITMSG using a
|
||||
;; tool other than git, which can be used outside a Git
|
||||
;; repository. See #5527.
|
||||
(ignore-error magit-outside-git-repo
|
||||
(magit-get-mode-buffer 'magit-diff-mode))))
|
||||
;; This window just started displaying the commit message buffer.
|
||||
;; Without unrecording that buffer would immediately be replaced
|
||||
;; with the diff buffer. See #2632.
|
||||
(unrecord-window-buffer nil diff-buffer))
|
||||
(message "Diffing changes to be committed (C-g to abort diffing)")
|
||||
(let ((inhibit-quit nil))
|
||||
(condition-case nil
|
||||
(magit-commit-diff-1)
|
||||
(with-demoted-errors "Error showing commit diff: %S"
|
||||
(magit-commit-diff--show))
|
||||
(quit)))))
|
||||
|
||||
(defun magit-commit-diff-1 ()
|
||||
(defun magit-commit-diff--args ()
|
||||
(let ((rev nil)
|
||||
(arg "--cached")
|
||||
(command (magit-repository-local-get 'this-commit-command))
|
||||
@@ -695,6 +702,9 @@ an alternative implementation."
|
||||
(and (file-exists-p f) (length (magit-file-lines f)))))
|
||||
(noalt nil))
|
||||
(pcase (list staged unstaged command)
|
||||
((guard (not (magit-commit-p "HEAD^")))
|
||||
(setq rev "HEAD")
|
||||
(setq arg nil))
|
||||
((and `(,_ ,_ magit-commit--rebase)
|
||||
(guard (integerp squash)))
|
||||
(setq rev (format "HEAD~%s" squash)))
|
||||
@@ -715,21 +725,24 @@ an alternative implementation."
|
||||
(setq rev "HEAD")
|
||||
(setq arg nil)))
|
||||
(cond
|
||||
((not
|
||||
(and (eq this-command 'magit-diff-while-committing)
|
||||
(and-let ((buf (magit-get-mode-buffer
|
||||
'magit-diff-mode nil 'selected)))
|
||||
(and (equal rev (buffer-local-value 'magit-buffer-range buf))
|
||||
(equal arg (buffer-local-value 'magit-buffer-typearg buf)))))))
|
||||
((eq command 'magit-commit-amend)
|
||||
(setq rev nil))
|
||||
((or squash
|
||||
(file-exists-p (expand-file-name "rebase-merge/amend" (magit-gitdir))))
|
||||
(setq rev "HEAD^"))
|
||||
(t
|
||||
(message "No alternative diff while committing")
|
||||
(setq noalt t)))
|
||||
(unless noalt
|
||||
((not
|
||||
(and-let*
|
||||
((_(eq this-command 'magit-diff-while-committing))
|
||||
(buf (magit-get-mode-buffer 'magit-diff-mode nil 'selected))
|
||||
(_(equal rev (buffer-local-value 'magit-buffer-diff-range buf)))
|
||||
(_(equal arg (buffer-local-value 'magit-buffer-diff-typearg buf)))))))
|
||||
((eq command 'magit-commit-amend)
|
||||
(setq rev nil))
|
||||
((or squash
|
||||
(file-exists-p (expand-file-name "rebase-merge/amend" (magit-gitdir))))
|
||||
(setq rev "HEAD^"))
|
||||
((setq noalt t)))
|
||||
(list rev arg noalt)))
|
||||
|
||||
(defun magit-commit-diff--show ()
|
||||
(pcase-let ((`(,rev ,arg ,noalt) (magit-commit-diff--args)))
|
||||
(if noalt
|
||||
(message "No alternative diff while committing")
|
||||
(let ((magit-inhibit-save-previous-winconf 'unset)
|
||||
(magit-display-buffer-noselect t)
|
||||
(display-buffer-overriding-action
|
||||
@@ -858,6 +871,7 @@ Also see `git-commit-post-finish-hook'."
|
||||
;; ("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")
|
||||
|
||||
Reference in New Issue
Block a user