Make it possible to write subclasses of Git.pm Signed-off-by: Christian Jaeger <christian@xxxxxxxxxxxxxx> --- I don't really know what the reason for the _maybe_self behaviour was; I'm hoping this fix doesn't break anything, I haven't run any tests with it except with my own code; the fix works on the assumptions that if an object does indeed have Git.pm in it's ancestry, _maybe_self should work just as if the object is a 'Git' object without inheritance. I'm currently using the following hack to make my scripts be able to inherit from a non-patched Git.pm: I inherit instead from a wrapper around Git.pm which inherits from and patches the latter at runtime using this code: if (do { my @res= Git::_maybe_self ( (bless {}, __PACKAGE__) ); not $res[0] }) { #warn "patching Git.pm";# no warnings; *Git::_maybe_self= sub { UNIVERSAL::isa($_[0], 'Git') ? @_ : (undef, @_); } } While this currently works, a proper fix would of course be preferable (like: when in the future will the above hack break?..). perl/Git.pm | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/perl/Git.pm b/perl/Git.pm index 6aab712..ba94453 100644 --- a/perl/Git.pm +++ b/perl/Git.pm @@ -1203,8 +1203,7 @@ either version 2, or (at your option) any later version. # the method was called upon an instance and (undef, @args) if # it was called directly. sub _maybe_self { - # This breaks inheritance. Oh well. - ref $_[0] eq 'Git' ? @_ : (undef, @_); + UNIVERSAL::isa($_[0], 'Git') ? @_ : (undef, @_); } # Check if the command id is something reasonable. -- 1.6.0.2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html