Re: packObjectsHook and the git executable
- From
Jeff King <peff@peff.net>
- Date
- Jan 30, 2020, 07:11 UTC
- Message-ID
- <20200130071102.GA2189233@coredump.intra.peff.net>
- In-Reply-To
- <CAGyf7-E==gzsvP-ckK0kwHD+f9pMmLBVpL4y2rC9tqk7ZiuW1g@mail.gmail.com>
On Wed, Jan 29, 2020 at 05:00:18PM -0800, Bryan Turner wrote:
Show 5 quoted lines
> In upload-pack.c, when Git invokes the packObjectsHook, it's > hard-coded to pass "git". Unless it modifies the PATH environment > variable, though, if the script were to invoke the provided command > line as-is, it may end up running a different version of Git than the > version being used to run upload-pack (or http-backend).
We do modify PATH to put git's exec-path at the start. This happens in setup_path(), which is called by the main "git" executable (so "git upload-pack" before it hits cmd_upload_pack()).
Programs which are invoked directly as "git-upload-pack" need to call that function on their own (which happens when upload-pack is invoked over ssh). But upload-pack and http-backend do that.
Show 5 quoted lines
> Is there any way the packObjectsHook could be passed the "right" git > executable? Or am I missing some surrounding context that means > executing "git" is somehow guaranteed to invoke the "right" binary? > (Perhaps this same PATH-related caveat applies to other places where > Git invokes itself recursively?)
I think all is working as designed, but if you have a reproducible case where we run the "wrong" git, I can take a look at it.
-Peff