Skip to content

Commit f4d715b

Browse files
committed
Merge branch 'ab/send-email-inline-hooks-path'
Code simplification. * ab/send-email-inline-hooks-path: send-email: move "hooks_path" invocation to git-send-email.perl send-email: don't needlessly abs_path() the core.hooksPath
2 parents 1accb34 + 7cbc045 commit f4d715b

File tree

3 files changed

+6
-17
lines changed

3 files changed

+6
-17
lines changed

git-send-email.perl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1959,7 +1959,8 @@ sub validate_patch {
19591959
my ($fn, $xfer_encoding) = @_;
19601960

19611961
if ($repo) {
1962-
my $validate_hook = catfile($repo->hooks_path(),
1962+
my $hooks_path = $repo->command_oneline('rev-parse', '--git-path', 'hooks');
1963+
my $validate_hook = catfile($hooks_path,
19631964
'sendemail-validate');
19641965
my $hook_error;
19651966
if (-x $validate_hook) {

perl/Git.pm

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -619,19 +619,6 @@ Return path to the git repository. Must be called on a repository instance.
619619

620620
sub repo_path { $_[0]->{opts}->{Repository} }
621621

622-
=item hooks_path ()
623-
624-
Return path to the hooks directory. Must be called on a repository instance.
625-
626-
=cut
627-
628-
sub hooks_path {
629-
my ($self) = @_;
630-
631-
my $dir = $self->command_oneline('rev-parse', '--git-path', 'hooks');
632-
my $abs = abs_path($dir);
633-
return $abs;
634-
}
635622

636623
=item wc_path ()
637624

t/t9001-send-email.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -539,14 +539,15 @@ test_expect_success $PREREQ "--validate respects relative core.hooksPath path" '
539539
test_path_is_file my-hooks.ran &&
540540
cat >expect <<-EOF &&
541541
fatal: longline.patch: rejected by sendemail-validate hook
542-
fatal: command '"'"'$PWD/my-hooks/sendemail-validate'"'"' died with exit code 1
542+
fatal: command '"'"'my-hooks/sendemail-validate'"'"' died with exit code 1
543543
warning: no patches were sent
544544
EOF
545545
test_cmp expect actual
546546
'
547547

548548
test_expect_success $PREREQ "--validate respects absolute core.hooksPath path" '
549-
test_config core.hooksPath "$(pwd)/my-hooks" &&
549+
hooks_path="$(pwd)/my-hooks" &&
550+
test_config core.hooksPath "$hooks_path" &&
550551
test_when_finished "rm my-hooks.ran" &&
551552
test_must_fail git send-email \
552553
--from="Example <[email protected]>" \
@@ -557,7 +558,7 @@ test_expect_success $PREREQ "--validate respects absolute core.hooksPath path" '
557558
test_path_is_file my-hooks.ran &&
558559
cat >expect <<-EOF &&
559560
fatal: longline.patch: rejected by sendemail-validate hook
560-
fatal: command '"'"'$PWD/my-hooks/sendemail-validate'"'"' died with exit code 1
561+
fatal: command '"'"'$hooks_path/sendemail-validate'"'"' died with exit code 1
561562
warning: no patches were sent
562563
EOF
563564
test_cmp expect actual

0 commit comments

Comments
 (0)