public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox•com>
To: "Jason Pyeron" <jpyeron@pdinc•us>
Cc: <git@vger•kernel.org>
Subject: Re: RFC: update hook for GPG signed submission on secured branches
Date: Fri, 16 Jan 2015 11:33:25 -0800	[thread overview]
Message-ID: <xmqqsifa1px6.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <BBE88A3EA44D47159C483F1046AC747E@black> (Jason Pyeron's message of "Fri, 16 Jan 2015 14:03:51 -0500")

"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.

> 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?

  reply	other threads:[~2015-01-16 19:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-16 19:03 RFC: update hook for GPG signed submission on secured branches Jason Pyeron
2015-01-16 19:33 ` Junio C Hamano [this message]
2015-01-16 19:41   ` Junio C Hamano
2015-01-16 19:47   ` Jason Pyeron
2015-01-16 19:59     ` John Keeping
2015-01-16 22:49     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqsifa1px6.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=jpyeron@pdinc$(echo .)us \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox