From: Junio C Hamano Date: Tue, 14 Apr 2015 17:17:26 GMT Subject: Re: PATH modifications for git-hook processes Message-ID: In-Reply-To: Matthew Rothenberg writes: > - what is the expected PATH modification behavior for subprocesses of > git-hooks? Is this documented anywhere? > - what would be causing /usr/local/bin to be prepended here, and can > it be adjusted via preference? This is not limited to hooks and very much deliberate, I think. In order to make sure anything that is called from "git" wrapper gets picked up from GIT_EXEC_PATH so that the matching version of the git subprogram is used, "git " does this before running "git-" (in git.c): /* * We use PATH to find git commands, but we prepend some higher * precedence paths: the "--exec-path" option, the GIT_EXEC_PATH * environment, and the $(gitexecdir) from the Makefile at build * time. */ setup_path(); And setup_path() is defined in exec_cmd.c to start the new PATH with git-exec-path, and then the path to the running "git" itself, and then finally the external PATH.