summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xPorting/cmpVERSION.pl20
-rw-r--r--t/test.pl2
2 files changed, 19 insertions, 3 deletions
diff --git a/Porting/cmpVERSION.pl b/Porting/cmpVERSION.pl
index 4da97e919f..8e083b502b 100755
--- a/Porting/cmpVERSION.pl
+++ b/Porting/cmpVERSION.pl
@@ -31,8 +31,24 @@ unless (GetOptions('diffs' => \$diffs,
die "$0: This does not look like a Perl directory\n"
unless -f "perl.h" && -d "Porting";
-die "$0: 'This is a Perl directory but does not look like Git working directory\n"
- unless (-d ".git" || (exists $ENV{GIT_DIR} && -d $ENV{GIT_DIR}));
+
+if (-d ".git" || (exists $ENV{GIT_DIR} && -d $ENV{GIT_DIR})) {
+ # Looks good
+} else {
+ # Also handle linked worktrees created by git-worktree:
+ my $found;
+ if (-f '.git') {
+ my $commit = '8d063cd8450e59ea1c611a2f4f5a21059a2804f1';
+ my $out = `git rev-parse --verify --quiet '$commit^{commit}'`;
+ chomp $out;
+ if($out eq $commit) {
+ ++$found;
+ }
+ }
+
+ die "$0: This is a Perl directory but does not look like Git working directory\n"
+ unless $found;
+}
my $null = devnull();
diff --git a/t/test.pl b/t/test.pl
index 945ad20702..c8f1bd38cc 100644
--- a/t/test.pl
+++ b/t/test.pl
@@ -203,7 +203,7 @@ sub find_git_or_skip {
}
$source_dir = $where;
}
- } elsif (exists $ENV{GIT_DIR}) {
+ } elsif (exists $ENV{GIT_DIR} || -f '.git') {
my $commit = '8d063cd8450e59ea1c611a2f4f5a21059a2804f1';
my $out = `git rev-parse --verify --quiet '$commit^{commit}'`;
chomp $out;