branch: elpa/git-commit commit e9df33bf2862b4222c044bddaf60901279a153b3 Author: Jonas Bernoulli <jo...@bernoul.li> Commit: Jonas Bernoulli <jo...@bernoul.li>
Silence warnings on older Emacs releases --- lisp/magit-diff.el | 2 -- lisp/magit-extras.el | 62 ++++++++++++++++++++++++++------------------------- lisp/magit-process.el | 6 ++--- 3 files changed, 34 insertions(+), 36 deletions(-) diff --git a/lisp/magit-diff.el b/lisp/magit-diff.el index 00400403eb..82fa150061 100644 --- a/lisp/magit-diff.el +++ b/lisp/magit-diff.el @@ -41,8 +41,6 @@ ;; For `magit-diff-popup' (declare-function magit-stash-show "magit-stash" (stash &optional args files)) ;; For `magit-diff-visit-file' -(declare-function dired-jump "dired" ; dired-x before 27.1 - (&optional other-window file-name)) (declare-function magit-find-file-noselect "magit-files" (rev file)) (declare-function magit-status-setup-buffer "magit-status" (&optional directory)) ;; For `magit-diff-while-committing' diff --git a/lisp/magit-extras.el b/lisp/magit-extras.el index 92678b8846..4222b94cd0 100644 --- a/lisp/magit-extras.el +++ b/lisp/magit-extras.el @@ -31,12 +31,11 @@ (require 'magit) -(declare-function change-log-insert-entries "add-log" (changelogs)) -(declare-function diff-add-log-current-defuns "diff-mode" ()) +;; For `magit-do-async-shell-command'. (declare-function dired-read-shell-command "dired-aux" (prompt arg files)) ;; For `magit-project-status'. -(declare-function project-root "project" (project)) -(declare-function vc-git-command "vc-git" (buffer okstatus file-or-list &rest flags)) +(declare-function vc-git-command "vc-git" + (buffer okstatus file-or-list &rest flags)) (defvar ido-exit) (defvar ido-fallback) @@ -226,7 +225,9 @@ like pretty much every other keymap: (defun magit-project-status () "Run `magit-status' in the current project's root." (interactive) - (magit-status-setup-buffer (project-root (project-current t)))) + (if (fboundp 'project-root) + (magit-status-setup-buffer (project-root (project-current t))) + (user-error "`magit-project-status' requires `project' 0.3.0 or greater"))) (defvar magit-bind-magit-project-status t "Whether to bind \"m\" to `magit-project-status' in `project-prefix-map'. @@ -390,31 +391,32 @@ in HEAD as well as staged changes in the diff to check." (require 'diff-mode) ; `diff-add-log-current-defuns'. (require 'vc-git) ; `vc-git-diff'. (require 'add-log) ; `change-log-insert-entries'. - (unless (and (fboundp 'change-log-insert-entries) - (fboundp 'diff-add-log-current-defuns)) - (user-error "`magit-generate-changelog' requires Emacs 27 or greater")) - (setq default-directory - (if (and (file-regular-p "gitdir") - (not (magit-git-true "rev-parse" "--is-inside-work-tree")) - (magit-git-true "rev-parse" "--is-inside-git-dir")) - (file-name-directory (magit-file-line "gitdir")) - (magit-toplevel))) - (let ((rev1 (if amending "HEAD^1" "HEAD")) - (rev2 nil)) - ;; Magit may have updated the files without notifying vc, but - ;; `diff-add-log-current-defuns' relies on vc being up-to-date. - (mapc #'vc-file-clearprops (magit-staged-files)) - (change-log-insert-entries - (with-temp-buffer - (vc-git-command (current-buffer) 1 nil - "diff-index" "--exit-code" "--patch" - (and (magit-anything-staged-p) "--cached") - rev1 "--") - ;; `diff-find-source-location' consults these vars. - (defvar diff-vc-revisions) - (setq-local diff-vc-revisions (list rev1 rev2)) - (setq-local diff-vc-backend 'Git) - (diff-add-log-current-defuns))))) + (cond + ((and (fboundp 'change-log-insert-entries) + (fboundp 'diff-add-log-current-defuns)) + (setq default-directory + (if (and (file-regular-p "gitdir") + (not (magit-git-true "rev-parse" "--is-inside-work-tree")) + (magit-git-true "rev-parse" "--is-inside-git-dir")) + (file-name-directory (magit-file-line "gitdir")) + (magit-toplevel))) + (let ((rev1 (if amending "HEAD^1" "HEAD")) + (rev2 nil)) + ;; Magit may have updated the files without notifying vc, but + ;; `diff-add-log-current-defuns' relies on vc being up-to-date. + (mapc #'vc-file-clearprops (magit-staged-files)) + (change-log-insert-entries + (with-temp-buffer + (vc-git-command (current-buffer) 1 nil + "diff-index" "--exit-code" "--patch" + (and (magit-anything-staged-p) "--cached") + rev1 "--") + ;; `diff-find-source-location' consults these vars. + (defvar diff-vc-revisions) + (setq-local diff-vc-revisions (list rev1 rev2)) + (setq-local diff-vc-backend 'Git) + (diff-add-log-current-defuns))))) + (t (user-error "`magit-generate-changelog' requires Emacs 27 or greater")))) ;;;###autoload (defun magit-add-change-log-entry (&optional whoami file-name other-window) diff --git a/lisp/magit-process.el b/lisp/magit-process.el index ef9a8ce79f..619bd089a0 100644 --- a/lisp/magit-process.el +++ b/lisp/magit-process.el @@ -40,9 +40,6 @@ (require 'ansi-color) (require 'with-editor) -(declare-function auth-source-search "auth-source" - (&rest spec &key max require create delete &allow-other-keys)) - ;;; Options (defcustom magit-process-connection-type (not (eq system-type 'cygwin)) @@ -838,7 +835,8 @@ be translated on the fly by doing this once [1]: https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token." (require 'auth-source) - (and (string-match "\\`\\(.+\\)@\\([^@]+\\)\\'" key) + (and (fboundp 'auth-source-search) + (string-match "\\`\\(.+\\)@\\([^@]+\\)\\'" key) (let* ((user (match-string 1 key)) (host (match-string 2 key)) (secret