git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Problem with Git.pm bidi_pipe methods

From
Philippe Bruhat (BooK) <philippe.bruhat@free.fr>
Date
Oct 24, 2008, 00:14 UTC
Message-ID
<20081024001446.GE17717@plop>
Hi,

To be able to call commit-tree from a Perl program, I had to use command_bidi_pipe() to pass the message on standard input, and get the new commit id on standard output. The only problem I have is that the method doesn't work (or at least, doesn't work like the other command_... methods).

    sub command_bidi_pipe {
        my ($pid, $in, $out);
        $pid = open2($in, $out, 'git', @_);
        return ($pid, $in, $out, join(' ', @_));
    }

First, it calls git in the current working dir, when all the other command_... methods do the appropriate chdir depending on the Git object.

Second, it can't be used as a method, since $self is not removed from @_ before calling open2, leading to errors such as this one:

    git: 'Git=HASH(0x82f898c)' is not a git-command. See 'git --help'.
Third, no access is given to STDERR (open3 may help).
I'm very sorry to complain without proposing a patch.

I think solving the current directory problem is probably going to be difficult with open2/open3, since open2 does the fork+exec, whereas Git.pm handles the fork+chdir+exec itself for the other command_... methods. And so there is no room to chdir when calling open2.

-- 
 Philippe Bruhat (BooK)

 Treat those you outrank well... you never know when they will outrank you.
                                                 (Moral from Groo #7 (Image))
Next: Christian Jaeger
Message 1 of 3 in “Problem with Git.pm bidi_pipe methods”
  1. Philippe Bruhat (BooK)Oct 24, 2008
  2. Christian JaegerOct 28, 2008
  3. nadim khemirNov 23, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.