File tree Expand file tree Collapse file tree 3 files changed +46
-1
lines changed Expand file tree Collapse file tree 3 files changed +46
-1
lines changed Original file line number Diff line number Diff line change @@ -1942,7 +1942,7 @@ sub validate_patch {
19421942 my ($fn , $xfer_encoding ) = @_ ;
19431943
19441944 if ($repo ) {
1945- my $validate_hook = catfile(catdir( $repo -> repo_path(), ' hooks ' ),
1945+ my $validate_hook = catfile($repo -> hooks_path( ),
19461946 ' sendemail-validate' );
19471947 my $hook_error ;
19481948 if (-x $validate_hook ) {
Original file line number Diff line number Diff line change @@ -619,6 +619,19 @@ Return path to the git repository. Must be called on a repository instance.
619619
620620sub 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+ }
622635
623636=item wc_path ()
624637
Original file line number Diff line number Diff line change 513513
514514done
515515
516+ test_expect_success $PREREQ " --validate respects relative core.hooksPath path" '
517+ clean_fake_sendmail &&
518+ mkdir my-hooks &&
519+ test_when_finished "rm my-hooks.ran" &&
520+ write_script my-hooks/sendemail-validate <<-\EOF &&
521+ >my-hooks.ran
522+ exit 1
523+ EOF
524+ test_config core.hooksPath "my-hooks" &&
525+ test_must_fail git send-email \
526+ --from="Example <nobody@example.com>" \
527+ --to=nobody@example.com \
528+ --smtp-server="$(pwd)/fake.sendmail" \
529+ --validate \
530+ longline.patch 2>err &&
531+ test_path_is_file my-hooks.ran &&
532+ grep "rejected by sendemail-validate" err
533+ '
534+
535+ test_expect_success $PREREQ " --validate respects absolute core.hooksPath path" '
536+ test_config core.hooksPath "$(pwd)/my-hooks" &&
537+ test_when_finished "rm my-hooks.ran" &&
538+ test_must_fail git send-email \
539+ --from="Example <nobody@example.com>" \
540+ --to=nobody@example.com \
541+ --smtp-server="$(pwd)/fake.sendmail" \
542+ --validate \
543+ longline.patch 2>err &&
544+ test_path_is_file my-hooks.ran &&
545+ grep "rejected by sendemail-validate" err
546+ '
547+
516548for enc in 7bit 8bit quoted-printable base64
517549do
518550 test_expect_success $PREREQ " --transfer-encoding=$enc produces correct header" '
You can’t perform that action at this time.
0 commit comments