diff options
author | Junio C Hamano <gitster@pobox.com> | 2022-10-28 21:26:54 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-10-28 21:26:54 +0300 |
commit | 330135ac8163c822934c92ac363bd14cd23e1e13 (patch) | |
tree | 261bea7995d84d5e3d10a44cafd47d6a2b7c5ada /t | |
parent | c5dd7773e138d4b41074d4c6a193651cc187ec1d (diff) | |
parent | 20da61f25f8f61a2b581b60f8820ad6116f88e6f (diff) |
Merge branch 'mm/git-pm-try-catch-syntax-fix'
Fix a longstanding syntax error in Git.pm error codepath.
* mm/git-pm-try-catch-syntax-fix:
Git.pm: trust rev-parse to find bare repositories
Git.pm: add semicolon after catch statement
Diffstat (limited to 't')
-rwxr-xr-x | t/t9700-perl-git.sh | 4 | ||||
-rwxr-xr-x | t/t9700/test.pl | 12 |
2 files changed, 16 insertions, 0 deletions
diff --git a/t/t9700-perl-git.sh b/t/t9700-perl-git.sh index 4aa5d90d328..b105d6d9d57 100755 --- a/t/t9700-perl-git.sh +++ b/t/t9700-perl-git.sh @@ -45,6 +45,10 @@ test_expect_success \ git config --add test.pathmulti bar ' +test_expect_success 'set up bare repository' ' + git init --bare bare.git +' + test_expect_success 'use t9700/test.pl to test Git.pm' ' "$PERL_PATH" "$TEST_DIRECTORY"/t9700/test.pl 2>stderr && test_must_be_empty stderr diff --git a/t/t9700/test.pl b/t/t9700/test.pl index e046f7db762..6d753708d2a 100755 --- a/t/t9700/test.pl +++ b/t/t9700/test.pl @@ -30,6 +30,18 @@ BEGIN { use_ok('Git') } # set up our $abs_repo_dir = cwd(); ok(our $r = Git->repository(Directory => "."), "open repository"); +{ + local $ENV{GIT_TEST_ASSUME_DIFFERENT_OWNER} = 1; + my $failed; + + $failed = eval { Git->repository(Directory => $abs_repo_dir) }; + ok(!$failed, "reject unsafe non-bare repository"); + like($@, qr/not a git repository/i, "unsafe error message"); + + $failed = eval { Git->repository(Directory => "$abs_repo_dir/bare.git") }; + ok(!$failed, "reject unsafe bare repository"); + like($@, qr/not a git repository/i, "unsafe error message"); +} # config is($r->config("test.string"), "value", "config scalar: string"); |