From patchwork Fri Nov 9 07:44:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Telezhnaya X-Patchwork-Id: 10675433 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8ACD514BD for ; Fri, 9 Nov 2018 07:44:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C1002E6D1 for ; Fri, 9 Nov 2018 07:44:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7081E2E6F7; Fri, 9 Nov 2018 07:44:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 152B92E6D1 for ; Fri, 9 Nov 2018 07:44:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728184AbeKIRXX (ORCPT ); Fri, 9 Nov 2018 12:23:23 -0500 Received: from a7-17.smtp-out.eu-west-1.amazonses.com ([54.240.7.17]:35706 "EHLO a7-17.smtp-out.eu-west-1.amazonses.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728054AbeKIRXX (ORCPT ); Fri, 9 Nov 2018 12:23:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=uku4taia5b5tsbglxyj6zym32efj7xqv; d=amazonses.com; t=1541749441; h=From:To:Message-ID:In-Reply-To:References:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding:Date:Feedback-ID; bh=VEuTz+lFag5ioqSEaJkPHzDIljA7STiJqtBuxWWBQbw=; b=vxu10QGF6HTKHyZUfLWsVeMdxSpw4TgmzlwPbGC2mAI+LSrwXNMBmspZKOCk/fiv 1qjc3FleYXRwm2uuiUIpU6cBMyvMGuEHiQ518al0gXKtFFF6aO/HO+cPZBxvL6MjcFe GoNi08XHctppGQ4aqqPH0rcPxSB4bRWjoRVicLIE= From: Olga Telezhnaya To: git@vger.kernel.org Message-ID: <01020166f76d845f-1a02a31e-5094-4b27-974d-a23811066c58-000000@eu-west-1.amazonses.com> In-Reply-To: References: Subject: [RFC PATCH 1/5] ref-filter: add objectsize:disk option MIME-Version: 1.0 Date: Fri, 9 Nov 2018 07:44:01 +0000 X-SES-Outgoing: 2018.11.09-54.240.7.17 Feedback-ID: 1.eu-west-1.YYPRFFOog89kHDDPKvTu4MK67j4wW0z7cAgZtFqQH58=:AmazonSES Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add new formatting option objectsize:disk to know exact size that object takes up on disk. Signed-off-by: Olga Telezhnaia --- ref-filter.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) -- https://github.com/git/git/pull/552 diff --git a/ref-filter.c b/ref-filter.c index 0c45ed9d94a4b..8ba1a4e72f2c3 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -231,12 +231,18 @@ static int objecttype_atom_parser(const struct ref_format *format, struct used_a static int objectsize_atom_parser(const struct ref_format *format, struct used_atom *atom, const char *arg, struct strbuf *err) { - if (arg) - return strbuf_addf_ret(err, -1, _("%%(objectsize) does not take arguments")); - if (*atom->name == '*') - oi_deref.info.sizep = &oi_deref.size; - else - oi.info.sizep = &oi.size; + if (!arg) { + if (*atom->name == '*') + oi_deref.info.sizep = &oi_deref.size; + else + oi.info.sizep = &oi.size; + } else if (!strcmp(arg, "disk")) { + if (*atom->name == '*') + oi_deref.info.disk_sizep = &oi_deref.disk_size; + else + oi.info.disk_sizep = &oi.disk_size; + } else + return strbuf_addf_ret(err, -1, _("unrecognized %%(objectsize) argument: %s"), arg); return 0; } @@ -876,11 +882,13 @@ 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")) { + else if (!strcmp(name, "objectsize:disk")) { + v->value = oi->disk_size; + v->s = xstrfmt("%lld", (long long)oi->disk_size); + } else if (!strcmp(name, "objectsize")) { v->value = oi->size; v->s = xstrfmt("%lu", oi->size); - } - else if (deref) + } else if (deref) grab_objectname(name, &oi->oid, v, &used_atom[i]); } }