Subject: Re: [PATCH] test-lib.sh: set PERL5LIB instead of GITPERLLIB

From: Junio C Hamano <[email-masked]>
Date: Sun, 01 Jun 2008 22:17:43 -0700

Lea Wiemann <[email-masked]> writes:

>>> How about [setting PERL5LIB in] test-lib.sh?
>> 
>> Sure, I think that would be sensible.
>
> Actually, GITPERLLIB becomes redundant in that case, so I've simply
> replaced it with PERL5LIB in test-lib.sh.

Sorry, but now you mention it, it comes back to me why we have GITPERLLIB,
why the setting of GITPERLLIB in t/test-lib.sh we already have did not
work, and why my "this on top of yours" was a mere workaround and not a
real fix.

The fact is that Git.pm can be installed in a private path outside of
where people usually install site-perl modules, and the primary Makefile
has this rule to munge our perl scripts:

        $(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl
                $(QUIET_GEN)$(RM) $@ $@+ && \
                INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C perl -s --no-print-directory instlibdir` && \
                sed -e '1{' \
                    -e '	s|#!.*perl|#!$(PERL_PATH_SQ)|' \
                    -e '	h' \
                    -e '	s=.*=use lib (split(/:/, $$ENV{GITPERLLIB} || "@@INSTLIBDIR@@"));=' \
                    -e '	H' \
                    -e '	x' \
                    -e '}' \
                    -e 's|@@INSTLIBDIR@@|'"$$INSTLIBDIR"'|g' \
                    -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
                    $@.perl >$@+ && \
                chmod +x $@+ && \
                mv $@+ $@

so that people do not have to have that path on PERL5LIB in their
environment when they use git (namely, git-send-email and other scripts
that do "use Git").

The real fix to the issue, which is consistent with what 6fcca93 (Use
$GITPERLLIB instead of $RUNNING_GIT_TESTS and centralize @INC munging,
2006-07-03) did, is not touch any of the t/* files (neither my "this on
top of yours", nor the patch I am responding to), but to fix the build
procedure of gitweb/gitweb.perl so that the above script rewriting is also
applied to it.