]> git.ipfire.org Git - thirdparty/git.git/commit
send-email: export patch counters in validate environment
authorRobin Jarry <robin@jarry.cc>
Fri, 14 Apr 2023 15:52:49 +0000 (17:52 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 14 Apr 2023 17:41:15 +0000 (10:41 -0700)
commit3c8d3adeae8326d3b73fee0b134abd68d55f7c67
tree09a635bd9b2dd026784d0d68cfe3eb5d2eff85e1
parent9857273be005833c71e2d16ba48e193113e12276
send-email: export patch counters in validate environment

When sending patch series (with a cover-letter or not)
sendemail-validate is called with every email/patch file independently
from the others. When one of the patches depends on a previous one, it
may not be possible to use this hook in a meaningful way. A hook that
wants to check some property of the whole series needs to know which
patch is the final one.

Expose the current and total number of patches to the hook via the
GIT_SENDEMAIL_PATCH_COUNTER and GIT_SENDEMAIL_PATCH_TOTAL environment
variables so that both incremental and global validation is possible.

Sharing any other state between successive invocations of the validate
hook must be done via external means. For example, by storing it in
a git config sendemail.validateWorktree entry.

Add a sample script with placeholder validations and update tests to
check that the counters are properly exported.

Suggested-by: Phillip Wood <phillip.wood123@gmail.com>
Signed-off-by: Robin Jarry <robin@jarry.cc>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/githooks.txt
git-send-email.perl
t/t9001-send-email.sh
templates/hooks--sendemail-validate.sample [new file with mode: 0755]