From: Olga Telezhnaya Date: Tue, 09 Jan 2018 13:05:23 GMT Subject: [PATCH 19/20] cat-file: move skip_object_info into ref-filter Message-ID: <01020160db067c8a-c3ce9582-bc4d-40fd-ac96-b530f93b2752-000000@eu-west-1.amazonses.com> In-Reply-To: <01020160db0679c9-799a0bc4-b6d1-43e2-ad3b-80be4e4c55e9-000000@eu-west-1.amazonses.com> Move logic related to skip_object_info into ref-filter, so that cat-file does not use that field at all. Signed-off-by: Olga Telezhnaia Mentored-by: Christian Couder Mentored by: Jeff King --- builtin/cat-file.c | 7 +------ ref-filter.c | 5 +++++ ref-filter.h | 1 + 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/builtin/cat-file.c b/builtin/cat-file.c index 5aac10b9808ff..19cee0d22fabe 100644 --- a/builtin/cat-file.c +++ b/builtin/cat-file.c @@ -395,16 +395,11 @@ static int batch_objects(struct batch_options *opt) opt->format->cat_file_data = &data; opt->format->is_cat = 1; opt->format->split_on_whitespace = &data.split_on_whitespace; + opt->format->all_objects = opt->all_objects; verify_ref_format(opt->format); if (opt->cmdmode) data.split_on_whitespace = 1; - if (opt->all_objects) { - struct object_info empty = OBJECT_INFO_INIT; - if (!memcmp(&data.info, &empty, sizeof(empty))) - data.skip_object_info = 1; - } - /* * If we are printing out the object, then always fill in the type, * since we will want to decide whether or not to stream. diff --git a/ref-filter.c b/ref-filter.c index ee27edb2dad56..dbca6856432c0 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -766,6 +766,11 @@ int verify_ref_format(struct ref_format *format) } if (format->need_color_reset_at_eol && !want_color(format->use_color)) format->need_color_reset_at_eol = 0; + if (is_cat && format->all_objects) { + struct object_info empty = OBJECT_INFO_INIT; + if (!memcmp(&cat_file_info->info, &empty, sizeof(empty))) + cat_file_info->skip_object_info = 1; + } return 0; } diff --git a/ref-filter.h b/ref-filter.h index 3228661414623..7f7b17e659241 100644 --- a/ref-filter.h +++ b/ref-filter.h @@ -128,6 +128,7 @@ struct ref_format { struct expand_data *cat_file_data; int is_cat; int *split_on_whitespace; + int all_objects; }; #define REF_FORMAT_INIT { NULL, 0, -1 } -- https://github.com/git/git/pull/450