Try to avoid eshell git prompt calls when inside a git directory
Not sure whether this is really the right way to do it.
This commit is contained in:
parent
437ce6daff
commit
263d1af073
|
@ -74,28 +74,35 @@ git repository."
|
||||||
(when (and (not (file-remote-p pwd))
|
(when (and (not (file-remote-p pwd))
|
||||||
(eshell-search-path "git")
|
(eshell-search-path "git")
|
||||||
(setq repo-dir (locate-dominating-file pwd ".git")))
|
(setq repo-dir (locate-dominating-file pwd ".git")))
|
||||||
(save-match-data
|
(if (string-prefix-p (file-truename (file-name-concat repo-dir ".git"))
|
||||||
(let* ((git-branch (string-trim
|
(file-truename pwd))
|
||||||
(shell-command-to-string "git rev-parse --abbrev-ref HEAD")))
|
"GIT_DIR"
|
||||||
(base-dir (file-name-nondirectory (string-trim-right repo-dir "/?")))
|
(save-match-data
|
||||||
(state-list (cl-remove-if #'null
|
(let* ((git-branch (string-trim
|
||||||
(list
|
(shell-command-to-string "git rev-parse --abbrev-ref HEAD")))
|
||||||
(when (file-exists-p (file-name-concat repo-dir ".git" "MERGE_HEAD"))
|
(base-dir (file-name-nondirectory (string-trim-right repo-dir "/?")))
|
||||||
"merge")
|
state-list)
|
||||||
(when (= 1 (call-process "git" nil nil nil
|
|
||||||
"diff" "--no-ext-diff" "--quiet" "--exit-code"))
|
(when (file-exists-p (file-name-concat repo-dir ".git" "MERGE_HEAD"))
|
||||||
"dirty")
|
(push "merge" state-list))
|
||||||
(when (= 1 (call-process "git" nil nil nil
|
|
||||||
"diff" "--no-ext-diff" "--quiet" "--exit-code" "--cached"))
|
(when (= 1 (call-process "git" nil nil nil
|
||||||
"uncommitted")
|
"diff" "--no-ext-diff" "--quiet" "--exit-code"))
|
||||||
(when (with-temp-buffer
|
(push "dirty" state-list))
|
||||||
(and (= 0 (call-process "git" nil t nil
|
|
||||||
"stash" "list"))
|
(when (= 1 (call-process "git" nil nil nil
|
||||||
(not (= 0 (buffer-size)))))
|
"diff" "--no-ext-diff" "--quiet" "--exit-code" "--cached"))
|
||||||
"stash")))))
|
(push "uncommitted" state-list))
|
||||||
(if state-list
|
|
||||||
(format "%s@%s[%s]" git-branch base-dir (apply #'concat (-interpose "|" state-list)))
|
(when (with-temp-buffer
|
||||||
(format "%s@%s" git-branch base-dir)))))))
|
(and (= 0 (call-process "git" nil t nil
|
||||||
|
"stash" "list"))
|
||||||
|
(not (= 0 (buffer-size)))))
|
||||||
|
(push "stash" state-list))
|
||||||
|
|
||||||
|
(if state-list
|
||||||
|
(format "%s@%s[%s]" git-branch base-dir (apply #'concat (-interpose "|" state-list)))
|
||||||
|
(format "%s@%s" git-branch base-dir))))))))
|
||||||
|
|
||||||
(defun eshell/default-prompt-function ()
|
(defun eshell/default-prompt-function ()
|
||||||
"A prompt for eshell of the form
|
"A prompt for eshell of the form
|
||||||
|
|
Loading…
Reference in New Issue