Merge branch 'jk/git-pm-bare-repo-fix'
In Git 2.39, Git.pm stopped working in a bare repository, which has been corrected. * jk/git-pm-bare-repo-fix: Git.pm: use "rev-parse --absolute-git-dir" rather than perl code Git.pm: fix bare repository search with Directory option
This commit is contained in:
14
perl/Git.pm
14
perl/Git.pm
@ -187,7 +187,7 @@ sub repository {
|
|||||||
try {
|
try {
|
||||||
# Note that "--is-bare-repository" must come first, as
|
# Note that "--is-bare-repository" must come first, as
|
||||||
# --git-dir output could contain newlines.
|
# --git-dir output could contain newlines.
|
||||||
$out = $search->command([qw(rev-parse --is-bare-repository --git-dir)],
|
$out = $search->command([qw(rev-parse --is-bare-repository --absolute-git-dir)],
|
||||||
STDERR => 0);
|
STDERR => 0);
|
||||||
} catch Git::Error::Command with {
|
} catch Git::Error::Command with {
|
||||||
throw Error::Simple("fatal: not a git repository: $opts{Directory}");
|
throw Error::Simple("fatal: not a git repository: $opts{Directory}");
|
||||||
@ -196,12 +196,12 @@ sub repository {
|
|||||||
chomp $out;
|
chomp $out;
|
||||||
my ($bare, $dir) = split /\n/, $out, 2;
|
my ($bare, $dir) = split /\n/, $out, 2;
|
||||||
|
|
||||||
require Cwd;
|
# We know this is an absolute path, because we used
|
||||||
if ($bare ne 'true') {
|
# --absolute-git-dir above.
|
||||||
require File::Spec;
|
$opts{Repository} = $dir;
|
||||||
File::Spec->file_name_is_absolute($dir) or $dir = $opts{Directory} . '/' . $dir;
|
|
||||||
$opts{Repository} = Cwd::abs_path($dir);
|
|
||||||
|
|
||||||
|
if ($bare ne 'true') {
|
||||||
|
require Cwd;
|
||||||
# If --git-dir went ok, this shouldn't die either.
|
# If --git-dir went ok, this shouldn't die either.
|
||||||
my $prefix = $search->command_oneline('rev-parse', '--show-prefix');
|
my $prefix = $search->command_oneline('rev-parse', '--show-prefix');
|
||||||
$dir = Cwd::abs_path($opts{Directory}) . '/';
|
$dir = Cwd::abs_path($opts{Directory}) . '/';
|
||||||
@ -214,8 +214,6 @@ sub repository {
|
|||||||
$opts{WorkingCopy} = $dir;
|
$opts{WorkingCopy} = $dir;
|
||||||
$opts{WorkingSubdir} = $prefix;
|
$opts{WorkingSubdir} = $prefix;
|
||||||
|
|
||||||
} else {
|
|
||||||
$opts{Repository} = Cwd::abs_path($dir);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete $opts{Directory};
|
delete $opts{Directory};
|
||||||
|
|||||||
@ -45,7 +45,8 @@ test_expect_success 'set up test repository' '
|
|||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'set up bare repository' '
|
test_expect_success 'set up bare repository' '
|
||||||
git init --bare bare.git
|
git init --bare bare.git &&
|
||||||
|
git -C bare.git --work-tree=. commit --allow-empty -m "bare commit"
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'use t9700/test.pl to test Git.pm' '
|
test_expect_success 'use t9700/test.pl to test Git.pm' '
|
||||||
|
|||||||
@ -147,6 +147,11 @@ close TEMPFILE3;
|
|||||||
unlink $tmpfile3;
|
unlink $tmpfile3;
|
||||||
chdir($abs_repo_dir);
|
chdir($abs_repo_dir);
|
||||||
|
|
||||||
|
# open alternate bare repo
|
||||||
|
my $r4 = Git->repository(Directory => "$abs_repo_dir/bare.git");
|
||||||
|
is($r4->command_oneline(qw(log --format=%s)), "bare commit",
|
||||||
|
"log of bare repo works");
|
||||||
|
|
||||||
# unquoting paths
|
# unquoting paths
|
||||||
is(Git::unquote_path('abc'), 'abc', 'unquote unquoted path');
|
is(Git::unquote_path('abc'), 'abc', 'unquote unquoted path');
|
||||||
is(Git::unquote_path('"abc def"'), 'abc def', 'unquote simple quoted path');
|
is(Git::unquote_path('"abc def"'), 'abc def', 'unquote simple quoted path');
|
||||||
|
|||||||
Reference in New Issue
Block a user