public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox•com>
To: Matthew Rothenberg <mroth@khanacademy•org>
Cc: git@vger•kernel.org
Subject: Re: PATH modifications for git-hook processes
Date: Tue, 14 Apr 2015 10:17:26 -0700	[thread overview]
Message-ID: <xmqqk2xe39zt.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <CAKuTQSGEmHHr-c+Tc2jM-JPkx6+_f3gp8Zjj8EuQy_e4=PvMzg@mail.gmail.com> (Matthew Rothenberg's message of "Tue, 14 Apr 2015 12:04:25 -0400")

Matthew Rothenberg <mroth@khanacademy•org> 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 <cmd>" does this before running "git-<cmd>"
(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.

  reply	other threads:[~2015-04-14 17:17 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-14 16:04 PATH modifications for git-hook processes Matthew Rothenberg
2015-04-14 17:17 ` Junio C Hamano [this message]
2015-04-15 15:00   ` Matthew Rothenberg
2015-04-16  6:17     ` Jeff King
2015-04-16  6:31       ` Jeff King
2015-04-22  0:39       ` David Rodríguez
2015-04-22 17:46       ` Junio C Hamano
2015-04-22 18:14         ` [PATCH] stop putting argv[0] dirname at front of PATH Jeff King
2015-04-22 18:23           ` Eric Sunshine
2015-04-22 18:36             ` Jeff King
2015-04-22 19:23           ` Jonathan Nieder
2015-04-22 20:00             ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqk2xe39zt.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=mroth@khanacademy$(echo .)org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox