git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH RESEND] hooks: add sendemail-validate-series

From
Robin Jarry <robin@jarry.cc>
Date
Apr 3, 2023, 14:32 UTC
Message-ID
<CRN7096DENCQ.1HF4OQ0ZD4HFP@ringo>
In-Reply-To
<66099367-4ea0-7d2a-a089-7a88e27f695e@dunelm.org.uk>
Hi Phillip,
Phillip Wood, Apr 03, 2023 at 16:09:
Show 5 quoted lines
> > +  <patch-file> LF
>
> Usually git commands that produce or consume paths either use quoted 
> paths terminated by LF or unquoted paths terminated by NUL. That way 
> there is no ambiguity when a path contains LF.

I had never imagined that some twisted mind would insert LF in path names but since nothing will forbid it, I agree that it is a possibility.

I'm not sure what you mean by quoted paths, you mean adding literal double quotes before printing them to the hook stdin? That means the hook needs to handle de-quoting after reading, right?

Show 14 quoted lines
> > diff --git a/git-send-email.perl b/git-send-email.perl
> > index 07f2a0cbeaad..bec4d0f4ab47 100755
> > --- a/git-send-email.perl
> > +++ b/git-send-email.perl
> > @@ -800,6 +800,7 @@ sub is_format_patch_arg {
> >   			validate_patch($f, $target_xfer_encoding);
> >   		}
> >   	}
> > +	validate_patch_series(@files)
>
> This happens fairly early, before the user has had a chance to edit the 
> patches and before we have added all the recipient and in-reply-to 
> headers to the patch files. Would it be more useful to validate what 
> will actually be sent?

I agree that it would be better. I added the check here to be in line with the existing sendemail-validate hook. I could move it after edition and header finalization but then we would need to move sendemail-validate as well for consistency. What do you think?

Show 9 quoted lines
> > +	# The hook needs a correct cwd and GIT_DIR.
> > +	require Cwd;
> > +	my $cwd_save = Cwd::getcwd();
> > +	chdir($repo->wc_path() or $repo->repo_path()) or die("chdir: $!");
> > +	local $ENV{"GIT_DIR"} = $repo->repo_path();
>
> This looks like it is copied from the existing code but why do we need 
> to do this? I'm struggling to come up with a scenario where "git 
> send-email" can find the repository but the hook cannot.

Again, for consistency I assumed it would be best to keep the code similar in both hooks. If you think it is safe to skip that check, I'll remove it gladly.

Show 7 quoted lines
> > +	# cannot use git hook run, it closes stdin before forking the hook
> > +	open(my $stdin, "|-", $validate_hook) or die("fork: $!");
>
> This passes $validate_hook to the shell to execute which is not what we 
> want as it will split the hook path on whitespace etc. I think it would 
> be better to use "git hook run --to-stdin" (see 0414b3891c (hook: 
> support a --to-stdin=<path> option, 2023-02-08))
Ah that's a nice addition. I'll add that in v2.
Thanks for reviewing!
Previous: Phillip WoodNext: Phillip Wood
Message 4 of 18 in “hooks: add sendemail-validate-series”
  1. hooks: add sendemail-validate-seriesRobin Jarry, Apr 2, 2023
  2. Eric SunshineApr 3, 2023
  3. Phillip WoodApr 3, 2023
  4. Robin JarryApr 3, 2023
  5. Phillip WoodApr 3, 2023
  6. Junio C HamanoApr 3, 2023
  7. Robin JarryApr 3, 2023
  8. Robin JarryApr 3, 2023
  9. Junio C HamanoApr 3, 2023
  10. Robin JarryApr 3, 2023
  11. Junio C HamanoApr 4, 2023
  12. Robin JarryApr 5, 2023
  13. Junio C HamanoApr 5, 2023
  14. hooks: add sendemail-validate-seriesRobin Jarry, Apr 5, 2023
  15. Ævar Arnfjörð BjarmasonApr 6, 2023
  16. Phillip WoodApr 11, 2023
  17. Robin JarryApr 11, 2023
  18. Junio C HamanoApr 11, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.