Skip to contentSkip to conversation

hooks: add sendemail-validate-series

PATCH Superseded Robin Jarry 5 participants 7 messages Jan 3, 2023 – Apr 3, 2023 Documentation

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hooks: add sendemail-validate-series

When sending patch series (with a cover-letter or not) sendemail-validate is called with every email/patch file independently from the others. When the one of the patches depend on a previous one to apply, it may not be possible to use this hook in a meaningful way.

Changing sendemail-validate to take all patches as arguments would break backward compatibility.

Add a new hook to allow validating patch series instead of patch by patch. The patch files are provided in the hook script standard input.

git hook run cannot be used since it closes the hook standard input. Run the hook directly.

---
 Documentation/git-send-email.txt |  1 +
 Documentation/githooks.txt       | 17 +++++++++++++
 git-send-email.perl              | 42 ++++++++++++++++++++++++++++++++
 3 files changed, 60 insertions(+)
Documentation/git-send-email.txt +1 -0
index 765b2df8530d..45113b928593 100644
@@ -438,6 +438,7 @@ have been specified, in which case default to 'compose'.
 +
 --
 		*	Invoke the sendemail-validate hook if present (see linkgit:githooks[5]).
+		*	Invoke the sendemail-validate-series hook if present (see linkgit:githooks[5]).
 		*	Warn of patches that contain lines longer than
 			998 characters unless a suitable transfer encoding
 			('auto', 'base64', or 'quoted-printable') is used;
Documentation/githooks.txt +17 -0
index a16e62bc8c8e..e2dc0b49eda5 100644
@@ -588,6 +588,23 @@ the name of the file that holds the e-mail to be sent.  Exiting with a
 non-zero status causes `git send-email` to abort before sending any
 e-mails.
 
+sendemail-validate-series
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+This hook is invoked by linkgit:git-send-email[1].  It allows performing
+validation on a complete patch series at once, instead of patch by patch with
+`sendemail-validate`.
+
+`sendemail-validate-series` takes no arguments, but for each e-mail to be sent
+it receives on standard input a line of the format:
+
+  <patch-file> LF
+
+where `<patch-file>` is a name of a file that holds an e-mail to be sent,
+
+If the hook exits with non-zero status, `git send-email` will abort before
+sending any e-mails.
+
 fsmonitor-watchman
 ~~~~~~~~~~~~~~~~~~
 
git-send-email.perl +42 -0

54 lines not on this page · raw message

Signature · 1 line
2.39.0
#1 lore raw

Hi all,

This is a gentle bump to see if that feature could be of interest for anyone.

Thanks in advance.

#3 lore raw
In reply to Robin Jarry

Le 04/01/2023 à 00:11, Robin Jarry a écrit :

Quoted 8 lines

When sending patch series (with a cover-letter or not) sendemail-validate is called with every email/patch file independently from the others. When the one of the patches depend on a previous one to apply, it may not be possible to use this hook in a meaningful way.

Changing sendemail-validate to take all patches as arguments would break backward compatibility.

Quoted 7 lines

Add a new hook to allow validating patch series instead of patch by patch. The patch files are provided in the hook script standard input.

git hook run cannot be used since it closes the hook standard input. Run the hook directly.

Any news on this patch?

Regards,
Nicolas

#4 lore raw
In reply to Robin Jarry
Quoted 4 lines · Robin Jarry
Documentation/githooks.txt +4 -0
+sendemail-validate-series
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+This hook is invoked by linkgit:git-send-email[1].  It allows performing

Documentation/githooks.txt the name of the file that holds the e-mail to be sent. Exiting with a · line 604

Quoted 10 lines
Documentation/githooks.txt +10 -0
+validation on a complete patch series at once, instead of patch by patch with
+`sendemail-validate`.
+
+`sendemail-validate-series` takes no arguments, but for each e-mail to be sent
+it receives on standard input a line of the format:
+
+  <patch-file> LF
+
+where `<patch-file>` is a name of a file that holds an e-mail to be sent,
+

In most cases, the patch series is generated by git-format-patch(1). When the command is run, it will output:

```
$ git format-patch -o /tmp --cover-letter --base=<base-commit> <base-commit>
/tmp/0000-cover-letter.patch
/tmp/0001-<patch-subject>.patch
/tmp/0002-<patch-subject>.patch
/tmp/0003-<patch-subject>.patch
...
```

The output can be fed to the hook (as you write).

But I think the hook should also take patch file arguments, for the sake of completeness with sendemail-validate hook; that is:

```
sendemail-validate-series <patch file>...
```

Also, there should have a check that In-Reply-To must be the first patch in the given series or the cover letter (if there is one).

Anyway, rather than pinging by random people, I'd like to see [PATCH RESEND], rebased on latest git.git tree, ideally with Junio Cc'ed.

Thanks.

Signature · 1 line
An old man doll... just what I always wanted! - Clara
#5 lore raw

Hi,

Bagas Sanjaya, Apr 01, 2023 at 04:54:

Quoted 12 lines

In most cases, the patch series is generated by git-format-patch(1). When the command is run, it will output:

```
$ git format-patch -o /tmp --cover-letter --base=<base-commit> <base-commit>
/tmp/0000-cover-letter.patch
/tmp/0001-<patch-subject>.patch
/tmp/0002-<patch-subject>.patch
/tmp/0003-<patch-subject>.patch
...
```
Quoted 8 lines

The output can be fed to the hook (as you write).

But I think the hook should also take patch file arguments, for the sake of completeness with sendemail-validate hook; that is:

```
sendemail-validate-series <patch file>...
```

I don't mind adding this but I am concerned with the maximum size of the command line arguments when sending large series. Standard input seems like a safer solution.

Quoted 2 lines

Also, there should have a check that In-Reply-To must be the first patch in the given series or the cover letter (if there is one).

This is really non-trivial as it depends on the --[no-]chain-reply-to and --[no-]thread options. Also, the validation occurs before the message id headers are generated. I'd prefer trusting git-format-patch to order the patch files properly based on their file names.

Quoted 2 lines

Anyway, rather than pinging by random people, I'd like to see [PATCH RESEND], rebased on latest git.git tree, ideally with Junio Cc'ed.

Will do. Thanks.

#6 lore raw
Quoted 12 lines · Robin Jarry

Bagas Sanjaya, Apr 01, 2023 at 04:54:

Quoted 11 lines

In most cases, the patch series is generated by git-format-patch(1). When the command is run, it will output:

$ git format-patch -o /tmp --cover-letter --base=<base-commit> <base-commit>
/tmp/0000-cover-letter.patch
/tmp/0001-<patch-subject>.patch
/tmp/0002-<patch-subject>.patch
/tmp/0003-<patch-subject>.patch

The output can be fed to the hook (as you write).

Quoted 8 lines
Quoted 4 lines

But I think the hook should also take patch file arguments, for the sake of completeness with sendemail-validate hook; that is:

sendemail-validate-series <patch file>...

I don't mind adding this but I am concerned with the maximum size of the command line arguments when sending large series. Standard input seems like a safer solution.

I share your concern, and don't see a good reason for complicating the implementation _and_ the API by feeding pathnames to the hook as both stdin and as arguments. Feeding them on stdin is the safer choice even if it makes the hook implementation a bit more clunky.

Quoted 7 lines
Quoted 2 lines

Also, there should have a check that In-Reply-To must be the first patch in the given series or the cover letter (if there is one).

This is really non-trivial as it depends on the --[no-]chain-reply-to and --[no-]thread options. Also, the validation occurs before the message id headers are generated. I'd prefer trusting git-format-patch to order the patch files properly based on their file names.

Moreover, enforcing In-Reply-To: like that would almost certainly be undesirable. It may be policy on _this_ project to chain rerolls like that, but other projects have different policies, even to the point of prohibiting chaining.

Such In-Reply-To: enforcement is also well outside the scope of the patch under discussion, as well as being entirely orthogonal.

Quoted 4 lines
Quoted 2 lines

Anyway, rather than pinging by random people, I'd like to see [PATCH RESEND], rebased on latest git.git tree, ideally with Junio Cc'ed.

Will do. Thanks.

Generally speaking, once you've sent a patch or patch series, when you re-roll, you should _not_ rebase it onto Junio's latest "master" since doing so makes it harder for him to pick up the new version. In this case, your original patch didn't get picked up, so no harm done by rebasing it on "master", but it's good practice to avoid doing so unless there is a strong reason.