Re: [PATCH v8 3/5] merge/pull: verify GPG signatures of commits being merged
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Apr 1, 2013, 02:47 UTC
- Message-ID
- <7vsj3bm0gr.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <51585E10.8090505@physik.tu-berlin.de>
Sebastian Götte <jaseg@physik.tu-berlin.de> writes:
Show 17 quoted lines
> + if (verify_signatures) {
> + for (p = remoteheads; p; p = p->next) {
> + struct commit *commit = p->item;
> + char hex[41];
> + struct signature_check signature_check;
> + memset(&signature_check, 0, sizeof(signature_check));
> +
> + check_commit_signature(commit, &signature_check);
> +
> + strcpy(hex, find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV));
> + switch(signature_check.result){
> + case 'G':
> + break;
> + case 'B':
> + die(_("Commit %s has a bad GPG signature allegedly by %s."), hex, signature_check.signer);
> + default: /* 'N' */
> + die(_("Commit %s does not have a GPG signature."), hex, hex);Count %s and number and arguments.
> + }
Style.
switch (expr) {
case 'G':
do_something_for_G();
break;
...
}Also avoid overlong lines.
I'll squash in something like the following and push out the result on 'pu' tonight. Please check to see if I made silly mistakes while doing so.
Thanks.
builtin/merge.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/builtin/merge.c b/builtin/merge.c index 7a33d03..e57c42c 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -1245,16 +1245,18 @@ int cmd_merge(int argc, const char **argv, const char *prefix) check_commit_signature(commit, &signature_check); strcpy(hex, find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV)); - switch(signature_check.result){ - case 'G': - break; - case 'B': - die(_("Commit %s has a bad GPG signature allegedly by %s."), hex, signature_check.signer); - default: /* 'N' */ - die(_("Commit %s does not have a GPG signature."), hex, hex); + switch (signature_check.result) { + case 'G': + break; + case 'B': + die(_("Commit %s has a bad GPG signature " + "allegedly by %s."), hex, signature_check.signer); + default: /* 'N' */ + die(_("Commit %s does not have a GPG signature."), hex); } if (verbosity >= 0 && signature_check.result == 'G') - printf(_("Commit %s has a good GPG signature by %s\n"), hex, signature_check.signer); + printf(_("Commit %s has a good GPG signature by %s\n"), + hex, signature_check.signer); free(signature_check.gpg_output); free(signature_check.gpg_status);