Dear diary, on Wed, Jun 28, 2006 at 12:05:03PM CEST, I got a letter
where Pavel Roskin [off-list ref] said that...
quoted hunk ↗ jump to hunk
I think the BEGIN block has priority over other statements. My solution
was to put the @INC change in the BEGIN block as well.
This patch is working for me:
diff --git a/git-fmt-merge-msg.perl b/git-fmt-merge-msg.perl
index e8fad02..1b23fa1 100755
--- a/git-fmt-merge-msg.perl
+++ b/git-fmt-merge-msg.perl
@@ -5,7 +5,7 @@ #
# Read .git/FETCH_HEAD and make a human readable merge message
# by grouping branches and tags together to form a single line.
-unshift @INC, '@@INSTLIBDIR@@';
+BEGIN { unshift @INC, '@@INSTLIBDIR@@'; }
use strict;
use Git;
use Error qw(:try);
I feel that it is time for another stupid question of mine - why can't
you just use lib?
use lib ('@@INSTLIBDIR@@');
Looks a lot better than some @INC unshifting, and it should be
equivalent.
Let's pour in to the confusion:
The unshifting was introduced w/o BEGIN{} in
From: Junio C Hamano [off-list ref]
Subject: Re: [PATCH 01/12] Introduce Git.pm (v4)
Date: Sat, 24 Jun 2006 04:57:31 -0700
but that patch is not in pu anymore while the description of the new
patch implicitly refers to it, which made it all a bit confusing.
So the purpose of the original patch was to make it play nicely with
$PERLLIB, but unshifting helps nothing, since:
There's default @INC
Perl spots PERLLIB and unshifts @INC
We then unshift @INC too, taking precedence
So didn't the original patch rather want to do push?
$ PERL5LIB=perl perl -le "BEGIN { unshift @INC, '/home/xpasky/lib/perl5/site_perl/5.8.8/i686-linux'; } use Git; print Git::hash_object('blob','Makefile');"
17842a3657ae8e5b4fd3ddfeb69268a4b94cb97a
$ PERL5LIB=perl perl -le "use Git; print Git::hash_object('blob','Makefile');"
syntax error at perl/Git.pm line 44, near "h>"
(after inserting random junk to perl/Git.pm)
--
Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
Snow falling on Perl. White noise covering line noise.
Hides all the bugs too. -- J. Putnam