From: "ZheNing Hu via GitGitGadget" <gitgitgadget@gmail.com> To: git@vger.kernel.org Cc: Junio C Hamano <gitster@pobox.com>, Jeff King <peff@peff.net>, Christian Couder <chriscool@tuxfamily.org>, Hariom Verma <hariom18599@gmail.com>, ZheNing Hu <adlternative@gmail.com>, ZheNing Hu <adlternative@gmail.com> Subject: [PATCH 1/2] [GSOC] ref-filter: add objectsize to used_atom Date: Sat, 08 May 2021 15:22:31 +0000 [thread overview] Message-ID: <91ca57c9d04a822aa4955dbfe3962a6fb2444e81.1620487353.git.gitgitgadget@gmail.com> (raw) In-Reply-To: <pull.951.git.1620487353.gitgitgadget@gmail.com> From: ZheNing Hu <adlternative@gmail.com> Since "objectsize:size" is composed of two parts, "type:attribute". However, the original implementation did not decouple the two parts "type" and "attribute" well, we still need to judge separately whether the atom is "objectsize" or "objectsize:disk" in `grab_common_values()`. Add a new member `objectsize` to the union `used_atom.u`, so that we can separate the judgment of atom type from the judgment of atom attribute, This will bring scalability to atom `%(objectsize)`. Signed-off-by: ZheNing Hu <adlternative@gmail.com> --- ref-filter.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/ref-filter.c b/ref-filter.c index a0adb4551d87..f420bae6e5ba 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -146,6 +146,9 @@ static struct used_atom { enum { O_FULL, O_LENGTH, O_SHORT } option; unsigned int length; } oid; + struct { + enum { O_SIZE, O_SIZE_DISK } option; + } objectsize; struct email_option { enum { EO_RAW, EO_TRIM, EO_LOCALPART } option; } email_option; @@ -269,11 +272,13 @@ static int objectsize_atom_parser(const struct ref_format *format, struct used_a const char *arg, struct strbuf *err) { if (!arg) { + atom->u.objectsize.option = O_SIZE; if (*atom->name == '*') oi_deref.info.sizep = &oi_deref.size; else oi.info.sizep = &oi.size; } else if (!strcmp(arg, "disk")) { + atom->u.objectsize.option = O_SIZE_DISK; if (*atom->name == '*') oi_deref.info.disk_sizep = &oi_deref.disk_size; else @@ -967,12 +972,14 @@ static void grab_common_values(struct atom_value *val, int deref, struct expand_ name++; if (!strcmp(name, "objecttype")) v->s = xstrdup(type_name(oi->type)); - else if (!strcmp(name, "objectsize:disk")) { - v->value = oi->disk_size; - v->s = xstrfmt("%"PRIuMAX, (uintmax_t)oi->disk_size); - } else if (!strcmp(name, "objectsize")) { - v->value = oi->size; - v->s = xstrfmt("%"PRIuMAX , (uintmax_t)oi->size); + else if (starts_with(name, "objectsize")) { + if (used_atom[i].u.objectsize.option == O_SIZE_DISK) { + v->value = oi->disk_size; + v->s = xstrfmt("%"PRIuMAX, (uintmax_t)oi->disk_size); + } else if (used_atom[i].u.objectsize.option == O_SIZE) { + v->value = oi->size; + v->s = xstrfmt("%"PRIuMAX , (uintmax_t)oi->size); + } } else if (!strcmp(name, "deltabase")) v->s = xstrdup(oid_to_hex(&oi->delta_base_oid)); else if (deref) -- gitgitgadget
next prev parent reply other threads:[~2021-05-08 15:22 UTC|newest] Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-05-08 15:22 [PATCH 0/2] [GSOC][RFC] ref-filter: introduce enum atom_type ZheNing Hu via GitGitGadget 2021-05-08 15:22 ` ZheNing Hu via GitGitGadget [this message] 2021-05-08 15:22 ` [PATCH 2/2] " ZheNing Hu via GitGitGadget 2021-05-09 6:21 ` Christian Couder 2021-05-09 8:26 ` Junio C Hamano 2021-05-09 13:44 ` ZheNing Hu 2021-05-09 13:40 ` ZheNing Hu 2021-05-10 15:03 ` [PATCH v2 0/2] " ZheNing Hu via GitGitGadget 2021-05-10 15:03 ` [PATCH v2 1/2] [GSOC] ref-filter: add objectsize to used_atom ZheNing Hu via GitGitGadget 2021-05-10 15:03 ` [PATCH v2 2/2] [GSOC] ref-filter: introduce enum atom_type ZheNing Hu via GitGitGadget 2021-05-11 2:14 ` Junio C Hamano 2021-05-11 5:51 ` Christian Couder 2021-05-11 6:12 ` Junio C Hamano 2021-05-11 12:53 ` ZheNing Hu 2021-05-11 12:37 ` ZheNing Hu 2021-05-11 13:05 ` Junio C Hamano 2021-05-11 12:18 ` ZheNing Hu 2021-05-12 12:11 ` [PATCH v3 0/2] [GSOC][RFC] " ZheNing Hu via GitGitGadget 2021-05-12 12:11 ` [PATCH v3 1/2] [GSOC] ref-filter: add objectsize to used_atom ZheNing Hu via GitGitGadget 2021-05-12 23:11 ` Junio C Hamano 2021-05-13 9:04 ` ZheNing Hu 2021-05-12 12:11 ` [PATCH v3 2/2] [GSOC] ref-filter: introduce enum atom_type ZheNing Hu via GitGitGadget 2021-05-12 23:21 ` Junio C Hamano 2021-05-13 9:25 ` ZheNing Hu 2021-05-13 15:15 ` [PATCH v4 0/2] [GSOC][RFC] " ZheNing Hu via GitGitGadget 2021-05-13 15:15 ` [PATCH v4 1/2] [GSOC] ref-filter: add objectsize to used_atom ZheNing Hu via GitGitGadget 2021-05-13 15:15 ` [PATCH v4 2/2] [GSOC] ref-filter: introduce enum atom_type ZheNing Hu via GitGitGadget
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 List information: http://vger.kernel.org/majordomo-info.html * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=91ca57c9d04a822aa4955dbfe3962a6fb2444e81.1620487353.git.gitgitgadget@gmail.com \ --to=gitgitgadget@gmail.com \ --cc=adlternative@gmail.com \ --cc=chriscool@tuxfamily.org \ --cc=git@vger.kernel.org \ --cc=gitster@pobox.com \ --cc=hariom18599@gmail.com \ --cc=peff@peff.net \ --subject='Re: [PATCH 1/2] [GSOC] ref-filter: add objectsize to used_atom' \ /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
Code repositories for project(s) associated with this inbox: https://80x24.org/mirrors/git.git 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).