[PATCH v3 0/2] Add new "signature" atom

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx/ 
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




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux