update of packages
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
;;; magit-sequence.el --- History manipulation in Magit -*- lexical-binding:t -*-
|
||||
|
||||
;; Copyright (C) 2008-2022 The Magit Project Contributors
|
||||
;; Copyright (C) 2008-2023 The Magit Project Contributors
|
||||
|
||||
;; Author: Jonas Bernoulli <jonas@bernoul.li>
|
||||
;; Maintainer: Jonas Bernoulli <jonas@bernoul.li>
|
||||
@@ -281,8 +281,8 @@ the process manually."
|
||||
(unless (magit-branch-p dst)
|
||||
(let ((magit-process-raise-error t))
|
||||
(magit-call-git "branch" dst start-point))
|
||||
(--when-let (magit-get-indirect-upstream-branch start-point)
|
||||
(magit-call-git "branch" "--set-upstream-to" it dst)))
|
||||
(when-let ((upstream (magit-get-indirect-upstream-branch start-point)))
|
||||
(magit-call-git "branch" "--set-upstream-to" upstream dst)))
|
||||
(unless (equal dst current)
|
||||
(let ((magit-process-raise-error t))
|
||||
(magit-call-git "checkout" dst)))
|
||||
@@ -335,12 +335,11 @@ the process manually."
|
||||
(list commits))))
|
||||
(magit-run-git-sequencer
|
||||
(if revert "revert" "cherry-pick")
|
||||
(pcase-let ((`(,merge ,non-merge)
|
||||
(-separate #'magit-merge-commit-p commits)))
|
||||
(let ((merges (seq-filter #'magit-merge-commit-p commits)))
|
||||
(cond
|
||||
((not merge)
|
||||
((not merges)
|
||||
(--remove (string-prefix-p "--mainline=" it) args))
|
||||
(non-merge
|
||||
((cl-set-difference commits merges :test #'equal)
|
||||
(user-error "Cannot %s merge and non-merge commits at once"
|
||||
command))
|
||||
((--first (string-prefix-p "--mainline=" it) args)
|
||||
@@ -353,11 +352,13 @@ the process manually."
|
||||
|
||||
(defun magit-cherry-pick-in-progress-p ()
|
||||
;; .git/sequencer/todo does not exist when there is only one commit left.
|
||||
(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))))
|
||||
(let ((dir (magit-gitdir)))
|
||||
(or (file-exists-p (expand-file-name "CHERRY_PICK_HEAD" dir))
|
||||
;; And CHERRY_PICK_HEAD does not exist when a conflict happens
|
||||
;; while picking a series of commits with --no-commit.
|
||||
(and-let* ((line (magit-file-line
|
||||
(expand-file-name "sequencer/todo" dir))))
|
||||
(string-prefix-p "pick" line)))))
|
||||
|
||||
;;; Revert
|
||||
|
||||
@@ -409,11 +410,13 @@ without prompting."
|
||||
|
||||
(defun magit-revert-in-progress-p ()
|
||||
;; .git/sequencer/todo does not exist when there is only one commit left.
|
||||
(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))))
|
||||
(let ((dir (magit-gitdir)))
|
||||
(or (file-exists-p (expand-file-name "REVERT_HEAD" dir))
|
||||
;; And REVERT_HEAD does not exist when a conflict happens
|
||||
;; while reverting a series of commits with --no-commit.
|
||||
(and-let* ((line (magit-file-line
|
||||
(expand-file-name "sequencer/todo" dir))))
|
||||
(string-prefix-p "revert" line)))))
|
||||
|
||||
;;; Patch
|
||||
|
||||
@@ -506,7 +509,7 @@ This discards all changes made since the sequence started."
|
||||
(user-error "Not applying any patches")))
|
||||
|
||||
(defun magit-am-in-progress-p ()
|
||||
(file-exists-p (magit-git-dir "rebase-apply/applying")))
|
||||
(file-exists-p (expand-file-name "rebase-apply/applying" (magit-gitdir))))
|
||||
|
||||
;;; Rebase
|
||||
|
||||
@@ -722,7 +725,7 @@ START has to be selected from a list of recent commits."
|
||||
(m2 ".\nDo you really want to modify them"))
|
||||
(magit-confirm (or magit--rebase-published-symbol 'rebase-published)
|
||||
(concat m1 "%s" m2)
|
||||
(concat m1 "%i public branches" m2)
|
||||
(concat m1 "%d public branches" m2)
|
||||
nil branches))
|
||||
(push (magit-toplevel) magit--rebase-public-edit-confirmed)))
|
||||
(if (and (magit-git-lines "rev-list" "--merges" (concat since "..HEAD"))
|
||||
@@ -814,12 +817,14 @@ edit. With a prefix argument the old message is reused as-is."
|
||||
(if (magit-rebase-in-progress-p)
|
||||
(if (magit-anything-unstaged-p t)
|
||||
(user-error "Cannot continue rebase with unstaged changes")
|
||||
(when (and (magit-anything-staged-p)
|
||||
(file-exists-p (magit-git-dir "rebase-merge"))
|
||||
(not (member (magit-toplevel)
|
||||
magit--rebase-public-edit-confirmed)))
|
||||
(magit-commit-amend-assert
|
||||
(magit-file-line (magit-git-dir "rebase-merge/orig-head"))))
|
||||
(let ((dir (magit-gitdir)))
|
||||
(when (and (magit-anything-staged-p)
|
||||
(file-exists-p (expand-file-name "rebase-merge" dir))
|
||||
(not (member (magit-toplevel)
|
||||
magit--rebase-public-edit-confirmed)))
|
||||
(magit-commit-amend-assert
|
||||
(magit-file-line
|
||||
(expand-file-name "rebase-merge/orig-head" dir)))))
|
||||
(if noedit
|
||||
(with-environment-variables (("GIT_EDITOR" "true"))
|
||||
(magit-run-git-async (magit--rebase-resume-command) "--continue")
|
||||
@@ -856,20 +861,25 @@ edit. With a prefix argument the old message is reused as-is."
|
||||
|
||||
(defun magit-rebase-in-progress-p ()
|
||||
"Return t if a rebase is in progress."
|
||||
(or (file-exists-p (magit-git-dir "rebase-merge"))
|
||||
(file-exists-p (magit-git-dir "rebase-apply/onto"))))
|
||||
(let ((dir (magit-gitdir)))
|
||||
(or (file-exists-p (expand-file-name "rebase-merge" dir))
|
||||
(file-exists-p (expand-file-name "rebase-apply/onto" dir)))))
|
||||
|
||||
(defun magit--rebase-resume-command ()
|
||||
(if (file-exists-p (magit-git-dir "rebase-recursive")) "rbr" "rebase"))
|
||||
(if (file-exists-p (expand-file-name "rebase-recursive" (magit-gitdir)))
|
||||
"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)))))
|
||||
(let ((dir (magit-gitdir)))
|
||||
(magit-file-line
|
||||
(expand-file-name
|
||||
(concat (if (file-directory-p (expand-file-name "rebase-merge" dir))
|
||||
"rebase-merge/"
|
||||
"rebase-apply/")
|
||||
file)
|
||||
dir)))))
|
||||
|
||||
;;; Sections
|
||||
|
||||
@@ -878,24 +888,25 @@ edit. With a prefix argument the old message is reused as-is."
|
||||
If no such sequence is in progress, do nothing."
|
||||
(let ((picking (magit-cherry-pick-in-progress-p)))
|
||||
(when (or picking (magit-revert-in-progress-p))
|
||||
(magit-insert-section (sequence)
|
||||
(magit-insert-heading (if picking "Cherry Picking" "Reverting"))
|
||||
(when-let ((lines
|
||||
(cdr (magit-file-lines (magit-git-dir "sequencer/todo")))))
|
||||
(dolist (line (nreverse lines))
|
||||
(when (string-match
|
||||
"^\\(pick\\|revert\\) \\([^ ]+\\) \\(.*\\)$" line)
|
||||
(magit-bind-match-strings (cmd hash msg) line
|
||||
(magit-insert-section (commit hash)
|
||||
(insert (propertize cmd 'font-lock-face 'magit-sequence-pick)
|
||||
" " (propertize hash 'font-lock-face 'magit-hash)
|
||||
" " msg "\n"))))))
|
||||
(magit-sequence-insert-sequence
|
||||
(magit-file-line (magit-git-dir (if picking
|
||||
"CHERRY_PICK_HEAD"
|
||||
"REVERT_HEAD")))
|
||||
(magit-file-line (magit-git-dir "sequencer/head")))
|
||||
(insert "\n")))))
|
||||
(let ((dir (magit-gitdir)))
|
||||
(magit-insert-section (sequence)
|
||||
(magit-insert-heading (if picking "Cherry Picking" "Reverting"))
|
||||
(when-let ((lines (cdr (magit-file-lines
|
||||
(expand-file-name "sequencer/todo" dir)))))
|
||||
(dolist (line (nreverse lines))
|
||||
(when (string-match
|
||||
"^\\(pick\\|revert\\) \\([^ ]+\\) \\(.*\\)$" line)
|
||||
(magit-bind-match-strings (cmd hash msg) line
|
||||
(magit-insert-section (commit hash)
|
||||
(insert (propertize cmd 'font-lock-face 'magit-sequence-pick)
|
||||
" " (propertize hash 'font-lock-face 'magit-hash)
|
||||
" " msg "\n"))))))
|
||||
(magit-sequence-insert-sequence
|
||||
(magit-file-line
|
||||
(expand-file-name (if picking "CHERRY_PICK_HEAD" "REVERT_HEAD")
|
||||
dir))
|
||||
(magit-file-line (expand-file-name "sequencer/head" dir)))
|
||||
(insert "\n"))))))
|
||||
|
||||
(defun magit-insert-am-sequence ()
|
||||
"Insert section for the on-going patch applying sequence.
|
||||
@@ -903,24 +914,31 @@ If no such sequence is in progress, do nothing."
|
||||
(when (magit-am-in-progress-p)
|
||||
(magit-insert-section (rebase-sequence)
|
||||
(magit-insert-heading "Applying patches")
|
||||
(let ((patches (nreverse (magit-rebase-patches)))
|
||||
patch commit)
|
||||
(while patches
|
||||
(let* ((patches (nreverse (magit-rebase-patches)))
|
||||
(dir (expand-file-name "rebase-apply" (magit-gitdir)))
|
||||
(i (string-to-number
|
||||
(magit-file-line (expand-file-name "last" dir))))
|
||||
(cur (string-to-number
|
||||
(magit-file-line (expand-file-name "next" dir))))
|
||||
patch commit)
|
||||
(while (and patches (>= i cur))
|
||||
(setq patch (pop patches))
|
||||
(setq commit (magit-commit-p
|
||||
(cadr (split-string (magit-file-line patch)))))
|
||||
(cond ((and commit patches)
|
||||
(cond ((and commit (= i cur))
|
||||
(magit-sequence-insert-commit
|
||||
"stop" commit 'magit-sequence-stop))
|
||||
((= i cur)
|
||||
(magit-sequence-insert-am-patch
|
||||
"stop" patch 'magit-sequence-stop))
|
||||
(commit
|
||||
(magit-sequence-insert-commit
|
||||
"pick" commit 'magit-sequence-pick))
|
||||
(patches
|
||||
(magit-sequence-insert-am-patch
|
||||
"pick" patch 'magit-sequence-pick))
|
||||
(commit
|
||||
(magit-sequence-insert-sequence commit "ORIG_HEAD"))
|
||||
(t
|
||||
(magit-sequence-insert-am-patch
|
||||
"stop" patch 'magit-sequence-stop)
|
||||
(magit-sequence-insert-sequence nil "ORIG_HEAD")))))
|
||||
"pick" patch 'magit-sequence-pick)))
|
||||
(cl-decf i)))
|
||||
(magit-sequence-insert-sequence nil "ORIG_HEAD")
|
||||
(insert ?\n))))
|
||||
|
||||
(defun magit-sequence-insert-am-patch (type patch face)
|
||||
@@ -941,13 +959,15 @@ If no such sequence is in progress, do nothing."
|
||||
"Insert section for the on-going rebase sequence.
|
||||
If no such sequence is in progress, do nothing."
|
||||
(when (magit-rebase-in-progress-p)
|
||||
(let* ((interactive (file-directory-p (magit-git-dir "rebase-merge")))
|
||||
(let* ((gitdir (magit-gitdir))
|
||||
(interactive
|
||||
(file-directory-p (expand-file-name "rebase-merge" gitdir)))
|
||||
(dir (if interactive "rebase-merge/" "rebase-apply/"))
|
||||
(name (thread-first (concat dir "head-name")
|
||||
magit-git-dir
|
||||
(expand-file-name gitdir)
|
||||
magit-file-line))
|
||||
(onto (thread-first (concat dir "onto")
|
||||
magit-git-dir
|
||||
(expand-file-name gitdir)
|
||||
magit-file-line))
|
||||
(onto (or (magit-rev-name onto name)
|
||||
(magit-rev-name onto "refs/heads/*") onto))
|
||||
@@ -962,11 +982,12 @@ If no such sequence is in progress, do nothing."
|
||||
(defun magit-rebase--todo ()
|
||||
"Return `git-rebase-action' instances for remaining rebase actions.
|
||||
These are ordered in that the same way they'll be sorted in the
|
||||
status buffer (i.e. the reverse of how they will be applied)."
|
||||
status buffer (i.e., the reverse of how they will be applied)."
|
||||
(let ((comment-start (or (magit-get "core.commentChar") "#"))
|
||||
lines)
|
||||
(with-temp-buffer
|
||||
(insert-file-contents (magit-git-dir "rebase-merge/git-rebase-todo"))
|
||||
(insert-file-contents
|
||||
(expand-file-name "rebase-merge/git-rebase-todo" (magit-gitdir)))
|
||||
(while (not (eobp))
|
||||
(let ((ln (git-rebase-current-line)))
|
||||
(when (oref ln action-type)
|
||||
@@ -993,28 +1014,34 @@ status buffer (i.e. the reverse of how they will be applied)."
|
||||
"\s"
|
||||
(magit-format-rev-summary hash) "\n"))
|
||||
(error "failed to parse merge message hash"))))))
|
||||
(magit-sequence-insert-sequence
|
||||
(magit-file-line (magit-git-dir "rebase-merge/stopped-sha"))
|
||||
onto
|
||||
(and-let* ((lines (magit-file-lines (magit-git-dir "rebase-merge/done"))))
|
||||
(cadr (split-string (car (last lines)))))))
|
||||
(let ((dir (magit-gitdir)))
|
||||
(magit-sequence-insert-sequence
|
||||
(magit-file-line (expand-file-name "rebase-merge/stopped-sha" dir))
|
||||
onto
|
||||
(and-let* ((lines (magit-file-lines
|
||||
(expand-file-name "rebase-merge/done" dir))))
|
||||
(cadr (split-string (car (last lines))))))))
|
||||
|
||||
(defun magit-rebase-insert-apply-sequence (onto)
|
||||
(let ((rewritten
|
||||
(--map (car (split-string it))
|
||||
(magit-file-lines (magit-git-dir "rebase-apply/rewritten"))))
|
||||
(stop (magit-file-line (magit-git-dir "rebase-apply/original-commit"))))
|
||||
(let* ((dir (magit-gitdir))
|
||||
(rewritten
|
||||
(--map (car (split-string it))
|
||||
(magit-file-lines
|
||||
(expand-file-name "rebase-apply/rewritten" dir))))
|
||||
(stop (magit-file-line
|
||||
(expand-file-name "rebase-apply/original-commit" dir))))
|
||||
(dolist (patch (nreverse (cdr (magit-rebase-patches))))
|
||||
(let ((hash (cadr (split-string (magit-file-line patch)))))
|
||||
(unless (or (member hash rewritten)
|
||||
(equal hash stop))
|
||||
(magit-sequence-insert-commit "pick" hash 'magit-sequence-pick)))))
|
||||
(magit-sequence-insert-sequence
|
||||
(magit-file-line (magit-git-dir "rebase-apply/original-commit"))
|
||||
onto))
|
||||
(magit-sequence-insert-commit "pick" hash 'magit-sequence-pick))))
|
||||
(magit-sequence-insert-sequence
|
||||
(magit-file-line (expand-file-name "rebase-apply/original-commit" dir))
|
||||
onto)))
|
||||
|
||||
(defun magit-rebase-patches ()
|
||||
(directory-files (magit-git-dir "rebase-apply") t "^[0-9]\\{4\\}$"))
|
||||
(directory-files (expand-file-name "rebase-apply" (magit-gitdir))
|
||||
t "\\`[0-9]\\{4\\}\\'"))
|
||||
|
||||
(defun magit-sequence-insert-sequence (stop onto &optional orig)
|
||||
(let ((head (magit-rev-parse "HEAD")) done)
|
||||
@@ -1022,8 +1049,8 @@ status buffer (i.e. the reverse of how they will be applied)."
|
||||
(setq done (magit-git-lines "log" "--format=%H" (concat onto "..HEAD")))
|
||||
(when (and stop (not (member (magit-rev-parse stop) done)))
|
||||
(let ((id (magit-patch-id stop)))
|
||||
(--if-let (--first (equal (magit-patch-id it) id) done)
|
||||
(setq stop it)
|
||||
(if-let ((matched (--first (equal (magit-patch-id it) id) done)))
|
||||
(setq stop matched)
|
||||
(cond
|
||||
((--first (magit-rev-equal it stop) done)
|
||||
;; The commit's testament has been executed.
|
||||
@@ -1041,10 +1068,12 @@ status buffer (i.e. the reverse of how they will be applied)."
|
||||
(cond
|
||||
;; ...but we could end up at the same tree just by committing.
|
||||
((or (magit-rev-equal staged stop)
|
||||
(magit-rev-equal unstaged stop)) "goal")
|
||||
(magit-rev-equal unstaged stop))
|
||||
"goal")
|
||||
;; ...but the changes are still there, untainted.
|
||||
((or (equal (magit-patch-id staged) id)
|
||||
(equal (magit-patch-id unstaged) id)) "same")
|
||||
(equal (magit-patch-id unstaged) id))
|
||||
"same")
|
||||
;; ...and some changes are gone and/or others were added.
|
||||
(t "work")))
|
||||
stop 'magit-sequence-part))
|
||||
|
||||
Reference in New Issue
Block a user