Skip to content
  • Johannes Sixt's avatar
    Propagate --exec-path setting to external commands via GIT_EXEC_PATH · c90d565a
    Johannes Sixt authored and Junio C Hamano's avatar Junio C Hamano committed
    
    
    Let PATH0=$PATH that was set before the invocation.
    Let /foo be a build directory.
    Let /pfx be the installation prefix.
    Let pfxexecpath=/pfx/libexec/git-core.
    
    The following is going on when 'git --exec-path=/foo gc' is invoked:
    
    1. git sets PATH=/foo:$PATH0 using the path from --exec-path
    
    2. gc execs 'git repack' (note: no dash).
    
    3. Since there is a git in /foo (it's a build directory), /foo/git is
       taken.
    
    4. No explicit exec-path is set this time, hence, this secondary git sets
       PATH=$pfxexecpath:/foo:$PATH
    
    5. Since 'repack' is not a built-in, execv_dashed_external execs
       'git-repack' (note: dash).
    
    6. There is a $pfxexecpath/git-repack, and it is taken.
    
    7. This git-repack runs 'git pack-objects' (note: no dash).
    
    8. There is no git in $pfxexecpath, but there is one in /foo. Hence,
       /foo/git is run.
    
    9. pack-objects is a builtin, hence, in effect /foo/git-pack-objects
       is run.
    
    As you can see, the way in which we previously set the PATH allowed to
    mix gits of different vintage.  By setting GIT_EXEC_PATH when --exec-path
    was given on the command line, we reduce the confusion.
    
    Signed-off-by: default avatarJohannes Sixt <j6t@kdbg.org>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    c90d565a