From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-2.7 required=3.0 tests=AWL,BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD shortcircuit=no autolearn=no autolearn_force=no version=3.4.0 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id C16331F406 for ; Tue, 9 Jan 2018 13:06:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757188AbeAINGG (ORCPT ); Tue, 9 Jan 2018 08:06:06 -0500 Received: from a7-20.smtp-out.eu-west-1.amazonses.com ([54.240.7.20]:37326 "EHLO a7-20.smtp-out.eu-west-1.amazonses.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757001AbeAINFZ (ORCPT ); Tue, 9 Jan 2018 08:05:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=shh3fegwg5fppqsuzphvschd53n6ihuv; d=amazonses.com; t=1515503123; h=From:To:Message-ID:In-Reply-To:References:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding:Date:Feedback-ID; bh=FJl96QU/r+gU2HnOTQlBFSgNwsqWJS+uE26e2yVddXw=; b=PRe3fJoJY+P6QKL5WEPl3k1UcjPnLfS8JYbxyBqiVOZPCW6WqAJ+7tF6k46XQ79F vS2iPBtmngBHY9unCAsN9g+jqApvv4pFfU9OU8ZeL7A8i4h4iXoEie5uiy6w7Fzmer9 TkYvH9dTt0VRsnP5cEKPUh24kRZF9339r93a9ifc= From: Olga Telezhnaya To: git@vger.kernel.org Message-ID: <01020160db067c89-c76828dd-d98c-45c6-8de1-2c9d7fc61841-000000@eu-west-1.amazonses.com> In-Reply-To: <01020160db0679c9-799a0bc4-b6d1-43e2-ad3b-80be4e4c55e9-000000@eu-west-1.amazonses.com> References: <01020160db0679c9-799a0bc4-b6d1-43e2-ad3b-80be4e4c55e9-000000@eu-west-1.amazonses.com> Subject: [PATCH 17/20] cat-file: add is_cat flag in ref-filter MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Tue, 9 Jan 2018 13:05:23 +0000 X-SES-Outgoing: 2018.01.09-54.240.7.20 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 Add is_cat flag, further it helps to get rid of cat_file_data field in ref_format. Signed-off-by: Olga Telezhnaia Mentored-by: Christian Couder Mentored by: Jeff King --- builtin/cat-file.c | 1 + ref-filter.c | 8 +++++--- ref-filter.h | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/builtin/cat-file.c b/builtin/cat-file.c index e11dbf88e386c..289912ab1f858 100644 --- a/builtin/cat-file.c +++ b/builtin/cat-file.c @@ -393,6 +393,7 @@ static int batch_objects(struct batch_options *opt) */ memset(&data, 0, sizeof(data)); opt->format->cat_file_data = &data; + opt->format->is_cat = 1; verify_ref_format(opt->format); if (opt->cmdmode) data.split_on_whitespace = 1; diff --git a/ref-filter.c b/ref-filter.c index 112336edbe871..4259c9b9cd767 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -101,6 +101,7 @@ static struct used_atom { } *used_atoms; static int used_atom_cnt, need_tagged, need_symref; struct expand_data *cat_file_info; +static int is_cat = 0; static void color_atom_parser(const struct ref_format *format, struct used_atom *atom, const char *color_value) { @@ -493,7 +494,7 @@ static int parse_ref_filter_atom(const struct ref_format *format, need_tagged = 1; if (!strcmp(valid_atoms[i].name, "symref")) need_symref = 1; - if (cat_file_info && !strcmp(valid_atoms[i].name, "rest")) + if (is_cat && !strcmp(valid_atoms[i].name, "rest")) cat_file_info->split_on_whitespace = 1; return at; } @@ -739,6 +740,7 @@ int verify_ref_format(struct ref_format *format) const char *cp, *sp; cat_file_info = format->cat_file_data; + is_cat = format->is_cat; format->need_color_reset_at_eol = 0; for (cp = format->format; *cp && (sp = find_next(cp)); ) { const char *color, *ep = strchr(sp, ')'); @@ -748,7 +750,7 @@ int verify_ref_format(struct ref_format *format) return error(_("malformed format string %s"), sp); /* sp points at "%(" and ep points at the closing ")" */ - if (format->cat_file_data) + if (is_cat) { at = parse_ref_filter_atom(format, valid_cat_file_atoms, ARRAY_SIZE(valid_cat_file_atoms), sp + 2, ep); @@ -1466,7 +1468,7 @@ int populate_value(struct ref_array_item *ref) ref->symref = ""; } - if (cat_file_info) { + if (is_cat) { if (!cat_file_info->skip_object_info && sha1_object_info_extended(ref->objectname.hash, &cat_file_info->info, OBJECT_INFO_LOOKUP_REPLACE) < 0) { diff --git a/ref-filter.h b/ref-filter.h index 9e4444cf3ef9a..5ba4724a472f6 100644 --- a/ref-filter.h +++ b/ref-filter.h @@ -126,6 +126,7 @@ struct ref_format { * hopefully would be reduced later. */ struct expand_data *cat_file_data; + int is_cat; }; #define REF_FORMAT_INIT { NULL, 0, -1 } -- https://github.com/git/git/pull/450