completion: add more parameter value completion
[gitweb.git] / pretty.c
index 32404953089e98409a93b3720cc3d9f20792f60d..55739a03374322049b75d80f6009d5a6f2a9a85f 100644 (file)
--- a/pretty.c
+++ b/pretty.c
@@ -98,6 +98,10 @@ static void setup_commit_formats(void)
                { "fuller",     CMIT_FMT_FULLER,        0,      8 },
                { "full",       CMIT_FMT_FULL,          0,      8 },
                { "oneline",    CMIT_FMT_ONELINE,       1,      0 }
+               /*
+                * Please update $__git_log_pretty_formats in
+                * git-completion.bash when you add new formats.
+                */
        };
        commit_formats_len = ARRAY_SIZE(builtin_formats);
        builtin_formats_len = commit_formats_len;
@@ -1085,6 +1089,7 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
        struct commit_list *p;
        const char *arg;
        int ch;
+       char **slot;
 
        /* these are independent of the commit */
        switch (placeholder[0]) {
@@ -1195,6 +1200,14 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
                load_ref_decorations(NULL, DECORATE_SHORT_REFS);
                format_decorations_extended(sb, commit, c->auto_color, "", ", ", "");
                return 1;
+       case 'S':               /* tag/branch like --source */
+               if (!(c->pretty_ctx->rev && c->pretty_ctx->rev->sources))
+                       return 0;
+               slot = revision_sources_at(c->pretty_ctx->rev->sources, commit);
+               if (!(slot && *slot))
+                       return 0;
+               strbuf_addstr(sb, *slot);
+               return 1;
        case 'g':               /* reflog info */
                switch(placeholder[1]) {
                case 'd':       /* reflog selector */
@@ -1257,6 +1270,14 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
                        if (c->signature_check.key)
                                strbuf_addstr(sb, c->signature_check.key);
                        break;
+               case 'F':
+                       if (c->signature_check.fingerprint)
+                               strbuf_addstr(sb, c->signature_check.fingerprint);
+                       break;
+               case 'P':
+                       if (c->signature_check.primary_key_fingerprint)
+                               strbuf_addstr(sb, c->signature_check.primary_key_fingerprint);
+                       break;
                default:
                        return 0;
                }
@@ -1491,6 +1512,9 @@ static size_t userformat_want_item(struct strbuf *sb, const char *placeholder,
        case 'N':
                w->notes = 1;
                break;
+       case 'S':
+               w->source = 1;
+               break;
        }
        return 0;
 }