Skip to content

Commit

Permalink
magit-gitk-executable: locate executable at load-time
Browse files Browse the repository at this point in the history
Locate the gitk executable at load-time when setting the default
value of `magit-gitk-executable', instead of doing it every time
`magit-run-gitk' is used.  This builds on a similar hack used
when setting the default value of `magit-git-executable'.
  • Loading branch information
tarsius committed Mar 23, 2014
1 parent a3c077e commit a1fee24
Showing 1 changed file with 9 additions and 33 deletions.
42 changes: 9 additions & 33 deletions magit.el
Expand Up @@ -264,9 +264,15 @@ tramp to connect to servers with ancient Git versions."
:group 'magit-process
:type '(repeat string))

(defcustom magit-gitk-executable (executable-find "gitk")
(defcustom magit-gitk-executable
(or (eq system-type 'windows-nt)
(let ((exe (expand-file-name
"gitk" (file-name-nondirectory magit-git-executable))))
(and (file-executable-p exe) exe))
(executable-find "gitk") "gitk")
"The Gitk executable."
:group 'magit-process
:set-after '(magit-git-executable)
:type 'string)

(defcustom magit-emacsclient-executable
Expand Down Expand Up @@ -7590,38 +7596,8 @@ blame to center around the line point is on."
Without a prefix argument run `gitk --all', with
a prefix argument run gitk without any arguments."
(interactive "P")
(let ((default-directory (magit-get-top-dir)))
(cond
((eq system-type 'windows-nt)
;; Gitk is a shell script, and Windows doesn't know how to
;; "execute" it. The Windows version of Git comes with an
;; implementation of "sh" and everything else it needs, but
;; Windows users might not have added the directory where it's
;; installed to their path
(let* ((git-bin-dir
;; According to #824, when using stand-alone installation
;; Gitk maybe installed in ...cmd or ...bin; while Sh
;; is installed in ...bin.
(expand-file-name "bin"
(file-name-directory
(directory-file-name
(file-name-directory
magit-gitk-executable)))))
;; Adding it onto the end so that anything the user
;; specified will get tried first. Emacs looks in
;; exec-path; PATH is the environment variable inherited by
;; the process. I need to change both.
(exec-path (append exec-path (list git-bin-dir)))
(process-environment process-environment))
(setenv "PATH"
(format "%s;%s"
(getenv "PATH")
(replace-regexp-in-string "/" "\\\\" git-bin-dir)))
(apply #'start-file-process "Gitk" nil "sh" magit-gitk-executable
(if arg nil (list "--all")))))
(t
(apply #'start-file-process "Gitk" nil "sh" magit-gitk-executable
(if arg nil (list "--all")))))))
(apply #'start-file-process "Gitk" nil "sh" magit-gitk-executable
(if arg nil (list "--all"))))

;;;; Maintenance Tools

Expand Down

0 comments on commit a1fee24

Please sign in to comment.