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

[PATCH v2 0/1] templates: pre-push hook: check for missing GPG signatures

From
SGSebastian Götte <jaseg@physik.tu-berlin.de>
Date
Apr 25, 2013, 12:19 UTC
Message-ID
<51791F41.3040203@physik.tu-berlin.de>
In-Reply-To
<7vppxjbt6t.fsf_-_@alter.siamese.dyndns.org>
On 04/24/2013 09:54 PM, Junio C Hamano wrote:
> None of the above is part of a proper commit log message, is it?
Fixed (I hope)
Show 5 quoted lines
>> Signed-off-by: Sebastian Götte <jaseg@physik-pool.tu-berlin.de>
>> diff --git a/templates/hooks--pre-push.sample b/templates/hooks--pre-push.sample
>> old mode 100644
>> new mode 100755
> Why?
According to man githooks(5):
>It is also a requirement for a given hook to be executable. However - in a
>freshly initialized repository - the .sample files are executable by default.

This file is the only one in templates/ that was not executable, so I assume this was a mistake.

Show 10 quoted lines
>> index 15ab6d8..08a72df
>> --- a/templates/hooks--pre-push.sample
>> +++ b/templates/hooks--pre-push.sample
>> -# This sample shows how to prevent push of commits where the log message starts
>> -# with "WIP" (work in progress).
>> +# This sample shows how to prevent pushing commits without good GPG signatures
> What justifies to remove existing demonstration?  It is far easier
> for the end users to remove parts that do not apply to their needs,
> than coming up with a solution to add themselves without help from
> an example.
re-added it.
>> +ec=0
> I think it is more customary to call this kind of variable "ret" or
> "retval", not an abbreviation for "european commission" ;-).
renamed it to "exitcode".
>> -IFS=' '
> Why?
Otherwise in the for-loop below the output of the pipe chain is not correctly
split by newlines. Also AFAIK, this is not needed: I think the default
'<space><tab><newline>' is just fine here.
 
>> +		commits=`git log --format="%G? %h" "$range" | grep -v '^G' | cut -d\  -f2`
> Useless use of cut.  You could do

I just tried this, but I really want the script to output a list of *all* offending commits (instead of exiting on the first problem). For this I need the exitcode variable, but since at least bash executes the while loop in a subshell due to the preceding pipe, I have some issues getting that out of the subshell. This is what the code looked like without grep/cut:

Show 13 quoted lines
># Check for missing good GPG signatures
>git log --format="%G? %h" "$range" |
>(
>                exitcode=0
>                while read sign commit
>                do
>                                test "$sign" = G && continue
>                                echo "Commit $commit does not have a good GPG signature"
>                                exitcode=1
>                done
>                exit $exitcode
>)
>let exitcode=exitcode\|$?
This is less readable and only spawns one process less.
Sebastian Götte (1):
  templates: pre-push hook: check for missing GPG signatures
 templates/hooks--pre-push.sample | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)
 mode change 100644 => 100755 templates/hooks--pre-push.sample
-- 
1.8.2
Previous: Junio C HamanoNext: Junio C Hamano
Message 12 of 15 in “Re: [PATCH] Add .gitconfig variable commit.gpg-sign”
  1. Junio C HamanoApr 22, 2013
  2. Joel JacobsonApr 23, 2013
  3. Michael J GruberApr 23, 2013
  4. Junio C HamanoApr 23, 2013
  5. Joel JacobsonApr 23, 2013
  6. Junio C HamanoApr 23, 2013
  7. Joel JacobsonApr 23, 2013
  8. Sebastian GötteApr 24, 2013
  9. Michael J GruberApr 24, 2013
  10. 1/1 templates: pre-push hook: check for missing GPG signatures (was: Re: [PATCH] Add .gitconfig variable commit.gpg-sign)Sebastian Götte, Apr 24, 2013
  11. Junio C HamanoApr 24, 2013
  12. 0/1 templates: pre-push hook: check for missing GPG signaturesSebastian Götte, Apr 25, 2013
  13. Junio C HamanoApr 25, 2013
  14. Junio C HamanoApr 23, 2013
  15. 1/1 templates: pre-push hook: check for missing GPG signaturesSebastian Götte, Apr 25, 2013

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.