threads / patch / 26421

patchmore portable absolute dir check in Git.pm

Subject: [PATCH] more portable absolute dir check in Git.pm

## tl;dr

2 messages between Feb 5, 2011 and Feb 6, 2011. Diffs are folded; open one to read it.

replies: 1people: 2as markdown or json

Rafael Kitover· Feb 5, 2011, 16:19 UTC · lore

I was trying to get msysGit to work with activeperl. I'm not sure how far I got, I will revisit this problem in the future, but here is a patch.

It removes a problematic make fragment that doesn't work on nmake (and probably dmake as well.) As well as a better absolute dir check in Git.pm .

>From 49f6d63f760d8b0b6988ce8cf4ed175965c3bf4b Mon Sep 17 00:00:00 2001
From: Rafael Kitover <rkitover@cpan.org>
Date: Sat, 5 Feb 2011 11:13:31 -0500
Subject: [PATCH] more portable absolute dir check in Git.pm
---
 perl/Git.pm      |    4 +++-
 perl/Makefile.PL |    7 ++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)
Show changes to 2 files +9 −2

perl/Git.pm, perl/Makefile.PL

diff --git a/perl/Git.pm b/perl/Git.pm
index 6cb0dd1..dee06e1 100644
--- a/perl/Git.pm
+++ b/perl/Git.pm
@@ -101,6 +101,7 @@ use Error qw(:try);
 use Cwd qw(abs_path);
 use IPC::Open2 qw(open2);
 use Fcntl qw(SEEK_SET SEEK_CUR);
+use File::Spec ();
 }
 
 
@@ -184,7 +185,8 @@ sub repository {
 		};
 
 		if ($dir) {
-			$dir =~ m#^/# or $dir = $opts{Directory} . '/' . $dir;
+                        File::Spec->file_name_is_absolute($dir)
+				or $dir = $opts{Directory} . '/' . $dir;
 			$opts{Repository} = abs_path($dir);
 
 			# If --git-dir went ok, this shouldn't die either.
diff --git a/perl/Makefile.PL b/perl/Makefile.PL
index 0b9deca..7ceec50 100644
--- a/perl/Makefile.PL
+++ b/perl/Makefile.PL
@@ -1,10 +1,13 @@
 use ExtUtils::MakeMaker;
 
 sub MY::postamble {
-	return <<'MAKE_FRAG';
+	my $make_frag = <<'MAKE_FRAG';
 instlibdir:
 	@echo '$(INSTALLSITELIB)'
 
+MAKE_FRAG
+
+	$make_frag .= <<'MAKE_FRAG' if $^O ne 'MSWin32';
 ifneq (,$(DESTDIR))
 ifeq (0,$(shell expr '$(MM_VERSION)' '>' 6.10))
 $(error ExtUtils::MakeMaker version "$(MM_VERSION)" is older than 6.11 and so \
@@ -14,6 +17,8 @@ endif
 endif
 
 MAKE_FRAG
+
+	return $make_frag;
 }
 
 my %pm = ('Git.pm' => '$(INST_LIBDIR)/Git.pm');
-- 
1.7.3.1
Erik Faye-Lund· Feb 6, 2011, 22:32 UTC · re: Rafael Kitover · lore

Re: [PATCH] more portable absolute dir check in Git.pm

On Sat, Feb 5, 2011 at 5:19 PM, Rafael Kitover <rkitover@io.com> wrote:
Show 6 quoted lines
> I was trying to get msysGit to work with activeperl. I'm not sure how far I
> got, I will revisit this problem in the future, but here is a patch.
>
> It removes a problematic make fragment that doesn't work on nmake (and
> probably dmake as well.) As well as a better absolute dir check in Git.pm .
>
Please read Documentation/SubmittingPatches. In particlar:
- We use inline patches on the mailing-list. git send-email can send
these for you.
- Your patch lacks a sign-off.

Other than that, interesting. But I think the make_frag-changes needs an explanation.

← back to recent threads