diff options
| author | Junio C Hamano <gitster@pobox.com> | 2020-07-30 13:20:33 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2020-07-30 13:20:33 -0700 |
| commit | be537062afe8be38631ee7b09ef09d06f03ab1ca (patch) | |
| tree | 21bdc9b001b91923457e1caacf81bd0b863f9762 /ref-filter.c | |
| parent | a20e20e4c8fe6c13e03af8109644a84d8f4e7f7f (diff) | |
| parent | b6839fda6809b1de8d528837dfc99d0837f77c9d (diff) | |
| download | git-be537062afe8be38631ee7b09ef09d06f03ab1ca.tar.xz | |
Merge branch 'cc/pretty-contents-size' into master
"git for-each-ref --format=<>" learned %(contents:size).
* cc/pretty-contents-size:
ref-filter: add support for %(contents:size)
t6300: test refs pointing to tree and blob
Documentation: clarify %(contents:XXXX) doc
Diffstat (limited to 'ref-filter.c')
| -rw-r--r-- | ref-filter.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/ref-filter.c b/ref-filter.c index 8447cb09be..73d8bfa86d 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -127,7 +127,8 @@ static struct used_atom { unsigned int nobracket : 1, push : 1, push_remote : 1; } remote_ref; struct { - enum { C_BARE, C_BODY, C_BODY_DEP, C_LINES, C_SIG, C_SUB, C_TRAILERS } option; + enum { C_BARE, C_BODY, C_BODY_DEP, C_LENGTH, + C_LINES, C_SIG, C_SUB, C_TRAILERS } option; struct process_trailer_options trailer_opts; unsigned int nlines; } contents; @@ -338,6 +339,8 @@ static int contents_atom_parser(const struct ref_format *format, struct used_ato atom->u.contents.option = C_BARE; else if (!strcmp(arg, "body")) atom->u.contents.option = C_BODY; + else if (!strcmp(arg, "size")) + atom->u.contents.option = C_LENGTH; else if (!strcmp(arg, "signature")) atom->u.contents.option = C_SIG; else if (!strcmp(arg, "subject")) @@ -1253,6 +1256,8 @@ static void grab_sub_body_contents(struct atom_value *val, int deref, void *buf) v->s = copy_subject(subpos, sublen); else if (atom->u.contents.option == C_BODY_DEP) v->s = xmemdupz(bodypos, bodylen); + else if (atom->u.contents.option == C_LENGTH) + v->s = xstrfmt("%"PRIuMAX, (uintmax_t)strlen(subpos)); else if (atom->u.contents.option == C_BODY) v->s = xmemdupz(bodypos, nonsiglen); else if (atom->u.contents.option == C_SIG) |
