Grzegorz,

> In mean time i've made a hack which is "fixing" this hack:
>
> open(my $NULL, '>', '/dev/null');
> my $ORIGINAL_STDOUT = select($NULL);
>
> <... do what you need using System::Command and/or Git::Repository ...>
>
> select($ORIGINAL_STDOUT);
> close($NULL);

Finally getting back to this after several weeks of being distracted
by other things.

After chasing this issue around for a while, I've decided to just give
up on Git::Repository altogether.  It's a shame, because I like it for
certain things, not the least of which is that I can give it any
subdir in the repo and it can tell me where the repo root is.
However, it looks like most of the Git plugins for Dist::Zilla use
Git::Wrapper instead, and that means that I'm going to be loading that
anyway, so I suppose I may as well use it.  The advantages that
Git::Repository brings to the table in terms of interface are sort of
crushed by the fact that, well, it just doesn't work. :-(

So, my immediate need (a test to see if a certain directory is part of
a Git working copy) can be scratched thus:

    lives_ok { Git::Wrapper->new( $dir )->show('HEAD') } "$dir is part
of a Git repo's working copy";

Notice that Git::Wrapper doesn't detect the bogus dir until you
actually _do_ something with it, which is a disadvantage, but at least
it doesn't disable stdout/stderr redirection for the remainder of my
test file.  I chose show('HEAD') as something fairly trivial that
hopefully wouldn't take any time to run and should always succeed on a
working copy; alternate suggestions are welcome.

I'm not sure how I'll determine the root of the working copy using
Git::Wrapper if I need to.  Possibly just try successive parent
directories until one fails and then back up one, although that seems
pretty messy.  We'll see.

Thanx to all for the tips and pointers.


            -- Buddy

Reply via email to