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

Re: RFC: update hook for GPG signed submission on secured branches

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 16, 2015, 19:33 UTC
Message-ID
<xmqqsifa1px6.fsf@gitster.dls.corp.google.com>
In-Reply-To
<BBE88A3EA44D47159C483F1046AC747E@black>
"Jason Pyeron" <jpyeron@pdinc.us> writes:
> What would you change? Any bugs that you see?
> sigkey=$(\
>  git cat-file $newrev -p |\

"-p" being a command line option should come before revision, but more importantly, because you accept pushes only to refs/heads/, you would want to explicitly require commit objects, no? i.e.

	git cat-file commit "$newrev" |

I am not sure if you need these unsightly backslashes. When you stop talking to it after saying "$(", or "$( git cat-file ... |", the shell _knows_ that you haven't stopped what you want to tell it.

>  sed -e '/^ /{H;$!d;}; x;/^gpgsig /!d; s/^gpgsig//;' |\
>  cut -c 2- |\

It always makes me feel nervous to see people pipe sed output to another filter that is a mere s/.//;

Is this complex pipeline the same as this (I didn't understand the trailing I at the end)?

	git cat-file commit "$newrev" |
        sed -ne '/^gpgsig /,/^ -----END/{
        	s/^gpgsig //
                s/^ //p
	}' |
	gpg --list-packets --textmode |
        sed -ne '/^:signature packet:/s/.*keyid \([0-9A-F]*\).*/\1/p'
>  gpg --list-packets --textmode |\
>  sed '/keyid/!d; s/.*keyid \([0-9A-F]\{16\}\).*/\1/I' \
> )
> if [ -z "$sigkey" ]; then
>         echo no GPG signature on commit $newrev
>         exit 1
> fi

I am not sure if the design of this, to require signature only on the tip commit, is sound. That is not a -bug- in the script, though.

Show 6 quoted lines
> if [[ $refname != refs/heads/* ]]; then
>         echo only heads may be pushed, illegal ref: $refname
>         exit 1;
> fi
>
> head="${refname:11}"
It is hard to tell where the magic number 11 comes from.  Perhaps
    head="${refname#refs/heads/}"
reads easier?
Previous: Jason PyeronNext: Junio C Hamano
Message 2 of 6 in “RFC: update hook for GPG signed submission on secured branches”
  1. Jason PyeronJan 16, 2015
  2. Junio C HamanoJan 16, 2015
  3. Junio C HamanoJan 16, 2015
  4. Jason PyeronJan 16, 2015
  5. John KeepingJan 16, 2015
  6. Junio C HamanoJan 16, 2015

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.