summaryrefslogtreecommitdiff
path: root/git-send-email.perl
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-06-02 15:05:59 +0900
committerJunio C Hamano <gitster@pobox.com>2017-06-02 15:06:00 +0900
commit8e6a904dd8afedcc0bcfcc4bf4c5f4b2c10edfbf (patch)
treea5edb5b4326539b352792f3397223aa2eaa67556 /git-send-email.perl
parentb85b88141ea102638cd532813767e6f9484b1498 (diff)
parent177409e5897988f03e0c8111c94db6ea0466b138 (diff)
downloadgit-8e6a904dd8afedcc0bcfcc4bf4c5f4b2c10edfbf.tar.gz
Merge branch 'jt/send-email-validate-hook'
A hotfix for a topic already in 'master'. * jt/send-email-validate-hook: send-email: check for repo before invoking hook
Diffstat (limited to 'git-send-email.perl')
-rwxr-xr-xgit-send-email.perl32
1 files changed, 17 insertions, 15 deletions
diff --git a/git-send-email.perl b/git-send-email.perl
index 0168a47649..7fd5874436 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -1755,21 +1755,23 @@ sub unique_email_list {
sub validate_patch {
my $fn = shift;
- my $validate_hook = catfile(catdir($repo->repo_path(), 'hooks'),
- 'sendemail-validate');
- my $hook_error;
- if (-x $validate_hook) {
- my $target = abs_path($fn);
- # The hook needs a correct cwd and GIT_DIR.
- my $cwd_save = cwd();
- chdir($repo->wc_path() or $repo->repo_path())
- or die("chdir: $!");
- local $ENV{"GIT_DIR"} = $repo->repo_path();
- $hook_error = "rejected by sendemail-validate hook"
- if system($validate_hook, $target);
- chdir($cwd_save) or die("chdir: $!");
- }
- return $hook_error if $hook_error;
+ if ($repo) {
+ my $validate_hook = catfile(catdir($repo->repo_path(), 'hooks'),
+ 'sendemail-validate');
+ my $hook_error;
+ if (-x $validate_hook) {
+ my $target = abs_path($fn);
+ # The hook needs a correct cwd and GIT_DIR.
+ my $cwd_save = cwd();
+ chdir($repo->wc_path() or $repo->repo_path())
+ or die("chdir: $!");
+ local $ENV{"GIT_DIR"} = $repo->repo_path();
+ $hook_error = "rejected by sendemail-validate hook"
+ if system($validate_hook, $target);
+ chdir($cwd_save) or die("chdir: $!");
+ }
+ return $hook_error if $hook_error;
+ }
open(my $fh, '<', $fn)
or die sprintf(__("unable to open %s: %s\n"), $fn, $!);