diff options
| -rw-r--r-- | .dir-locals.el | 5 | ||||
| -rw-r--r-- | lisp/git-commit.el | 44 | ||||
| -rw-r--r-- | lisp/git-rebase.el | 84 | ||||
| -rw-r--r-- | lisp/magit-base.el | 52 | ||||
| -rw-r--r-- | lisp/magit-branch.el | 226 | ||||
| -rw-r--r-- | lisp/magit-clone.el | 12 | ||||
| -rw-r--r-- | lisp/magit-commit.el | 114 | ||||
| -rw-r--r-- | lisp/magit-diff.el | 650 | ||||
| -rw-r--r-- | lisp/magit-extras.el | 126 | ||||
| -rw-r--r-- | lisp/magit-fetch.el | 8 | ||||
| -rw-r--r-- | lisp/magit-files.el | 20 | ||||
| -rw-r--r-- | lisp/magit-git.el | 80 | ||||
| -rw-r--r-- | lisp/magit-log.el | 48 | ||||
| -rw-r--r-- | lisp/magit-mode.el | 50 | ||||
| -rw-r--r-- | lisp/magit-process.el | 40 | ||||
| -rw-r--r-- | lisp/magit-pull.el | 18 | ||||
| -rw-r--r-- | lisp/magit-push.el | 60 | ||||
| -rw-r--r-- | lisp/magit-refs.el | 60 | ||||
| -rw-r--r-- | lisp/magit-remote.el | 44 | ||||
| -rw-r--r-- | lisp/magit-section.el | 300 | ||||
| -rw-r--r-- | lisp/magit-sequence.el | 222 | ||||
| -rw-r--r-- | lisp/magit-status.el | 54 | ||||
| -rw-r--r-- | lisp/magit-submodule.el | 28 | ||||
| -rw-r--r-- | lisp/magit-tag.el | 32 | ||||
| -rw-r--r-- | lisp/magit-wip.el | 74 | ||||
| -rw-r--r-- | lisp/magit-worktree.el | 20 |
26 files changed, 1236 insertions, 1235 deletions
diff --git a/.dir-locals.el b/.dir-locals.el index 5098510..2044c5d 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -1,11 +1,12 @@ ((nil (indent-tabs-mode . nil)) + (emacs-lisp-mode + (checkdoc-allow-quoting-nil-and-t . t) + (lisp-indent-local-overrides . ((cond . 0)))) (makefile-mode (indent-tabs-mode . t) (mode . outline-minor) (outline-regexp . "#\\(#+\\)")) - (emacs-lisp-mode - (checkdoc-allow-quoting-nil-and-t . t)) (git-commit-mode (git-commit-major-mode . git-commit-elisp-text-mode)) (".github/PULL_REQUEST_TEMPLATE" diff --git a/lisp/git-commit.el b/lisp/git-commit.el index aee3646..c2133c0 100644 --- a/lisp/git-commit.el +++ b/lisp/git-commit.el @@ -159,14 +159,14 @@ full loading." (remove-hook 'after-change-major-mode-hook #'git-commit-setup-font-lock-in-buffer))) (cond - (global-git-commit-mode - (add-hook 'find-file-hook #'git-commit-setup-check-buffer) - (add-hook 'after-change-major-mode-hook - #'git-commit-setup-font-lock-in-buffer)) - (t - (remove-hook 'find-file-hook #'git-commit-setup-check-buffer) - (remove-hook 'after-change-major-mode-hook - #'git-commit-setup-font-lock-in-buffer)))) + (global-git-commit-mode + (add-hook 'find-file-hook #'git-commit-setup-check-buffer) + (add-hook 'after-change-major-mode-hook + #'git-commit-setup-font-lock-in-buffer)) + (t + (remove-hook 'find-file-hook #'git-commit-setup-check-buffer) + (remove-hook 'after-change-major-mode-hook + #'git-commit-setup-font-lock-in-buffer)))) (defcustom git-commit-major-mode #'text-mode "Major mode used to edit Git commit messages. @@ -915,20 +915,20 @@ completion candidates. The input must have the form \"NAME <EMAIL>\"." (setq leading-comment-end (point)) (goto-char (point-max)) (cond - ;; Look backwards for existing trailers. - ((re-search-backward (git-commit--trailer-regexp) nil t) - (end-of-line) - (insert ?\n string) - (unless (= (char-after) ?\n) - (insert ?\n))) - ;; Or place the new trailer right before the first non-leading - ;; comments. - (t - (while (re-search-backward (concat "^" comment-start) - leading-comment-end t)) - (unless (looking-back "\n\n" nil) - (insert ?\n)) - (insert string ?\n)))) + ;; Look backwards for existing trailers. + ((re-search-backward (git-commit--trailer-regexp) nil t) + (end-of-line) + (insert ?\n string) + (unless (= (char-after) ?\n) + (insert ?\n))) + ;; Or place the new trailer right before the first non-leading + ;; comments. + (t + (while (re-search-backward (concat "^" comment-start) + leading-comment-end t)) + (unless (looking-back "\n\n" nil) + (insert ?\n)) + (insert string ?\n)))) (unless (or (eobp) (= (char-after) ?\n)) (insert ?\n)))) diff --git a/lisp/git-rebase.el b/lisp/git-rebase.el index b019bc5..07c11d9 100644 --- a/lisp/git-rebase.el +++ b/lisp/git-rebase.el @@ -399,23 +399,23 @@ of its action type." (with-slots (action-type target trailer comment-p) (git-rebase-current-line) (cond - ((and action (eq action-type 'commit)) - (let ((inhibit-read-only t)) - (magit-delete-line) - (insert (concat action " " target " ")) - (when (magit-git-version>= "2.50.0") - (insert "# ")) - (insert (concat trailer "\n")))) - ((and (not action) action-type) - (let ((inhibit-read-only t)) - (if comment-p - (delete-region beg (+ beg 2)) - (insert comment-start " "))) - (forward-line)) - ;; In the case of --rebase-merges, commit lines may have - ;; other lines with other action types, empty lines, and - ;; "Branch" comments interspersed. Move along. - ((forward-line))))) + ((and action (eq action-type 'commit)) + (let ((inhibit-read-only t)) + (magit-delete-line) + (insert (concat action " " target " ")) + (when (magit-git-version>= "2.50.0") + (insert "# ")) + (insert (concat trailer "\n")))) + ((and (not action) action-type) + (let ((inhibit-read-only t)) + (if comment-p + (delete-region beg (+ beg 2)) + (insert comment-start " "))) + (forward-line)) + ;; In the case of --rebase-merges, commit lines may have + ;; other lines with other action types, empty lines, and + ;; "Branch" comments interspersed. Move along. + ((forward-line))))) (goto-char (cond (git-rebase-auto-advance end-marker) (pt-below-p (1- end-marker)) (beg))) @@ -435,15 +435,15 @@ point or mark. If the region isn't active and FALLBACK is non-nil, return the beginning and end of the current rebase line, if any." (cond - ((use-region-p) - (let ((beg (magit--bol-position (region-beginning))) - (end (magit--eol-position (region-end)))) - (and (git-rebase-line-p beg) - (git-rebase-line-p end) - (list beg (1+ end))))) - ((and fallback (git-rebase-line-p)) - (list (line-beginning-position) - (1+ (line-end-position)))))) + ((use-region-p) + (let ((beg (magit--bol-position (region-beginning))) + (end (magit--eol-position (region-end)))) + (and (git-rebase-line-p beg) + (git-rebase-line-p end) + (list beg (1+ end))))) + ((and fallback (git-rebase-line-p)) + (list (line-beginning-position) + (1+ (line-end-position)))))) (defun git-rebase-move-line-down (n) "Move the current commit (or command) N lines down. @@ -875,22 +875,22 @@ except for the \"pick\" command." (replace-match (make-string 10 ?\s) t t nil 1)) (setq cmd (intern (concat "git-rebase-" (match-str 4)))) (cond - ((not (fboundp cmd)) - (delete-line)) - ((eq cmd 'git-rebase-fixup) - (delete-line) - (git-rebase--insert-descriptions git-rebase-fixup-descriptions)) - (t - (add-text-properties (line-beginning-position) - (1+ (line-end-position)) - '(font-lock-face font-lock-comment-face)) - (replace-match " " t t nil 2) - (replace-match - (string-pad - (save-match-data - (substitute-command-keys (format "\\[%s]" cmd))) - 8) - t t nil 3)))))))))) + ((not (fboundp cmd)) + (delete-line)) + ((eq cmd 'git-rebase-fixup) + (delete-line) + (git-rebase--insert-descriptions git-rebase-fixup-descriptions)) + (t + (add-text-properties (line-beginning-position) + (1+ (line-end-position)) + '(font-lock-face font-lock-comment-face)) + (replace-match " " t t nil 2) + (replace-match + (string-pad + (save-match-data + (substitute-command-keys (format "\\[%s]" cmd))) + 8) + t t nil 3)))))))))) (defun git-rebase--insert-descriptions (alist) (pcase-dolist (`(,cmd . ,desc) alist) diff --git a/lisp/magit-base.el b/lisp/magit-base.el index c6ddcd0..781e1d1 100644 --- a/lisp/magit-base.el +++ b/lisp/magit-base.el @@ -963,32 +963,32 @@ Pad the left side of STRING so that it aligns with the text area." (goto-char (point-min)) (while (search-forward "%" nil t) (cond - ;; Quoted percent sign. - ((eq (char-after) ?%) - (delete-char 1)) - ;; Valid format spec. - ((looking-at "\\([-0-9.]*\\)\\([a-zA-Z]\\)") - (let* ((num (match-str 1)) - (spec (string-to-char (match-str 2))) - (val (assq spec specification))) - (unless val - (error "Invalid format character: `%%%c'" spec)) - (setq val (cdr val)) - ;; Pad result to desired length. - (let ((text (format (concat "%" num "s") val))) - ;; Insert first, to preserve text properties. - (if (next-property-change 0 (concat " " text)) - ;; If the inserted text has properties, then preserve those. - (insert text) - ;; Otherwise preserve FORMAT's properties, like `format-spec'. - (insert-and-inherit text)) - ;; Delete the specifier body. - (delete-region (+ (match-beginning 0) (length text)) - (+ (match-end 0) (length text))) - ;; Delete the percent sign. - (delete-region (1- (match-beginning 0)) (match-beginning 0))))) - ;; Signal an error on bogus format strings. - ((error "Invalid format string")))) + ;; Quoted percent sign. + ((eq (char-after) ?%) + (delete-char 1)) + ;; Valid format spec. + ((looking-at "\\([-0-9.]*\\)\\([a-zA-Z]\\)") + (let* ((num (match-str 1)) + (spec (string-to-char (match-str 2))) + (val (assq spec specification))) + (unless val + (error "Invalid format character: `%%%c'" spec)) + (setq val (cdr val)) + ;; Pad result to desired length. + (let ((text (format (concat "%" num "s") val))) + ;; Insert first, to preserve text properties. + (if (next-property-change 0 (concat " " text)) + ;; If the inserted text has properties, then preserve those. + (insert text) + ;; Otherwise preserve FORMAT's properties, like `format-spec'. + (insert-and-inherit text)) + ;; Delete the specifier body. + (delete-region (+ (match-beginning 0) (length text)) + (+ (match-end 0) (length text))) + ;; Delete the percent sign. + (delete-region (1- (match-beginning 0)) (match-beginning 0))))) + ;; Signal an error on bogus format strings. + ((error "Invalid format string")))) (buffer-string))) ;;; Missing from Emacs diff --git a/lisp/magit-branch.el b/lisp/magit-branch.el index a852b31..3dac76f 100644 --- a/lisp/magit-branch.el +++ b/lisp/magit-branch.el @@ -376,26 +376,26 @@ when using `magit-branch-and-checkout'." (list choice)) ((list choice (magit-read-starting-point "Create" choice)))))) (cond - ((not start-point) - (magit--checkout branch (magit-branch-arguments)) - (magit-refresh)) - (t - (when (magit-anything-modified-p t) - (user-error "Cannot checkout when there are uncommitted changes")) - (magit-run-git-async "checkout" (magit-branch-arguments) - "-b" branch start-point) - (set-process-sentinel - magit-this-process - (lambda (process event) - (when (memq (process-status process) '(exit signal)) - (magit-branch-maybe-adjust-upstream branch start-point) - (when (magit-remote-branch-p start-point) - (pcase-let ((`(,remote . ,remote-branch) - (magit-split-branch-name start-point))) - (when (and (equal branch remote-branch) - (not (equal remote (magit-get "remote.pushDefault")))) - (magit-set remote "branch" branch "pushRemote")))) - (magit-process-sentinel process event))))))) + ((not start-point) + (magit--checkout branch (magit-branch-arguments)) + (magit-refresh)) + (t + (when (magit-anything-modified-p t) + (user-error "Cannot checkout when there are uncommitted changes")) + (magit-run-git-async "checkout" (magit-branch-arguments) + "-b" branch start-point) + (set-process-sentinel + magit-this-process + (lambda (process event) + (when (memq (process-status process) '(exit signal)) + (magit-branch-maybe-adjust-upstream branch start-point) + (when (magit-remote-branch-p start-point) + (pcase-let ((`(,remote . ,remote-branch) + (magit-split-branch-name start-point))) + (when (and (equal branch remote-branch) + (not (equal remote (magit-get "remote.pushDefault")))) + (magit-set remote "branch" branch "pushRemote")))) + (magit-process-sentinel process event))))))) (defun magit-branch-maybe-adjust-upstream (branch start-point) (when-let ((upstream @@ -423,20 +423,20 @@ when using `magit-branch-and-checkout'." (if magit-branch-read-upstream-first (let ((choice (magit-read-starting-point prompt nil default-start))) (cond - ((magit-rev-verify choice) - (list (magit-read-string-ns - (if magit-completing-read--silent-default - (format "%s (starting at `%s')" prompt choice) - "Name for new branch") - (let ((def (string-join (cdr (split-string choice "/")) "/"))) - (and (member choice (magit-list-remote-branch-names)) - (not (member def (magit-list-local-branch-names))) - def))) - choice)) - ((eq magit-branch-read-upstream-first 'fallback) - (list choice - (magit-read-starting-point prompt choice default-start))) - ((user-error "Not a valid starting-point: %s" choice)))) + ((magit-rev-verify choice) + (list (magit-read-string-ns + (if magit-completing-read--silent-default + (format "%s (starting at `%s')" prompt choice) + "Name for new branch") + (let ((def (string-join (cdr (split-string choice "/")) "/"))) + (and (member choice (magit-list-remote-branch-names)) + (not (member def (magit-list-local-branch-names))) + def))) + choice)) + ((eq magit-branch-read-upstream-first 'fallback) + (list choice + (magit-read-starting-point prompt choice default-start))) + ((user-error "Not a valid starting-point: %s" choice)))) (let ((branch (magit-read-string-ns (concat prompt " named")))) (if (magit-branch-p branch) (magit-branch-read-args @@ -614,86 +614,86 @@ prompt is confusing." "%s ambiguous; please cleanup using git directly" (let ((len (length ambiguous))) (cond - ((= len 1) - (format "%s is" (seq-find #'magit-ref-ambiguous-p branches))) - ((= len (length refs)) - (format "These %s names are" len)) - ((format "%s of these names are" len)))))) + ((= len 1) + (format "%s is" (seq-find #'magit-ref-ambiguous-p branches))) + ((= len (length refs)) + (format "These %s names are" len)) + ((format "%s of these names are" len)))))) (cond - ((string-match "^refs/remotes/\\([^/]+\\)" (car refs)) - (let* ((remote (match-str 1 (car refs))) - (offset (1+ (length remote)))) - (cond - ((magit-confirm 'delete-branch-on-remote - (list "Deleting local %s. Also delete on %s" - (magit-ref-fullname (car branches)) - remote) - (list "Deleting %d local refs. Also delete on %s" - (length refs) - remote) - 'noabort refs) - ;; The ref may actually point at another rev on the remote, - ;; but this is better than nothing. - (dolist (ref refs) - (message "Delete %s (was %s)" ref - (magit-rev-parse "--short" ref))) - ;; Assume the branches actually still exist on the remote. - (magit-run-git-async - "push" - (and (or force magit-branch-delete-never-verify) "--no-verify") - remote - (mapcar (##concat ":" (substring % offset)) branches)) - ;; If that is not the case, then this deletes the tracking branches. - (set-process-sentinel - magit-this-process - (apply-partially #'magit-delete-remote-branch-sentinel remote refs))) - (t - (dolist (ref refs) - (message "Delete %s (was %s)" ref - (magit-rev-parse "--short" ref)) - (magit-call-git "update-ref" "-d" ref)) - (magit-refresh))))) - ((length> branches 1) - (setq branches (delete (magit-get-current-branch) branches)) - (mapc #'magit-branch-maybe-delete-pr-remote branches) - (mapc #'magit-branch-unset-pushRemote branches) - (magit-run-git "branch" (if force "-D" "-d") branches)) - (t ; And now for something completely different. - (let* ((branch (car branches)) - (prompt (format "Branch %s is checked out. " branch)) - (target (magit-get-indirect-upstream-branch branch t))) - (when (equal branch (magit-get-current-branch)) - (when (or (equal branch target) - (not target)) - (setq target (magit-main-branch))) - (pcase (if (or (equal branch target) - (not target)) - (magit-read-char-case prompt nil - (?d "[d]etach HEAD & delete" 'detach) - (?a "[a]bort" 'abort)) - (magit-read-char-case prompt nil - (?d "[d]etach HEAD & delete" 'detach) - (?c (format "[c]heckout %s & delete" target) 'target) - (?a "[a]bort" 'abort))) - (`detach (unless (or (equal force '(4)) - (member branch force) - (magit-branch-merged-p branch t)) - (magit-confirm 'delete-unmerged-branch - "Delete unmerged branch %s" "" - nil (list branch))) - (magit-call-git "checkout" "--detach")) - (`target (unless (or (equal force '(4)) - (member branch force) - (magit-branch-merged-p branch target)) - (magit-confirm 'delete-unmerged-branch - "Delete unmerged branch %s" "" - nil (list branch))) - (magit-call-git "checkout" target)) - (`abort (user-error "Abort"))) - (setq force t)) - (magit-branch-maybe-delete-pr-remote branch) - (magit-branch-unset-pushRemote branch) - (magit-run-git "branch" (if force "-D" "-d") branch)))))) + ((string-match "^refs/remotes/\\([^/]+\\)" (car refs)) + (let* ((remote (match-str 1 (car refs))) + (offset (1+ (length remote)))) + (cond + ((magit-confirm 'delete-branch-on-remote + (list "Deleting local %s. Also delete on %s" + (magit-ref-fullname (car branches)) + remote) + (list "Deleting %d local refs. Also delete on %s" + (length refs) + remote) + 'noabort refs) + ;; The ref may actually point at another rev on the remote, + ;; but this is better than nothing. + (dolist (ref refs) + (message "Delete %s (was %s)" ref + (magit-rev-parse "--short" ref))) + ;; Assume the branches actually still exist on the remote. + (magit-run-git-async + "push" + (and (or force magit-branch-delete-never-verify) "--no-verify") + remote + (mapcar (##concat ":" (substring % offset)) branches)) + ;; If that is not the case, then this deletes the tracking branches. + (set-process-sentinel + magit-this-process + (apply-partially #'magit-delete-remote-branch-sentinel remote refs))) + (t + (dolist (ref refs) + (message "Delete %s (was %s)" ref + (magit-rev-parse "--short" ref)) + (magit-call-git "update-ref" "-d" ref)) + (magit-refresh))))) + ((length> branches 1) + (setq branches (delete (magit-get-current-branch) branches)) + (mapc #'magit-branch-maybe-delete-pr-remote branches) + (mapc #'magit-branch-unset-pushRemote branches) + (magit-run-git "branch" (if force "-D" "-d") branches)) + (t ; And now for something completely different. + (let* ((branch (car branches)) + (prompt (format "Branch %s is checked out. " branch)) + (target (magit-get-indirect-upstream-branch branch t))) + (when (equal branch (magit-get-current-branch)) + (when (or (equal branch target) + (not target)) + (setq target (magit-main-branch))) + (pcase (if (or (equal branch target) + (not target)) + (magit-read-char-case prompt nil + (?d "[d]etach HEAD & delete" 'detach) + (?a "[a]bort" 'abort)) + (magit-read-char-case prompt nil + (?d "[d]etach HEAD & delete" 'detach) + (?c (format "[c]heckout %s & delete" target) 'target) + (?a "[a]bort" 'abort))) + (`detach (unless (or (equal force '(4)) + (member branch force) + (magit-branch-merged-p branch t)) + (magit-confirm 'delete-unmerged-branch + "Delete unmerged branch %s" "" + nil (list branch))) + (magit-call-git "checkout" "--detach")) + (`target (unless (or (equal force '(4)) + (member branch force) + (magit-branch-merged-p branch target)) + (magit-confirm 'delete-unmerged-branch + "Delete unmerged branch %s" "" + nil (list branch))) + (magit-call-git "checkout" target)) + (`abort (user-error "Abort"))) + (setq force t)) + (magit-branch-maybe-delete-pr-remote branch) + (magit-branch-unset-pushRemote branch) + (magit-run-git "branch" (if force "-D" "-d") branch)))))) (put 'magit-branch-delete 'interactive-only t) diff --git a/lisp/magit-clone.el b/lisp/magit-clone.el index 5502507..272ec66 100644 --- a/lisp/magit-clone.el +++ b/lisp/magit-clone.el @@ -337,12 +337,12 @@ Then show the status buffer for the new repository." url-format `((?h . ,host) (?n . ,(cond - ((string-search "/" repo) repo) - ((string-search "." user) - (if-let ((user (magit-get user))) - (concat user "/" repo) - (user-error "Set %S or specify owner explicitly" user))) - ((concat user "/" repo)))))) + ((string-search "/" repo) repo) + ((string-search "." user) + (if-let ((user (magit-get user))) + (concat user "/" repo) + (user-error "Set %S or specify owner explicitly" user))) + ((concat user "/" repo)))))) (user-error "Bogus `magit-clone-url-format' (bad type or missing default)"))) diff --git a/lisp/magit-commit.el b/lisp/magit-commit.el index 7ea971d..ef79071 100644 --- a/lisp/magit-commit.el +++ b/lisp/magit-commit.el @@ -457,49 +457,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 @@ -715,20 +715,20 @@ 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))) + ((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 (let ((magit-inhibit-save-previous-winconf 'unset) (magit-display-buffer-noselect t) diff --git a/lisp/magit-diff.el b/lisp/magit-diff.el index b0511ae..ecc06d6 100644 --- a/lisp/magit-diff.el +++ b/lisp/magit-diff.el @@ -1151,33 +1151,33 @@ use the commands that allow you to explicitly specify what you need." (let ((default-directory default-directory) (section (magit-current-section))) (cond - ((magit-section-match 'module section) - (setq default-directory - (expand-file-name - (file-name-as-directory (oref section value)))) - (magit-diff-range (oref section range))) - (t - (when (magit-section-match 'module-commit section) - (setq args nil) - (setq files nil) - (setq default-directory - (expand-file-name - (file-name-as-directory (magit-section-parent-value section))))) - (pcase (magit-diff--dwim) - ('unmerged (magit-diff-unmerged args files)) - ('unstaged (magit-diff-unstaged args files)) - ('staged - (let ((file (magit-file-at-point))) - (if (and file (equal (cddr (car (magit-file-status file))) '(?D ?U))) - ;; File was deleted by us and modified by them. Show the latter. - (magit-diff-unmerged args (list file)) - (magit-diff-staged nil args files)))) - (`(stash . ,value) (magit-stash-show value args)) - (`(commit . ,value) - (magit-diff-range (format "%s^..%s" value value) args files)) - ((and range (pred stringp)) - (magit-diff-range range args files)) - (_ (call-interactively #'magit-diff-range))))))) + ((magit-section-match 'module section) + (setq default-directory + (expand-file-name + (file-name-as-directory (oref section value)))) + (magit-diff-range (oref section range))) + (t + (when (magit-section-match 'module-commit section) + (setq args nil) + (setq files nil) + (setq default-directory + (expand-file-name + (file-name-as-directory (magit-section-parent-value section))))) + (pcase (magit-diff--dwim) + ('unmerged (magit-diff-unmerged args files)) + ('unstaged (magit-diff-unstaged args files)) + ('staged + (let ((file (magit-file-at-point))) + (if (and file (equal (cddr (car (magit-file-status file))) '(?D ?U))) + ;; File was deleted by us and modified by them. Show the latter. + (magit-diff-unmerged args (list file)) + (magit-diff-staged nil args files)))) + (`(stash . ,value) (magit-stash-show value args)) + (`(commit . ,value) + (magit-diff-range (format "%s^..%s" value value) args files)) + ((and range (pred stringp)) + (magit-diff-range range args files)) + (_ (call-interactively #'magit-diff-range))))))) (defun magit-diff--dwim () "Return information for performing DWIM diff. @@ -1256,17 +1256,17 @@ If no DWIM context is found, nil is returned." (if mbase (let ((base (magit-git-string "merge-base" revA revB))) (cond - ((string= (magit-rev-parse revA) base) - (format "%s..%s" revA revB)) - ((string= (magit-rev-parse revB) base) - (format "%s..%s" revB revA)) - (interactive - (let ((main (magit-completing-read "View changes along" - (list revA revB) - nil t nil nil revB))) - (format "%s...%s" - (if (string= main revB) revA revB) main))) - ((format "%s...%s" revA revB)))) + ((string= (magit-rev-parse revA) base) + (format "%s..%s" revA revB)) + ((string= (magit-rev-parse revB) base) + (format "%s..%s" revB revA)) + (interactive + (let ((main (magit-completing-read "View changes along" + (list revA revB) + nil t nil nil revB))) + (format "%s...%s" + (if (string= main revB) revA revB) main))) + ((format "%s...%s" revA revB)))) (format "%s..%s" revA revB))))) (defun magit-diff-read-range-or-commit (prompt &optional secondary-default mbase) @@ -1454,22 +1454,22 @@ for a revision." (len (cadr range)) (end (+ beg len))) (cond - ((> beg line) - (setq pos (oref diff start))) - ((<= beg line end) - (save-excursion - (goto-char (oref hunk content)) - (let ((l beg)) - (while (or (< l line) - (= (char-after) ?-)) - (unless (= (char-after) ?-) - (cl-incf l)) - (forward-line))) - (setq found (if (= (char-after) ?+) 'line 'hunk)) - (forward-char (1+ column)) - (setq pos (point)))) - ((null hunks) - (setq pos (oref hunk start)))))) + ((> beg line) + (setq pos (oref diff start))) + ((<= beg line end) + (save-excursion + (goto-char (oref hunk content)) + (let ((l beg)) + (while (or (< l line) + (= (char-after) ?-)) + (unless (= (char-after) ?-) + (cl-incf l)) + (forward-line))) + (setq found (if (= (char-after) ?+) 'line 'hunk)) + (forward-char (1+ column)) + (setq pos (point)))) + ((null hunks) + (setq pos (oref hunk start)))))) (and pos (list pos (or found file)))))) @@ -1523,15 +1523,15 @@ instead." (transient-infix-read 'magit:--))) (magit-refresh))) (cond - ((derived-mode-p 'magit-log-mode - 'magit-cherry-mode - 'magit-reflog-mode) - (if-let ((buffer (magit-get-mode-buffer 'magit-revision-mode))) - (with-current-buffer buffer (toggle)) - (message "No revision buffer"))) - ((local-variable-p 'magit-buffer-diff-files) - (toggle)) - ((user-error "Cannot toggle file filter in this buffer"))))) + ((derived-mode-p 'magit-log-mode + 'magit-cherry-mode + 'magit-reflog-mode) + (if-let ((buffer (magit-get-mode-buffer 'magit-revision-mode))) + (with-current-buffer buffer (toggle)) + (message "No revision buffer"))) + ((local-variable-p 'magit-buffer-diff-files) + (toggle)) + ((user-error "Cannot toggle file filter in this buffer"))))) (defun magit-diff-less-context (&optional count) "Decrease the context for diff hunks by COUNT lines." @@ -1891,36 +1891,36 @@ commit or stash at point, then prompt for a commit." (defun magit-diff-show-or-scroll (fn) (let (rev cmd buf win) (cond - ((and (bound-and-true-p magit-blame-mode) - (fboundp 'magit-current-blame-chunk)) - (setq rev (oref (magit-current-blame-chunk) orig-rev)) - (setq cmd #'magit-show-commit) - (setq buf (magit-get-mode-buffer 'magit-revision-mode))) - ((derived-mode-p 'git-rebase-mode) - (with-slots (action-type target) - (git-rebase-current-line) - (if (not (eq action-type 'commit)) - (user-error "No commit on this line") - (setq rev target) + ((and (bound-and-true-p magit-blame-mode) + (fboundp 'magit-current-blame-chunk)) + (setq rev (oref (magit-current-blame-chunk) orig-rev)) + (setq cmd #'magit-show-commit) + (setq buf (magit-get-mode-buffer 'magit-revision-mode))) + ((derived-mode-p 'git-rebase-mode) + (with-slots (action-type target) + (git-rebase-current-line) + (if (not (eq action-type 'commit)) + (user-error "No commit on this line") + (setq rev target) + (setq cmd #'magit-show-commit) + (setq buf (magit-get-mode-buffer 'magit-revision-mode))))) + ((magit-section-case + (branch + (setq rev (magit-ref-maybe-qualify (oref it value))) + (setq cmd #'magit-show-commit) + (setq buf (magit-get-mode-buffer 'magit-revision-mode))) + (commit + (setq rev (oref it value)) + (setq cmd #'magit-show-commit) + (setq buf (magit-get-mode-buffer 'magit-revision-mode))) + (tag + (setq rev (magit-rev-hash (oref it value))) (setq cmd #'magit-show-commit) - (setq buf (magit-get-mode-buffer 'magit-revision-mode))))) - ((magit-section-case - (branch - (setq rev (magit-ref-maybe-qualify (oref it value))) - (setq cmd #'magit-show-commit) - (setq buf (magit-get-mode-buffer 'magit-revision-mode))) - (commit - (setq rev (oref it value)) - (setq cmd #'magit-show-commit) - (setq buf (magit-get-mode-buffer 'magit-revision-mode))) - (tag - (setq rev (magit-rev-hash (oref it value))) - (setq cmd #'magit-show-commit) - (setq buf (magit-get-mode-buffer 'magit-revision-mode))) - (stash - (setq rev (oref it value)) - (setq cmd #'magit-stash-show) - (setq buf (magit-get-mode-buffer 'magit-stash-mode)))))) + (setq buf (magit-get-mode-buffer 'magit-revision-mode))) + (stash + (setq rev (oref it value)) + (setq cmd #'magit-stash-show) + (setq buf (magit-get-mode-buffer 'magit-stash-mode)))))) (if rev (if (and buf (setq win (get-buffer-window buf)) @@ -2320,29 +2320,29 @@ keymap is the parent of their keymaps." (defun magit-diff-wash-signature (object) (cond - ((looking-at "^No signature") - (delete-line)) - ((looking-at "^gpg: ") - (let (title end) - (save-excursion - (while (looking-at "^gpg: ") - (cond - ((looking-at "^gpg: Good signature from") - (setq title (magit--propertize-face - (buffer-substring (point) (line-end-position)) - 'magit-signature-good))) - ((looking-at "^gpg: Can't check signature") - (setq title (magit--propertize-face - (buffer-substring (point) (line-end-position)) - '(italic bold))))) - (forward-line)) - (setq end (point-marker))) - (magit-insert-section (signature object title) - (when title - (magit-insert-heading title)) - (goto-char end) - (set-marker end nil) - (insert "\n")))))) + ((looking-at "^No signature") + (delete-line)) + ((looking-at "^gpg: ") + (let (title end) + (save-excursion + (while (looking-at "^gpg: ") + (cond + ((looking-at "^gpg: Good signature from") + (setq title (magit--propertize-face + (buffer-substring (point) (line-end-position)) + 'magit-signature-good))) + ((looking-at "^gpg: Can't check signature") + (setq title (magit--propertize-face + (buffer-substring (point) (line-end-position)) + '(italic bold))))) + (forward-line)) + (setq end (point-marker))) + (magit-insert-section (signature object title) + (when title + (magit-insert-heading title)) + (goto-char end) + (set-marker end nil) + (insert "\n")))))) (defun magit-diff-wash-diffstat () (let (heading (beg (point))) @@ -2394,135 +2394,135 @@ keymap is the parent of their keymaps." (require 'ansi-color) (ansi-color-apply-on-region (point-min) (point-max))) (cond - ((looking-at "^Submodule") - (magit-diff-wash-submodule)) - ((looking-at "^\\* Unmerged path \\(.*\\)") - (let ((file (magit-decode-git-path (match-str 1)))) - (magit-delete-line) - (unless (and (derived-mode-p 'magit-status-mode) - (not (member "--cached" args))) - (magit-insert-section (file file) - (insert (propertize - (format "unmerged %s%s" file - (pcase (cddr (car (magit-file-status file))) - ('(?D ?D) " (both deleted)") - ('(?D ?U) " (deleted by us)") - ('(?U ?D) " (deleted by them)") - ('(?A ?A) " (both added)") - ('(?A ?U) " (added by us)") - ('(?U ?A) " (added by them)") - ('(?U ?U) ""))) - 'font-lock-face 'magit-diff-file-heading)) - (insert ?\n)))) - t) - ((looking-at magit-diff-conflict-headline-re) - (let ((long-status (match-str 0)) - (status "BUG") - file orig base) - (if (equal long-status "merged") - (progn (setq status long-status) - (setq long-status nil)) - (setq status (pcase-exhaustive long-status - ("added in remote" "new file") - ("added in both" "new file") - ("added in local" "new file") - ("removed in both" "removed") - ("changed in both" "changed") - ("removed in local" "removed") - ("removed in remote" "removed")))) - (magit-delete-line) - (while (looking-at - "^ \\([^ ]+\\) +[0-9]\\{6\\} \\([a-z0-9]\\{40,\\}\\) \\(.+\\)$") - (magit-bind-match-strings (side _blob name) nil - (pcase side - ("result" (setq file name)) - ("our" (setq orig name)) - ("their" (setq file name)) - ("base" (setq base name)))) - (magit-delete-line)) - (when orig (setq orig (magit-decode-git-path orig))) - (when file (setq file (magit-decode-git-path file))) - (magit-diff-insert-file-section - (or file base) orig status nil nil nil nil long-status))) - ;; The files on this line may be ambiguous due to whitespace. - ;; That's okay. We can get their names from subsequent headers. - ((looking-at "^diff --\ + ((looking-at "^Submodule") + (magit-diff-wash-submodule)) + ((looking-at "^\\* Unmerged path \\(.*\\)") + (let ((file (magit-decode-git-path (match-str 1)))) + (magit-delete-line) + (unless (and (derived-mode-p 'magit-status-mode) + (not (member "--cached" args))) + (magit-insert-section (file file) + (insert (propertize + (format "unmerged %s%s" file + (pcase (cddr (car (magit-file-status file))) + ('(?D ?D) " (both deleted)") + ('(?D ?U) " (deleted by us)") + ('(?U ?D) " (deleted by them)") + ('(?A ?A) " (both added)") + ('(?A ?U) " (added by us)") + ('(?U ?A) " (added by them)") + ('(?U ?U) ""))) + 'font-lock-face 'magit-diff-file-heading)) + (insert ?\n)))) + t) + ((looking-at magit-diff-conflict-headline-re) + (let ((long-status (match-str 0)) + (status "BUG") + file orig base) + (if (equal long-status "merged") + (progn (setq status long-status) + (setq long-status nil)) + (setq status (pcase-exhaustive long-status + ("added in remote" "new file") + ("added in both" "new file") + ("added in local" "new file") + ("removed in both" "removed") + ("changed in both" "changed") + ("removed in local" "removed") + ("removed in remote" "removed")))) + (magit-delete-line) + (while (looking-at + "^ \\([^ ]+\\) +[0-9]\\{6\\} \\([a-z0-9]\\{40,\\}\\) \\(.+\\)$") + (magit-bind-match-strings (side _blob name) nil + (pcase side + ("result" (setq file name)) + ("our" (setq orig name)) + ("their" (setq file name)) + ("base" (setq base name)))) + (magit-delete-line)) + (when orig (setq orig (magit-decode-git-path orig))) + (when file (setq file (magit-decode-git-path file))) + (magit-diff-insert-file-section + (or file base) orig status nil nil nil nil long-status))) + ;; The files on this line may be ambiguous due to whitespace. + ;; That's okay. We can get their names from subsequent headers. + ((looking-at "^diff --\ \\(?:\\(?1:git\\) \\(?:\\(?2:.+?\\) \\2\\)?\ \\|\\(?:cc\\|combined\\) \\(?3:.+\\)\\)") - (let ((status (cond ((equal (match-str 1) "git") "modified") - ((derived-mode-p 'magit-revision-mode) "resolved") - (t "unmerged"))) - (orig nil) - (file (or (match-str 2) (match-str 3))) - (header (list (buffer-substring-no-properties - (line-beginning-position) (1+ (line-end-position))))) - (modes nil) - (rename nil) - (binary nil)) - (magit-delete-line) - (while (not (or (eobp) - (looking-at magit-diff-headline-re) - (looking-at magit-log-heading-re))) - (cond - ((looking-at "old mode \\(?:[^\n]+\\)\nnew mode \\(?:[^\n]+\\)\n") - (setq modes (match-str 0))) - ((looking-at "deleted file .+\n") - (setq status "deleted")) - ((looking-at "new file .+\n") - (setq status "new file")) - ((looking-at "rename from \\(.+\\)\nrename to \\(.+\\)\n") - (setq rename (match-str 0)) - (setq orig (match-str 1)) - (setq file (match-str 2)) - (setq status "renamed")) - ((looking-at "copy from \\(.+\\)\ncopy to \\(.+\\)\n") - (setq orig (match-str 1)) - (setq file (match-str 2)) - (setq status "new file")) - ((looking-at "similarity index .+\n")) - ((looking-at "dissimilarity index .+\n")) - ((looking-at "index .+\n")) - ((looking-at "--- \\(.+?\\)\t?\n") - (unless (equal (match-str 1) "/dev/null") - (setq orig (match-str 1)))) - ((looking-at "\\+\\+\\+ \\(.+?\\)\t?\n") - (unless (equal (match-str 1) "/dev/null") - (setq file (match-str 1)))) - ((looking-at "Binary files .+ and .+ differ\n") - (setq binary t)) - ((looking-at "Binary files differ\n") - (setq binary t)) - ;; TODO Use all combined diff extended headers. - ((looking-at "mode .+\n")) - ((error "BUG: Unknown extended header: %S" - (buffer-substring (point) (line-end-position))))) - ;; These headers are treated as some sort of special hunk. - (unless (or (string-prefix-p "old mode" (match-str 0)) - (string-prefix-p "rename" (match-str 0))) - (push (match-str 0) header)) - (magit-delete-match)) - (when orig - (setq orig (magit-decode-git-path orig))) - (setq file (magit-decode-git-path file)) - (setq header (nreverse header)) - ;; KLUDGE `git-log' ignores `--no-prefix' when `-L' is used. - (when (and (derived-mode-p 'magit-log-mode) - (seq-some (##string-prefix-p "-L" %) - magit-buffer-log-args)) - (when orig - (setq orig (substring orig 2))) - (setq file (substring file 2)) - (setq header (list (save-excursion - (string-match "diff [^ ]+" (car header)) - (format "%s %s %s\n" - (match-str 0 (car header)) - (or orig file) - (or file orig))) - (format "--- %s\n" (or orig "/dev/null")) - (format "+++ %s\n" (or file "/dev/null"))))) - (setq header (string-join header)) - (magit-diff-insert-file-section - file orig status modes rename header binary nil))))) + (let ((status (cond ((equal (match-str 1) "git") "modified") + ((derived-mode-p 'magit-revision-mode) "resolved") + (t "unmerged"))) + (orig nil) + (file (or (match-str 2) (match-str 3))) + (header (list (buffer-substring-no-properties + (line-beginning-position) (1+ (line-end-position))))) + (modes nil) + (rename nil) + (binary nil)) + (magit-delete-line) + (while (not (or (eobp) + (looking-at magit-diff-headline-re) + (looking-at magit-log-heading-re))) + (cond + ((looking-at "old mode \\(?:[^\n]+\\)\nnew mode \\(?:[^\n]+\\)\n") + (setq modes (match-str 0))) + ((looking-at "deleted file .+\n") + (setq status "deleted")) + ((looking-at "new file .+\n") + (setq status "new file")) + ((looking-at "rename from \\(.+\\)\nrename to \\(.+\\)\n") + (setq rename (match-str 0)) + (setq orig (match-str 1)) + (setq file (match-str 2)) + (setq status "renamed")) + ((looking-at "copy from \\(.+\\)\ncopy to \\(.+\\)\n") + (setq orig (match-str 1)) + (setq file (match-str 2)) + (setq status "new file")) + ((looking-at "similarity index .+\n")) + ((looking-at "dissimilarity index .+\n")) + ((looking-at "index .+\n")) + ((looking-at "--- \\(.+?\\)\t?\n") + (unless (equal (match-str 1) "/dev/null") + (setq orig (match-str 1)))) + ((looking-at "\\+\\+\\+ \\(.+?\\)\t?\n") + (unless (equal (match-str 1) "/dev/null") + (setq file (match-str 1)))) + ((looking-at "Binary files .+ and .+ differ\n") + (setq binary t)) + ((looking-at "Binary files differ\n") + (setq binary t)) + ;; TODO Use all combined diff extended headers. + ((looking-at "mode .+\n")) + ((error "BUG: Unknown extended header: %S" + (buffer-substring (point) (line-end-position))))) + ;; These headers are treated as some sort of special hunk. + (unless (or (string-prefix-p "old mode" (match-str 0)) + (string-prefix-p "rename" (match-str 0))) + (push (match-str 0) header)) + (magit-delete-match)) + (when orig + (setq orig (magit-decode-git-path orig))) + (setq file (magit-decode-git-path file)) + (setq header (nreverse header)) + ;; KLUDGE `git-log' ignores `--no-prefix' when `-L' is used. + (when (and (derived-mode-p 'magit-log-mode) + (seq-some (##string-prefix-p "-L" %) + magit-buffer-log-args)) + (when orig + (setq orig (substring orig 2))) + (setq file (substring file 2)) + (setq header (list (save-excursion + (string-match "diff [^ ]+" (car header)) + (format "%s %s %s\n" + (match-str 0 (car header)) + (or orig file) + (or file orig))) + (format "--- %s\n" (or orig "/dev/null")) + (format "+++ %s\n" (or file "/dev/null"))))) + (setq header (string-join header)) + (magit-diff-insert-file-section + file orig status modes rename header binary nil))))) (defun magit-diff-insert-file-section (file orig status modes rename header binary long-status) @@ -2605,56 +2605,56 @@ function errors." (magit-delete-line) (setq modified t)) (cond - ((and (looking-at "^Submodule \\([^ ]+\\) \\([^ :]+\\)\\( (rewind)\\)?:$") - (equal (match-str 1) module)) - (magit-bind-match-strings (_module range rewind) nil - (magit-delete-line) - (while (looking-at "^ \\([<>]\\) \\(.*\\)$") - (magit-delete-line)) - (when rewind - (setq range (replace-regexp-in-string "[^.]\\(\\.\\.\\)[^.]" - "..." range t t 1))) - (magit-insert-section (module module t) - (magit-insert-heading - (magit-format-file 'module module 'magit-diff-file-heading - "modified") - " (" - (cond (rewind "rewind") - ((string-search "..." range) "non-ff") - ("new commits")) - (and (or modified untracked) - (concat ", " - (and modified "modified") - (and modified untracked " and ") - (and untracked "untracked") - " content")) - ")") - (magit-insert-section-body - (let ((default-directory - (file-name-as-directory - (expand-file-name module (magit-toplevel))))) - (magit-git-wash (apply-partially #'magit-log-wash-log 'module) - "log" "--oneline" "--left-right" range) - (delete-char -1)))))) - ((and (looking-at "^Submodule \\([^ ]+\\) \\([^ ]+\\) (\\([^)]+\\))$") - (equal (match-str 1) module)) - (magit-bind-match-strings (_module _range msg) nil - (magit-delete-line) - (magit-insert-section (module module) - (magit-insert-heading - (magit-format-file 'module module 'magit-diff-file-heading - "submodule") - " (" msg ")")))) - (t - (magit-insert-section (module module) - (magit-insert-heading - (magit-format-file 'module module 'magit-diff-file-heading - "modified") - " (" - (and modified "modified") - (and modified untracked " and ") - (and untracked "untracked") - " content)"))))))) + ((and (looking-at "^Submodule \\([^ ]+\\) \\([^ :]+\\)\\( (rewind)\\)?:$") + (equal (match-str 1) module)) + (magit-bind-match-strings (_module range rewind) nil + (magit-delete-line) + (while (looking-at "^ \\([<>]\\) \\(.*\\)$") + (magit-delete-line)) + (when rewind + (setq range (replace-regexp-in-string "[^.]\\(\\.\\.\\)[^.]" + "..." range t t 1))) + (magit-insert-section (module module t) + (magit-insert-heading + (magit-format-file 'module module 'magit-diff-file-heading + "modified") + " (" + (cond (rewind "rewind") + ((string-search "..." range) "non-ff") + ("new commits")) + (and (or modified untracked) + (concat ", " + (and modified "modified") + (and modified untracked " and ") + (and untracked "untracked") + " content")) + ")") + (magit-insert-section-body + (let ((default-directory + (file-name-as-directory + (expand-file-name module (magit-toplevel))))) + (magit-git-wash (apply-partially #'magit-log-wash-log 'module) + "log" "--oneline" "--left-right" range) + (delete-char -1)))))) + ((and (looking-at "^Submodule \\([^ ]+\\) \\([^ ]+\\) (\\([^)]+\\))$") + (equal (match-str 1) module)) + (magit-bind-match-strings (_module _range msg) nil + (magit-delete-line) + (magit-insert-section (module module) + (magit-insert-heading + (magit-format-file 'module module 'magit-diff-file-heading + "submodule") + " (" msg ")")))) + (t + (magit-insert-section (module module) + (magit-insert-heading + (magit-format-file 'module module 'magit-diff-file-heading + "modified") + " (" + (and modified "modified") + (and modified untracked " and ") + (and untracked "untracked") + " content)"))))))) (defun magit-diff-wash-hunk () (when (looking-at "^@\\{2,\\} \\(.+?\\) @\\{2,\\}\\(?: \\(.*\\)\\)?") @@ -3126,14 +3126,14 @@ It the SECTION has a different type, then do nothing." (while (looking-at "^[ @]") (forward-line)) (let ((beg (magit-point))) (list (cond - ((looking-at "^[-+]") - (forward-line) - (while (looking-at "^[-+]") (forward-line)) - (while (looking-at "^ ") (forward-line)) - (forward-line -1) - (regexp-quote (buffer-substring-no-properties - beg (line-end-position)))) - (t)))))))) + ((looking-at "^[-+]") + (forward-line) + (while (looking-at "^[-+]") (forward-line)) + (while (looking-at "^ ") (forward-line)) + (forward-line -1) + (regexp-quote (buffer-substring-no-properties + beg (line-end-position)))) + (t)))))))) (cl-defmethod magit-section-goto-successor ((section magit-hunk-section) line char &optional arg) @@ -3381,31 +3381,31 @@ actually a `diff' but a `diffstat' section." (put-text-property (point) (1+ (line-end-position)) 'font-lock-face (cond - ((looking-at "^\\+\\+?\\([<=|>]\\)\\{7\\}") - (setq stage (pcase (list (match-str 1) highlight) - ('("<" nil) 'magit-diff-our) - ('("<" t) 'magit-diff-our-highlight) - ('("|" nil) 'magit-diff-base) - ('("|" t) 'magit-diff-base-highlight) - ('("=" nil) 'magit-diff-their) - ('("=" t) 'magit-diff-their-highlight) - ('(">" nil) nil))) - (if highlight - 'magit-diff-conflict-heading-highlight - 'magit-diff-conflict-heading)) - ((looking-at (if merging "^\\(\\+\\| \\+\\)" "^\\+")) - (magit-diff-paint-tab merging tab-width) - (magit-diff-paint-whitespace merging 'added diff-type) - (or stage - (if highlight 'magit-diff-added-highlight 'magit-diff-added))) - ((looking-at (if merging "^\\(-\\| -\\)" "^-")) - (magit-diff-paint-tab merging tab-width) - (magit-diff-paint-whitespace merging 'removed diff-type) - (if highlight 'magit-diff-removed-highlight 'magit-diff-removed)) - (t - (magit-diff-paint-tab merging tab-width) - (magit-diff-paint-whitespace merging 'context diff-type) - (if highlight 'magit-diff-context-highlight 'magit-diff-context)))) + ((looking-at "^\\+\\+?\\([<=|>]\\)\\{7\\}") + (setq stage (pcase (list (match-str 1) highlight) + ('("<" nil) 'magit-diff-our) + ('("<" t) 'magit-diff-our-highlight) + ('("|" nil) 'magit-diff-base) + ('("|" t) 'magit-diff-base-highlight) + ('("=" nil) 'magit-diff-their) + ('("=" t) 'magit-diff-their-highlight) + ('(">" nil) nil))) + (if highlight + 'magit-diff-conflict-heading-highlight + 'magit-diff-conflict-heading)) + ((looking-at (if merging "^\\(\\+\\| \\+\\)" "^\\+")) + (magit-diff-paint-tab merging tab-width) + (magit-diff-paint-whitespace merging 'added diff-type) + (or stage + (if highlight 'magit-diff-added-highlight 'magit-diff-added))) + ((looking-at (if merging "^\\(-\\| -\\)" "^-")) + (magit-diff-paint-tab merging tab-width) + (magit-diff-paint-whitespace merging 'removed diff-type) + (if highlight 'magit-diff-removed-highlight 'magit-diff-removed)) + (t + (magit-diff-paint-tab merging tab-width) + (magit-diff-paint-whitespace merging 'context diff-type) + (if highlight 'magit-diff-context-highlight 'magit-diff-context)))) (forward-line))) (when (eq magit-diff-refine-hunk 'all) (magit-diff-update-hunk-refinement section)) diff --git a/lisp/magit-extras.el b/lisp/magit-extras.el index b03ca18..2b51546 100644 --- a/lisp/magit-extras.el +++ b/lisp/magit-extras.el @@ -447,69 +447,69 @@ list returned by `magit-rebase-arguments'." (user-error "Refusing to reshelve detached head"))) (backup (concat "refs/original/refs/heads/" current))) (cond - ((not commit) - (when (and (magit-ref-p backup) - (not (magit-y-or-n-p - (format "Backup ref %s already exists. Override? " - backup)))) - (user-error "Abort")) - (magit-log-select - (lambda (rev) - (magit-reshelve-since rev keyid)) - "Type %p on a commit to reshelve it and the commits above it,")) - (t - (cl-flet ((adjust (time offset) - (format-time-string - "%F %T %z" - (+ (floor time) - (* offset 60) - (- (car (decode-time time))))))) - (let* ((start (concat commit "^")) - (range (concat start ".." current)) - (time-rev (adjust (float-time (string-to-number - (magit-rev-format "%at" start))) - 1)) - (time-now (adjust (float-time) - (- (string-to-number - (magit-git-string "rev-list" "--count" - range)))))) - (push time-rev magit--reshelve-history) - (let ((date (floor - (float-time - (date-to-time - (read-string "Date for first commit: " - time-now 'magit--reshelve-history)))))) - (with-environment-variables (("FILTER_BRANCH_SQUELCH_WARNING" "1")) - (magit-with-toplevel - (magit-run-git-async - "filter-branch" "--force" "--env-filter" - (format - "case $GIT_COMMIT in %s\nesac" - (mapconcat - (lambda (rev) - (prog1 - (concat - (format "%s) " rev) - (and (not magit-reshelve-since-committer-only) - (format "export GIT_AUTHOR_DATE=\"%s\"; " date)) - (format "export GIT_COMMITTER_DATE=\"%s\";;" date)) - (cl-incf date 60))) - (magit-git-lines "rev-list" "--reverse" range) - " ")) - (and keyid - (list "--commit-filter" - (format "git commit-tree --gpg-sign=%s \"$@\";" - keyid))) - range "--")) - (set-process-sentinel - magit-this-process - (lambda (process event) - (when (memq (process-status process) '(exit signal)) - (if (> (process-exit-status process) 0) - (magit-process-sentinel process event) - (process-put process 'inhibit-refresh t) - (magit-process-sentinel process event) - (magit-run-git "update-ref" "-d" backup))))))))))))) + ((not commit) + (when (and (magit-ref-p backup) + (not (magit-y-or-n-p + (format "Backup ref %s already exists. Override? " + backup)))) + (user-error "Abort")) + (magit-log-select + (lambda (rev) + (magit-reshelve-since rev keyid)) + "Type %p on a commit to reshelve it and the commits above it,")) + (t + (cl-flet ((adjust (time offset) + (format-time-string + "%F %T %z" + (+ (floor time) + (* offset 60) + (- (car (decode-time time))))))) + (let* ((start (concat commit "^")) + (range (concat start ".." current)) + (time-rev (adjust (float-time (string-to-number + (magit-rev-format "%at" start))) + 1)) + (time-now (adjust (float-time) + (- (string-to-number + (magit-git-string "rev-list" "--count" + range)))))) + (push time-rev magit--reshelve-history) + (let ((date (floor + (float-time + (date-to-time + (read-string "Date for first commit: " + time-now 'magit--reshelve-history)))))) + (with-environment-variables (("FILTER_BRANCH_SQUELCH_WARNING" "1")) + (magit-with-toplevel + (magit-run-git-async + "filter-branch" "--force" "--env-filter" + (format + "case $GIT_COMMIT in %s\nesac" + (mapconcat + (lambda (rev) + (prog1 + (concat + (format "%s) " rev) + (and (not magit-reshelve-since-committer-only) + (format "export GIT_AUTHOR_DATE=\"%s\"; " date)) + (format "export GIT_COMMITTER_DATE=\"%s\";;" date)) + (cl-incf date 60))) + (magit-git-lines "rev-list" "--reverse" range) + " ")) + (and keyid + (list "--commit-filter" + (format "git commit-tree --gpg-sign=%s \"$@\";" + keyid))) + range "--")) + (set-process-sentinel + magit-this-process + (lambda (process event) + (when (memq (process-status process) '(exit signal)) + (if (> (process-exit-status process) 0) + (magit-process-sentinel process event) + (process-put process 'inhibit-refresh t) + (magit-process-sentinel process event) + (magit-run-git "update-ref" "-d" backup))))))))))))) ;;; Revision Stack diff --git a/lisp/magit-fetch.el b/lisp/magit-fetch.el index cb41ff8..07205f2 100644 --- a/lisp/magit-fetch.el +++ b/lisp/magit-fetch.el @@ -81,10 +81,10 @@ push-remote." (remote (magit-get-push-remote branch)) (v (magit--push-remote-variable branch t))) (cond - ((member remote (magit-list-remotes)) remote) - (remote - (format "%s, replacing invalid" v)) - ((format "%s, setting that" v))))) + ((member remote (magit-list-remotes)) remote) + (remote + (format "%s, replacing invalid" v)) + ((format "%s, setting that" v))))) ;;;###autoload(autoload 'magit-fetch-from-upstream "magit-fetch" nil t) (transient-define-suffix magit-fetch-from-upstream (remote args) diff --git a/lisp/magit-files.el b/lisp/magit-files.el index c2c2f7e..e64c604 100644 --- a/lisp/magit-files.el +++ b/lisp/magit-files.el @@ -85,16 +85,16 @@ the line and column corresponding to that location." (setq line (line-number-at-pos)) (setq col (current-column)) (cond - ((not (equal visited-file file))) - ((equal magit-buffer-revision rev)) - ((equal rev "{worktree}") - (setq line (magit-diff-visit--offset file magit-buffer-revision line))) - ((equal rev "{index}") - (setq line (magit-diff-visit--offset file nil line))) - (magit-buffer-revision - (setq line (magit-diff-visit--offset - file (concat magit-buffer-revision ".." rev) line))) - ((setq line (magit-diff-visit--offset file (list "-R" rev) line))))) + ((not (equal visited-file file))) + ((equal magit-buffer-revision rev)) + ((equal rev "{worktree}") + (setq line (magit-diff-visit--offset file magit-buffer-revision line))) + ((equal rev "{index}") + (setq line (magit-diff-visit--offset file nil line))) + (magit-buffer-revision + (setq line (magit-diff-visit--offset + file (concat magit-buffer-revision ".." rev) line))) + ((setq line (magit-diff-visit--offset file (list "-R" rev) line))))) (funcall fn buf) (when line (with-current-buffer buf diff --git a/lisp/magit-git.el b/lisp/magit-git.el index 1726de1..26a9718 100644 --- a/lisp/magit-git.el +++ b/lisp/magit-git.el @@ -561,12 +561,12 @@ insert the run command and stderr into the process buffer." (goto-char (point-max)) (setq errmsg (cond - ((eq return-error 'full) - (let ((str (buffer-string))) - (and (not (equal str "")) str))) - ((functionp magit-git-debug) - (funcall magit-git-debug (buffer-string))) - ((magit--locate-error-message))))) + ((eq return-error 'full) + (let ((str (buffer-string))) + (and (not (equal str "")) str))) + ((functionp magit-git-debug) + (funcall magit-git-debug (buffer-string))) + ((magit--locate-error-message))))) (when magit-git-debug (let ((magit-git-debug nil)) (with-current-buffer (magit-process-buffer t) @@ -708,29 +708,29 @@ format." (status (magit-process-git t "version")) (output (buffer-string))) (cond - ((not (zerop status)) - (display-warning - 'magit - (format "%S\n\nRunning \"%s --version\" failed with output:\n\n%s" - (if host - (format "Magit cannot find Git on host %S.\n + ((not (zerop status)) + (display-warning + 'magit + (format "%S\n\nRunning \"%s --version\" failed with output:\n\n%s" + (if host + (format "Magit cannot find Git on host %S.\n Check the value of `magit-remote-git-executable' using `magit-debug-git-executable' and consult the info node `(tramp)Remote programs'." host) - "Magit cannot find Git.\n + "Magit cannot find Git.\n Check the values of `magit-git-executable' and `exec-path' using `magit-debug-git-executable'.") - (magit-git-executable) - output))) - ((save-match-data - (and (string-match magit--git-version-regexp output) - (let ((version (match-str 1 output))) - (push (cons host version) - magit--host-git-version-cache) - version)))) - ((error "Unexpected \"%s --version\" output: %S" - (magit-git-executable) - output))))))))) + (magit-git-executable) + output))) + ((save-match-data + (and (string-match magit--git-version-regexp output) + (let ((version (match-str 1 output))) + (push (cons host version) + magit--host-git-version-cache) + version)))) + ((error "Unexpected \"%s --version\" output: %S" + (magit-git-executable) + output))))))))) (defun magit-git-version-assert (&optional minimal who) "Assert that the used Git version is greater than or equal to MINIMAL. @@ -1750,10 +1750,10 @@ The amount of time spent searching is limited by (concat remote "/" newname)))) (pcase-dolist (`(,branch ,upstream) branches) (cond - ((equal upstream oldname) - (magit-set-upstream-branch branch new)) - ((equal upstream (concat remote "/" oldname)) - (magit-set-upstream-branch branch (concat remote "/" newname)))))))) + ((equal upstream oldname) + (magit-set-upstream-branch branch new)) + ((equal upstream (concat remote "/" oldname)) + (magit-set-upstream-branch branch (concat remote "/" newname)))))))) (defun magit--get-default-branch (&optional update) (let ((remote (magit-primary-remote))) @@ -2469,18 +2469,18 @@ and this option only controls what face is used.") (string-match "^[^/]*/" push) (setq push (substring push 0 (match-end 0)))) (cond - ((equal name current) - (setq head - (concat push - (magit--propertize-face - name 'magit-branch-current)))) - ((equal name target) - (setq upstream - (concat push - (magit--propertize-face - name '(magit-branch-upstream - magit-branch-local))))) - ((push (concat push name) combined))))) + ((equal name current) + (setq head + (concat push + (magit--propertize-face + name 'magit-branch-current)))) + ((equal name target) + (setq upstream + (concat push + (magit--propertize-face + name '(magit-branch-upstream + magit-branch-local))))) + ((push (concat push name) combined))))) (cond-let ((or upstream (not target))) ((member target remotes) diff --git a/lisp/magit-log.el b/lisp/magit-log.el index 1dafdb0..a9ca97e 100644 --- a/lisp/magit-log.el +++ b/lisp/magit-log.el @@ -569,19 +569,19 @@ commits before and half after." ("b" "buffer lock" magit-toggle-buffer-lock)]] (interactive) (cond - ((not (eq transient-current-command 'magit-log-refresh)) - (pcase major-mode - ('magit-reflog-mode - (user-error "Cannot change log arguments in reflog buffers")) - ('magit-cherry-mode - (user-error "Cannot change log arguments in cherry buffers"))) - (transient-setup 'magit-log-refresh)) - (t - (pcase-let ((`(,args ,files) (magit-log-arguments))) - (setq magit-buffer-log-args args) - (unless (derived-mode-p 'magit-log-select-mode) - (setq magit-buffer-log-files files))) - (magit-refresh)))) + ((not (eq transient-current-command 'magit-log-refresh)) + (pcase major-mode + ('magit-reflog-mode + (user-error "Cannot change log arguments in reflog buffers")) + ('magit-cherry-mode + (user-error "Cannot change log arguments in cherry buffers"))) + (transient-setup 'magit-log-refresh)) + (t + (pcase-let ((`(,args ,files) (magit-log-arguments))) + (setq magit-buffer-log-args args) + (unless (derived-mode-p 'magit-log-select-mode) + (setq magit-buffer-log-files files))) + (magit-refresh)))) ;;;; Infix Commands @@ -1257,17 +1257,17 @@ Do not add this to a hook variable." (setq args (remove "--show-signature" args)) (let ((limit (magit-log-get-commit-limit args))) (cond - ((not limit) - (message - "Dropping --show-signature because -n isn't set (see %s)" - 'magit-log-show-signatures-limit) - "") - ((> limit magit-log-show-signatures-limit) - (message - "Dropping --show-signature because -n is larger than %s" - 'magit-log-show-signatures-limit) - "") - ("%G?")))) + ((not limit) + (message + "Dropping --show-signature because -n isn't set (see %s)" + 'magit-log-show-signatures-limit) + "") + ((> limit magit-log-show-signatures-limit) + (message + "Dropping --show-signature because -n is larger than %s" + 'magit-log-show-signatures-limit) + "") + ("%G?")))) (if magit-log-margin-show-committer-date "%ct" "%at") (if magit-log-trailer-labels (format "%%(trailers:%s%s)" diff --git a/lisp/magit-mode.el b/lisp/magit-mode.el index fde5713..e2aba58 100644 --- a/lisp/magit-mode.el +++ b/lisp/magit-mode.el @@ -1098,21 +1098,21 @@ The arguments are for internal use." (when magit-refresh-verbose (message "%s buffer `%s'..." action (buffer-name))) (cond - (created - (funcall refresh) - (cond (initial-section (funcall initial-section)) - (select-section (funcall select-section)))) - (t - (deactivate-mark) - (setq magit-section-pre-command-section nil) - (setq magit-section-highlight-overlays nil) - (setq magit-section-selection-overlays nil) - (setq magit-section-highlighted-sections nil) - (setq magit-section-focused-sections nil) - (let ((positions (magit--refresh-buffer-get-positions))) - (funcall refresh) - (cond (select-section (funcall select-section)) - ((magit--refresh-buffer-set-positions positions)))))) + (created + (funcall refresh) + (cond (initial-section (funcall initial-section)) + (select-section (funcall select-section)))) + (t + (deactivate-mark) + (setq magit-section-pre-command-section nil) + (setq magit-section-highlight-overlays nil) + (setq magit-section-selection-overlays nil) + (setq magit-section-highlighted-sections nil) + (setq magit-section-focused-sections nil) + (let ((positions (magit--refresh-buffer-get-positions))) + (funcall refresh) + (cond (select-section (funcall select-section)) + ((magit--refresh-buffer-set-positions positions)))))) (let ((magit-section-cache-visibility nil)) (magit-section-show magit-root-section)) (run-hooks 'magit-refresh-buffer-hook) @@ -1580,16 +1580,16 @@ The additional output can be found in the *Messages* buffer." (defun magit-run-hook-with-benchmark (hook) (cond - ((not hook)) - (magit-refresh-verbose - (message "Running %s..." hook) - (message "Running %s...done (%.3fs)" hook - (benchmark-elapse - (run-hook-wrapped - hook - (lambda (fn) - (message " %-50s %f" fn (benchmark-elapse (funcall fn)))))))) - ((run-hooks hook)))) + ((not hook)) + (magit-refresh-verbose + (message "Running %s..." hook) + (message "Running %s...done (%.3fs)" hook + (benchmark-elapse + (run-hook-wrapped + hook + (lambda (fn) + (message " %-50s %f" fn (benchmark-elapse (funcall fn)))))))) + ((run-hooks hook)))) (defun magit-file-region-line-numbers () "Return the bounds of the region as line numbers. diff --git a/lisp/magit-process.el b/lisp/magit-process.el index 637bd4a..7c7e6ae 100644 --- a/lisp/magit-process.el +++ b/lisp/magit-process.el @@ -805,26 +805,26 @@ Magit status buffer." (defun magit-process--format-arguments (program args) (cond - ((and args (equal program (magit-git-executable))) - (let ((global (magit-process-git-arguments--length))) - (concat - (propertize (file-name-nondirectory program) - 'font-lock-face 'magit-section-heading) - " " - (propertize (magit--ellipsis) - 'font-lock-face 'magit-section-heading - 'help-echo (string-join (seq-take args global) " ")) - " " - (propertize (mapconcat #'shell-quote-argument (seq-drop args global) " ") - 'font-lock-face 'magit-section-heading)))) - ((and args (equal program shell-file-name)) - (propertize (cadr args) - 'font-lock-face 'magit-section-heading)) - ((concat (propertize (file-name-nondirectory program) - 'font-lock-face 'magit-section-heading) - " " - (propertize (mapconcat #'shell-quote-argument args " ") - 'font-lock-face 'magit-section-heading))))) + ((and args (equal program (magit-git-executable))) + (let ((global (magit-process-git-arguments--length))) + (concat + (propertize (file-name-nondirectory program) + 'font-lock-face 'magit-section-heading) + " " + (propertize (magit--ellipsis) + 'font-lock-face 'magit-section-heading + 'help-echo (string-join (seq-take args global) " ")) + " " + (propertize (mapconcat #'shell-quote-argument (seq-drop args global) " ") + 'font-lock-face 'magit-section-heading)))) + ((and args (equal program shell-file-name)) + (propertize (cadr args) + 'font-lock-face 'magit-section-heading)) + ((concat (propertize (file-name-nondirectory program) + 'font-lock-face 'magit-section-heading) + " " + (propertize (mapconcat #'shell-quote-argument args " ") + 'font-lock-face 'magit-section-heading))))) (defun magit-process-truncate-log () (let* ((head nil) diff --git a/lisp/magit-pull.el b/lisp/magit-pull.el index e5b2b4b..fe23d77 100644 --- a/lisp/magit-pull.el +++ b/lisp/magit-pull.el @@ -138,15 +138,15 @@ the upstream." (merge (magit-get "branch" branch "merge")) (u (magit--propertize-face "@{upstream}" 'bold))) (cond - ((magit--unnamed-upstream-p remote merge) - (format "%s of %s" - (magit--propertize-face merge 'magit-branch-remote) - (magit--propertize-face remote 'bold))) - ((magit--valid-upstream-p remote merge) - (concat u ", replacing non-existent")) - ((or remote merge) - (concat u ", replacing invalid")) - ((concat u ", setting that"))))))) + ((magit--unnamed-upstream-p remote merge) + (format "%s of %s" + (magit--propertize-face merge 'magit-branch-remote) + (magit--propertize-face remote 'bold))) + ((magit--valid-upstream-p remote merge) + (concat u ", replacing non-existent")) + ((or remote merge) + (concat u ", replacing invalid")) + ((concat u ", setting that"))))))) ;;;###autoload (defun magit-pull-branch (source args) diff --git a/lisp/magit-push.el b/lisp/magit-push.el index ea1b9a2..75aa9b0 100644 --- a/lisp/magit-push.el +++ b/lisp/magit-push.el @@ -100,14 +100,14 @@ argument the push-remote can be changed before pushed to it." (remote (magit-get-push-remote branch)) (v (magit--push-remote-variable branch t))) (cond - (target) - ((member remote (magit-list-remotes)) - (format "%s, creating it" - (magit--propertize-face (concat remote "/" branch) - 'magit-branch-remote))) - (remote - (format "%s, replacing invalid" v)) - ((format "%s, setting that" v))))) + (target) + ((member remote (magit-list-remotes)) + (format "%s, creating it" + (magit--propertize-face (concat remote "/" branch) + 'magit-branch-remote))) + (remote + (format "%s, replacing invalid" v)) + ((format "%s, setting that" v))))) ;;;###autoload(autoload 'magit-push-current-to-upstream "magit-push" nil t) (transient-define-suffix magit-push-current-to-upstream (args) @@ -160,17 +160,17 @@ the upstream." (merge (magit-get "branch" branch "merge")) (u (magit--propertize-face "@{upstream}" 'bold))) (cond - ((magit--unnamed-upstream-p remote merge) - (format "%s as %s" - (magit--propertize-face remote 'bold) - (magit--propertize-face merge 'magit-branch-remote))) - ((magit--valid-upstream-p remote merge) - (format "%s creating %s" - (magit--propertize-face remote 'magit-branch-remote) - (magit--propertize-face merge 'magit-branch-remote))) - ((or remote merge) - (concat u ", creating it and replacing invalid")) - ((concat u ", creating it"))))))) + ((magit--unnamed-upstream-p remote merge) + (format "%s as %s" + (magit--propertize-face remote 'bold) + (magit--propertize-face merge 'magit-branch-remote))) + ((magit--valid-upstream-p remote merge) + (format "%s creating %s" + (magit--propertize-face remote 'magit-branch-remote) + (magit--propertize-face merge 'magit-branch-remote))) + ((or remote merge) + (concat u ", creating it and replacing invalid")) + ((concat u ", creating it"))))))) ;;;###autoload (defun magit-push-current (target args) @@ -326,17 +326,17 @@ what this command will do. To add it use something like: (format "%s to %s" (magit--propertize-face branch 'magit-branch-current) (cond - ((string-prefix-p "refs/heads/" ref) - (magit--propertize-face - (format "%s/%s" remote - (substring ref (length "refs/heads/"))) - 'magit-branch-remote)) - ((not (string-match "/" ref)) - (magit--propertize-face (format "%s/%s" remote ref) - 'magit-branch-remote)) - ((format "%s as %s" - (magit--propertize-face remote 'bold) - (magit--propertize-face ref 'bold))))) + ((string-prefix-p "refs/heads/" ref) + (magit--propertize-face + (format "%s/%s" remote + (substring ref (length "refs/heads/"))) + 'magit-branch-remote)) + ((not (string-match "/" ref)) + (magit--propertize-face (format "%s/%s" remote ref) + 'magit-branch-remote)) + ((format "%s as %s" + (magit--propertize-face remote 'bold) + (magit--propertize-face ref 'bold))))) "nothing (no upstream)"))) ("matching" (format "all matching to %s" (magit--propertize-face remote 'bold))))))))) diff --git a/lisp/magit-refs.el b/lisp/magit-refs.el index 10c7f22..653aa0b 100644 --- a/lisp/magit-refs.el +++ b/lisp/magit-refs.el @@ -587,36 +587,36 @@ line is inserted at all." (split-string line "\0") :test #'equal))) (cond - (head-branch - ;; Note: Use `ref' instead of `branch' for the check - ;; below because 'refname:short' shortens the remote - ;; HEAD to '<remote>' instead of '<remote>/HEAD' as of - ;; Git v2.40.0. - (cl-assert - (equal ref (concat "refs/remotes/" remote "/HEAD"))) - (setq head head-branch)) - ((not (equal ref (concat "refs/remotes/" remote "/HEAD"))) - ;; ^ Skip mis-configured remotes where HEAD is not a - ;; symref. See #5092. - (when (magit-refs--insert-refname-p branch) - (magit-insert-section (branch branch t) - (let ((headp (equal branch head)) - (abbrev (if magit-refs-show-remote-prefix - branch - (substring branch (1+ (length remote)))))) - (magit-insert-heading - (magit-refs--format-focus-column branch) - (magit-refs--propertize-branch - abbrev ref (and headp 'magit-branch-remote-head)) - (make-string - (max 1 (- (if (consp magit-refs-primary-column-width) - (car magit-refs-primary-column-width) - magit-refs-primary-column-width) - (length abbrev))) - ?\s) - (and msg (magit-log--wash-summary msg)))) - (magit-refs--maybe-format-margin branch) - (magit-refs--insert-cherry-commits branch)))))))) + (head-branch + ;; Note: Use `ref' instead of `branch' for the check + ;; below because 'refname:short' shortens the remote + ;; HEAD to '<remote>' instead of '<remote>/HEAD' as of + ;; Git v2.40.0. + (cl-assert + (equal ref (concat "refs/remotes/" remote "/HEAD"))) + (setq head head-branch)) + ((not (equal ref (concat "refs/remotes/" remote "/HEAD"))) + ;; ^ Skip mis-configured remotes where HEAD is not a + ;; symref. See #5092. + (when (magit-refs--insert-refname-p branch) + (magit-insert-section (branch branch t) + (let ((headp (equal branch head)) + (abbrev (if magit-refs-show-remote-prefix + branch + (substring branch (1+ (length remote)))))) + (magit-insert-heading + (magit-refs--format-focus-column branch) + (magit-refs--propertize-branch + abbrev ref (and headp 'magit-branch-remote-head)) + (make-string + (max 1 (- (if (consp magit-refs-primary-column-width) + (car magit-refs-primary-column-width) + magit-refs-primary-column-width) + (length abbrev))) + ?\s) + (and msg (magit-log--wash-summary msg)))) + (magit-refs--maybe-format-margin branch) + (magit-refs--insert-cherry-commits branch)))))))) (insert ?\n) (magit-make-margin-overlay)))) diff --git a/lisp/magit-remote.el b/lisp/magit-remote.el index f52851e..770a708 100644 --- a/lisp/magit-remote.el +++ b/lisp/magit-remote.el @@ -262,28 +262,28 @@ Delete the symbolic-ref \"refs/remotes/<remote>/HEAD\"." (pcase-let ((`(,_remote ,oldname) (magit--get-default-branch)) (`( ,remote ,newname) (magit--get-default-branch t))) (cond - ((equal oldname newname) - (setq oldname - (read-string - (format - "Name of default branch is still `%s', %s\n%s `%s': " oldname - "but the upstreams of some local branches might need updating." - "Name of upstream branches to replace with" newname))) - (magit--set-default-branch newname oldname) - (magit-refresh)) - (t - (unless oldname - (setq oldname - (magit-read-other-local-branch - (format "Name of old default branch to be renamed to `%s'" - newname) - newname "master"))) - (cond - ((y-or-n-p (format "Default branch changed from `%s' to `%s' on %s.%s?" - oldname newname remote " Do the same locally")) - (magit--set-default-branch newname oldname) - (magit-refresh)) - ((user-error "Abort"))))))) + ((equal oldname newname) + (setq oldname + (read-string + (format + "Name of default branch is still `%s', %s\n%s `%s': " oldname + "but the upstreams of some local branches might need updating." + "Name of upstream branches to replace with" newname))) + (magit--set-default-branch newname oldname) + (magit-refresh)) + (t + (unless oldname + (setq oldname + (magit-read-other-local-branch + (format "Name of old default branch to be renamed to `%s'" + newname) + newname "master"))) + (cond + ((y-or-n-p (format "Default branch changed from `%s' to `%s' on %s.%s?" + oldname newname remote " Do the same locally")) + (magit--set-default-branch newname oldname) + (magit-refresh)) + ((user-error "Abort"))))))) ;;;###autoload (defun magit-remote-unshallow (remote) diff --git a/lisp/magit-section.el b/lisp/magit-section.el index c86862f..4999f16 100644 --- a/lisp/magit-section.el +++ b/lisp/magit-section.el @@ -817,33 +817,33 @@ the beginning of the current section." (user-error "No previous section") (let ((section (magit-current-section)) children) (cond - ((and (= (point) - (1- (oref section end))) - (setq children (oref section children))) - (magit-section-goto (car (last children)))) - ((and (oref section parent) - (not (= (point) - (oref section start)))) - (magit-section-goto section)) - (t - (let ((prev (car (magit-section-siblings section 'prev)))) - (if prev - (while (and (not (oref prev hidden)) - (setq children (oref prev children))) - (setq prev (car (last children)))) - (setq prev (oref section parent))) - (cond (prev - (magit-section-goto prev)) - ((oref section parent) - (user-error "No previous section")) - ;; Eob special cases. - ((not (get-text-property (1- (point)) 'invisible)) - (magit-section-goto -1)) - (t - (goto-char (previous-single-property-change - (1- (point)) 'invisible)) - (forward-line -1) - (magit-section-goto (magit-current-section)))))))))) + ((and (= (point) + (1- (oref section end))) + (setq children (oref section children))) + (magit-section-goto (car (last children)))) + ((and (oref section parent) + (not (= (point) + (oref section start)))) + (magit-section-goto section)) + (t + (let ((prev (car (magit-section-siblings section 'prev)))) + (if prev + (while (and (not (oref prev hidden)) + (setq children (oref prev children))) + (setq prev (car (last children)))) + (setq prev (oref section parent))) + (cond (prev + (magit-section-goto prev)) + ((oref section parent) + (user-error "No previous section")) + ;; Eob special cases. + ((not (get-text-property (1- (point)) 'invisible)) + (magit-section-goto -1)) + (t + (goto-char (previous-single-property-change + (1- (point)) 'invisible)) + (forward-line -1) + (magit-section-goto (magit-current-section)))))))))) (defun magit-section-up () "Move to the beginning of the parent section." @@ -1442,19 +1442,19 @@ anything this time around. (oset obj hidden (let (set old) (cond - ((setq set (run-hook-with-args-until-success - 'magit-section-set-visibility-hook obj)) - (eq set 'hide)) - ((setq old (and (not magit-section-preserve-visibility) - magit-insert-section--oldroot - (magit-get-section - (magit-section-ident obj) - magit-insert-section--oldroot))) - (oref old hidden)) - ((setq set (magit-section-match-assoc - obj magit-section-initial-visibility-alist)) - (eq (if (functionp set) (funcall set obj) set) 'hide)) - (hide))))) + ((setq set (run-hook-with-args-until-success + 'magit-section-set-visibility-hook obj)) + (eq set 'hide)) + ((setq old (and (not magit-section-preserve-visibility) + magit-insert-section--oldroot + (magit-get-section + (magit-section-ident obj) + magit-insert-section--oldroot))) + (oref old hidden)) + ((setq set (magit-section-match-assoc + obj magit-section-initial-visibility-alist)) + (eq (if (functionp set) (funcall set obj) set) 'hide)) + (hide))))) (unless (oref obj keymap) (let ((type (oref obj type))) (oset obj keymap @@ -1471,24 +1471,24 @@ anything this time around. (oset obj end (point-marker)) (set-marker-insertion-type (oref obj start) t)) (cond - ((eq obj magit-root-section) - (when (eq magit-section-inhibit-markers 'delay) - (setq magit-section-inhibit-markers nil) - (magit-map-sections - (lambda (section) - (oset section start (copy-marker (oref section start) t)) - (oset section end (copy-marker (oref section end) t)))))) - (t - (magit-section--set-section-properties obj) - (magit-section-maybe-add-heading-map obj) - (when (oref obj children) - (magit-insert-child-count obj)) - (if magit-section-insert-in-reverse - (push obj (oref (oref obj parent) children)) - (let ((parent (oref obj parent))) - (oset parent children - (nconc (oref parent children) - (list obj))))))) + ((eq obj magit-root-section) + (when (eq magit-section-inhibit-markers 'delay) + (setq magit-section-inhibit-markers nil) + (magit-map-sections + (lambda (section) + (oset section start (copy-marker (oref section start) t)) + (oset section end (copy-marker (oref section end) t)))))) + (t + (magit-section--set-section-properties obj) + (magit-section-maybe-add-heading-map obj) + (when (oref obj children) + (magit-insert-child-count obj)) + (if magit-section-insert-in-reverse + (push obj (oref (oref obj parent) children)) + (let ((parent (oref obj parent))) + (oset parent children + (nconc (oref parent children) + (list obj))))))) (when magit-section-insert-in-reverse (oset obj children (nreverse (oref obj children))))) @@ -1665,24 +1665,24 @@ This function is called by `magit-insert-section' after that has evaluated its BODY. Admittedly that's a bit of a hack." (let (content count) (cond - ((not (and magit-section-show-child-count - (setq content (oref section content)) - (setq count (length (oref section children))) - (> count 0)))) - ((eq (char-before (- content 1)) ?:) - (save-excursion - (goto-char (- content 2)) - (insert (magit--propertize-face (format " (%s)" count) - 'magit-section-child-count)) - (delete-char 1))) - ((and (eq (char-before (- content 4)) ?\s) - (eq (char-before (- content 3)) ?\() - (eq (char-before (- content 2)) ?t ) - (eq (char-before (- content 1)) ?\))) - (save-excursion - (goto-char (- content 3)) - (delete-char 1) - (insert (format "%s" count))))))) + ((not (and magit-section-show-child-count + (setq content (oref section content)) + (setq count (length (oref section children))) + (> count 0)))) + ((eq (char-before (- content 1)) ?:) + (save-excursion + (goto-char (- content 2)) + (insert (magit--propertize-face (format " (%s)" count) + 'magit-section-child-count)) + (delete-char 1))) + ((and (eq (char-before (- content 4)) ?\s) + (eq (char-before (- content 3)) ?\() + (eq (char-before (- content 2)) ?t ) + (eq (char-before (- content 1)) ?\))) + (save-excursion + (goto-char (- content 3)) + (delete-char 1) + (insert (format "%s" count))))))) (defun magit-section--opportunistic-wash (section) (when-let ((washer (oref section washer))) @@ -1739,37 +1739,37 @@ evaluated its BODY. Admittedly that's a bit of a hack." (let ((section (magit-current-section)) (focused (magit-focused-sections))) (cond - ((or force - magit-section-highlight-force-update - (xor magit-section-pre-command-region-p (region-active-p)) - (not (eq magit-section-pre-command-section section))) - (let ((inhibit-read-only t) - (deactivate-mark nil) - (selection (magit-region-sections))) - (mapc #'delete-overlay magit-section-highlight-overlays) - (mapc #'delete-overlay magit-section-selection-overlays) - (setq magit-section-highlight-overlays nil) - (setq magit-section-selection-overlays nil) - (cond ((magit-section--maybe-enable-long-lines-shortcuts)) - ((eq section magit-root-section)) - ((not magit-section-highlight-current) - (when selection - (magit-section-highlight-selection selection))) - ((not selection) - (magit-section-highlight section)) - (t - (mapc #'magit-section-highlight selection) - (magit-section-highlight-selection selection))) - (dolist (section (cl-union magit-section-highlighted-sections focused)) - (when (slot-boundp section 'painted) - (magit-section-update-paint section focused))) - (restore-buffer-modified-p nil))) - ((and (eq magit-section-pre-command-section section) - magit-section-selection-overlays - (region-active-p) - (not (magit-region-sections))) - (mapc #'delete-overlay magit-section-selection-overlays) - (setq magit-section-selection-overlays nil))) + ((or force + magit-section-highlight-force-update + (xor magit-section-pre-command-region-p (region-active-p)) + (not (eq magit-section-pre-command-section section))) + (let ((inhibit-read-only t) + (deactivate-mark nil) + (selection (magit-region-sections))) + (mapc #'delete-overlay magit-section-highlight-overlays) + (mapc #'delete-overlay magit-section-selection-overlays) + (setq magit-section-highlight-overlays nil) + (setq magit-section-selection-overlays nil) + (cond ((magit-section--maybe-enable-long-lines-shortcuts)) + ((eq section magit-root-section)) + ((not magit-section-highlight-current) + (when selection + (magit-section-highlight-selection selection))) + ((not selection) + (magit-section-highlight section)) + (t + (mapc #'magit-section-highlight selection) + (magit-section-highlight-selection selection))) + (dolist (section (cl-union magit-section-highlighted-sections focused)) + (when (slot-boundp section 'painted) + (magit-section-update-paint section focused))) + (restore-buffer-modified-p nil))) + ((and (eq magit-section-pre-command-section section) + magit-section-selection-overlays + (region-active-p) + (not (magit-region-sections))) + (mapc #'delete-overlay magit-section-selection-overlays) + (setq magit-section-selection-overlays nil))) (setq magit-section-highlight-force-update nil) (magit-section-maybe-paint-visibility-ellipses))) @@ -1779,22 +1779,22 @@ evaluated its BODY. Admittedly that's a bit of a hack." (headlight heading-highlight-face) (selective (magit-section-selective-highlight-p section))) (cond - (selective - (magit-section-highlight-range start (or content end) headlight) - (cond (children - (let ((child-start (oref (car children) start))) - (when (and content (< content child-start)) - (magit-section-highlight-range content child-start))) - (mapc #'magit-section-highlight children)) - ((and content (not (slot-boundp section 'painted))) - (magit-section-highlight-range content end)) - ;; Unfortunate kludge for delayed hunk refinement. - ((magit-section--refine section)))) - (headlight - (magit-section-highlight-range start (or content end) headlight) - (when content - (magit-section-highlight-range (if headlight content start) end))) - ((magit-section-highlight-range start end))))) + (selective + (magit-section-highlight-range start (or content end) headlight) + (cond (children + (let ((child-start (oref (car children) start))) + (when (and content (< content child-start)) + (magit-section-highlight-range content child-start))) + (mapc #'magit-section-highlight children)) + ((and content (not (slot-boundp section 'painted))) + (magit-section-highlight-range content end)) + ;; Unfortunate kludge for delayed hunk refinement. + ((magit-section--refine section)))) + (headlight + (magit-section-highlight-range start (or content end) headlight) + (when content + (magit-section-highlight-range (if headlight content start) end))) + ((magit-section-highlight-range start end))))) (defun magit-section-highlight-selection (selection) (when magit-section-highlight-selection @@ -2474,21 +2474,21 @@ This is like moving to POS and then calling `pos-eol'." (mapcan (lambda (section) (cond - (magit--imenu-group-types - (and (if (eq (car-safe magit--imenu-group-types) 'not) - (not (magit-section-match - (cdr magit--imenu-group-types) - section)) - (magit-section-match magit--imenu-group-types section)) - (and-let ((children (oref section children))) - `((,(magit--imenu-index-name section) - ,@(mapcar (##cons (magit--imenu-index-name %) - (oref % start)) - children)))))) - (magit--imenu-item-types - (and (magit-section-match magit--imenu-item-types section) - `((,(magit--imenu-index-name section) - . ,(oref section start))))))) + (magit--imenu-group-types + (and (if (eq (car-safe magit--imenu-group-types) 'not) + (not (magit-section-match + (cdr magit--imenu-group-types) + section)) + (magit-section-match magit--imenu-group-types section)) + (and-let ((children (oref section children))) + `((,(magit--imenu-index-name section) + ,@(mapcar (##cons (magit--imenu-index-name %) + (oref % start)) + children)))))) + (magit--imenu-item-types + (and (magit-section-match magit--imenu-item-types section) + `((,(magit--imenu-index-name section) + . ,(oref section start))))))) (oref magit-root-section children)))) (if (and magit--imenu-group-types (symbolp magit--imenu-group-types)) (cdar index) @@ -2501,18 +2501,18 @@ This is like moving to POS and then calling `pos-eol'." (oref section end)))))) (save-match-data (cond - ((and (magit-section-match [commit logbuf] section) - (string-match "[^ ]+\\([ *|]*\\).+" heading)) - (replace-match " " t t heading 1)) - ((magit-section-match - '([branch local branchbuf] [tag tags branchbuf]) section) - (oref section value)) - ((magit-section-match [branch remote branchbuf] section) - (concat (oref (oref section parent) value) "/" - (oref section value))) - ((string-match " ([0-9]+)\\'" heading) - (substring heading 0 (match-beginning 0))) - (heading))))) + ((and (magit-section-match [commit logbuf] section) + (string-match "[^ ]+\\([ *|]*\\).+" heading)) + (replace-match " " t t heading 1)) + ((magit-section-match + '([branch local branchbuf] [tag tags branchbuf]) section) + (oref section value)) + ((magit-section-match [branch remote branchbuf] section) + (concat (oref (oref section parent) value) "/" + (oref section value))) + ((string-match " ([0-9]+)\\'" heading) + (substring heading 0 (match-beginning 0))) + (heading))))) (defun magit--imenu-goto-function (_name position &rest _rest) "Go to the section at POSITION. diff --git a/lisp/magit-sequence.el b/lisp/magit-sequence.el index 18b586c..3702d4b 100644 --- a/lisp/magit-sequence.el +++ b/lisp/magit-sequence.el @@ -95,12 +95,12 @@ "Resume the current cherry-pick or revert sequence." (interactive) (cond - ((not (magit-sequencer-in-progress-p)) - (user-error "No cherry-pick or revert in progress")) - ((magit-anything-unmerged-p) - (user-error "Cannot continue due to unresolved conflicts")) - ((magit-run-git-sequencer - (if (magit-revert-in-progress-p) "revert" "cherry-pick") "--continue")))) + ((not (magit-sequencer-in-progress-p)) + (user-error "No cherry-pick or revert in progress")) + ((magit-anything-unmerged-p) + (user-error "Cannot continue due to unresolved conflicts")) + ((magit-run-git-sequencer + (if (magit-revert-in-progress-p) "revert" "cherry-pick") "--continue")))) ;;;###autoload (defun magit-sequencer-skip () @@ -117,13 +117,13 @@ This discards all changes made since the sequence started." (interactive) (cond - ((not (magit-sequencer-in-progress-p)) - (user-error "No cherry-pick or revert in progress")) - ((magit-revert-in-progress-p) - (magit-confirm 'abort-revert "Really abort revert") - (magit-run-git-sequencer "revert" "--abort")) - ((magit-confirm 'abort-cherry-pick "Really abort cherry-pick") - (magit-run-git-sequencer "cherry-pick" "--abort")))) + ((not (magit-sequencer-in-progress-p)) + (user-error "No cherry-pick or revert in progress")) + ((magit-revert-in-progress-p) + (magit-confirm 'abort-revert "Really abort revert") + (magit-run-git-sequencer "revert" "--abort")) + ((magit-confirm 'abort-cherry-pick "Really abort cherry-pick") + (magit-run-git-sequencer "cherry-pick" "--abort")))) (defun magit-sequencer-in-progress-p () (or (magit-cherry-pick-in-progress-p) @@ -308,32 +308,32 @@ the process manually." (process-put process 'inhibit-refresh t) (magit-process-sentinel process event) (cond - ((magit-rev-equal tip src) - (magit-call-git "update-ref" - "-m" (format "reset: moving to %s" keep) - (magit-ref-fullname src) - keep tip) - (if (not checkout-dst) - (magit-run-git "checkout" src) - (magit-refresh))) - (t - (magit-git "checkout" src) - (with-environment-variables - (("GIT_SEQUENCE_EDITOR" - (format "%s -i -ne '/^pick (%s)/ or print'" - magit-perl-executable - (mapconcat #'magit-rev-abbrev commits "|")))) - (magit-run-git-sequencer "rebase" "-i" keep)) - (when checkout-dst - (set-process-sentinel - magit-this-process - (lambda (process event) - (when (memq (process-status process) '(exit signal)) - (if (> (process-exit-status process) 0) - (magit-process-sentinel process event) - (process-put process 'inhibit-refresh t) - (magit-process-sentinel process event) - (magit-run-git "checkout" dst)))))))))))))))) + ((magit-rev-equal tip src) + (magit-call-git "update-ref" + "-m" (format "reset: moving to %s" keep) + (magit-ref-fullname src) + keep tip) + (if (not checkout-dst) + (magit-run-git "checkout" src) + (magit-refresh))) + (t + (magit-git "checkout" src) + (with-environment-variables + (("GIT_SEQUENCE_EDITOR" + (format "%s -i -ne '/^pick (%s)/ or print'" + magit-perl-executable + (mapconcat #'magit-rev-abbrev commits "|")))) + (magit-run-git-sequencer "rebase" "-i" keep)) + (when checkout-dst + (set-process-sentinel + magit-this-process + (lambda (process event) + (when (memq (process-status process) '(exit signal)) + (if (> (process-exit-status process) 0) + (magit-process-sentinel process event) + (process-put process 'inhibit-refresh t) + (magit-process-sentinel process event) + (magit-run-git "checkout" dst)))))))))))))))) (defun magit--cherry-pick (commits args &optional revert) (let ((command (if revert "revert" "cherry-pick"))) @@ -345,16 +345,16 @@ the process manually." (if revert "revert" "cherry-pick") (let ((merges (seq-filter #'magit-merge-commit-p commits))) (cond - ((not merges) - (seq-remove (##string-prefix-p "--mainline=" %) args)) - ((cl-set-difference commits merges :test #'equal) - (user-error "Cannot %s merge and non-merge commits at once" - command)) - ((seq-find (##string-prefix-p "--mainline=" %) args) - args) - ((cons (format "--mainline=%s" - (read-number "Replay merges relative to parent: ")) - args)))) + ((not merges) + (seq-remove (##string-prefix-p "--mainline=" %) args)) + ((cl-set-difference commits merges :test #'equal) + (user-error "Cannot %s merge and non-merge commits at once" + command)) + ((seq-find (##string-prefix-p "--mainline=" %) args) + args) + ((cons (format "--mainline=%s" + (read-number "Replay merges relative to parent: ")) + args)))) commits))) (defun magit-cherry-pick-in-progress-p () @@ -491,11 +491,11 @@ without prompting." "Resume the current patch applying sequence." (interactive) (cond - ((not (magit-am-in-progress-p)) - (user-error "Not applying any patches")) - ((magit-anything-unstaged-p t) - (user-error "Cannot continue due to unstaged changes")) - ((magit-run-git-sequencer "am" "--continue")))) + ((not (magit-am-in-progress-p)) + (user-error "Not applying any patches")) + ((magit-anything-unstaged-p t) + (user-error "Cannot continue due to unstaged changes")) + ((magit-run-git-sequencer "am" "--continue")))) ;;;###autoload (defun magit-am-skip () @@ -628,13 +628,13 @@ the upstream." (merge (magit-get "branch" branch "merge")) (u (magit--propertize-face "@{upstream}" 'bold))) (cond - ((magit--unnamed-upstream-p remote merge) - (concat u ", replacing unnamed")) - ((magit--valid-upstream-p remote merge) - (concat u ", replacing non-existent")) - ((or remote merge) - (concat u ", replacing invalid")) - ((concat u ", setting that"))))))) + ((magit--unnamed-upstream-p remote merge) + (concat u ", replacing unnamed")) + ((magit--valid-upstream-p remote merge) + (concat u ", replacing non-existent")) + ((or remote merge) + (concat u ", replacing invalid")) + ((concat u ", setting that"))))))) ;;;###autoload (defun magit-rebase-branch (target args) @@ -823,25 +823,25 @@ In some cases this pops up a commit message buffer for you do edit. With a prefix argument the old message is reused as-is." (interactive "P") (cond - ((not (magit-rebase-in-progress-p)) - (user-error "No rebase in progress")) - ((magit-anything-unstaged-p t) - (user-error "Cannot continue rebase with unstaged changes")) - (t - (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") - (set-process-sentinel magit-this-process - #'magit-sequencer-process-sentinel) - magit-this-process) - (magit-run-git-sequencer (magit--rebase-resume-command) "--continue"))))) + ((not (magit-rebase-in-progress-p)) + (user-error "No rebase in progress")) + ((magit-anything-unstaged-p t) + (user-error "Cannot continue rebase with unstaged changes")) + (t + (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") + (set-process-sentinel magit-this-process + #'magit-sequencer-process-sentinel) + magit-this-process) + (magit-run-git-sequencer (magit--rebase-resume-command) "--continue"))))) ;;;###autoload (defun magit-rebase-skip () @@ -1066,37 +1066,37 @@ status buffer (i.e., the reverse of how they will be applied)." (if-let ((matched (car (assoc (##equal (magit-patch-id %) id) done)))) (setq stop matched) (cond - ((assoc (##magit-rev-equal % stop) done) - ;; The commit's testament has been executed. - (magit-sequence-insert-commit "void" stop 'magit-sequence-drop)) - ;; The faith of the commit is still undecided... - ((magit-anything-unmerged-p) - ;; ...and time travel isn't for the faint of heart. - (magit-sequence-insert-commit "join" stop 'magit-sequence-part)) - ((magit-anything-modified-p t) - ;; ...and the dust hasn't settled yet... - (magit-sequence-insert-commit - (let* ((magit--refresh-cache nil) - (staged (magit-commit-tree "oO" nil "HEAD")) - (unstaged (magit-commit-worktree "oO" "--reset"))) - (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") - ;; ...but the changes are still there, untainted. - ((or (equal (magit-patch-id staged) id) - (equal (magit-patch-id unstaged) id)) - "same") - ;; ...and some changes are gone and/or others were added. - ("work"))) - stop 'magit-sequence-part)) - ;; The commit is definitely gone... - ((assoc (##magit-rev-equal % stop) done) - ;; ...but all of its changes are still in effect. - (magit-sequence-insert-commit "poof" stop 'magit-sequence-drop)) - ;; ...and some changes are gone and/or other changes were added. - ((magit-sequence-insert-commit "gone" stop 'magit-sequence-drop))) + ((assoc (##magit-rev-equal % stop) done) + ;; The commit's testament has been executed. + (magit-sequence-insert-commit "void" stop 'magit-sequence-drop)) + ;; The faith of the commit is still undecided... + ((magit-anything-unmerged-p) + ;; ...and time travel isn't for the faint of heart. + (magit-sequence-insert-commit "join" stop 'magit-sequence-part)) + ((magit-anything-modified-p t) + ;; ...and the dust hasn't settled yet... + (magit-sequence-insert-commit + (let* ((magit--refresh-cache nil) + (staged (magit-commit-tree "oO" nil "HEAD")) + (unstaged (magit-commit-worktree "oO" "--reset"))) + (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") + ;; ...but the changes are still there, untainted. + ((or (equal (magit-patch-id staged) id) + (equal (magit-patch-id unstaged) id)) + "same") + ;; ...and some changes are gone and/or others were added. + ("work"))) + stop 'magit-sequence-part)) + ;; The commit is definitely gone... + ((assoc (##magit-rev-equal % stop) done) + ;; ...but all of its changes are still in effect. + (magit-sequence-insert-commit "poof" stop 'magit-sequence-drop)) + ;; ...and some changes are gone and/or other changes were added. + ((magit-sequence-insert-commit "gone" stop 'magit-sequence-drop))) (setq stop nil)))) (pcase-dolist (`(,rev ,abbrev ,msg) done) (apply #'magit-sequence-insert-commit diff --git a/lisp/magit-status.el b/lisp/magit-status.el index 42a96c2..766e52a 100644 --- a/lisp/magit-status.el +++ b/lisp/magit-status.el @@ -622,33 +622,33 @@ arguments are for internal use only." (insert (format "%-10s" (or keyword (if rebase "Rebase: " "Merge: ")))) (insert (cond - (upstream - (concat (and magit-status-show-hashes-in-headers - (concat (propertize (magit-rev-format "%h" upstream) - 'font-lock-face 'magit-hash) - " ")) - upstream " " - (magit-log--wash-summary - (or (magit-rev-format "%s" upstream) - "(no commit message)")))) - ((magit--unnamed-upstream-p remote merge) - (concat (propertize merge 'font-lock-face 'magit-branch-remote) - " from " - (propertize remote 'font-lock-face 'bold))) - ((magit--valid-upstream-p remote merge) - (if (equal remote ".") - (concat - (propertize merge 'font-lock-face 'magit-branch-local) " " - (propertize "does not exist" - 'font-lock-face 'magit-branch-warning)) - (format - "%s %s %s" - (propertize merge 'font-lock-face 'magit-branch-remote) - (propertize "does not exist on" - 'font-lock-face 'magit-branch-warning) - (propertize remote 'font-lock-face 'magit-branch-remote)))) - ((propertize "invalid upstream configuration" - 'font-lock-face 'magit-branch-warning)))) + (upstream + (concat (and magit-status-show-hashes-in-headers + (concat (propertize (magit-rev-format "%h" upstream) + 'font-lock-face 'magit-hash) + " ")) + upstream " " + (magit-log--wash-summary + (or (magit-rev-format "%s" upstream) + "(no commit message)")))) + ((magit--unnamed-upstream-p remote merge) + (concat (propertize merge 'font-lock-face 'magit-branch-remote) + " from " + (propertize remote 'font-lock-face 'bold))) + ((magit--valid-upstream-p remote merge) + (if (equal remote ".") + (concat + (propertize merge 'font-lock-face 'magit-branch-local) " " + (propertize "does not exist" + 'font-lock-face 'magit-branch-warning)) + (format + "%s %s %s" + (propertize merge 'font-lock-face 'magit-branch-remote) + (propertize "does not exist on" + 'font-lock-face 'magit-branch-warning) + (propertize remote 'font-lock-face 'magit-branch-remote)))) + ((propertize "invalid upstream configuration" + 'font-lock-face 'magit-branch-warning)))) (insert ?\n)))))) (defun magit-insert-push-branch-header () diff --git a/lisp/magit-submodule.el b/lisp/magit-submodule.el index 24f478e..9a7da87 100644 --- a/lisp/magit-submodule.el +++ b/lisp/magit-submodule.el @@ -539,20 +539,20 @@ With a prefix argument, visit in another window." (magit-with-toplevel (let ((path (expand-file-name module))) (cond - ((file-exists-p (expand-file-name ".git" module)) - (magit-diff-visit-directory path other-window)) - ((y-or-n-p (format "Initialize submodule '%s' first?" module)) - (magit-run-git-async "submodule" "update" "--init" "--" module) - (set-process-sentinel - magit-this-process - (lambda (process event) - (let ((magit-process-raise-error t)) - (magit-process-sentinel process event)) - (when (and (eq (process-status process) 'exit) - (= (process-exit-status process) 0)) - (magit-diff-visit-directory path other-window))))) - ((file-exists-p path) - (dired-jump other-window (concat path "/."))))))) + ((file-exists-p (expand-file-name ".git" module)) + (magit-diff-visit-directory path other-window)) + ((y-or-n-p (format "Initialize submodule '%s' first?" module)) + (magit-run-git-async "submodule" "update" "--init" "--" module) + (set-process-sentinel + magit-this-process + (lambda (process event) + (let ((magit-process-raise-error t)) + (magit-process-sentinel process event)) + (when (and (eq (process-status process) 'exit) + (= (process-exit-status process) 0)) + (magit-diff-visit-directory path other-window))))) + ((file-exists-p path) + (dired-jump other-window (concat path "/."))))))) ;;;###autoload (defun magit-insert-modules-unpulled-from-upstream () diff --git a/lisp/magit-tag.el b/lisp/magit-tag.el index a71c981..589ccc6 100644 --- a/lisp/magit-tag.el +++ b/lisp/magit-tag.el @@ -174,22 +174,22 @@ that is not the case, propose a message using a reasonable format." (magit-rev-format "%s" ptag)) (user-error "Use `sisyphus-create-release' first"))) (tag (cond - ((not ptag) - ;; Force the user to review the message used for the - ;; initial release tag, in case they do not like the - ;; default format. - (cl-pushnew "--edit" args :test #'equal) - (read-string "Create first release tag: " - (if (and ver (string-match-p "\\`[0-9]" ver)) - (concat "v" ver) - ver))) - (ver - (concat (and (string-match magit-release-tag-regexp ptag) - (match-str 1 ptag)) - ver)) - ((read-string (format "Create release tag (previous was %s): " - ptag) - ptag)))) + ((not ptag) + ;; Force the user to review the message used for the + ;; initial release tag, in case they do not like the + ;; default format. + (cl-pushnew "--edit" args :test #'equal) + (read-string "Create first release tag: " + (if (and ver (string-match-p "\\`[0-9]" ver)) + (concat "v" ver) + ver))) + (ver + (concat (and (string-match magit-release-tag-regexp ptag) + (match-str 1 ptag)) + ver)) + ((read-string (format "Create release tag (previous was %s): " + ptag) + ptag)))) (ver (and (string-match magit-release-tag-regexp tag) (match-str 2 tag)))) (list tag diff --git a/lisp/magit-wip.el b/lisp/magit-wip.el index 7f9eaf1..da12fa1 100644 --- a/lisp/magit-wip.el +++ b/lisp/magit-wip.el @@ -105,20 +105,20 @@ buffer." :lighter magit-wip-mode-lighter :global t (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) + (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)))) (defun magit-wip-commit-buffer-file (&optional msg) "Commit visited file to a worktree work-in-progress ref." @@ -220,29 +220,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))) diff --git a/lisp/magit-worktree.el b/lisp/magit-worktree.el index 89fa067..e8058f8 100644 --- a/lisp/magit-worktree.el +++ b/lisp/magit-worktree.el @@ -256,16 +256,16 @@ If there is only one worktree, then insert nothing." (lambda (config) (pcase-let ((`(,_ ,commit ,branch ,bare) config)) (cons (cond - (branch - (propertize - branch 'font-lock-face - (if (equal branch (magit-get-current-branch)) - 'magit-branch-current - 'magit-branch-local))) - (commit - (propertize (magit-rev-abbrev commit) - 'font-lock-face 'magit-hash)) - (bare "(bare)")) + (branch + (propertize + branch 'font-lock-face + (if (equal branch (magit-get-current-branch)) + 'magit-branch-current + 'magit-branch-local))) + (commit + (propertize (magit-rev-abbrev commit) + 'font-lock-face 'magit-hash)) + (bare "(bare)")) config))) worktrees)) (align (1+ (apply #'max (mapcar (##string-width (car %)) cols))))) |
