From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9EDEDC7EE23 for ; Sun, 4 Jun 2023 18:58:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231481AbjFDS6v (ORCPT ); Sun, 4 Jun 2023 14:58:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230366AbjFDS6u (ORCPT ); Sun, 4 Jun 2023 14:58:50 -0400 Received: from mail-oo1-xc29.google.com (mail-oo1-xc29.google.com [IPv6:2607:f8b0:4864:20::c29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14699B3 for ; Sun, 4 Jun 2023 11:58:49 -0700 (PDT) Received: by mail-oo1-xc29.google.com with SMTP id 006d021491bc7-558cf19575dso190843eaf.3 for ; Sun, 04 Jun 2023 11:58:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685905128; x=1688497128; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zfci1FB6QNhwA7NYZUGdUNhB732GCQ+u8ugySF9rGys=; b=qjSuHro02/aEGCqa2/bd8P3pSayh5igAJ69igajyEmtwYST6JTH+ME6bMWga8WLMKE 0qTYvWeFBc/vgIiMIhPTc6gCTBRAS+sS2Ja3LaXG4ewnu+HdUFnwFh4uTkVRnV2OzGy5 2aLcOaQFkiF3bxT8R/dDj9PTpyig7KmPYGJhRtF3+6fLSdJZ87K8FZLG+d3Gfh3eXDQk BxujbVlZIraJpe7QcIa+NJVr43itTlObv1EVNWfH2YpzcjlnXDn+/tIRpjGAYaSs7+W1 uVTfxDe8Zd32+pZ5ANmgCJc9ZxU3qeaTABiYtRc2mq2O+3KIye+FgHBmBTjCmgc5YiZB xjCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685905128; x=1688497128; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zfci1FB6QNhwA7NYZUGdUNhB732GCQ+u8ugySF9rGys=; b=H759O349YnZ6fDv8cG2B3zYPMDLlophhy28lL9bVBb/qMYfOM24b9eD97XvITpTBSO xK6N0zxuJMjtfUs66mPuBwBCo6TCP6sMT1bjurfl08MVbankFAxXRwyqmGCwAtCEdUes yw8ogBDevwUjtx7DU5M+7lnsWO1CN2c8TZRiQ63c4jHSYdT5nb9bqLqsptq3ynhdX644 6zOXtzynQ6z+8UvhwtZt7fS2ALxkBJ8S4hJkLEgEE7IONMmRhaA28tC82MBq0M+sqh4D YDMl57O2FTh0OkZde2pe+Kz5C/iYJw2xp7srhAKTPfeSscqB3npwlTtncFwOK/Bui8pH pWew== X-Gm-Message-State: AC+VfDzBM4e9HAtwbspnMPe+od4XWF824ltQuBRwkFHFbi9VPGRjGpg+ vQCKwHG2qy5a5qvGg1+LD8VJwQayu/EPiG71 X-Google-Smtp-Source: ACHHUZ6p95chQuxJRuKkvIeUHuykgMzakQ8kEvblkgrFCqxnL+sEMBvtvpHH6rxkwQkCoL3PYqSsug== X-Received: by 2002:a05:6358:c1d:b0:127:96d6:be18 with SMTP id f29-20020a0563580c1d00b0012796d6be18mr23880898rwj.21.1685905127935; Sun, 04 Jun 2023 11:58:47 -0700 (PDT) Received: from fivlite-virtual-machine.localdomain ([49.37.151.19]) by smtp.gmail.com with ESMTPSA id mh12-20020a17090b4acc00b00256a4657519sm4495805pjb.15.2023.06.04.11.58.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Jun 2023 11:58:47 -0700 (PDT) From: Kousik Sanagavarapu To: git@vger.kernel.org Cc: Junio C Hamano , Christian Couder , Eric Sunshine , Oswald Buddenhagen , Kousik Sanagavarapu Subject: [PATCH v3 0/2] Add new "signature" atom Date: Sun, 4 Jun 2023 23:52:45 +0530 Message-ID: <20230604185815.15761-1-five231003@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230602023105.17979-1-five231003@gmail.com> References: <20230602023105.17979-1-five231003@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Hi, Thanks for the reviews. Changes since v2: PATCH 1/2 - Changed "it's" to "its" in the commit message. Changed the `case` statement in prereq GPG2 to use the glob pattern instead. This has the advantage of being precise and less typo-prone. PATCH 2/2 - Changed "it's" to "its" in the commit message. Changed the `if else` to `switch` when handling options in grab_siganture(). This increases the readability of code unlike the previous `if else` checking for the type of option, which also didn't comply with the style. The same kind of refactoring of can be done in other parts of ref-filter as well. ZheNing Hu has done some work on it [1], but it looks like they were generated by some kind of a script and there are unnecessary braces around. [1]: https://lore.kernel.org/git/2321b873d0c0223e553492d80ced2a51d8ce7281.1629189701.git.gitgitgadget@gmail.com/ Range-diff against v2: 1: 87465ef1a8 ! 1: a7ed6628e0 t/lib-gpg: introduce new prereq GPG2 @@ Commit message is the "First stable version of GnuPG integrating OpenPGP and S/MIME". - Use this version or it's successors for tests that will fail for + Use this version or its successors for tests that will fail for versions less than v2.0.0 because of the difference in the output on stderr between the versions (v2.* vs v0.* or v2.* vs v1.*). Skip if the GPG version detected is less than v2.0.0. @@ t/lib-gpg.sh: test_lazy_prereq GPG ' + test $? != 127 || exit 1 + + case "$gpg_version" in -+ "gpg (GnuPG) 0."* | "gpg (GnuPG) 1.*") ++ "gpg (GnuPG) "[01].*) + say "This test requires a GPG version >= v2.0.0" + exit 1 + ;; 2: 690869aa47 ! 2: b6da96dab2 ref-filter: add new "signature" atom @@ Metadata ## Commit message ## ref-filter: add new "signature" atom - Duplicate the code for outputting the signature and it's other + Duplicate the code for outputting the signature and its other parameters for commits and tags in ref-filter from pretty. In the future, this will help in getting rid of the current duplicate implementations of such logic everywhere, when ref-filter can do everything that pretty is doing. - The new atom "signature" and it's friends are equivalent to the existing + The new atom "signature" and its friends are equivalent to the existing pretty formats as follows: %(signature) = %GG @@ Documentation/git-for-each-ref.txt: symref:: + The fingerprint of the GPG signature of a commit. + +signature:primarykeyfingerprint:: -+ The Primary Key fingerprint of the GPG signature of a commit. ++ The primary key fingerprint of the GPG signature of a commit. + +signature:trustlevel:: -+ The Trust level of the GPG signature of a commit. Possible ++ The trust level of the GPG signature of a commit. Possible + outputs are `ultimate`, `fully`, `marginal`, `never` and `undefined`. + worktreepath:: @@ ref-filter.c: static struct used_atom { } email_option; + struct { + enum { S_BARE, S_GRADE, S_SIGNER, S_KEY, -+ S_FINGERPRINT, S_PRI_KEY_FP, S_TRUST_LEVEL} option; ++ S_FINGERPRINT, S_PRI_KEY_FP, S_TRUST_LEVEL } option; + } signature; struct refname_atom refname; char *head; @@ ref-filter.c: static void grab_person(const char *who, struct atom_value *val, i + struct used_atom *atom = &used_atom[i]; + const char *name = atom->name; + struct atom_value *v = &val[i]; ++ int opt; + + if (!!deref != (*name == '*')) + continue; + if (deref) + name++; + -+ if (!skip_prefix(name, "signature", &name) || (*name && -+ *name != ':')) ++ if (!skip_prefix(name, "signature", &name) || ++ (*name && *name != ':')) + continue; + if (!*name) + name = NULL; + else + name++; -+ if (parse_signature_option(name) < 0) ++ ++ opt = parse_signature_option(name); ++ if (opt < 0) + continue; + + if (!signature_checked) { @@ ref-filter.c: static void grab_person(const char *who, struct atom_value *val, i + signature_checked = 1; + } + -+ if (atom->u.signature.option == S_BARE) ++ switch (opt) { ++ case S_BARE: + v->s = xstrdup(sigc.output ? sigc.output: ""); -+ else if (atom->u.signature.option == S_SIGNER) ++ break; ++ case S_SIGNER: + v->s = xstrdup(sigc.signer ? sigc.signer : ""); -+ else if (atom->u.signature.option == S_GRADE) { ++ break; ++ case S_GRADE: + switch (sigc.result) { + case 'G': + switch (sigc.trust_level) { @@ ref-filter.c: static void grab_person(const char *who, struct atom_value *val, i + case 'Y': + case 'R': + v->s = xstrfmt("%c", (char)sigc.result); ++ break; + } -+ } -+ else if (atom->u.signature.option == S_KEY) ++ break; ++ case S_KEY: + v->s = xstrdup(sigc.key ? sigc.key : ""); -+ else if (atom->u.signature.option == S_FINGERPRINT) -+ v->s = xstrdup(sigc.fingerprint ? sigc.fingerprint : ""); -+ else if (atom->u.signature.option == S_PRI_KEY_FP) -+ v->s = xstrdup(sigc.primary_key_fingerprint ? sigc.primary_key_fingerprint : ""); -+ else if (atom->u.signature.option == S_TRUST_LEVEL) ++ break; ++ case S_FINGERPRINT: ++ v->s = xstrdup(sigc.fingerprint ? ++ sigc.fingerprint : ""); ++ break; ++ case S_PRI_KEY_FP: ++ v->s = xstrdup(sigc.primary_key_fingerprint ? ++ sigc.primary_key_fingerprint : ""); ++ break; ++ case S_TRUST_LEVEL: + v->s = xstrdup(gpg_trust_level_to_str(sigc.trust_level)); ++ break; ++ } + } ++ + if (signature_checked) + signature_check_clear(&sigc); +} Kousik Sanagavarapu (2): t/lib-gpg: introduce new prereq GPG2 ref-filter: add new "signature" atom Documentation/git-for-each-ref.txt | 27 ++++ ref-filter.c | 126 ++++++++++++++++++- t/lib-gpg.sh | 21 ++++ t/t6300-for-each-ref.sh | 191 +++++++++++++++++++++++++++++ t/t7510-signed-commit.sh | 7 ++ 5 files changed, 370 insertions(+), 2 deletions(-) -- 2.41.0