diff options
| author | Junio C Hamano <gitster@pobox.com> | 2023-04-25 13:56:20 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2023-04-25 13:56:20 -0700 |
| commit | c4c9d5586fed1b994ef579a0862b86ff36afcbe8 (patch) | |
| tree | f05dacd2410a8e49e85aa2c0ef0f11c2d7ab2461 /git-send-email.perl | |
| parent | Merge branch 'jk/protocol-cap-parse-fix' (diff) | |
| parent | send-email: export patch counters in validate environment (diff) | |
| download | git-c4c9d5586fed1b994ef579a0862b86ff36afcbe8.tar.gz git-c4c9d5586fed1b994ef579a0862b86ff36afcbe8.zip | |
Merge branch 'rj/send-email-validate-hook-count-messages'
The sendemail-validate validate hook learned to pass the total
number of input files and where in the sequence each invocation is
via environment variables.
* rj/send-email-validate-hook-count-messages:
send-email: export patch counters in validate environment
Diffstat (limited to 'git-send-email.perl')
| -rwxr-xr-x | git-send-email.perl | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/git-send-email.perl b/git-send-email.perl index fd8cd0d46f..66c9171109 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -795,11 +795,26 @@ if (@rev_list_opts) { @files = handle_backup_files(@files); if ($validate) { + # FIFOs can only be read once, exclude them from validation. + my @real_files = (); foreach my $f (@files) { unless (-p $f) { - validate_patch($f, $target_xfer_encoding); + push(@real_files, $f); } } + + # Run the loop once again to avoid gaps in the counter due to FIFO + # arguments provided by the user. + my $num = 1; + my $num_files = scalar @real_files; + $ENV{GIT_SENDEMAIL_FILE_TOTAL} = "$num_files"; + foreach my $r (@real_files) { + $ENV{GIT_SENDEMAIL_FILE_COUNTER} = "$num"; + validate_patch($r, $target_xfer_encoding); + $num += 1; + } + delete $ENV{GIT_SENDEMAIL_FILE_COUNTER}; + delete $ENV{GIT_SENDEMAIL_FILE_TOTAL}; } if (@files) { |
