Re: [PATCH v2 2/4] git-send-email: refactor duplicate $? checks into a function
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Apr 8, 2021, 22:43 UTC
- Message-ID
- <xmqqpmz4qtxi.fsf@gitster.g>
- In-Reply-To
- <xmqqft0447lu.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 9 quoted lines
> One big thing that is different between this version and the one in > Emily's "config hook" topic is that this is still limited to the > case where $repo exists. In the new world order, it will not matter > in what directory the command runs, as long as "git hook" finds the > hook, and details of the invocation is hidden behind the command. > > I presume that Emily's series is expected to be updated soonish? > Please figure out who to go first and other details to work well > together between you two.
Since I didn't hear from either of you, I'll queue with this possibly bogus conflict resolution for now.
Thanks.
diff --cc git-send-email.perl
index 175da07d94,73e1e0b51a..0000000000
--- i/git-send-email.perl
+++ w/git-send-email.perl
@@@ -1947,27 -1940,11 +1947,13 @@@ sub unique_email_list
sub validate_patch {
my ($fn, $xfer_encoding) = @_;
--
- if ($repo) {
- my $validate_hook = catfile($repo->hooks_path(),
- '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 = system_or_msg([$validate_hook, $target]);
- chdir($cwd_save) or die("chdir: $!");
- }
- if ($hook_error) {
- die sprintf(__("fatal: %s: rejected by sendemail-validate hook\n" .
- "%s\n" .
- "warning: no patches were sent\n"), $fn, $hook_error);
- }
+ my $target = abs_path($fn);
- return "rejected by sendemail-validate hook"
- if system(("git", "hook", "run", "sendemail-validate", "-a",
- $target));
++ $hook_error = system_or_msg([qw(git hook run sendemail-validate -a), $target]);
++ if ($hook_error) {
++ die sprintf(__("fatal: %s: rejected by sendemail-validate hook\n" .
++ "%s\n" .
++ "warning: no patches were sent\n"), $fn, $hook_error);
+ }
# Any long lines will be automatically fixed if we use a suitable transfer
# encoding.