On Wed, Jun 19, 2013 at 07:10:21PM -0400, Daniel B. Boorstein via RT wrote:
Show quoted text> Queue: Git-Repository
> Ticket <URL:
https://rt.cpan.org/Ticket/Display.html?id=86154 >
>
> On Wed Jun 19 18:18:14 2013, BOOK wrote:
> > Not sure what you mean by "work-tree" discovery.
>
> I'm by no means a git expert, so my terminology and understanding may be off.
> I just mean that in the case of:
>
> cd deep/
> git add file.txt
>
> git walks up the directory tree to find the working root of my repository. I
> don't have to tell it to chdir or provide a path relative to the root. My
> point was that if git can already do this, why chdir before invoking git? Not
> trying to question the choice, I just don't understand the history and
> reasoning yet.
First of all, the use cases (interactive shell usage vs. standalone program)
are very different. A user usually has a sense of where he is, while a
program deals with paths that may come from anywhere. The logical base for
relative paths in this context is the work tree.
I remember dealing with git commands that wanted a path relative to the
root of the work tree, no matter what the current workding was. The only
issue is that I can't remember the command-name, nor could I find it the
docs. So maybe I mis-remember.
Also, Git::Repository is designed to make it easy to work with several
repositories at the same time, at which point it's probably better to
not have to worry about where the current directory points to.
Show quoted text> > I'm wondering if it would be worth adding support for a coderef or
> > just make a special case to mean Cwd::getcwd, so that option could be
> > given to new(), instead of being passed to every command.
>
> Those could work. Or to avoid system calls, just allow it to be explicitly disabled with a boolean option like:
>
> { chdir => 0 } ## default is { chdir => 1 }
>
After checking the code, it turns out that System::Command (the base class
for Git::Repository::Command, which actually runs the git commands) will
not chdir if the cwd option is set to undef.
So you can force the "no chdir" behaviour once and for all by creating
your object like so:
my $r = Git::Repository->new( { cwd => undef } );
And then you do not need to setup the option in every call to run()
or command(). Another thing to add to the docs.
--
Philippe Bruhat (BooK)
The friends we make and the friends we lose are all better than the friends
who want to make us lose. (Moral from Groo The Wanderer #1 (Pacific))