CC: | druoso [...] bloomberg.net |
Subject: | Use rev-parse --show-toplevel when computing work_tree |
Date: | Fri, 14 Aug 2015 14:18:56 -0000 |
To: | bug-Git-Repository [...] rt.cpan.org |
From: | "Mike Seplowitz (BLOOMBERG/ 731 LEX)" <mseplowitz [...] bloomberg.net> |
While using some git workareas in an unorthodox configuration, we encountered a problem in using Git::Repository.
https://metacpan.org/source/BOOK/Git-Repository-1.315/lib/Git/Repository.pm
line 124:
# in a non-bare repository, the work tree is just above the gitdir
if ( $self->run(qw( config --bool core.bare )) ne 'true' ) {
$self->{work_tree}
= _abs_path( File::Spec->updir, $self->{git_dir} );
}
The assumption that the work tree is directly above the gitdir doesn't hold true in our case. We're using git repos that have the setting core.worktree = ../.. in the repo's config.
We propose that using 'git rev-parse --show-toplevel' to compute the work tree would be more reliable:
$self->{work_tree} = Git::Repository->run( qw( rev-parse --show-toplevel ),
{ %$options, cwd => $cwd } );
Thanks for your consideration.