• M
    perl: command_bidi_pipe() method should set-up git environmens · 48d9e6ae
    Masatake Osanai 提交于
    When command_input_pipe and command_output_pipe are used as a
    method of a Git::repository instance, they eventually call into
    _cmd_exec method that sets up the execution environment such as
    GIT_DIR, GIT_WORK_TREE environment variables and the current
    working directory in the child process that interacts with the
    repository.
    
    command_bidi_pipe however didn't expect to be called as such, and
    lacked all these set-up.  Because of this, a program that did this
    did not work as expected:
    
        my $repo = Git->repository(Directory => '/some/where/else');
        my ($pid, $in, $out, $ctx) =
        $repo->command_bidi_pipe(qw(hash-object -w --stdin-paths));
    
    This patch refactors the _cmd_exec into _setup_git_cmd_env that
    sets up the execution environment, and makes _cmd_exec and
    command_bidi_pipe to use it.
    
    Note that unlike _cmd_exec that execv's a git command as an
    external process, command_bidi_pipe is called from the main line
    of control, and the execution environment needs to be restored
    after open2() does its magic.
    Signed-off-by: NMasatake Osanai <unpush@gmail.com>
    Signed-off-by: NJunio C Hamano <gitster@pobox.com>
    48d9e6ae
Git.pm 35.4 KB