Merge branch 'jd/gpg-interface-trust-level-string'
The code to convert between GPG trust level strings and internal constants we use to represent them have been cleaned up. * jd/gpg-interface-trust-level-string: gpg-interface: add function for converting trust level to string
This commit is contained in:
commit
ba69ae876b
@ -165,15 +165,17 @@ static struct {
|
|||||||
{ 0, "TRUST_", GPG_STATUS_TRUST_LEVEL },
|
{ 0, "TRUST_", GPG_STATUS_TRUST_LEVEL },
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct {
|
/* Keep the order same as enum signature_trust_level */
|
||||||
|
static struct sigcheck_gpg_trust_level {
|
||||||
const char *key;
|
const char *key;
|
||||||
|
const char *display_key;
|
||||||
enum signature_trust_level value;
|
enum signature_trust_level value;
|
||||||
} sigcheck_gpg_trust_level[] = {
|
} sigcheck_gpg_trust_level[] = {
|
||||||
{ "UNDEFINED", TRUST_UNDEFINED },
|
{ "UNDEFINED", "undefined", TRUST_UNDEFINED },
|
||||||
{ "NEVER", TRUST_NEVER },
|
{ "NEVER", "never", TRUST_NEVER },
|
||||||
{ "MARGINAL", TRUST_MARGINAL },
|
{ "MARGINAL", "marginal", TRUST_MARGINAL },
|
||||||
{ "FULLY", TRUST_FULLY },
|
{ "FULLY", "fully", TRUST_FULLY },
|
||||||
{ "ULTIMATE", TRUST_ULTIMATE },
|
{ "ULTIMATE", "ultimate", TRUST_ULTIMATE },
|
||||||
};
|
};
|
||||||
|
|
||||||
static void replace_cstring(char **field, const char *line, const char *next)
|
static void replace_cstring(char **field, const char *line, const char *next)
|
||||||
@ -905,6 +907,20 @@ const char *get_signing_key(void)
|
|||||||
return git_committer_info(IDENT_STRICT | IDENT_NO_DATE);
|
return git_committer_info(IDENT_STRICT | IDENT_NO_DATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *gpg_trust_level_to_str(enum signature_trust_level level)
|
||||||
|
{
|
||||||
|
struct sigcheck_gpg_trust_level *trust;
|
||||||
|
|
||||||
|
if (level < 0 || level >= ARRAY_SIZE(sigcheck_gpg_trust_level))
|
||||||
|
BUG("invalid trust level requested %d", level);
|
||||||
|
|
||||||
|
trust = &sigcheck_gpg_trust_level[level];
|
||||||
|
if (trust->value != level)
|
||||||
|
BUG("sigcheck_gpg_trust_level[] unsorted");
|
||||||
|
|
||||||
|
return sigcheck_gpg_trust_level[level].display_key;
|
||||||
|
}
|
||||||
|
|
||||||
int sign_buffer(struct strbuf *buffer, struct strbuf *signature, const char *signing_key)
|
int sign_buffer(struct strbuf *buffer, struct strbuf *signature, const char *signing_key)
|
||||||
{
|
{
|
||||||
return use_format->sign_buffer(buffer, signature, signing_key);
|
return use_format->sign_buffer(buffer, signature, signing_key);
|
||||||
|
@ -71,6 +71,14 @@ size_t parse_signed_buffer(const char *buf, size_t size);
|
|||||||
int sign_buffer(struct strbuf *buffer, struct strbuf *signature,
|
int sign_buffer(struct strbuf *buffer, struct strbuf *signature,
|
||||||
const char *signing_key);
|
const char *signing_key);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns corresponding string in lowercase for a given member of
|
||||||
|
* enum signature_trust_level. For example, `TRUST_ULTIMATE` will
|
||||||
|
* return "ultimate".
|
||||||
|
*/
|
||||||
|
const char *gpg_trust_level_to_str(enum signature_trust_level level);
|
||||||
|
|
||||||
int git_gpg_config(const char *, const char *, void *);
|
int git_gpg_config(const char *, const char *, void *);
|
||||||
void set_signing_key(const char *);
|
void set_signing_key(const char *);
|
||||||
const char *get_signing_key(void);
|
const char *get_signing_key(void);
|
||||||
|
18
pretty.c
18
pretty.c
@ -1575,23 +1575,7 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
|
|||||||
strbuf_addstr(sb, c->signature_check.primary_key_fingerprint);
|
strbuf_addstr(sb, c->signature_check.primary_key_fingerprint);
|
||||||
break;
|
break;
|
||||||
case 'T':
|
case 'T':
|
||||||
switch (c->signature_check.trust_level) {
|
strbuf_addstr(sb, gpg_trust_level_to_str(c->signature_check.trust_level));
|
||||||
case TRUST_UNDEFINED:
|
|
||||||
strbuf_addstr(sb, "undefined");
|
|
||||||
break;
|
|
||||||
case TRUST_NEVER:
|
|
||||||
strbuf_addstr(sb, "never");
|
|
||||||
break;
|
|
||||||
case TRUST_MARGINAL:
|
|
||||||
strbuf_addstr(sb, "marginal");
|
|
||||||
break;
|
|
||||||
case TRUST_FULLY:
|
|
||||||
strbuf_addstr(sb, "fully");
|
|
||||||
break;
|
|
||||||
case TRUST_ULTIMATE:
|
|
||||||
strbuf_addstr(sb, "ultimate");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user