Git Mailing List Archive mirror
 help / color / mirror / Atom feed
From: Kousik Sanagavarapu <five231003@gmail.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
	Christian Couder <christian.couder@gmail.com>,
	Eric Sunshine <sunshine@sunshineco.com>,
	Oswald Buddenhagen <oswald.buddenhagen@gmx.de>,
	Kousik Sanagavarapu <five231003@gmail.com>
Subject: [PATCH v3 0/2] Add new "signature" atom
Date: Sun,  4 Jun 2023 23:52:45 +0530	[thread overview]
Message-ID: <20230604185815.15761-1-five231003@gmail.com> (raw)
In-Reply-To: <20230602023105.17979-1-five231003@gmail.com>

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


  parent reply	other threads:[~2023-06-04 18:58 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-29 18:32 [GSoC][PATCH 0/2] Add new "signature" atom Kousik Sanagavarapu
2023-05-29 18:32 ` [PATCH 1/2] t/lib-gpg: introduce new prereq GPG2 Kousik Sanagavarapu
2023-06-01  8:39   ` Christian Couder
2023-05-29 18:32 ` [PATCH 2/2] ref-filter: add new "signature" atom Kousik Sanagavarapu
2023-06-01  8:58   ` Christian Couder
2023-06-01  9:11 ` [GSoC][PATCH 0/2] Add " Christian Couder
2023-06-02  2:11 ` [PATCH v2 " Kousik Sanagavarapu
2023-06-02  2:11   ` [PATCH v2 1/2] t/lib-gpg: introduce new prereq GPG2 Kousik Sanagavarapu
2023-06-02  6:50     ` Christian Couder
2023-06-02 12:58       ` Kousik Sanagavarapu
2023-06-02  2:11   ` [PATCH v2 2/2] ref-filter: add new "signature" atom Kousik Sanagavarapu
2023-06-02  8:23     ` Oswald Buddenhagen
2023-06-02  7:29   ` [PATCH v2 0/2] Add " Junio C Hamano
2023-06-02  7:51     ` Eric Sunshine
2023-06-03  0:16       ` Junio C Hamano
2023-06-02 13:13     ` Kousik Sanagavarapu
2023-06-04 18:22   ` Kousik Sanagavarapu [this message]
2023-06-04 18:22     ` [PATCH v3 1/2] t/lib-gpg: introduce new prereq GPG2 Kousik Sanagavarapu
2023-06-04 18:22     ` [PATCH v3 2/2] ref-filter: add new "signature" atom Kousik Sanagavarapu

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=20230604185815.15761-1-five231003@gmail.com \
    --to=five231003@gmail.com \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=oswald.buddenhagen@gmx.de \
    --cc=sunshine@sunshineco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).