diff options
| author | Kyle Meyer <kyle@kyleam.com> | 2022-11-09 22:17:20 -0500 |
|---|---|---|
| committer | Kyle Meyer <kyle@kyleam.com> | 2022-11-13 17:21:17 -0500 |
| commit | 05b0d99d714350d51676b86da9f5daa2f6b7fa3e (patch) | |
| tree | b75ae37e3149baec983e3996f6f29e97fc196940 | |
| parent | 36059e0b881cb1465cb5ad0099e55e00845a8222 (diff) | |
Consider Git's exec path when searching for extensions
Commands that depend on optional third-party Git extensions use
executable-find to check whether the extension is available. That
misses the legitimate case where an extension is installed in Git's
exec path rather than a directory in $PATH.
Update these spots to call a new helper that looks in Git's exec path
before calling executable-find. Note that the order is chosen to
follow Git's precedence (though that doesn't matter for any of the
current callers because they don't use the return value).
Closes #4812.
| -rw-r--r-- | docs/RelNotes/3.4.0.org | 4 | ||||
| -rw-r--r-- | lisp/magit-commit.el | 4 | ||||
| -rw-r--r-- | lisp/magit-git.el | 13 | ||||
| -rw-r--r-- | lisp/magit-log.el | 2 |
4 files changed, 20 insertions, 3 deletions
diff --git a/docs/RelNotes/3.4.0.org b/docs/RelNotes/3.4.0.org index 42ea3fa..9169af1 100644 --- a/docs/RelNotes/3.4.0.org +++ b/docs/RelNotes/3.4.0.org @@ -174,6 +174,10 @@ b1ad283941 #4526 magit-version: more compatible fix for #4511 - A diff header added in a new Git release wasn't handled yet. #4531 +- Commands that use optional third-party Git extensions didn't + consider that extension executables may be installed in Git's exec + path instead of a directory in ~exec-path~. #4812 + - Fixed calculation of gravatar image size. ecfaa325a3 a14f847d97 magit-branch-checkout: Refresh after all configuration took place diff --git a/lisp/magit-commit.el b/lisp/magit-commit.el index c852065..03be34b 100644 --- a/lisp/magit-commit.el +++ b/lisp/magit-commit.el @@ -463,7 +463,7 @@ See `magit-commit-autofixup' for an alternative implementation." (transient-args 'magit-commit-absorb)))) (if (eq phase 'transient) (transient-setup 'magit-commit-absorb) - (unless (compat-executable-find "git-absorb" t) + (unless (magit-git-executable-find "git-absorb") (user-error "This command requires the git-absorb executable, which %s" "is available from https://github.com/tummychow/git-absorb")) (unless (magit-anything-staged-p) @@ -506,7 +506,7 @@ See `magit-commit-absorb' for an alternative implementation." (transient-args 'magit-commit-autofixup)))) (if (eq phase 'transient) (transient-setup 'magit-commit-autofixup) - (unless (compat-executable-find "git-autofixup" t) + (unless (magit-git-executable-find "git-autofixup") (user-error "This command requires the git-autofixup script, which %s" "is available from https://github.com/torbiak/git-autofixup")) (unless (magit-anything-modified-p) diff --git a/lisp/magit-git.el b/lisp/magit-git.el index 641bbc3..502b5f0 100644 --- a/lisp/magit-git.el +++ b/lisp/magit-git.el @@ -582,6 +582,19 @@ call function WASHER with ARGS as its sole argument." (magit-cancel-section)) (magit-maybe-make-margin-overlay)))) +(defun magit-git-executable-find (command) + "Search for COMMAND in Git's exec path, falling back to `exec-path'. +Like `executable-find', return the absolute file name of the +executable." + (or (locate-file command + (list (concat + (file-remote-p default-directory) + (or (magit-git-string "--exec-path") + (error "`git --exec-path' failed")))) + exec-suffixes + #'file-executable-p) + (compat-executable-find command t))) + ;;; Git Version (defconst magit--git-version-regexp diff --git a/lisp/magit-log.el b/lisp/magit-log.el index 95290d5..eac0536 100644 --- a/lisp/magit-log.el +++ b/lisp/magit-log.el @@ -826,7 +826,7 @@ https://github.com/mhagger/git-when-merged." (list commit (magit-read-other-branch "Merged into" commit))) (magit-log-arguments))) - (unless (compat-executable-find "git-when-merged" t) + (unless (magit-git-executable-find "git-when-merged") (user-error "This command requires git-when-merged (%s)" "https://github.com/mhagger/git-when-merged")) (let (exit m) |
