Subject: | "fatal: Not a git repository: $valid_workingcopy\n" under Dist::Zilla::Plugin::@blah |
Hi Philippe,
Thank you for writing Git::Repository. It made App::MediaWiki2Git much
simpler.
The bug in short: Git::Repository->new is not defending itself against
changes to $/ ($INPUT_RECORD_SEPARATOR or $RS).
This causes pathnames based on data returned from "git rev-parse
--gitdir" etc. to have a trailing \n and that trips the sanity check.
This happens when Dist::Zilla::Plugins::GitFmtChanges v0.003 reads
git-log with local $/="\n\n"; then calls DZP:Git::DescribeVersion, which
calls Git::DescribeVersion, which will take advantage of Git::Repository
when installed.
I have only seen the bug triggered with this combination of modules.
The attached file is a hackpatch to my installed copy, which makes the
problem go away but may not be an ideal solution. It also changes the
sanity check error message three ways,
- to make it less like the built-in Git error. This should make
"search for similar error messages in existing bug reports" easier.
- add quotes round the offending data. This makes trailing \n more
obvious.
- show the two values being compared, since this is an A != B error.
Sorry, I didn't stop to think which is Expected and which is Got.
I will also file tickets for these other modules...
I'm sorry I didn't write a test to run under changed $/ , but I'm
already shaving fractal yaks!
Thanks again for your work,
--
Matthew
Subject: | git-rep.diff |
diff --git a/lib/perl5/Git/Repository.pm b/lib/perl5/Git/Repository.pm
index 2a7e3ab..c842e3b 100644
--- a/lib/perl5/Git/Repository.pm
+++ b/lib/perl5/Git/Repository.pm
@@ -11,7 +11,7 @@ use Scalar::Util qw( looks_like_number );
use Git::Repository::Command;
-our $VERSION = '1.22';
+our $VERSION = '1.22001';
# a few simple accessors
for my $attr (qw( git_dir work_tree options )) {
@@ -56,6 +56,7 @@ sub import {
sub new {
my ( $class, @arg ) = @_;
+ local $/ = "\n";
# create the object
my $self = bless {}, $class;
@@ -139,7 +140,7 @@ sub new {
my $gitdir
= eval { _abs_path( $self->run(qw( rev-parse --git-dir )), $cwd ) }
|| '';
- croak "fatal: Not a git repository: $self->{git_dir}"
+ croak "fatal: Cannot find the git repository: '$self->{git_dir}' ne '$gitdir'"
if $self->{git_dir} ne $gitdir;
# put back the ignored option