On 2025-01-12 at 11:53:48, Ian Jackson wrote:
> To reproduce:
> 
>   git clone https://salsa.debian.org/dgit-team/dgit.git -b 
> commit-message-sob-botch-repro
>   cd dgit/
>   cp .git/hooks/prepare-commit-msg{.sample,}
>   # (The following enables the SOB-processing parts of the sample:)
>   perl -i~ -pe 's{^\# }{} if m{^\# SOB}..m{^$}' .git/hooks/prepare-commit-msg
>   git-rebase -i HEAD~5
> 
>   # Now, delete the first commit from the interactive rebase instructions,
>   # to force an actual rewrite of the final commit.
>   # Complete the rebase.
> 
>   git cat-file commit HEAD
> 
> Actual results:
> 
>   tree 79d4e0670895c30744706c5f835268e36dc8c99a
>   parent ...
> 
>   tag2upload-oracled: Coding style changes
>   Signed-off-by: Ian Jackson <ijack...@chiark.greenend.org.uk>
> 
> Expected results:
> 
>   tree 79d4e0670895c30744706c5f835268e36dc8c99a
>   parent ...
> 
>   tag2upload-oracled: Coding style changes
> 
>   Signed-off-by: Ian Jackson <ijack...@chiark.greenend.org.uk>

I believe that someone has sent a patch to the Git list to fix this
problem (c02414a997 ("interpret-trailers: handle message without
trailing newline", 2024-09-06)) and it's included in 2.46.2.  I'm
unable to reproduce it with 2.48.

The good news is that this is fixed in `git interpret-trailers` so
even older versions of the hooks should continue to work.

> Discussion:
> 
> It is unfortunate that this is done by ad-hoc open-coding in a script
> that git promiscuously copies everywhere and that you're expected to
> edit.

I will think about this and maybe try to start a discussion upstream.
I think the goal of the sample hooks is to show what you _could_ do and
instruct you on how to use the hooks and not to be actually generally
useful, but I admit that we may have been too successful with our
examples and people may have ended up actually using them.
-- 
brian m. carlson (they/them or he/him)
Toronto, Ontario, CA

Attachment: signature.asc
Description: PGP signature

Reply via email to