提交 dbe48256 编写于 作者: C Clifford Caoile 提交者: Junio C Hamano

git.el: Set process-environment instead of invoking env

According to the similar patch from David Kågedal [1], "this will make
it a little less posix-dependent and more efficient." However, there
are two other areas that need to replaced, namely
git-run-command-region and git-run-hooks. This patch implements the
changes of [1] onto those Emacs Lisp functions.

If unpatched, using the git port "msysgit" on Windows will require
defadvice changes as shown at [2] (also explained at 4msysgit.git
[3]).

I have tested git-run-command-region on msysgit, because this is
always called by git-commit (via git-commit-tree <- git-do-commit <-
git-commit-file). However, I could not test git-run-hooks because it
currently does not work on the Emacs Windows port. The latter reports
the hooks files as a+rw and a-x, despite msysgit and cygwin chmod
setting on the respective files.

References:
[1] f27e5586
[2] http://groups.google.com/group/msysgit/browse_thread/thread/b852fef689817707
[3] http://repo.or.cz/w/git/mingw/4msysgit.git?a=commit;h=3c30e5e87358eba7b6d7dcd6301ae8438f0c30eaSigned-off-by: NClifford Caoile <piyo@users.sourceforge.net>
Acked-by: NDavid Kågedal <davidk@lysator.liu.se>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 5909ca92
......@@ -232,10 +232,8 @@ and returns the process output as a string, or nil if the git failed."
(defun git-run-command-region (buffer start end env &rest args)
"Run a git command with specified buffer region as input."
(unless (eq 0 (if env
(git-run-process-region
buffer start end "env"
(append (git-get-env-strings env) (list "git") args))
(unless (eq 0 (let ((process-environment (append (git-get-env-strings env)
process-environment)))
(git-run-process-region
buffer start end "git" args)))
(error "Failed to run \"git %s\":\n%s" (mapconcat (lambda (x) x) args " ") (buffer-string))))
......@@ -250,9 +248,8 @@ and returns the process output as a string, or nil if the git failed."
(erase-buffer)
(cd dir)
(setq status
(if env
(apply #'call-process "env" nil (list buffer t) nil
(append (git-get-env-strings env) (list hook-name) args))
(let ((process-environment (append (git-get-env-strings env)
process-environment)))
(apply #'call-process hook-name nil (list buffer t) nil args))))
(display-message-or-buffer buffer)
(eq 0 status)))))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册